Data Realms Fan Forums
http://forums.datarealms.com/

Force actor to keep weapon?
http://forums.datarealms.com/viewtopic.php?f=73&t=25242
Page 1 of 1

Author:  Awesomeness [ Sat Aug 20, 2011 1:54 am ]
Post subject:  Force actor to keep weapon?

Some of you may notice very similar circumstances between this thread and another thread I wrote, but this is slightly different. In the old thread the Lua was in mission routines, in this one the Lua is tied to an actor.

I want to force an actor to hold a certain item it comes with. So, I tried using a similar technique compared to the solution used in the old thread to make it work, however, it didn't. :P

Here's what I put in Update(self):
Code:
   if self:GetController():IsState(Controller.WEAPON_PICKUP) then
      self:GetController():SetState(Controller.WEAPON_PICKUP, false);
   end
   if self:GetController():IsState(Controller.WEAPON_DROP) then
      self:GetController():SetState(Controller.WEAPON_DROP, false);
   end

The actor could still pick up and drop any weapon as it pleased. What's wrong? :-(

Author:  Coops [ Sat Aug 20, 2011 2:04 am ]
Post subject:  Re: Force actor to keep weapon?

I think those only work if the actor is not controlled by a player.

I had a work around for this though, what you can do is make it so that if the actor drops the weapon then it deletes the weapon and adds it to the actor's inventory. That's only for dropping weapons though, I'm not sure how you can do the picking up weapons. Possibly the same thing but backwards?

Author:  Awesomeness [ Sat Aug 20, 2011 2:17 am ]
Post subject:  Re: Force actor to keep weapon?

Hm... Well this is a problem. There's got to be a solution...

Author:  TheLastBanana [ Sat Aug 20, 2011 3:02 am ]
Post subject:  Re: Force actor to keep weapon?

That's odd. This worked fine for me in Prison Escape 3, although that code was being called from an Activity instead of the actor itself.
Just for the sake of testing, try taking the if statements out and just constantly setting the states to false.

Author:  Awesomeness [ Sat Aug 20, 2011 3:52 am ]
Post subject:  Re: Force actor to keep weapon?

I already tried that. It didn't work. Well... Is it possible to make an actor incapable of using weapons? The item the actor is given upon creation isn't a weapon, so it would be just fine.

Author:  Coops [ Sat Aug 20, 2011 3:55 am ]
Post subject:  Re: Force actor to keep weapon?

Code:
if self.EquippedItem.ClassName == "HDFirearm" then
   self.EquippedItem:Deactivate()
end

Author:  Awesomeness [ Sat Aug 20, 2011 4:02 am ]
Post subject:  Re: Force actor to keep weapon?

I see what you mean, that code makes sense to me.

However, the console says EquippedItem is nil even though the LuaDocs say all AHumans have EquippedItem! Ahhh!

Help! :(


It turns out I was still using B23 for reasons unrelated to this thread and EquippedItem doesn't exist in 23. In B25 it works, but Deactivate() doesn't exist. I'll look for an answer.

EDIT: This made it not throw errors anymore, however it doesn't prevent the actor from shooting.
Code:
   if self.EquippedItem.ClassName == "HDFirearm" then
      ToHDFirearm(self.EquippedItem):Deactivate();
   end


Could it be possible to prevent picking up or dropping weapons via the new B25 custom AI routines?

Author:  Awesomeness [ Thu Sep 08, 2011 10:38 pm ]
Post subject:  Re: Force actor to keep weapon?

Solution: I removed the front arm, and set the hand of the back one to be a medkit. :P

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