diff.txt (6,189 bytes)
2009-12-09 09:23
diff --git a/rts/Game/GameHelper.cpp b/rts/Game/GameHelper.cpp
index fc2b48d..60fea7f 100644
--- a/rts/Game/GameHelper.cpp
+++ b/rts/Game/GameHelper.cpp
@@ -820,8 +820,14 @@ void CGameHelper::GenerateTargets(const CWeapon *weapon, CUnit* lastTarget,
if (unit == lastTarget) {
value *= weapon->avoidTarget ? 10.0f : 0.4f;
}
- if (paralyzer && unit->paralyzeDamage > unit->maxHealth) {
- value *= 4.0f;
+ if (modInfo.paralyzeOnMaxHealth) {
+ if (paralyzer && unit->paralyzeDamage > unit->maxHealth) {
+ value *= 4.0f;
+ }
+ } else {
+ if (paralyzer && unit->paralyzeDamage > unit->health) {
+ value *= 4.0f;
+ }
}
if (weapon->hasTargetWeight) {
value *= weapon->TargetWeight(unit);
diff --git a/rts/Lua/LuaSyncedCtrl.cpp b/rts/Lua/LuaSyncedCtrl.cpp
index 365b576..92a647e 100644
--- a/rts/Lua/LuaSyncedCtrl.cpp
+++ b/rts/Lua/LuaSyncedCtrl.cpp
@@ -988,10 +988,18 @@ int LuaSyncedCtrl::SetUnitHealth(lua_State* L)
}
else if (key == "paralyze") {
unit->paralyzeDamage = max(0.0f, value);
- if (unit->paralyzeDamage > unit->maxHealth) {
- unit->stunned = true;
- } else if (value < 0.0f) {
- unit->stunned = false;
+ if (modInfo.paralyzeOnMaxHealth) {
+ if (unit->paralyzeDamage > unit->maxHealth) {
+ unit->stunned = true;
+ } else if (value < 0.0f) {
+ unit->stunned = false;
+ }
+ } else {
+ if (unit->paralyzeDamage > unit->health) {
+ unit->stunned = true;
+ } else if (value < 0.0f) {
+ unit->stunned = false;
+ }
}
}
else if (key == "build") {
diff --git a/rts/Sim/Misc/ModInfo.cpp b/rts/Sim/Misc/ModInfo.cpp
index 4b15a85..df2e842 100644
--- a/rts/Sim/Misc/ModInfo.cpp
+++ b/rts/Sim/Misc/ModInfo.cpp
@@ -86,6 +86,10 @@ void CModInfo::Init(const char* modname)
const LuaTable captureTbl = root.SubTable("capture");
captureEnergyCostFactor = captureTbl.GetFloat("energyCostFactor", 0.0);
+ // paralyze
+ const LuaTable paralyzeTbl = root.SubTable("paralyze");
+ paralyzeOnMaxHealth = paralyzeTbl.GetBool("paralyzeOnMaxHealth", true);
+
// fire-at-dead-units
const LuaTable fireAtDeadTbl = root.SubTable("fireAtDead");
fireAtKilled = fireAtDeadTbl.GetBool("fireAtKilled", false);
diff --git a/rts/Sim/Misc/ModInfo.h b/rts/Sim/Misc/ModInfo.h
index aea5dac..32c692f 100644
--- a/rts/Sim/Misc/ModInfo.h
+++ b/rts/Sim/Misc/ModInfo.h
@@ -63,6 +63,10 @@ public:
/// How much should energy should capture cost, default 0.0
float captureEnergyCostFactor;
+ // Paralyze behaviour
+ /// paralyze unit depending on maxHealth? if not depending on current health, default true
+ bool paralyzeOnMaxHealth;
+
// Transportation behaviour
/// 0 = all ground units cannot be transported, 1 = all ground units can be transported (mass and size restrictions still apply). Defaults to 1.
int transportGround;
diff --git a/rts/Sim/Units/Unit.cpp b/rts/Sim/Units/Unit.cpp
index 5e260b8..1dad60c 100644
--- a/rts/Sim/Units/Unit.cpp
+++ b/rts/Sim/Units/Unit.cpp
@@ -708,8 +708,14 @@ void CUnit::SlowUpdate()
if (stunned) {
// de-stun only if we are not (still) inside a non-firebase transport
- if (paralyzeDamage <= maxHealth && !(transporter && !transporter->unitDef->isFirePlatform) ) {
- stunned = false;
+ if (modInfo.paralyzeOnMaxHealth) {
+ if (paralyzeDamage < maxHealth && !(transporter && !transporter->unitDef->isFirePlatform) ) {
+ stunned = false;
+ }
+ } else {
+ if (paralyzeDamage <= health && !(transporter && !transporter->unitDef->isFirePlatform) ) {
+ stunned = false;
+ }
}
SlowUpdateCloak(true);
@@ -976,6 +982,11 @@ void CUnit::DoDamage(const DamageArray& damages, CUnit* attacker, const float3&
if (health > maxHealth) {
health = maxHealth;
}
+ if (!modInfo.paralyzeOnMaxHealth) {
+ if (health > paralyzeDamage) {
+ stunned = false;
+ }
+ }
}
}
else { // paralyzation
@@ -996,8 +1007,14 @@ void CUnit::DoDamage(const DamageArray& damages, CUnit* attacker, const float3&
experienceMod = 0.0f;
}
paralyzeDamage += damage;
- if (paralyzeDamage > maxHealth) {
- stunned = true;
+ if (modInfo.paralyzeOnMaxHealth) {
+ if (paralyzeDamage > maxHealth) {
+ stunned = true;
+ }
+ } else {
+ if (paralyzeDamage > health) {
+ stunned = true;
+ }
}
}
else { // paralyzation healing
@@ -1005,10 +1022,19 @@ void CUnit::DoDamage(const DamageArray& damages, CUnit* attacker, const float3&
experienceMod = 0.0f;
}
paralyzeDamage += damage;
- if (paralyzeDamage < maxHealth) {
- stunned = false;
- if (paralyzeDamage < 0.0f) {
- paralyzeDamage = 0.0f;
+ if (modInfo.paralyzeOnMaxHealth) {
+ if (paralyzeDamage < maxHealth) {
+ stunned = false;
+ if (paralyzeDamage < 0.0f) {
+ paralyzeDamage = 0.0f;
+ }
+ }
+ } else {
+ if (paralyzeDamage < health) {
+ stunned = false;
+ if (paralyzeDamage < 0.0f) {
+ paralyzeDamage = 0.0f;
+ }
}
}
}
diff --git a/rts/Sim/Units/UnitTypes/TransportUnit.cpp b/rts/Sim/Units/UnitTypes/TransportUnit.cpp
index 0a5d871..b5c8a10 100644
--- a/rts/Sim/Units/UnitTypes/TransportUnit.cpp
+++ b/rts/Sim/Units/UnitTypes/TransportUnit.cpp
@@ -155,7 +155,11 @@ void CTransportUnit::KillUnit(bool selfDestruct, bool reclaimed, CUnit* attacker
mt->StartFlying();
}
- u->stunned = (u->paralyzeDamage > u->maxHealth);
+ if (modInfo.paralyzeOnMaxHealth) {
+ u->stunned = (u->paralyzeDamage > u->maxHealth);
+ } else {
+ u->stunned = (u->paralyzeDamage > u->health);
+ }
u->moveType->LeaveTransport();
u->speed = speed*(0.5f + 0.5f*gs->randFloat());
@@ -272,7 +276,12 @@ bool CTransportUnit::DetachUnitCore(CUnit* unit)
}
// de-stun in case it isFirePlatform=0
- unit->stunned = (unit->paralyzeDamage > unit->maxHealth);
+ if (modInfo.paralyzeOnMaxHealth) {
+ unit->stunned = (unit->paralyzeDamage > unit->maxHealth);
+ } else {
+ unit->stunned = (unit->paralyzeDamage > unit->health);
+ }
+
loshandler->MoveUnit(unit, false);
transportCapacityUsed -= ti->size;