Jump to content

Recommended Posts

Posted

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

  • Thanks 2
Posted

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.

Posted
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

  • Thanks 1
Posted
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.

Posted
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

  • Thanks 1
  • 2 months later...
  • 3 weeks later...
Posted
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!

  • Thanks 1

member of 06 MHR /  FENNEC Mi-24P

  • 2 months later...
  • 5 months later...
Posted

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()
    )
)
  • Like 1
  • Thanks 1
Posted
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 !!! 🤩

  • Like 1
Posted (edited)

Concur, is needed. If for nothing more than simplicity and streamlining in making triggers now there is an .lua script for it.

Edited by killjoy73au
Posted

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)
  • Like 2
Posted
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

Posted

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)

 

  • Like 1
Posted

@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. 

  • Like 2
Posted

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 *

Posted
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...