Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2014-12-22 21:34:20 +0000
committerStijn Buys <ingar@osirion.org>2014-12-22 21:34:20 +0000
commit4ca3ba6e59b871fc77662eccb51e0c773a95299f (patch)
tree9d6a9ee851031b4ce88a3277f233a340353ef1f0 /src/game/base
parent243ef412d9abb609ec1ad6ed296056c6c7c3a063 (diff)
Wingmen will try to repair their ship when not in combat.
Diffstat (limited to 'src/game/base')
-rw-r--r--src/game/base/npc.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc
index ec43ea0..f327f16 100644
--- a/src/game/base/npc.cc
+++ b/src/game/base/npc.cc
@@ -14,8 +14,10 @@
namespace game {
-const float NPC_WIMPY = 20.0f; // indicates the health percentage at which the NPC willtry to repair itself
-const float NPC_REPAIR_ARMOR_PER_SECOND = 25.0f; // repair rate in units of armor per second
+const float NPC_REPAIR_WIMPY = 20.0f; // the health percentage at which the NPC willtry to repair itself
+const float NPC_REPAIR_IDLE = 70.0f; //the health percentage at which the NPC willtry to repair itself when not in combat
+const float NPC_REPAIR_RATE = 25.0f; // repair rate in units of armor per second
+
// NPC Wingman factory function
NPC *NPC::add_wingman(Ship *leader)
@@ -322,7 +324,7 @@ void NPC::frame(const unsigned long elapsed)
} else {
while (npc_repair_timestamp + 1000 < now)
{
- set_armor(armor() + NPC_REPAIR_ARMOR_PER_SECOND);
+ set_armor(armor() + NPC_REPAIR_RATE);
npc_repair_timestamp += 1000;
}
}
@@ -339,7 +341,7 @@ void NPC::frame(const unsigned long elapsed)
}
}
} else {
- if (leader()->has_flag(core::Entity::Dockable) && (health() < NPC_WIMPY))
+ if (leader()->has_flag(core::Entity::Dockable) && (health() < NPC_REPAIR_WIMPY))
{
set_autopilot_target(leader());
@@ -364,8 +366,16 @@ void NPC::frame(const unsigned long elapsed)
set_autopilot_flag(Ship::AutoPilotEnabled);
unset_autopilot_flag(Ship::AutoPilotCombat);
- unset_autopilot_flag(Ship::AutoPilotDock);
- set_autopilot_flag(Ship::AutoPilotFormation);
+
+ if (leader()->has_flag(core::Entity::Dockable) && (health() < NPC_REPAIR_IDLE))
+ {
+ set_autopilot_flag(Ship::AutoPilotDock);
+ unset_autopilot_flag(Ship::AutoPilotFormation);
+ } else
+ {
+ unset_autopilot_flag(Ship::AutoPilotDock);
+ set_autopilot_flag(Ship::AutoPilotFormation);
+ }
}
}
}