View unanswered posts | View active topics It is currently Fri Dec 27, 2024 7:31 am



Reply to topic  [ 8 posts ] 
 Force actor to keep weapon? 
Author Message
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 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? :-(


Sat Aug 20, 2011 1:54 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post 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?


Sat Aug 20, 2011 2:04 am
Profile
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post Re: Force actor to keep weapon?
Hm... Well this is a problem. There's got to be a solution...


Sat Aug 20, 2011 2:17 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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.


Sat Aug 20, 2011 3:02 am
Profile WWW
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 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.


Sat Aug 20, 2011 3:52 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Force actor to keep weapon?
Code:
if self.EquippedItem.ClassName == "HDFirearm" then
   self.EquippedItem:Deactivate()
end


Sat Aug 20, 2011 3:55 am
Profile
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 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?


Sat Aug 20, 2011 4:02 am
Profile
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post 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


Thu Sep 08, 2011 10:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.041s | 14 Queries | GZIP : Off ]