miscellaneous aircraft-related improvements

miscellaneous aircraft-related improvements

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
raaar
Metal Factions Developer
Posts: 925
Joined: 20 Feb 2010, 12:17

miscellaneous aircraft-related improvements

Post by raaar »

here goes

There have been some issues with fighter/bomber aircraft for a long time:

- fighters dive dangerously close toward ground targets and often bump into them

- aircraft clump together when moving and turning (especially if collisions are disabled)

- sometimes when you order them to move back to avoid going into enemy AA they turn the wrong way (take the long turn)

- if the game devs want maneuverable aircraft (ex: using maxRudder,etc. = 0.02 instead of 0.005 or 0.01), aircraft noticeably shake when taking off and adjusting trajectory

- maneuverable aircraft keep flying straight after flying past a target for longer than they need to (and no way to control that)

(others?)


to try to solve these issues the following pull requests were created:

add attackSafetyDistance unitDef
(merged in 99.0 rc4 !)

miscellaneous aircraft-related improvements
(postponed for next spring version)

these bring new unitdefs:

- attackSafetyDistance : fighters abort dive toward target if within attackSafetyDistance and climb back to normal altitude (default 0 = disabled, for a typical 600 range fighter a good value may be 300)

- airManeuverabilitySpread : fighter/bomber aircraft maneuverability parameter randomness (previously hardcoded to 0.02, which is the new default. Larger values like 0.25 can be used to significantly reduce clumping in zk fighters, note that it doesn't change max velocity)

- attackOverflyDistance : controls how far fighter/bomber aircraft move after overflying target. Default value of 0 is converted internally to max(turnRadius, maxWeaponRange). Only applies if attacking and against targets moving at less than 25% of the aircraft's speed.


note that i've tried to make it so the new properties have default values that work with existing games as-is, and from the tests i've made in XTA, ZK and BA and S44 (not the latest) and MF, they sort of do.

opinions?
User avatar
jamerlan
Balanced Annihilation Developer
Posts: 683
Joined: 20 Oct 2009, 13:04

Re: miscellaneous aircraft-related improvements

Post by jamerlan »

Sounds good! Thanks!
raaar
Metal Factions Developer
Posts: 925
Joined: 20 Feb 2010, 12:17

Re: miscellaneous aircraft-related improvements

Post by raaar »

Kloot wrote:FOR FUCK'S SAKE ... viewtopic.php?f=12&t=33575#p570401
politeness

my priority is to resolve the issues, not go into a screaming contest

When I first made the changes, people told me to make behavior configurable. Then I looked at how to add unitDefs and it seemed easy enough.

attackOverflyDistance's default is probably good enough and airManeuverabilitySpread is a cheap way to spread out aircraft without fancy (and probably computationally expensive) coding.

I'd use the defaults on my game. They should work for other games as well....Those unitDefs could be removed, but do we really gain much from removing them? Why?

We could use a Lua way to dinamically flag specific units to use custom unitdef trees (with weapondefs, movedefs, etc.) that can be updated and reloaded in-game. But that implies attributes being registered as unitDefs in the first place.
User avatar
Silentwings
Moderator
Posts: 3686
Joined: 25 Oct 2008, 00:23

Re: miscellaneous aircraft-related improvements

Post by Silentwings »

Split general discussion of unitdef tags versus lua callins to viewtopic.php?f=12&t=33575
raaar
Metal Factions Developer
Posts: 925
Joined: 20 Feb 2010, 12:17

Re: miscellaneous aircraft-related improvements

Post by raaar »

the attackSafetyDistance unitdef was added in 99.0 but replaced by devs in 100.0 (?%#!) with a lua workaround.

example code for gadget:

[code]local specialCases = {
aven_ace = 9999.0
}

local DEFAULT_DISTANCE = 350.0


if (gadgetHandler:IsSyncedCode()) then
function gadget:UnitCreated(unitID, unitDefID, unitTeam)
if (UnitDefs[unitDefID].canFly and UnitDefs[unitDefID].isStrafingAirUnit and not UnitDefs[unitDefID].hoverAttack) then
local dist = DEFAULT_DISTANCE
local name = UnitDefs[unitDefID].name
if specialCases[name] then
dist = specialCases[name]
end

Spring.MoveCtrl.SetAirMoveTypeData(unitID,{attackSafetyDistance=dist})
end
end

end[/code]


this example makes all fighter aircraft use safety distance of 350 except "aven_ace" (which is classified by engine as a fighter but is a bomber that shoots a tracking mini-nuke : setting to 9999 makes it fly like a normal bomber).

There was also a bug that made spring crash when SetAirMoveTypeData with that parameter was called for construction aircraft, that's why i used the apparently redundant tests on my code. I can't find it on mantis though, maybe it was sneakfixed.

I've been focusing on finishing other stuff but plan to work some more in the aircraft code in the next week or so.
User avatar
Jools
XTA Developer
Posts: 2814
Joined: 23 Feb 2009, 16:29

Re: miscellaneous aircraft-related improvements

Post by Jools »

Feel free to put the relevant code also in xta if you have the energy: you have better knowledge of these issues than anyone else.
Post Reply

Return to “Engine”

cron