@@ -1980,6 +1980,96 @@ function registerCheat(id:String, code:String, linked:Array) {
1980
1980
}
1981
1981
};
1982
1982
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
+
1983
2073
this.hack_init = function() {
1984
2074
// HACK: If the current level's team is not the default, wipe the indicators.
1985
2075
// This prevents impossible to fulfill indicator conditions.
@@ -1988,7 +2078,7 @@ function registerCheat(id:String, code:String, linked:Array) {
1988
2078
this.indicators.splice(0);
1989
2079
}
1990
2080
}
1991
- }
2081
+ };
1992
2082
1993
2083
var indHackHook:Object = _level0.addPostHook(this.init, this.hack_init);
1994
2084
this.init = indHackHook.override;
@@ -2577,7 +2667,7 @@ function CACMod_OnGameMenu():Void {
2577
2667
var hook9:Object = wrapper.addPostHook(game.Weapon, WeaponHook);
2578
2668
game.Weapon = hook9.override;
2579
2669
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.
2581
2671
var hook10:Object = wrapper.addPostHook(game.Unit, UnitHook);
2582
2672
game.Unit = hook10.override;
2583
2673
@@ -2619,6 +2709,18 @@ function CACMod_OnGameMenu():Void {
2619
2709
</persistentData >
2620
2710
<PrinterSettings />
2621
2711
<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" />
2622
2724
<PublishItem publishSize =" 15503" publishTime =" 1493613293" />
2623
2725
<PublishItem publishSize =" 15506" publishTime =" 1493612078" />
2624
2726
<PublishItem publishSize =" 15492" publishTime =" 1493611945" />
@@ -2627,17 +2729,5 @@ function CACMod_OnGameMenu():Void {
2627
2729
<PublishItem publishSize =" 15797" publishTime =" 1478412410" />
2628
2730
<PublishItem publishSize =" 15805" publishTime =" 1478412191" />
2629
2731
<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" />
2642
2732
</publishHistory >
2643
2733
</DOMDocument >
0 commit comments