Index: binaries/data/mods/public/gui/session/unit_actions.js
===================================================================
--- binaries/data/mods/public/gui/session/unit_actions.js
+++ binaries/data/mods/public/gui/session/unit_actions.js
@@ -1435,7 +1435,7 @@
if (entState.capturePoints && entState.capturePoints[entState.player] < entState.maxCapturePoints / 2)
return translate("You cannot destroy this entity as you own less than half the capture points");
- if (!entState.canDelete)
+ if (!entState.identity.canDelete)
return translate("This entity is undeletable");
return false;
Index: binaries/data/mods/public/maps/random/survivalofthefittest.js
===================================================================
--- binaries/data/mods/public/maps/random/survivalofthefittest.js
+++ binaries/data/mods/public/maps/random/survivalofthefittest.js
@@ -30,7 +30,7 @@
const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTree1, tForestFloor2 + TERRAIN_SEPARATOR + oTree2, tForestFloor2];
const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTree4, tForestFloor1 + TERRAIN_SEPARATOR + oTree5, tForestFloor1];
-const oTreasureSeeker = "skirmish/units/default_support_female_citizen";
+const oTreasureSeeker = "undeletable|skirmish/units/default_support_female_citizen";
const triggerPointAttacker = "trigger/trigger_point_A";
const triggerPointTreasures = [
Index: binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js
===================================================================
--- binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js
+++ binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js
@@ -178,9 +178,6 @@
let cmpDamageReceiver = Engine.QueryInterface(entity, IID_DamageReceiver);
cmpDamageReceiver.SetInvulnerability(true);
-
- let cmpHealth = Engine.QueryInterface(entity, IID_Health);
- cmpHealth.SetUndeletable(true);
}
}
}
Index: binaries/data/mods/public/simulation/components/Attack.js
===================================================================
--- binaries/data/mods/public/simulation/components/Attack.js
+++ binaries/data/mods/public/simulation/components/Attack.js
@@ -253,7 +253,7 @@
for (let type of types)
{
- if (type != "Capture" && !cmpEntityPlayer.IsEnemy(targetOwner))
+ if (type != "Capture" && (!cmpEntityPlayer.IsEnemy(targetOwner) || cmpIdentity.IsUndeletable()))
continue;
if (type == "Capture" && (!cmpCapturable || !cmpCapturable.CanCapture(entityOwner)))
Index: binaries/data/mods/public/simulation/components/GuiInterface.js
===================================================================
--- binaries/data/mods/public/simulation/components/GuiInterface.js
+++ binaries/data/mods/public/simulation/components/GuiInterface.js
@@ -277,7 +277,8 @@
"rank": cmpIdentity.GetRank(),
"classes": cmpIdentity.GetClassesList(),
"visibleClasses": cmpIdentity.GetVisibleClassesList(),
- "selectionGroupName": cmpIdentity.GetSelectionGroupName()
+ "selectionGroupName": cmpIdentity.GetSelectionGroupName(),
+ "canDelete": !cmpIdentity.IsUndeletable()
};
let cmpPosition = Engine.QueryInterface(ent, IID_Position);
@@ -294,7 +295,6 @@
ret.maxHitpoints = cmpHealth.GetMaxHitpoints();
ret.needsRepair = cmpHealth.IsRepairable() && cmpHealth.GetHitpoints() < cmpHealth.GetMaxHitpoints();
ret.needsHeal = !cmpHealth.IsUnhealable();
- ret.canDelete = !cmpHealth.IsUndeletable();
}
let cmpCapturable = QueryMiragedInterface(ent, IID_Capturable);
Index: binaries/data/mods/public/simulation/components/Health.js
===================================================================
--- binaries/data/mods/public/simulation/components/Health.js
+++ binaries/data/mods/public/simulation/components/Health.js
@@ -47,9 +47,6 @@
"" +
"" +
"" +
- "" +
- "" +
- "" +
"" +
"" +
"";
@@ -63,7 +60,6 @@
this.hitpoints = +(this.template.Initial || this.GetMaxHitpoints());
this.regenRate = ApplyValueModificationsToEntity("Health/RegenRate", +this.template.RegenRate, this.entity);
this.idleRegenRate = ApplyValueModificationsToEntity("Health/IdleRegenRate", +this.template.IdleRegenRate, this.entity);
- this.undeletable = this.template.Undeletable == "true";
this.CheckRegenTimer();
this.UpdateActor();
};
@@ -122,16 +118,6 @@
|| this.GetHitpoints() >= this.GetMaxHitpoints());
};
-Health.prototype.IsUndeletable = function()
-{
- return this.undeletable;
-};
-
-Health.prototype.SetUndeletable = function(undeletable)
-{
- this.undeletable = undeletable;
-};
-
Health.prototype.GetIdleRegenRate = function()
{
return this.idleRegenRate;
Index: binaries/data/mods/public/simulation/components/Identity.js
===================================================================
--- binaries/data/mods/public/simulation/components/Identity.js
+++ binaries/data/mods/public/simulation/components/Identity.js
@@ -86,6 +86,11 @@
"" +
"" +
"" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
"";
@@ -93,6 +98,7 @@
{
this.classesList = GetIdentityClasses(this.template);
this.visibleClassesList = GetVisibleIdentityClasses(this.template);
+ this.undeletable = this.template.Undeletable !== undefined && this.template.Undeletable == "true";
};
Identity.prototype.Deserialize = function ()
@@ -159,4 +165,9 @@
return this.template.GenericName;
};
+Identity.prototype.IsUndeletable = function()
+{
+ return this.undeletable;
+};
+
Engine.RegisterComponentType(IID_Identity, "Identity", Identity);
Index: binaries/data/mods/public/simulation/components/Mirage.js
===================================================================
--- binaries/data/mods/public/simulation/components/Mirage.js
+++ binaries/data/mods/public/simulation/components/Mirage.js
@@ -22,7 +22,6 @@
this.hitpoints = null;
this.repairable = null;
this.unhealable = null;
- this.undeletable = null;
this.capturePoints = [];
this.maxCapturePoints = 0;
@@ -92,14 +91,12 @@
this.hitpoints = cmpHealth.GetHitpoints();
this.repairable = cmpHealth.IsRepairable();
this.unhealable = cmpHealth.IsUnhealable();
- this.undeletable = cmpHealth.IsUndeletable();
};
Mirage.prototype.GetMaxHitpoints = function() { return this.maxHitpoints; };
Mirage.prototype.GetHitpoints = function() { return this.hitpoints; };
Mirage.prototype.IsRepairable = function() { return this.repairable; };
Mirage.prototype.IsUnhealable = function() { return this.unhealable; };
-Mirage.prototype.IsUndeletable = function() { return this.undeletable; };
// Capture data
Index: binaries/data/mods/public/simulation/components/SkirmishReplacer.js
===================================================================
--- binaries/data/mods/public/simulation/components/SkirmishReplacer.js
+++ binaries/data/mods/public/simulation/components/SkirmishReplacer.js
@@ -40,6 +40,15 @@
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
var templateName = cmpTemplateManager.GetCurrentTemplateName(this.entity);
+ let specialFilter = "";
+ let specialFilterPos = templateName.lastIndexOf("|");
+
+ if (specialFilterPos != -1)
+ {
+ specialFilter = templateName.substr(0, specialFilterPos + 1);
+ templateName = templateName.substr(specialFilterPos);
+ }
+
if (templateName in replacementEntities)
templateName = replacementEntities[templateName];
else if (this.template && "general" in this.template)
@@ -53,7 +62,7 @@
return;
}
- templateName = templateName.replace(/\{civ\}/g, civ);
+ templateName = specialFilter + templateName.replace(/\{civ\}/g, civ);
var cmpCurPosition = Engine.QueryInterface(this.entity, IID_Position);
var replacement = Engine.AddEntity(templateName);
Index: binaries/data/mods/public/simulation/components/tests/test_Attack.js
===================================================================
--- binaries/data/mods/public/simulation/components/tests/test_Attack.js
+++ binaries/data/mods/public/simulation/components/tests/test_Attack.js
@@ -105,7 +105,8 @@
AddMock(defender, IID_Identity, {
"GetClassesList": () => [defenderClass],
- "HasClass": className => className == defenderClass
+ "HasClass": className => className == defenderClass,
+ "IsUndeletable": () => false
});
AddMock(defender, IID_Ownership, {
Index: binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
===================================================================
--- binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
+++ binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
@@ -566,8 +566,7 @@
GetHitpoints: function() { return 50; },
GetMaxHitpoints: function() { return 60; },
IsRepairable: function() { return false; },
- IsUnhealable: function() { return false; },
- IsUndeletable: function() { return false; }
+ IsUnhealable: function() { return false; }
});
AddMock(10, IID_Identity, {
@@ -575,7 +574,8 @@
GetVisibleClassesList: function() { return ["class3", "class4"]; },
GetRank: function() { return "foo"; },
GetSelectionGroupName: function() { return "Selection Group Name"; },
- HasClass: function() { return true; }
+ HasClass: function() { return true; },
+ IsUndeletable: function() { return false; }
});
AddMock(10, IID_Position, {
@@ -614,7 +614,8 @@
rank: "foo",
classes: ["class1", "class2"],
visibleClasses: ["class3", "class4"],
- selectionGroupName: "Selection Group Name"
+ selectionGroupName: "Selection Group Name",
+ canDelete: true
},
fogging: null,
foundation: null,
@@ -637,8 +638,7 @@
hitpoints: 50,
maxHitpoints: 60,
needsRepair: false,
- needsHeal: true,
- canDelete: true
+ needsHeal: true
});
TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedEntityState(-1, 10), {
Index: binaries/data/mods/public/simulation/helpers/Commands.js
===================================================================
--- binaries/data/mods/public/simulation/helpers/Commands.js
+++ binaries/data/mods/public/simulation/helpers/Commands.js
@@ -386,10 +386,10 @@
{
for (let ent of data.entities)
{
- let cmpHealth = QueryMiragedInterface(ent, IID_Health);
if (!data.controlAllUnits)
{
- if (cmpHealth && cmpHealth.IsUndeletable())
+ let cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
+ if (cmpIdentity && cmpIdentity.IsUndeletable())
continue;
let cmpCapturable = QueryMiragedInterface(ent, IID_Capturable);
@@ -412,8 +412,11 @@
Engine.DestroyEntity(cmpMirage.parent);
Engine.DestroyEntity(ent);
+ continue;
}
- else if (cmpHealth)
+
+ let cmpHealth = QueryMiragedInterface(ent, IID_Health);
+ if (cmpHealth)
cmpHealth.Kill();
else
Engine.DestroyEntity(ent);
Index: binaries/data/mods/public/simulation/templates/special/filter/undeletable.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/special/filter/undeletable.xml
+++ binaries/data/mods/public/simulation/templates/special/filter/undeletable.xml
@@ -0,0 +1,6 @@
+
+
+
+ true
+
+
Index: binaries/data/mods/public/simulation/templates/template_structure.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure.xml
+++ binaries/data/mods/public/simulation/templates/template_structure.xml
@@ -53,7 +53,6 @@
corpse
0
0
- false
true
Index: binaries/data/mods/public/simulation/templates/template_unit.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit.xml
+++ binaries/data/mods/public/simulation/templates/template_unit.xml
@@ -34,7 +34,6 @@
100
0
0
- false
false
Index: binaries/data/mods/public/simulation/templates/template_unit_catafalque.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit_catafalque.xml
+++ binaries/data/mods/public/simulation/templates/template_unit_catafalque.xml
@@ -10,9 +10,6 @@
2.0
-
- true
-
gaia
-ConquestCritical
@@ -21,6 +18,7 @@
units/catafalque.png
template_unit_catafalque
A catafalque that holds the remains of a great leader.
+ true
Relic