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

AHuman Weapon Restrictions
http://forums.datarealms.com/viewtopic.php?f=73&t=45849
Page 1 of 1

Author:  Arcalane [ Sun Nov 09, 2014 8:07 pm ]
Post subject:  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.

Author:  Bad Boy [ Sun Nov 09, 2014 8:24 pm ]
Post subject:  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.

Author:  clunatic [ Sun Nov 09, 2014 8:45 pm ]
Post subject:  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

Author:  Arcalane [ Mon Nov 10, 2014 9:01 am ]
Post subject:  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)

Author:  Bad Boy [ Mon Nov 10, 2014 4:26 pm ]
Post subject:  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);

Author:  Arcalane [ Wed Nov 12, 2014 2:39 pm ]
Post subject:  Re: AHuman Weapon Restrictions

First one worked fine. Thanks. :)

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