View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:30 am



Reply to topic  [ 6 posts ] 
 AHuman Weapon Restrictions 
Author Message
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post AHuman Weapon Restrictions
To put it simply, an upcoming AHuman-type actor for the Brotherhood mod needs to be unable to use any weapons it picks up. Likewise, it has a special weapon that only it should be allowed to use.

Any ideas/pointers? Mods that have implemented similar things in the past? etc.


Sun Nov 09, 2014 8:07 pm
Profile YIM

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: AHuman Weapon Restrictions
Make the weapon settle/delete instantly on drop. I think it's doable with ini but if not:
Code:
function Update(self)
   if not (self.IsAttached()) then
      self.ToDelete = true;
   end
end


You have two choices for making sure no one else picks it up. Either a script for the actor (you'll need to redirect his ai to a new one which has this bit included on top of the base ai stuff) or for the gun (you'll still want the previous stuff if you do it for the gun).
For the actor:
Code:
function Update(self)
   if self.EquippedItem ~= nil and self.EquippedItem.PresetName == "Item I don't want picked up's preset name here" then
      self:GetController():SetState(Controller.WEAPON_DROP, true);
   end
end


For the gun:
Code:
function Update(self)
   if self:IsAttached() and MovableMan:GetMOFromID(self.RootID).PresetName ~= "The only actor who can hold the gun's preset name here" then
      MovableMan:GetMOFromID(self.RootID):GetController():SetState(Controller.WEAPON_DROP, true);
   end
end


They're basically the same thing, just the second one has to find the actor holding the gun. Note that you can make both of these check happen infrequently (probably every 100 or 1000 MS is fine) with timers if you want to make it slightly less expensive. It's probably pretty insignificant though, since each of those is just a couple lines to be executed.

Also keep in mind that, in theory, if the item is deleted whenever it's dropped, you should never run into the issue of someone else picking it up so the second stuff is probably unnecessary.


Sun Nov 09, 2014 8:24 pm
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post Re: AHuman Weapon Restrictions
And to stop the actor from firing any other guns, you could do something like this in the actor's lua:

Code:
function Update(self)
   if self.EquippedItem ~= nil and self.EquippedItem.PresetName ~= "Allowed gun here" then
      self:GetController():SetState(Controller.WEAPON_FIRE, false);
   end
end


Sun Nov 09, 2014 8:45 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: AHuman Weapon Restrictions
That doesn't stop it from trying to equip the wrong weapon though, which is something I'd also like to avoid (to minimize confusion).

A quick tweak to BB's second script should fix that nicely, though. ;)

Ed: The third script, though, just spews out this;

Code:
ERROR: Brotherhood.rte/Scripts/Weapons/CyborgGatling.lua:3: attempt to call method 'GetController' (a nil value)


Mon Nov 10, 2014 9:01 am
Profile YIM

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: AHuman Weapon Restrictions
Ah sorry, forgot to cast.
Change it to ToActor(MovableMan:GetMOFromID(self.RootID)):GetController():SetState(Controller.WEAPON_DROP, true);
If that doesn't work, ToAHuman(MovableMan:GetMOFromID(self.RootID)):GetController():SetState(Controller.WEAPON_DROP, true);


Mon Nov 10, 2014 4:26 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: AHuman Weapon Restrictions
First one worked fine. Thanks. :)


Wed Nov 12, 2014 2:39 pm
Profile YIM
Display posts from previous:  Sort by  
Reply to topic   [ 6 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.093s | 14 Queries | GZIP : Off ]