Page 1 of 1

For the TA scripters (SetMaxReloadTime)

Posted: 07 May 2005, 00:35
by Fnordia
I am trying to get the Illuminator unit to function, and it seems to expect a call to SetMaxReloadTime to work properly. So I'm wondering when this function should be called, and with what values?

My guess would be that it wants the reloadtime from the weapon in some manner, but if so, for which weapon? Or perhaps it should be max(weapon1+weapon2+weapon3) and called after the unit is created?

Posted: 07 May 2005, 05:19
by Prognosis
I think it doesn't set anything, it gets the max reload time the unit has. If you look at the scripts, it's used in conjunction with the RestoreAfterDelay callback.

Like this:

static-var restore_delay;

create()
{
}

SetMaxReloadTime(time)
{
restore_delay = time * 2;
}

RestoreAfterDelay()
{
sleep restore_delay;

//restore stuff goes here
}

so basically it's just waiting for the weapon to finish reloading before it moves everything back... to my knowlege if SetMaxReloadTime is called by the script it won't have the correct value for time specified.

Posted: 07 May 2005, 19:43
by Fnordia
Hm no I think you misunderstand me. :) I am not planning to edit the script. What I meant is that the engine has to call SetMaxReloadTime and pass this value at some point. So I was wondering when TA calls it, and with what value, so I can do it in the same way in spring.

Calling it right after calling Create seems to work fine in this case, but if TA does it differently it could possibly break some other more exotic script.

Posted: 08 May 2005, 03:16
by Prognosis
ah yes, sorry, I misunderstood.

I did some poking around in ollydbg and it looks like the time argument is always 3,000

that really seems wierd to me and I thought it wasn't always like this but... whatever.

Posted: 13 May 2005, 00:47
by zwzsg
The SetMaxReloadTime(time) function is called only once, when the unit starts existing.

The argument value is the reload time defined in the weapon .tdf, but in milliseconds instead of seconds. And floored to the nearest multiple of 33.3333...

Proof:
This modified version of my Bridodon that ejects a chassis each time the function is called and constantly display the value of the argument in last call.

If there is more than one weapon, then it uses the reload time of the slowest weapon.

If there are two weapons and both have reload under 3sec, then it uses 3000. But if there is only one weapon, then the argument follow the weapon reload time under 3sec.

Test I did:
One weapon, reload 0.19: -> 166
One weapon, reload 0.21: -> 200
One weapon, reload 0.95: -> 933
One weapon, reload 1: -> 1000
One weapon, reload 1.2: -> 1200
Weapon1, reload 1.2, Weapon2, reload 1.8: -> 3000
Weapon1, reload 1.05, Weapon2, reload 1.8: -> 3000
Weapon1, reload 0.8, Weapon2, reload 1.8: -> 3000
Weapon1, reload 2.9, Weapon2, reload 1.8: -> 3000
Weapon1, reload 3.1, Weapon2, reload 1.8: -> 3100
Weapon1, reload 4, Weapon2, reload 1.8: -> 4000

Posted: 13 May 2005, 01:28
by Fnordia
Thanks! Just one thing then, for units with no weapons, should it be 0, 3000 or no call at all perhaps? :)

Posted: 13 May 2005, 01:52
by zwzsg
For a weaponless unit, it's called, with a value of 0.

I don't know about what happens when there is three weapons.