For the TA scripters (SetMaxReloadTime)

For the TA scripters (SetMaxReloadTime)

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
Fnordia
Former Engine Dev
Posts: 425
Joined: 13 Aug 2004, 16:11

For the TA scripters (SetMaxReloadTime)

Post 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?
Prognosis
Posts: 3
Joined: 07 May 2005, 05:14

Post 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.
Fnordia
Former Engine Dev
Posts: 425
Joined: 13 Aug 2004, 16:11

Post 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.
Prognosis
Posts: 3
Joined: 07 May 2005, 05:14

Post 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.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Post 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
Fnordia
Former Engine Dev
Posts: 425
Joined: 13 Aug 2004, 16:11

Post by Fnordia »

Thanks! Just one thing then, for units with no weapons, should it be 0, 3000 or no call at all perhaps? :)
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Post 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.
Post Reply

Return to “Game Development”