Skip to content

Commit

Permalink
Merge pull request #492 from GoogleFrog/stopToAttack
Browse files Browse the repository at this point in the history
Added stopToAttack
  • Loading branch information
gajop committed May 9, 2020
2 parents ff4e66d + 36249ce commit a22b2eb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions rts/Lua/LuaUnitDefs.cpp
Expand Up @@ -865,6 +865,7 @@ ADD_BOOL("canAttackWater", canAttackWater); // CUSTOM

ADD_BOOL("levelGround", ud.levelGround);
ADD_BOOL("strafeToAttack", ud.strafeToAttack);
ADD_BOOL("stopToAttack", ud.stopToAttack);

ADD_BOOL( "useBuildingGroundDecal", ud.decalDef.useGroundDecal);
ADD_INT( "buildingDecalType", ud.decalDef.groundDecalType);
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Units/CommandAI/MobileCAI.cpp
Expand Up @@ -710,7 +710,7 @@ void CMobileCAI::ExecuteObjectAttack(Command& c)
// also make sure that we're not locked in close-in/in-range state
// loop due to rotates invoked by in-range or out-of-range states
if (tryTargetRotate) {
const bool canChaseTarget = (owner->moveState != MOVESTATE_HOLDPOS);
const bool canChaseTarget = (!owner->unitDef->stopToAttack) && (owner->moveState != MOVESTATE_HOLDPOS);
const bool targetBehind = (targetMidPosVec.dot(orderTarget->speed) < 0.0f);

if (canChaseTarget && tryTargetHeading && targetBehind && !owner->unitDef->IsHoveringAirUnit()) {
Expand Down
2 changes: 2 additions & 0 deletions rts/Sim/Units/UnitDef.cpp
Expand Up @@ -110,6 +110,7 @@ UnitDef::UnitDef()
, floatOnWater(false)
, pushResistant(false)
, strafeToAttack(false)
, stopToAttack(false)
, minCollisionSpeed(0.0f)
, slideTolerance(0.0f)
, maxHeightDif(0.0f)
Expand Down Expand Up @@ -599,6 +600,7 @@ UnitDef::UnitDef(const LuaTable& udTable, const std::string& unitName, int id)
canLoopbackAttack = udTable.GetBool("canLoopbackAttack", false);
levelGround = udTable.GetBool("levelGround", true);
strafeToAttack = udTable.GetBool("strafeToAttack", false);
stopToAttack = udTable.GetBool("stopToAttack", false);


// initialize the (per-unitdef) collision-volume
Expand Down
1 change: 1 addition & 0 deletions rts/Sim/Units/UnitDef.h
Expand Up @@ -177,6 +177,7 @@ struct UnitDef: public SolidObjectDef
bool floatOnWater;
bool pushResistant;
bool strafeToAttack; /// should the unit move sideways when it can't shoot?
bool stopToAttack;
float minCollisionSpeed;
float slideTolerance;
float maxHeightDif; /// maximum terraform height this building allows
Expand Down

0 comments on commit a22b2eb

Please sign in to comment.