WirtsLegs Posted July 24, 2024 Posted July 24, 2024 Pretty simple request, currently there is a trigger action called "UNIT AI SET LIFE" if this function could be exposed to the LUA api that would be incredibly useful for a variety of scripts/scenarios 2
Gunfreak Posted July 24, 2024 Posted July 24, 2024 What does "UNIT AI SET LIFE" Does it what it sounds like. You can specify how much "health/life" an AI unit has? I'm asking as this sounds interesting, as some units have way too much health (like the German uboat that can take several 500lb bombs ) i7 13700k @5.2ghz, GTX 5090 OC, 128Gig ram 4800mhz DDR5, M2 drive.
WirtsLegs Posted July 24, 2024 Author Posted July 24, 2024 3 minutes ago, Gunfreak said: What does "UNIT AI SET LIFE" Does it what it sounds like. You can specify how much "health/life" an AI unit has? I'm asking as this sounds interesting, as some units have way too much health (like the German uboat that can take several 500lb bombs ) yeah basically you can set a units life to a percentage of its max, essentially let you apply damage (or remove it) on the fly to AI units without needing to actually hit them with a weapon 1
Gunfreak Posted July 24, 2024 Posted July 24, 2024 1 minute ago, WirtsLegs said: yeah basically you can set a units life to a percentage of its max, essentially let you apply damage (or remove it) on the fly to AI units without needing to actually hit them with a weapon Excellent, there are definitely some units that take too much damage, like the previous mentioned uboat, but also the 3 other ww2 ships in the game. Also some stuff like ww2 AT guns, I assume if you just want them to take less punishment You just add "at mission start" and add UNIT AI SET LIFE. No need for anything else? i7 13700k @5.2ghz, GTX 5090 OC, 128Gig ram 4800mhz DDR5, M2 drive.
WirtsLegs Posted July 24, 2024 Author Posted July 24, 2024 39 minutes ago, Gunfreak said: Excellent, there are definitely some units that take too much damage, like the previous mentioned uboat, but also the 3 other ww2 ships in the game. Also some stuff like ww2 AT guns, I assume if you just want them to take less punishment You just add "at mission start" and add UNIT AI SET LIFE. No need for anything else? yeah that should do it just know that if you get fancy and do it later in the mission if you try to set life on a unit thats dead and burning (not fully gone yet) it will revive it but break the groups AI and it will just stop working 1
Kappa-131st Posted October 9, 2024 Posted October 9, 2024 @ED : Can you give us an LUA function to use SET AI UNIT LIFE ? Ex : Unit.setLife(Class Self, number ) 1
Migow Posted October 25, 2024 Posted October 25, 2024 On 10/9/2024 at 11:41 PM, Kappa-131st said: @ED : Can you give us an LUA function to use SET AI UNIT LIFE ? Ex : Unit.setLife(Class Self, number ) Please ED we need this function asap please if it does exist with a trigger then it could be implemented easy way! 1 member of 06 MHR / FENNEC Mi-24P
Dovivan Posted January 14 Posted January 14 (edited) need this function too. Trigger works @Wags @NineLine Edited January 14 by Dovivan 1 2
Actium Posted June 24 Posted June 24 This has been acknowledged as "not currently planned" by BIGNEWY: Fortunately, the required command is available within the mission editor/triggers Lua environment, so I've found a way to access it from the mission scripting Lua environment: net.dostring_in("mission", string.format("a_unit_set_life_percentage(%d, 42)", Unit.getByName("Aerial-1-1"):getID() ) ) 1 1
Kappa-131st Posted June 24 Posted June 24 21 minutes ago, Actium said: This has been acknowledged as "not currently planned" by BIGNEWY: Fortunately, the required command is available within the mission editor/triggers Lua environment, so I've found a way to access it from the mission scripting Lua environment: net.dostring_in("mission", string.format("a_unit_set_life_percentage(%d, 42)", Unit.getByName("Aerial-1-1"):getID() ) ) Oh my good, I will try this right now, if it's work I will be so grateful to you !!! 1
Kappa-131st Posted June 24 Posted June 24 It work well !!! I've been looking for a way to adjust hit points for so long! Thank you so Much !! 1
Migow Posted June 24 Posted June 24 @Actium many thanks , you save our life 1 member of 06 MHR / FENNEC Mi-24P
WirtsLegs Posted June 25 Author Posted June 25 @Actium good find! still silly that this isnt just part of the standard lua api 1
killjoy73au Posted June 25 Posted June 25 (edited) Concur, is needed. If for nothing more than simplicity and streamlining in making triggers now there is an .lua script for it. Edited June 25 by killjoy73au
Actium Posted June 25 Posted June 25 Happy to help. I only stumbled over this yesterday, toying around with my Lua WebConsole. Here's a way to monkey patch it into the existing Unit singleton: -- monkey patch method into Unit singleton (needed only once) function Unit:setLifePercent(life) net.dostring_in("mission", string.format("a_unit_set_life_percentage(%d, %f)", self:getID(), life) ) end -- usage example Unit.getByName("Naval-1-1"):setLifePercent(42) 2
WirtsLegs Posted June 25 Author Posted June 25 3 hours ago, Actium said: Happy to help. I only stumbled over this yesterday, toying around with my Lua WebConsole. Here's a way to monkey patch it into the existing Unit singleton: -- monkey patch method into Unit singleton (needed only once) function Unit:setLifePercent(life) net.dostring_in("mission", string.format("a_unit_set_life_percentage(%d, %f)", self:getID(), life) ) end -- usage example Unit.getByName("Naval-1-1"):setLifePercent(42) yeah did something similar in a script I'm working on last night worth noting, this should be doable for all trigger functions as there are a few others that are not accessible via the normal lua api
cfrag Posted June 25 Posted June 25 This is a GREAT find, thank you @Actium - and IMHO it might help put to shame the sorry excuse that we currently have as 'mission save state' - if this works out well, we can finally create create mission persistence where a unit can be restored to a saved location and health (of course, it still has full ammo, but beggars can't be choosers). It's sometimes depressing to be reminded just how godawful ED's abilities are when following what content creators desperately need and are clamouring for (or designing sensible API) 1
El Tonio Posted June 27 Posted June 27 @Actium just gotta add my thanks as well for this, have wanted this about as long as Wirt has, thanks for pointing this out, works really well. 2
Pikey Posted Wednesday at 06:50 AM Posted Wednesday at 06:50 AM What is the impact when run on a connected client in mp from the pov of server and client being in sych? Not everything works or is designed to work like this. I've seen lots of occasions in MP many years back where clients run around invisible because they aren't synched. I'd be glad if it did, but it's not an area I've found the simulation was strong in. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
WirtsLegs Posted Wednesday at 08:44 PM Author Posted Wednesday at 08:44 PM 13 hours ago, Pikey said: What is the impact when run on a connected client in mp from the pov of server and client being in sych? Not everything works or is designed to work like this. I've seen lots of occasions in MP many years back where clients run around invisible because they aren't synched. I'd be glad if it did, but it's not an area I've found the simulation was strong in. Shouldn't be a problem for AI units As for player aircraft, hard to say, but setLife does weird things for anything that doesn't have a healthbar anyway (aircraft basically) so unlikely to be used for that regardless
Recommended Posts