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?
For the TA scripters (SetMaxReloadTime)
Moderator: Moderators
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.
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.
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.
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.
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
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