Afterburner for air units

Afterburner for air units

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Afterburner for air units

Post by MadRat »

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?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I would use a lua gadget for this, but you have an aversion to anything lua, so you're foobarred. But its a good pointer for anyone else interested in the same thing.
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Post by Peet »

Ehh...friendly aircraft already do enough damage to each other through collisions already, without a major intermittent speed boost :P
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Post by yuritch »

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.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

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. :(
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

I'm familiar with cobs, yes.
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

yuritch-

When setting max_speed for the unit, doesn't that afix a new max speed until reset?

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.
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

When setting max_speed for the unit, doesn't that afix a new max speed until reset?
Yes. You'll have to save its original max_speed in a static-var.
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.
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!
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...
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

You can just use a weapon that only aims, never fires (melee works nicely since it ignores terrain).
Post Reply

Return to “Lua Scripts”