OpenXcom Forum

Modding => OXCE Support => OpenXcom Extended => OXCE Support Y-scripts => Topic started by: Nord on September 14, 2023, 08:37:11 pm

Title: Scripthooks for burning and smoke damage.
Post by: Nord on September 14, 2023, 08:37:11 pm
Hi. I have a pair of questions:
1. Which ScriptHook is used when fire damage ignites a unit? (So we can influence this process?)
2. Which ScriptHook is used for stun damage from standing in smoke?

Because "HitUnit", as i see, does not work.
Thanks.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Yankes on September 14, 2023, 11:59:18 pm
`damageUnit` is thing you look for.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Nord on September 15, 2023, 06:47:15 am
`damageUnit` is thing you look for.
Are you sure? Because when fire bullet hits energy shield, and shield reduces bullet power to 0 (shield script uses hitUnit), a unit still become burning.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Yankes on September 15, 2023, 11:39:03 am
Ok, I do not read carefully, my aswer was for fire and smoke environment damage (env fire catching is not scripted yet).
For handing fire during hit, there is special hook `damageSpecialUnit`that is repressible for this and other "post processing" of unit hit.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Nord on September 15, 2023, 07:59:05 pm
Ok, I do not read carefully, my aswer was for fire and smoke environment damage (env fire catching is not scripted yet).
For handing fire during hit, there is special hook `damageSpecialUnit`that is repressible for this and other "post processing" of unit hit.
Aha, seems that my saved "verbose log" is outdated. Thanks, going to make new one.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Nord on September 16, 2023, 11:16:32 am
Well...
How do i can forbid unit to burn?
"unit.setFire 0;" does nothing.
Sorry for doubleposting.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Yankes on September 16, 2023, 12:12:15 pm
Setting this you set fire that was "before" this hook call, as right after this hook engine code call `unit.setFire X` and override that you set there.
Whole point of this hook is expose `fire` variable that allow you to alter it for engine and it will be set on unit.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Nord on September 16, 2023, 01:41:23 pm
Setting this you set fire that was "before" this hook call, as right after this hook engine code call `unit.setFire X` and override that you set there.
Whole point of this hook is expose `fire` variable that allow you to alter it for engine and it will be set on unit.
Ok, thanks.

So, if i want to prevent my unit from start burning, this script hook will not help me?
Then as i understand, ignition of units standing in fire is hardcoded?
Title: Re: Scripthooks for burning and smoke damage.
Post by: Meridian on September 16, 2023, 02:13:46 pm
So, if i want to prevent my unit from start burning, this script hook will not help me?

This script can help you.

But instead of using setFire yourself, you should just set the value of the output parameter(s) that will then call setFire for you.

What you're doing now:
1. game calculates duration of fire to be for example X = 7
2. you call setFire 0
3. game calls setFire X (7)

What you should be doing instead:
1. game calculates duration of fire to be for example X = 7
2. you change X from 7 to 0
3. game calls setFire X (0)

Then as i understand, ignition of units standing in fire is hardcoded?

yes, Yankes said above that the catching on fire from environment is not scripted yet

only hits by projectiles and explosions are scripted

you can still make the armor fire-proof, and the unit will not catch on fire then
Title: Re: Scripthooks for burning and smoke damage.
Post by: Nord on September 16, 2023, 05:15:49 pm
...
What you're doing now:
1. game calculates duration of fire to be for example X = 7
2. you call setFire 0
3. game calls setFire X (7)
...
Ok, i dont understand that. One thing missing: what is "X" from this example in the terms of script?  Maybe you mean "BattleUnit.setFire" in the "newTurnUnit" script hook?
Title: Re: Scripthooks for burning and smoke damage.
Post by: Meridian on September 16, 2023, 05:30:46 pm
In terms of script, it is the 6th input/output parameter of the "damageSpecialUnit" hook, called "fire".

The one highlighted in the screenshot.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Nord on September 16, 2023, 06:30:16 pm
So, command will be
Code: [Select]
set fire 0;Have tried. Did not work.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Meridian on September 16, 2023, 06:41:21 pm
Can you paste the whole script?

And also describe in which scenario did you test it?
Title: Re: Scripthooks for burning and smoke damage.
Post by: Meridian on September 16, 2023, 07:02:20 pm
I just tried this and it works without problems:

Code: [Select]
extended:
  scripts:
    damageSpecialUnit:
      - offset: 88    # Script to disable setting units on fire by projectiles and explosions
        code: |
          set fire 0;
          return;

I sprayed my rookies with Autocannon Incendiary rounds and none of them caught on fire.
Title: Re: Scripthooks for burning and smoke damage.
Post by: Nord on September 16, 2023, 08:16:56 pm
Thanks, maybe i did something wrong. Will try again.