If HoverAttack=1 and AirStrafe=1, then gunships will behave as they do at the moment. They're strafe in a circle around the target.
However, if HoverAttack=1 and AirStrafe=0, they will not strafe, and they will sit stationary in the air firing their weapons.
The same applies for other strafing. A construction aircraft with AirStrafe=0 will not move in a circle around a construction project, fature being reclaimed, or ressurecting feature.
Tested and verified using the EE bumblebee and the XTA arm construction plane to test if it works. Other planes without the tag showed no changes in behaviour.
Also I believe this does not affect fighters (hawk style), which use a different movement model, aka units with HoverAttack=0; who cant build, and genreally fall into the class of hawks and vamps. This shouldnt be a problem though.
Code: Select all
Index: Sim/MoveTypes/TAAirMoveType.cpp
===================================================================
--- Sim/MoveTypes/TAAirMoveType.cpp (revision 3269)
+++ Sim/MoveTypes/TAAirMoveType.cpp (working copy)
@@ -343,43 +343,48 @@
//logOutput.Print("In position, landing");
return;
case FLY_CIRCLING:
+ // break;
waitCounter++;
if (waitCounter > 100) {
//logOutput.Print("moving circlepos");
+ if(owner->unitDef->AirStrafe){
+ float3 relPos = pos - circlingPos;
+ if(relPos.x<0.0001f && relPos.x>-0.0001f)
+ relPos.x=0.0001f;
+ relPos.y = 0;
+ relPos.Normalize();
+ CMatrix44f rot;
+ rot.RotateY(1.0f);
+ float3 newPos = rot.Mul(relPos);
+
+ //Make sure the point is on the circle
+ newPos = newPos.Normalize() * goalDistance;
+
+ //Go there in a straight line
+ goalPos = circlingPos + newPos;
+ }
+ waitCounter = 0;
+ }
+ break;
+ case FLY_ATTACKING:{
+ //logOutput.Print("wait is %d", waitCounter);
+ if(owner->unitDef->AirStrafe){
float3 relPos = pos - circlingPos;
if(relPos.x<0.0001f && relPos.x>-0.0001f)
relPos.x=0.0001f;
relPos.y = 0;
relPos.Normalize();
CMatrix44f rot;
- rot.RotateY(1.0f);
+ if (gs->randFloat()>0.5f)
+ rot.RotateY(0.6f+gs->randFloat()*0.6f);
+ else
+ rot.RotateY(-(0.6f+gs->randFloat()*0.6f));
float3 newPos = rot.Mul(relPos);
-
- //Make sure the point is on the circle
newPos = newPos.Normalize() * goalDistance;
//Go there in a straight line
goalPos = circlingPos + newPos;
- waitCounter = 0;
}
- break;
- case FLY_ATTACKING:{
- //logOutput.Print("wait is %d", waitCounter);
- float3 relPos = pos - circlingPos;
- if(relPos.x<0.0001f && relPos.x>-0.0001f)
- relPos.x=0.0001f;
- relPos.y = 0;
- relPos.Normalize();
- CMatrix44f rot;
- if (gs->randFloat()>0.5f)
- rot.RotateY(0.6f+gs->randFloat()*0.6f);
- else
- rot.RotateY(-(0.6f+gs->randFloat()*0.6f));
- float3 newPos = rot.Mul(relPos);
- newPos = newPos.Normalize() * goalDistance;
-
- //Go there in a straight line
- goalPos = circlingPos + newPos;
// logOutput.Print("Changed circle pos");
break;}
case FLY_LANDING:{
Index: Sim/Units/UnitDef.h
===================================================================
--- Sim/Units/UnitDef.h (revision 3269)
+++ Sim/Units/UnitDef.h (working copy)
@@ -177,6 +177,7 @@
float turnRadius;
float wantedHeight;
bool hoverAttack;
+ bool AirStrafe;
float dlHoverFactor; // < 0 means it can land, >= 0 indicates how much the unit will move during hovering on the spot
bool DontLand () { return dlHoverFactor >= 0.0f; }
Index: Sim/Units/UnitDefHandler.cpp
===================================================================
--- Sim/Units/UnitDefHandler.cpp (revision 3269)
+++ Sim/Units/UnitDefHandler.cpp (working copy)
@@ -352,8 +352,9 @@
if(ud.builder && !ud.buildSpeed) //core anti is flagged as builder for some reason
ud.builder=false;
- ud.wantedHeight=atof(tdfparser.SGetValueDef("0", "UNITINFO\\cruisealt").c_str());;
- ud.hoverAttack = !!atoi(tdfparser.SGetValueDef("0", "UNITINFO\\hoverattack").c_str());
+ ud.wantedHeight=atof(tdfparser.SGetValueDef("0", "UNITINFO\\cruisealt").c_str());
+ tdfparser.GetDef(ud.hoverAttack,"0", "UNITINFO\\hoverattack");
+ tdfparser.GetDef(ud.AirStrafe,"1", "UNITINFO\\AirStrafe");
ud.dlHoverFactor = atof(tdfparser.SGetValueDef("-1", "UNITINFO\\airhoverfactor").c_str());
tdfparser.GetDef(ud.transportSize, "0", "UNITINFO\\transportsize");