8
8
import arc .struct .*;
9
9
import arc .util .*;
10
10
import arc .util .pooling .Pools ;
11
- import mindustry .ai .types .FlyingAI ;
11
+ import mindustry .ai .types .* ;
12
12
import mindustry .content .*;
13
13
import mindustry .entities .abilities .*;
14
14
import mindustry .entities .bullet .SapBulletType ;
@@ -43,18 +43,17 @@ public class CrawlerArenaMod extends Plugin {
43
43
44
44
@ Override
45
45
public void init (){
46
- content .units ().each (un -> un .controller = u -> new FlyingAI ());
47
- UnitTypes .crawler .controller = u -> new ArenaAI ();
48
- UnitTypes .atrax .controller = u -> new ArenaAI ();
49
- UnitTypes .spiroct .controller = u -> new ArenaAI ();
50
- UnitTypes .arkyid .controller = u -> new ArenaAI ();
51
- UnitTypes .toxopid .controller = u -> new ArenaAI ();
46
+ UnitTypes .crawler .controller = u -> !u .type .playerControllable || (u .team .isAI () && !u .team .rules ().rtsAi ) ? new ArenaAI () : new CommandAI ();
47
+ UnitTypes .atrax .controller = u -> !u .type .playerControllable || (u .team .isAI () && !u .team .rules ().rtsAi ) ? new ArenaAI () : new CommandAI ();
48
+ UnitTypes .spiroct .controller = u -> !u .type .playerControllable || (u .team .isAI () && !u .team .rules ().rtsAi ) ? new ArenaAI () : new CommandAI ();
49
+ UnitTypes .arkyid .controller = u -> !u .type .playerControllable || (u .team .isAI () && !u .team .rules ().rtsAi ) ? new ArenaAI () : new CommandAI ();
50
+ UnitTypes .toxopid .controller = u -> !u .type .playerControllable || (u .team .isAI () && !u .team .rules ().rtsAi ) ? new ArenaAI () : new CommandAI ();
52
51
53
52
UnitTypes .poly .controller = u -> new SwarmAI ();
54
- UnitTypes .mega .controller = u -> new ReinforcementAI ();
53
+ UnitTypes .mega .controller = u -> u . team == CVars . reinforcementTeam ? new ReinforcementAI () : ! u . type . playerControllable || ( u . team . isAI () && ! u . team . rules (). rtsAi ) ? u . type . aiController . get () : new CommandAI ();
55
54
56
- UnitTypes .scepter .controller = u -> new ArenaAI ();
57
- UnitTypes .reign .controller = u -> new ArenaAI ();
55
+ UnitTypes .scepter .controller = u -> ! u . type . playerControllable || ( u . team . isAI () && ! u . team . rules (). rtsAi ) ? new ArenaAI () : new CommandAI ();
56
+ UnitTypes .reign .controller = u -> ! u . type . playerControllable || ( u . team . isAI () && ! u . team . rules (). rtsAi ) ? new ArenaAI () : new CommandAI ();
58
57
59
58
UnitTypes .risso .flying = true ;
60
59
UnitTypes .minke .flying = true ;
@@ -488,7 +487,6 @@ public void setUnit(Unit unit, boolean ultraEligible){
488
487
addUnitAbility (unit , new UnitSpawnAbility (UnitTypes .dagger , ultraDaggerCooldown , 0f , -1f ));
489
488
applyStatus (unit , Float .MAX_VALUE , 3 , StatusEffects .overclock , StatusEffects .overdrive , StatusEffects .boss );
490
489
}
491
- unit .controller (new FlyingAI ());
492
490
}
493
491
public void setUnit (Unit unit ){
494
492
setUnit (unit , false );
@@ -512,7 +510,7 @@ public void reset(){
512
510
513
511
@ Override
514
512
public void registerClientCommands (CommandHandler handler ){
515
- handler .<Player >register ("upgrade" , "<type> [amount]" , "Upgrade to another unit" , (args , player ) -> {
513
+ handler .<Player >register ("upgrade" , "<type> [amount]" , "Upgrade to another unit. Specifying amount instead buys units to fight alongside you " , (args , player ) -> {
516
514
UnitType newUnitType = Seq .with (unitCosts .keys ()).find (u -> u .name .equalsIgnoreCase (args [0 ]));
517
515
if (newUnitType == null ){
518
516
Bundle .bundled (player , "commands.upgrade.unit-not-found" );
@@ -538,7 +536,7 @@ public void registerClientCommands(CommandHandler handler){
538
536
}
539
537
540
538
if (money .get (player .uuid ()) >= unitCosts .get (newUnitType ) * amount ){
541
- if (!player .dead () && player .unit ().type == newUnitType || amount > 1 ){
539
+ if (!player .dead () && player .unit ().type == newUnitType || args . length == 2 ){
542
540
for (int i = 0 ; i < amount ; i ++){
543
541
Unit newUnit = newUnitType .spawn (player .x + Mathf .random (), player .y + Mathf .random ());
544
542
setUnit (newUnit );
@@ -605,6 +603,20 @@ public void registerClientCommands(CommandHandler handler){
605
603
});
606
604
player .sendMessage (upgrades .toString ());
607
605
});
606
+
607
+ handler .<Player >register ("cost" , "<type>" , "Lookup the cost of a unit" , (args , player ) -> {
608
+ int cost = -1 ;
609
+ for (ObjectIntMap .Entry <UnitType > pair : unitCosts .entries ()){
610
+ if (pair .key .name .equalsIgnoreCase (args [0 ])){
611
+ cost = pair .value ;
612
+ }
613
+ }
614
+ if (cost == -1 ){
615
+ Bundle .bundled (player , "commands.upgrade.unit-not-found" );
616
+ return ;
617
+ }
618
+ player .sendMessage (Integer .toString (cost ));
619
+ });
608
620
}
609
621
610
622
public void registerServerCommands (CommandHandler handler ){
0 commit comments