Permalink
Browse files

Override Level.win and Level.lose to fix respawning units remaining a…

…fter winning or losing a level.
  • Loading branch information...
leveleditor committed May 7, 2017
1 parent a2e40da commit 95fa7d3662ff16758f2e08da3008e7e34b705759
Showing with 59 additions and 3 deletions.
  1. +59 −3 mods/redux/redux/DOMDocument.xml
@@ -2161,6 +2161,62 @@ function registerCheat(id:String, code:String, linked:Array) {
}
};
this.win = function() {
this.arena.shroud.clear();
if (this.level < 21) {
if ((this.level != 10) && (this.level != 20)) {
if (this.level < 11) {
SO.data.goodUnlocked = this.level;
} else if (this.level < 21) {
SO.data.evilUnlocked = this.level;
}
}
}
this.victory = true;
this.active = false;
this.parent.sfx.play("music_ingame_" + this.jukebox + "_stop");
this.parent.sfx.play("INT_optionsadd");
for (var i in this.units) {
var current = this.units[i];
if (current.active && !current.friend) {
// Fix opposing team's units remaining after winning a level.
// The real problem is that the units are destroyed before the buildings that respawn them.
// So we can just set them to not respawn.
current.respawn = false;
current.destroy();
}
}
for (var i in this.buildings) {
var current = this.buildings[i];
if (current.active && !current.friend) {
current.destroy();
}
}
};
this.lose = function() {
this.active = false;
this.victory = false;
this.parent.sfx.play("music_ingame_" + this.jukebox + "_stop");
this.parent.sfx.play("INT_optionsremove");
for (var i in this.units) {
var current = this.units[i];
if (current.active && current.friend) {
// Fix player team's units remaining after losing a level.
// The real problem is that the units are destroyed before the buildings that respawn them.
// So we can just set them to not respawn.
current.respawn = false;
current.destroy();
}
}
for (var i in this.buildings) {
var current = this.buildings[i];
if (current.active && current.friend) {
current.destroy();
}
}
};
this.engageEnemy = function() {
if (!this.stats.weapon) {
return;
@@ -2890,6 +2946,9 @@ function CACMod_OnGameMenu():Void {
</persistentData>
<PrinterSettings/>
<publishHistory>
<PublishItem publishSize="17259" publishTime="1494125320"/>
<PublishItem publishSize="17259" publishTime="1494123872"/>
<PublishItem publishSize="16975" publishTime="1494102691"/>
<PublishItem publishSize="17015" publishTime="1494102575"/>
<PublishItem publishSize="17048" publishTime="1494102419"/>
<PublishItem publishSize="17047" publishTime="1494102191"/>
@@ -2907,8 +2966,5 @@ function CACMod_OnGameMenu():Void {
<PublishItem publishSize="16953" publishTime="1494098849"/>
<PublishItem publishSize="16953" publishTime="1494098831"/>
<PublishItem publishSize="16946" publishTime="1494097001"/>
<PublishItem publishSize="16953" publishTime="1494096865"/>
<PublishItem publishSize="16981" publishTime="1494096791"/>
<PublishItem publishSize="16012" publishTime="1493618426"/>
</publishHistory>
</DOMDocument>

0 comments on commit 95fa7d3

Please sign in to comment.