I was wondering if there is a way to check the if any limbs are missing on a player, and if you are able to replace them? The idea was for a medical gun that once you are above 100 health, it will start replacing lost limbs. Sorry if this is available somewhere really easily, I took a cursory glance and didn't see it.
On a similar note, checking if a thruster has been destroyed on a dropship.
I was wondering if there is a way to check the if any limbs are missing on a player, and if you are able to replace them? The idea was for a medical gun that once you are above 100 health, it will start replacing lost limbs. Sorry if this is available somewhere really easily, I took a cursory glance and didn't see it.
On a similar note, checking if a thruster has been destroyed on a dropship.
It isn't unfortunately possible to replace individual missing limbs. A method though is to upon reaching 100% health check if it needs any limbs (checking if they are ~= nil and their ID ~= 255) then if it needs any, make it drop all his items and then spawn a new actor (use the preset name to get the original actor) then force all the new limbs RotAngle, Position, HFlipped, Velocity ect. to be exactly the same as their original counterparts. Then when the new actor is spawned, remove the old one (self.ToDelete = true), and add all the nearby items to the new actors inventory.
Hope it helps
Wed Oct 26, 2011 6:21 pm
Azukki
Joined: Sat Nov 03, 2007 9:44 pm Posts: 1916 Location: Flint Hills
Re: Checking limb status
Isn't deleting the actor going to delete what's in his inventory, not expel it? Bah, I missed the bit where you specifically mentioned what I brought to question. Unless you edited the post?
Last edited by Azukki on Wed Oct 26, 2011 9:22 pm, edited 1 time in total.
Wed Oct 26, 2011 6:38 pm
Zaneo
Joined: Sun Oct 23, 2011 7:57 am Posts: 23
Re: Checking limb status
That helps a lot, it is a bit silly that it has to be done like that though.
Isn't deleting the actor going to delete what's in his inventory, not expel it?
self:DropAllInventory() before deleting it. Try waiting a frame before deleting if that doesn't.
Wed Oct 26, 2011 7:10 pm
Zaneo
Joined: Sun Oct 23, 2011 7:57 am Posts: 23
Re: Checking limb status
What exactly would the mechanism for checking the limb though?
I attemted to get the thrusters on a dropship using Abduls Alhazred's code from his air support mod.
Code:
self.EngineA = nil self.EngineB = nil
local foundA = nil local foundB = nil
local selfID = ToActor(self).ID ConsoleMan:PrintString("Self ID: " .. selfID) local foundObject = nil for i = 1, MovableMan:GetMOIDCount()-1 do ConsoleMan:PrintString("Object ID: " .. i) foundObject = MovableMan:GetMOFromID(i) ConsoleMan:PrintString("Object Name: " .. foundObject.PresetName) if (i ~= selfID) and (MovableMan:GetRootMOID(i) == selfID) then -- an obj without a parent has ID == RootID --foundObject = MovableMan:GetMOFromID(i) --ConsoleMan:PrintString("Object Name: " .. foundObject.PresetName) if foundObject.PresetName == "Drop Ship Engine A" then ConsoleMan:PrintString("Found Engine A") self.EngineA = ToAEmitter(foundObject) foundA = true elseif foundObject.PresetName == "Drop Ship Engine B" then ConsoleMan:PrintString("Found Engine A") self.EngineB = ToAEmitter(foundObject) foundB = true end if foundA and foundB then break end end
Code:
Self ID: 255 Object ID: 1 Object Name: Door Slide Short Object ID: 2 Object Name: Door Slide Short A Object ID: 3 Object Name: Door Slide Short Object ID: 4 Object Name: Door Slide Short A Object ID: 5 Object Name: Door Slide Short Object ID: 6 Object Name: Door Slide Short A Object ID: 7 Object Name: Door Slide Short Object ID: 8 Object Name: Door Slide Short A Object ID: 9 Object Name: Dummy Controller Object ID: 10 Object Name: Door Rotate Short Object ID: 11 Object Name: Door Rotate Short A Object ID: 12 Object Name: Door Rotate Short Object ID: 13 Object Name: Door Rotate Short A Object ID: 14 Object Name: Brain Case Object ID: 15 Object Name: Dummy Object ID: 16 Object Name: Dummy Leg BG A Object ID: 17 Object Name: Dummy Arm BG A Object ID: 18 Object Name: Dummy Head A Object ID: 19 Object Name: Dummy Leg FG A Object ID: 20 Object Name: Dummy Arm FG A Object ID: 21 Object Name: Dummy Object ID: 22 Object Name: Dummy Leg BG A Object ID: 23 Object Name: Dummy Arm BG A Object ID: 24 Object Name: Dummy Head A Object ID: 25 Object Name: Dummy Leg FG A Object ID: 26 Object Name: Dummy Arm FG A Object ID: 27 Object Name: Dummy Object ID: 28 Object Name: Dummy Leg BG A Object ID: 29 Object Name: Dummy Arm BG A Object ID: 30 Object Name: Dummy Head A Object ID: 31 Object Name: Dummy Leg FG A Object ID: 32 Object Name: Dummy Arm FG A Object ID: 33 Object Name: Dummy Object ID: 34 Object Name: Dummy Leg BG A Object ID: 35 Object Name: Dummy Arm BG A Object ID: 36 Object Name: Dummy Head A Object ID: 37 Object Name: Dummy Leg FG A Object ID: 38 Object Name: Dummy Arm FG A Object ID: 39 Object Name: Dreadnought Object ID: 40 Object Name: Dummy Crab Leg BG Object ID: 41 Object Name: Dummy Crab Leg BG Object ID: 42 Object Name: Dummy Crab Leg FG Object ID: 43 Object Name: Dummy Crab Leg FG Object ID: 44 Object Name: Dummy Turret Large Object ID: 45 Object Name: Dreadnought MG Object ID: 46 Object Name: Dummy Turret Large B Object ID: 47 Object Name: Dummy Turret Large A Object ID: 48 Object Name: Dummy Turret Large D Object ID: 49 Object Name: Dreadnought Object ID: 50 Object Name: Dummy Crab Leg BG Object ID: 51 Object Name: Dummy Crab Leg BG Object ID: 52 Object Name: Dummy Crab Leg FG Object ID: 53 Object Name: Dummy Crab Leg FG Object ID: 54 Object Name: Dummy Turret Large Object ID: 55 Object Name: Dreadnought MG Object ID: 56 Object Name: Dummy Turret Large B Object ID: 57 Object Name: Dummy Turret Large A Object ID: 58 Object Name: Dummy Turret Large D Object ID: 59 Object Name: Dummy Object ID: 60 Object Name: Dummy Leg BG A Object ID: 61 Object Name: Dummy Arm BG A Object ID: 62 Object Name: Dummy Head A Object ID: 63 Object Name: Dummy Leg FG A Object ID: 64 Object Name: Dummy Arm FG A Object ID: 65 Object Name: Dummy Object ID: 66 Object Name: Dummy Leg BG A Object ID: 67 Object Name: Dummy Arm BG A Object ID: 68 Object Name: Dummy Head A Object ID: 69 Object Name: Dummy Leg FG A Object ID: 70 Object Name: Dummy Arm FG A Object ID: 71 Object Name: Dummy Object ID: 72 Object Name: Dummy Leg BG A Object ID: 73 Object Name: Dummy Arm BG A Object ID: 74 Object Name: Dummy Head A Object ID: 75 Object Name: Dummy Leg FG A Object ID: 76 Object Name: Dummy Arm FG A Object ID: 77 Object Name: Crab Object ID: 78 Object Name: Crab Leg BG A Object ID: 79 Object Name: Crab Leg BG A Object ID: 80 Object Name: Crab Leg FG A Object ID: 81 Object Name: Crab Leg FG A Object ID: 82 Object Name: AK-47 Object ID: 83 Object Name: Light Digger Object ID: 84 Object Name: AK-47 Object ID: 85 Object Name: Shotgun Object ID: 86 Object Name: SMG Object ID: 87 Object Name: AK-47
When I looked in console though I didn't see any "Drop Ship Engine A/B" I assume there is a different way to access them? Or in hindsight the dropship isn't on screen yet so this doesn't work because it isn't registered on scene? If that is the case how would I access the thrusters before the ship is placed on scene?
Tue Nov 01, 2011 5:33 am
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
Re: Checking limb status
You can access any MovableObject owned by the MovableManager with the method you mentioned. Note that the object has to have GetsHitByMOs set to 1, so the code below works on the big engines but not on the tiny thrusters.
Code:
function Create(self) local MoObj for i = 1, MovableMan:GetMOIDCount()-1 do if MovableMan:GetRootMOID(i) == self.ID then -- an obj without a parent has ID == RootID MoObj = MovableMan:GetMOFromID(i) if MoObj.PresetName == "PresetNameOfLeftEngine" then self.LeftEngine = ToAEmitter(MoObj) elseif MoObj.PresetName == "PresetNameOfRightEngine" then self.RightEngine = ToAEmitter(MoObj) end
if self.LeftEngine and self.RightEngine then break end end end end
Hmm, I am still having the same problem it can't find the engines. When I set it announce all objects found, it doesn't list the engine objects. Lots of human parts, but no dropship parts.
Code:
Object: Door Slide Short Object: Door Slide Short A Object: Door Slide Short Object: Door Slide Short A Object: Door Slide Short Object: Door Slide Short A Object: Door Slide Short Object: Door Slide Short A Object: Dummy Controller Object: Door Rotate Short Object: Door Rotate Short A Object: Door Rotate Short Object: Door Rotate Short A Object: Brain Case Object: Dummy Object: Dummy Leg BG A Object: Dummy Arm BG A Object: Dummy Head A Object: Dummy Leg FG A Object: Dummy Arm FG A Object: Dummy Object: Dummy Leg BG A Object: Dummy Arm BG A Object: Dummy Head A Object: Dummy Leg FG A Object: Dummy Arm FG A Object: Dummy Object: Dummy Leg BG A Object: Dummy Arm BG A Object: Dummy Head A Object: Dummy Leg FG A Object: Dummy Arm FG A Object: Dummy Object: Dummy Leg BG A Object: Dummy Arm BG A Object: Dummy Head A Object: Dummy Leg FG A Object: Dummy Arm FG A Object: Dreadnought Object: Dummy Crab Leg BG Object: Dummy Crab Leg BG Object: Dummy Crab Leg FG Object: Dummy Crab Leg FG Object: Dummy Turret Large Object: Dreadnought MG Object: Dummy Turret Large B Object: Dummy Turret Large A Object: Dummy Turret Large D Object: Dreadnought Object: Dummy Crab Leg BG Object: Dummy Crab Leg BG Object: Dummy Crab Leg FG Object: Dummy Crab Leg FG Object: Dummy Turret Large Object: Dreadnought MG Object: Dummy Turret Large B Object: Dummy Turret Large A Object: Dummy Turret Large D Object: Dummy Object: Dummy Leg BG A Object: Dummy Arm BG A Object: Dummy Head A Object: Dummy Leg FG A Object: Dummy Arm FG A Object: Dummy Object: Dummy Leg BG A Object: Dummy Arm BG A Object: Dummy Head A Object: Dummy Leg FG A Object: Dummy Arm FG A Object: Dummy Object: Dummy Leg BG A Object: Dummy Arm BG A Object: Dummy Head A Object: Dummy Leg FG A Object: Dummy Arm FG A Object: Crab Object: Crab Leg BG A Object: Crab Leg BG A Object: Crab Leg FG A Object: Crab Leg FG A Object: AK-47 Object: Light Digger Object: AK-47 Object: Shotgun Object: SMG Object: AK-47
Tue Nov 01, 2011 1:10 pm
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
Re: Checking limb status
Zaneo wrote:
Hmm, I am still having the same problem it can't find the engines. When I set it announce all objects found, it doesn't list the engine objects. Lots of human parts, but no dropship parts.
I just tested it and you are of course right. It turned out that my script only works when the craft is spawned by a script, and not when ordered form the buy menu. I always spawn stuff with scripts to save time so I never noticed. Thanks for bringing this up!
Try this instead:
Code:
function Update(self) if not self.searchedForEngines then self.searchedForEngines = true local MoObj for i = 1, MovableMan:GetMOIDCount()-1 do if MovableMan:GetRootMOID(i) == self.ID then -- an obj without a parent has ID == RootID MoObj = MovableMan:GetMOFromID(i) if MoObj.PresetName == "Drop Ship Engine A" then self.LeftEngine = ToAEmitter(MoObj) elseif MoObj.PresetName == "Drop Ship Engine B" then self.RightEngine = ToAEmitter(MoObj) end
if self.LeftEngine and self.RightEngine then print("Found " .. self.LeftEngine.PresetName .. " and " .. self.RightEngine.PresetName) break end end end end
if self.LeftEngine then if self.LeftEngine:IsAttached() then self.LeftEngine:TriggerBurst() else self.LeftEngine = nil end end
if self.RightEngine then if self.RightEngine:IsAttached() then self.RightEngine:EnableEmission(false) else self.RightEngine = nil end end end
Tue Nov 01, 2011 8:47 pm
Zaneo
Joined: Sun Oct 23, 2011 7:57 am Posts: 23
Re: Checking limb status
I must be doing it completely wrong... maybe this doesn't work on the default dropship?
Code:
if not self.searchedForEngines then ConsoleMan:PrintString("Searching for engines") self.searchedForEngines = true local MoObj for i = 1, MovableMan:GetMOIDCount()-1 do ConsoleMan:PrintString("Object: ".. i .."| ".. MovableMan:GetMOFromID(i).PresetName) if MovableMan:GetRootMOID(i) == self.ID then -- an obj without a parent has ID == RootID MoObj = MovableMan:GetMOFromID(i) if MoObj.PresetName == "Drop Ship Engine A" then self.LeftEngine = ToAEmitter(MoObj) elseif MoObj.PresetName == "Drop Ship Engine B" then self.RightEngine = ToAEmitter(MoObj) end
if self.LeftEngine and self.RightEngine then ConsoleMan:PrintString("Found " .. self.LeftEngine.PresetName .. " and " .. self.RightEngine.PresetName) break end end end
if not (self.LeftEngine and self.LeftEngine:IsAttached())then self.LeftEngine = nil end if not (self.RightEngine and self.RightEngine:IsAttached()) then self.RightEngine = nil end end
Code:
Searching for engines Object: 1| Door Slide Short Object: 2| Door Slide Short A Object: 3| Door Slide Short Object: 4| Door Slide Short A Object: 5| Door Slide Short Object: 6| Door Slide Short A Object: 7| Door Slide Short Object: 8| Door Slide Short A Object: 9| Dummy Controller Object: 10| Door Rotate Short Object: 11| Door Rotate Short A Object: 12| Door Rotate Short Object: 13| Door Rotate Short A Object: 14| Brain Case Object: 15| Dummy Object: 16| Dummy Leg BG A Object: 17| Dummy Arm BG A Object: 18| Dummy Head A Object: 19| Dummy Leg FG A Object: 20| Dummy Arm FG A Object: 21| Dummy Object: 22| Dummy Leg BG A Object: 23| Dummy Arm BG A Object: 24| Dummy Head A Object: 25| Dummy Leg FG A Object: 26| Dummy Arm FG A Object: 27| Dummy Object: 28| Dummy Leg BG A Object: 29| Dummy Arm BG A Object: 30| Dummy Head A Object: 31| Dummy Leg FG A Object: 32| Dummy Arm FG A Object: 33| Dummy Object: 34| Dummy Leg BG A Object: 35| Dummy Arm BG A Object: 36| Dummy Head A Object: 37| Dummy Leg FG A Object: 38| Dummy Arm FG A Object: 39| Dreadnought Object: 40| Dummy Crab Leg BG Object: 41| Dummy Crab Leg BG Object: 42| Dummy Crab Leg FG Object: 43| Dummy Crab Leg FG Object: 44| Dummy Turret Large Object: 45| Dreadnought MG Object: 46| Dummy Turret Large B Object: 47| Dummy Turret Large A Object: 48| Dummy Turret Large D Object: 49| Dreadnought Object: 50| Dummy Crab Leg BG Object: 51| Dummy Crab Leg BG Object: 52| Dummy Crab Leg FG Object: 53| Dummy Crab Leg FG Object: 54| Dummy Turret Large Object: 55| Dreadnought MG Object: 56| Dummy Turret Large B Object: 57| Dummy Turret Large A Object: 58| Dummy Turret Large D Object: 59| Dummy Object: 60| Dummy Leg BG A Object: 61| Dummy Arm BG A Object: 62| Dummy Head A Object: 63| Dummy Leg FG A Object: 64| Dummy Arm FG A Object: 65| Dummy Object: 66| Dummy Leg BG A Object: 67| Dummy Arm BG A Object: 68| Dummy Head A Object: 69| Dummy Leg FG A Object: 70| Dummy Arm FG A Object: 71| Dummy Object: 72| Dummy Leg BG A Object: 73| Dummy Arm BG A Object: 74| Dummy Head A Object: 75| Dummy Leg FG A Object: 76| Dummy Arm FG A Object: 77| Crab Object: 78| Crab Leg BG A Object: 79| Crab Leg BG A Object: 80| Crab Leg FG A Object: 81| Crab Leg FG A Object: 82| AK-47 Object: 83| Light Digger Object: 84| AK-47 Object: 85| Shotgun Object: 86| SMG Object: 87| AK-47
Wed Nov 02, 2011 12:42 am
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
Re: Checking limb status
Did you move the code from Create() to Update()?
Wed Nov 02, 2011 8:01 am
Zaneo
Joined: Sun Oct 23, 2011 7:57 am Posts: 23
Re: Checking limb status
Yup
Code:
function UpdateAI(self) if not self.DockMode == "NotDocked" then return end if not self.searchedForEngines then self.searchedForEngines = true local MoObj for i = 1, MovableMan:GetMOIDCount()-1 do if MovableMan:GetRootMOID(i) == self.ID then -- an obj without a parent has ID == RootID MoObj = MovableMan:GetMOFromID(i) if MoObj.PresetName == "Drop Ship Engine A" then self.LeftEngine = ToAEmitter(MoObj) elseif MoObj.PresetName == "Drop Ship Engine B" then self.RightEngine = ToAEmitter(MoObj) end
if self.LeftEngine and self.RightEngine then ConsoleMan:PrintString("Found " .. self.LeftEngine.PresetName .. " and " .. self.RightEngine.PresetName) break end end end
if not (self.LeftEngine and self.LeftEngine:IsAttached())then self.LeftEngine = nil end if not (self.RightEngine and self.RightEngine:IsAttached()) then self.RightEngine = nil end end
...
end
Wed Nov 02, 2011 11:54 am
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
Re: Checking limb status
No, that is the UpdateAI(self) function. The code that finds the emitters must be in the Update(self) function. The code that adjust the engine output can be in UpdateAI though.
I suspect the Create and UpdateAI functions are executed before a newly created object is registered in the MovableManager, but Update is executed afterwards.
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