Skip to content

Commit ed524d2

Browse files
Brian151leveleditor
authored andcommitted
Add fix for units targeting flying units even though they shouldn't be able to.
1 parent 9d5c84c commit ed524d2

File tree

1 file changed

+104
-14
lines changed

1 file changed

+104
-14
lines changed

mods/redux/redux/DOMDocument.xml

+104-14
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,96 @@ function registerCheat(id:String, code:String, linked:Array) {
19801980
}
19811981
};
19821982
1983+
this.engageEnemy = function() {
1984+
if (!this.stats.weapon) {
1985+
return;
1986+
}
1987+
if (this.isBuilding) {
1988+
if (this.friend && this.parent.powerOff) {
1989+
return;
1990+
}
1991+
if (!this.friend && this.parent.powerOffOppo) {
1992+
return;
1993+
}
1994+
}
1995+
if (this.weaponCharge) {
1996+
this.weaponCharge--;
1997+
return;
1998+
}
1999+
if (this.blink) {
2000+
this.blink--;
2001+
return;
2002+
}
2003+
if (this.stats.boomerang && !this.target) {
2004+
return;
2005+
}
2006+
if (this.target.stats.carrier && (this.target.team == this.team)) {
2007+
return;
2008+
}
2009+
if (this.stats.flying && (this.nav.landerPerc > 25) && !this.stats.transformer) {
2010+
return;
2011+
}
2012+
var target;
2013+
//ETX WUZ HERE, WITH A PATCH
2014+
//Fixes the bug with units targeting flying units even though they shouldn't be able to.
2015+
var cantTouchThis = (this.target.stats.flying && this.stats.weapon == "laser" && this.target.nav.landerPerc < 75);
2016+
if (this.target && !cantTouchThis) {
2017+
target = this.target;
2018+
} else {
2019+
var highestThreat = 1;
2020+
for (var i in this.parent.buildings) {
2021+
var building = this.parent.buildings[i];
2022+
if (building.friend == this.friend) {
2023+
continue;
2024+
}
2025+
if (building.stats.threat < highestThreat) {
2026+
continue;
2027+
}
2028+
if (this.friend && !building.stats.weapon) {
2029+
continue;
2030+
}
2031+
var dist = distance(this.posX, this.posY, building.posX, building.posY);
2032+
if (dist < this.stats.weaponRange) {
2033+
target = building;
2034+
highestThreat = target.stats.threat;
2035+
}
2036+
}
2037+
for (var i in this.parent.units) {
2038+
var unit = this.parent.units[i];
2039+
if (unit.friend == this.friend) {
2040+
continue;
2041+
}
2042+
if (unit.stats.pickup) {
2043+
continue;
2044+
}
2045+
if (unit.stats.flying && (this.stats.weapon == "laser") && (unit.nav.landerPerc < 75)) {
2046+
continue;
2047+
}
2048+
if (unit.stats.threat < highestThreat) {
2049+
continue;
2050+
}
2051+
var dist = distance(this.posX, this.posY, unit.posX, unit.posY);
2052+
if (dist < this.stats.weaponRange) {
2053+
target = unit;
2054+
highestThreat = target.stats.threat;
2055+
}
2056+
}
2057+
// don't get too attached to gun towers!
2058+
if (target && this.hal && !(target.isBuilding && target.stats.weapon)) {
2059+
this.target = target;
2060+
}
2061+
// we don't want to do this every time!
2062+
this.blink = 10 + random(4);
2063+
}
2064+
if (!target) {
2065+
return;
2066+
}
2067+
if (this.hal && this.target) {
2068+
this.hal.type = "seek";
2069+
}
2070+
this.shoot(target);
2071+
};
2072+
19832073
this.hack_init = function() {
19842074
// HACK: If the current level's team is not the default, wipe the indicators.
19852075
// This prevents impossible to fulfill indicator conditions.
@@ -1988,7 +2078,7 @@ function registerCheat(id:String, code:String, linked:Array) {
19882078
this.indicators.splice(0);
19892079
}
19902080
}
1991-
}
2081+
};
19922082
19932083
var indHackHook:Object = _level0.addPostHook(this.init, this.hack_init);
19942084
this.init = indHackHook.override;
@@ -2577,7 +2667,7 @@ function CACMod_OnGameMenu():Void {
25772667
var hook9:Object = wrapper.addPostHook(game.Weapon, WeaponHook);
25782668
game.Weapon = hook9.override;
25792669
2580-
// Hook Unit to fix land units not picking up crates when embarking from a carrier.
2670+
// Hook Unit to fix land units not picking up crates when disembarking from a carrier.
25812671
var hook10:Object = wrapper.addPostHook(game.Unit, UnitHook);
25822672
game.Unit = hook10.override;
25832673
@@ -2619,6 +2709,18 @@ function CACMod_OnGameMenu():Void {
26192709
</persistentData>
26202710
<PrinterSettings/>
26212711
<publishHistory>
2712+
<PublishItem publishSize="16012" publishTime="1493618426"/>
2713+
<PublishItem publishSize="16046" publishTime="1493618062"/>
2714+
<PublishItem publishSize="16046" publishTime="1493618041"/>
2715+
<PublishItem publishSize="16046" publishTime="1493617633"/>
2716+
<PublishItem publishSize="16046" publishTime="1493617608"/>
2717+
<PublishItem publishSize="16024" publishTime="1493617518"/>
2718+
<PublishItem publishSize="16046" publishTime="1493617019"/>
2719+
<PublishItem publishSize="16046" publishTime="1493616920"/>
2720+
<PublishItem publishSize="16046" publishTime="1493616909"/>
2721+
<PublishItem publishSize="16046" publishTime="1493616836"/>
2722+
<PublishItem publishSize="15538" publishTime="1493615330"/>
2723+
<PublishItem publishSize="15503" publishTime="1493613485"/>
26222724
<PublishItem publishSize="15503" publishTime="1493613293"/>
26232725
<PublishItem publishSize="15506" publishTime="1493612078"/>
26242726
<PublishItem publishSize="15492" publishTime="1493611945"/>
@@ -2627,17 +2729,5 @@ function CACMod_OnGameMenu():Void {
26272729
<PublishItem publishSize="15797" publishTime="1478412410"/>
26282730
<PublishItem publishSize="15805" publishTime="1478412191"/>
26292731
<PublishItem publishSize="15820" publishTime="1478407492"/>
2630-
<PublishItem publishSize="15820" publishTime="1478407190"/>
2631-
<PublishItem publishSize="15801" publishTime="1478406511"/>
2632-
<PublishItem publishSize="15786" publishTime="1478406258"/>
2633-
<PublishItem publishSize="15697" publishTime="1478403149"/>
2634-
<PublishItem publishSize="15657" publishTime="1478399428"/>
2635-
<PublishItem publishSize="15657" publishTime="1478223372"/>
2636-
<PublishItem publishSize="15663" publishTime="1468811136"/>
2637-
<PublishItem publishSize="15662" publishTime="1468811029"/>
2638-
<PublishItem publishSize="15519" publishTime="1462583971"/>
2639-
<PublishItem publishSize="15570" publishTime="1462583819"/>
2640-
<PublishItem publishSize="15570" publishTime="1462583724"/>
2641-
<PublishItem publishSize="15542" publishTime="1462583594"/>
26422732
</publishHistory>
26432733
</DOMDocument>

0 commit comments

Comments
 (0)