AirStrafe.patch (3,719 bytes)
2007-01-27 00:27
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");