I'd like to have some way for units to kick in an afterburner maxvelocity variable once they enter within range of their target equal to or less than the "AttackRunLength" setting. The afterburner setting needs to allow for flexible fuel usage rates proportionately higher than their normal rate, perhaps using an exponential factor of some type. This would only be for units designated with an afterburner and not for all of the air units. And this would need to work for units regardless of weapons type.
1. How would I declare a variable in my fbi for this?
2. How would I declare a separate maxvelocity for afterburners usage that did not change the original maxvelocity value?
3. How would I make the fuel usage burn exponentially faster than normal when using afterburner?
Afterburner for air units
Moderator: Moderators
This can surely done in pure COB, without any lua tricks. We have set CURRENT_FUEL (at least in svn, I'm not sure about 0.75b2), we have set MAX_SPEED (this is in 0.75b2 for sure). That means we can control fuel reserve and speed of an aircraft via script.
Of course, accounting for weapons firing (if they are set to use fuel) will be a bit trickier, but this can too be done (by using FireWeaponX() COB call).
Strangely I'd prefer some aircraft to actually slow down during an attack "dive" so that it can fire more shots at the enemy, but this depends on weapons heavily - if your plane uses cannons, it should stay over the target longer; if it has bombs or rockets, it should try to fire them as quickly as possible and leave.
Of course, accounting for weapons firing (if they are set to use fuel) will be a bit trickier, but this can too be done (by using FireWeaponX() COB call).
Strangely I'd prefer some aircraft to actually slow down during an attack "dive" so that it can fire more shots at the enemy, but this depends on weapons heavily - if your plane uses cannons, it should stay over the target longer; if it has bombs or rockets, it should try to fire them as quickly as possible and leave.
MadRat: have you ever scripted a unit yet?
Just set a var in one of your AimWeapon functions to make the unit slow down when it's attacking and start a script with a timeout (which also kills itself with a signal!) to unset the var, much like that RestoreAfterDelay() stuff you find in every other script.
For the fuel and speed checks/updates I'd run a seperate endless loop or integrate it in some other endless loop (for animations perhaps).
edit: Eh yeah, what yuritch said. Slow posting ftl. :(
Just set a var in one of your AimWeapon functions to make the unit slow down when it's attacking and start a script with a timeout (which also kills itself with a signal!) to unset the var, much like that RestoreAfterDelay() stuff you find in every other script.
For the fuel and speed checks/updates I'd run a seperate endless loop or integrate it in some other endless loop (for animations perhaps).
edit: Eh yeah, what yuritch said. Slow posting ftl. :(
-
- Posts: 854
- Joined: 28 Jan 2005, 18:15
Yes. You'll have to save its original max_speed in a static-var.When setting max_speed for the unit, doesn't that afix a new max speed until reset?
fbi? Fancy lua stuff! Hehe... don't ask me just yet, I won't know until I get to the point where I have to flesh that stuff out myself, and I'm hoping someone else already has!How would I check range of target against "AttackRunLength" when Spring ignores it currently? Sounds like it would have to be hardcoded in the cob. I'd much prefer it in the fbi.
But basically, because all the unitdef stuff is parsed with a lua parser now, it is all accessable directly by lua. check it. Especially the stuff about CustomParams, though I have no clue what it means from that short blurb. Notice how this second part isn't really an answer...