Skip to content

Commit

Permalink
Fix AI ships roaming to world origin
Browse files Browse the repository at this point in the history
  • Loading branch information
GinjaNinja32 committed Aug 4, 2024
1 parent 951630e commit d75196a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ai/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void ShipAI::runOrders()
}else{
auto diff = owner->getOrderTargetLocation() - owner->getPosition();
if (glm::length2(diff) < 1000.0f*1000.0f)
owner->orderRoamingAt(glm::vec2(random(-long_range, long_range), random(-long_range, long_range)));
owner->orderRoamingAt(owner->getPosition() + glm::vec2(random(-long_range, long_range), random(-long_range, long_range)));
flyTowards(owner->getOrderTargetLocation());
}
}else if (owner->weapon_tube_count > 0)
Expand All @@ -394,7 +394,7 @@ void ShipAI::runOrders()
}else{
auto diff = owner->getOrderTargetLocation() - owner->getPosition();
if (glm::length2(diff) < 1000.0f*1000.0f)
owner->orderRoamingAt(glm::vec2(random(-long_range, long_range), random(-long_range, long_range)));
owner->orderRoamingAt(owner->getPosition() + glm::vec2(random(-long_range, long_range), random(-long_range, long_range)));
flyTowards(owner->getOrderTargetLocation());
}
}else{
Expand Down
2 changes: 1 addition & 1 deletion src/spaceObjects/cpuShip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void CpuShip::orderRoaming()
target_rotation = getRotation();
orders = AI_Roaming;
order_target = NULL;
order_target_location = glm::vec2(0, 0);
order_target_location = getPosition();
this->addBroadcast(FVF_Friendly, tr("cpulog", "Searching for targets."));
}

Expand Down

0 comments on commit d75196a

Please sign in to comment.