Data Realms Fan Forums http://45.55.195.193/ |
|
CPU-controlled actor inventory http://45.55.195.193/viewtopic.php?f=73&t=28279 |
Page 1 of 1 |
Author: | weegee [ Sun Dec 25, 2011 12:03 am ] |
Post subject: | CPU-controlled actor inventory |
I'm trying to get actor's inventory, script works fine with player-controlled actors but for AI-controlled actor EquippedItem property is always nil. To check I use a simple piece of code: Code: for actor in MovableMan.Actors do if actor.Team == CF_CPUTeam then print(actor.EquippedItem) end end Although the contents of backpack seem to retreive correctly, the only problem is equipped item. Any reasonbale workarounds for this problem? |
Author: | Asklar [ Sun Dec 25, 2011 7:51 am ] |
Post subject: | Re: CPU-controlled actor inventory |
Well, you could do a check through all the MOs of the actor and check which one has ClassName == "HDFirearm" or ClassName == "TDExplosive". I'm pretty sure that kind of code is used in mods for B24 or something. EDIT: CaveCricket don't kill me for taking this bits of code from your scanner! Code: for i = 1, MovableMan:GetMOIDCount()-1 do local gun = MovableMan:GetMOFromID(i); if gun.ClassName == "HDFirearm" and gun.PresetName == "Scanner" and SceneMan:ShortestDistance(self.Pos,ToHDFirearm(gun).MuzzlePos,self.mapwrapx).Magnitude < 5 then Well, I suppose you can modify the if to fit your needs, like "if gun.ClassName == "HDFirearm" or gun.ClassName == "TDExplosive" then actorweapon = gun" or something like it. |
Author: | weegee [ Sun Dec 25, 2011 11:33 am ] |
Post subject: | Re: CPU-controlled actor inventory |
Ok, I'll try it, thank to both of you, your names won't be forgotten |
Author: | Abdul Alhazred [ Sun Dec 25, 2011 7:42 pm ] |
Post subject: | Re: CPU-controlled actor inventory |
weegee wrote: Code: for actor in MovableMan.Actors do if actor.Team == CF_CPUTeam then print(actor.EquippedItem) end end This is a side effect of the underlying C++ code. The EquippedItem property only exists for AHumans, but you are working with Actor pointers in the code above. The correct way of doing this would be to convert the pointer using ToAHuman() when appropriate. |
Author: | weegee [ Sun Dec 25, 2011 9:47 pm ] |
Post subject: | Re: CPU-controlled actor inventory |
Thank's a lot, now everything's back to normal Didn't took into account that actors and ahumans are not the same. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |