Data Realms Fan Forums
http://45.55.195.193/

Non dropable weapons
http://45.55.195.193/viewtopic.php?f=1&t=25421
Page 1 of 1

Author:  SnowMonster20 [ Mon Sep 05, 2011 2:03 am ]
Post subject:  Non dropable weapons

How do you make it so a weapon can not be dropped?

Also if its dropped the GibImpulseLimit set really low make it pop upon hitting the ground right?

Author:  Asklar [ Mon Sep 05, 2011 2:25 am ]
Post subject:  Re: Non dropable weapons

Add a lua script to said gun and make it force the parent to not drop it.

Something like:

Code:
function Create(self)
self.parent = MovableMan:GetMOFromID(self.RootID)
end
function Update(self)
self.parent:GetController():SetState(WEAPON_DROP,false)
end


I'm not entirely sure though, something looks wierd.

Author:  Azukki [ Mon Sep 05, 2011 3:21 am ]
Post subject:  Re: Non dropable weapons

It seems constantly forcing the actor to not drop stuff does not work. (Constantly making it drop does work, though, and is fun to watch when an unarmed AI actor wants it)

If an item that replaces itself back into one's inventory when dropped is acceptable, use this. Mind you, this can be exploited to repair damaged weapons, the replacement won't have the same wounds.

Code:
function Update(self)
   if self.ID ~= self.RootID then
      self.operator = ToActor(MovableMan:GetMOFromID(self.RootID))
   elseif self.operator then
      if self.operator.ID ~= 255 and self.Lifetime ~= 1 then
         local Replacement = CreateHDFirearm(self.PresetName)
         self.operator:AddInventoryItem(Replacement)
         self.Lifetime = 1
      end
   end
end


I could try to make it so that this can't be exploited for instant reloading, if that's needed.

Author:  Asklar [ Mon Sep 05, 2011 3:25 am ]
Post subject:  Re: Non dropable weapons

Hey Azukki, could this work?

Code:
function Create(self)
    self.parent = MovableMan:GetMOFromID(self.RootID)
end
function Update(self)
    if self.parent == nil then
        self.parent = MovableMan:GetMOFromID(self.RootID)
    end
    if self.parent:GetController():IsState(WEAPON_DROP) then
        self.parent:GetController():SetState(WEAPON_DROP,false)
    end
end

Author:  Azukki [ Mon Sep 05, 2011 3:29 am ]
Post subject:  Re: Non dropable weapons

Before, I attempted constantly telling it to not drop. I seriously doubt waiting until it's already trying to drop [an instantaneous process] and telling it not to in response will do any better.
And I don't think you need the create function in there, since parent, when undefined, gets defined in the update function.
And you'll get errors when no one's holding it, because it is its own parent when unheld, and then you'll attempt to check and set states of its controller, which is invalid because it has no controller nor controller states because it's a HDFirearm.

Resolve those issues and maybe some minor formatting fixes, and it should work.

Author:  Asklar [ Mon Sep 05, 2011 3:42 am ]
Post subject:  Re: Non dropable weapons

Uh, I still need to learn a lot more lua.

Author:  alphagamer774 [ Mon Sep 05, 2011 4:01 am ]
Post subject:  Re: Non dropable weapons

When did azukki get so epic with lua?

Author:  Azukki [ Mon Sep 05, 2011 5:50 am ]
Post subject:  Re: Non dropable weapons

Well, I heard CC would have Lua scripting a couple days after that was announced, so I downloaded a Lua compiler, failed (to format) basic addition, and it was a gradual process of trials and errors from there to here.

Author:  SnowMonster20 [ Mon Sep 05, 2011 6:36 am ]
Post subject:  Re: Non dropable weapons

I think replacing would work. Only reason I need it is cause the
"weapon" is supposed to be part of the actor (Digging claws) so realistically you cant drop those.

Not like people or AI will go around dropping them though. Although hands dont grow back so maybe I'll just leave it at a high gibimpulse. That way if dropped or shot it wont come back.

So would that replace code work for attachables? Say for example a tail getting shot off then growing back after the actor gets a kill or a timer runs out?

Author:  Azukki [ Mon Sep 05, 2011 6:52 am ]
Post subject:  Re: Non dropable weapons

Oh, it's specific to an actor? Mentioning that before might have saved some trouble.
In that case, you could copy the method I used for the [SE] Rifleman's Neck Breaker device. It may be slightly superior and simpler.
But if this works well enough, and you don't want to mess with it, that works too.


In the case of attachables, that would be very different. It used to be impossible without entirely replacing the actor, and if B25 has made it possible, I know nothing of how to do it.
I can think of a workaround, though, that also may or may not be possible.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/