Another Damage Question

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

Another Damage Question

Post by Gunner98 »

Playing around with damaging components a little. Setup this code:

ScenEdit_SetUnitDamage({side='NATO', unitname='D 615 FS Jean Bart', fires=1, components={ {'Hangar (1x Small Aircraft (0-12m Long))','Heavy'}, {'type',type='sensor',1} } })
ScenEdit_SetUnitDamage({side='NATO', unitname='D 615 FS Jean Bart', components={ {'Pad (1x Small Aircraft (0-12m Long))','Heavy'}}})


This works fine, but have a couple questions:

a. When I try to put both components on one line it gets messed up. Have tried several different ways and it is probably only a syntax issue but - Do they need to be on separate lines?
b. I don't really understand the numbers for the other bits - for fires the '1' seems to indicate moderate fire, but changing it to 3 or 400 doesn't seem to make a difference, How is that supposed to work.
c. For the sensor type, the '1' seems to indicate that one random sensor will be damaged, but changing that number messes stuff up. How do I get multiple random sensors damaged (like 3 or 4)?
d. There is a helicopter in the hangar which escapes undamaged. This event is going to happen randomly, the helo may be there or it may not. I guess the simplest solution would be to leave things alone: With a damaged pad, the helo can't take off anyway and if it is airborne it will land somewhere else or run out of fuel. But is there a simple way of saying - if helo is present than destroy it? Will the fire do that for me anyway?

Thanks guys.
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Another Damage Question

Post by KnightHawk75 »

a: You can do multiple, but you should use component's guids for names, especially where they are identical otherwise it gets ambiguous when two components share the same name.
local u = SE_GetUnit({name='R 97 Jeanne d Arc', guid='4FH7PU-0HM779RRTM4FS'}) --has 3 pads all named the same.
ScenEdit_SetUnitDamage({side='Blue', guid=u.guid, fires=0, components={ {'4FH7PU-0HM779RRTM4IB','Heavy'}, {'type',type='sensor',1}, {'4FH7PU-0HM779RRTM4IC','Heavy'}, {'type',type='sensor',1} } }) --damage 2 helipads and 2 random sensors.


b:
fires=0 there is not a fire
fires=1 There is a minor fire
fires=2 There is a major fire
fires=3 There is a severe fire
fires=4 There is conflagration

flood=0 there is no flooding
flood=1 There is flooding,
flood=2 There is minor flooding
flood=3 there is severe flooding
flood=4 capsizing\sinking

c: Can call it multiple times or use multiple inline as follows:
ScenEdit_SetUnitDamage({side='Blue', guid=u.guid, fires=0, components={ {'type',type='sensor',1}, {'type',type='sensor',1} } }) --damage 2 random sensors
That said I usually use different method to damage sensors when I want more specific control on which sensors get damaged but it's more involved.

d: Have to try and see, though for those things that ultimately destroy themselves it destroys what's contained in the hosting component. So if the hanger in yours was eventually flipped to 'Destroyed', the contained units in that hanger will get whacked as well. I don't think that happens from fire but maybe it does. There might be a way but idk how to via lua set a non-sensor component to a destroyed state (if you wanted to try forcing it yourself).

Hope that helps a bit.




User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Another Damage Question

Post by Gunner98 »

Thanks KnightHawk75 appreciate the help.

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
Post Reply

Return to “Lua Legion”