diff -Nur a/trunk/binaries/data/mods/public/simulation/ai/qbot-wc/attack_plan.js b/trunk/binaries/data/mods/public/simulation/ai/qbot-wc/attack_plan.js
a
|
b
|
|
519 | 519 | // HACK (TODO replace) : if we have no trainable template... Then we'll simply remove the buildOrder, effectively removing the unit from the plan. |
520 | 520 | if (template === undefined) { |
521 | 521 | // TODO: this is a complete hack. |
522 | | if (this.needsShip && this.buildOrder[0][4] == "TransportShip") |
| 522 | if (this.needsShip && this.buildOrder[0][4] == "TransportShip") { |
| 523 | Engine.ProfileStop(); |
| 524 | Engine.ProfileStop(); |
523 | 525 | return 0; |
| 526 | } |
524 | 527 | delete this.unitStat[this.buildOrder[0][4]]; // deleting the associated unitstat. |
525 | 528 | this.buildOrder.splice(0,1); |
526 | 529 | } else { |
… |
… |
|
569 | 572 | } |
570 | 573 | } |
571 | 574 | */ |
| 575 | Engine.ProfileStop(); |
| 576 | Engine.ProfileStop(); |
572 | 577 | // can happen for now |
573 | 578 | if (this.buildOrder.length === 0) { |
574 | 579 | debug ("Ending plan: no build orders"); |
575 | 580 | return 0; // will abort the plan, should return something else |
576 | 581 | } |
577 | | Engine.ProfileStop(); |
578 | | Engine.ProfileStop(); |
579 | 582 | return 1; |
580 | 583 | } |
581 | 584 | this.unitCollection.forEach(function (entity) { entity.setMetadata(PlayerID, "role","attack"); }); |
… |
… |
|
729 | 732 | var bool_attacked = false; |
730 | 733 | // raids don't care about attacks much |
731 | 734 | |
732 | | if (this.unitCollection.length === 0) |
| 735 | if (this.unitCollection.length === 0) { |
| 736 | Engine.ProfileStop(); |
733 | 737 | return 0; |
| 738 | } |
734 | 739 | |
735 | 740 | this.position = this.unitCollection.getCentrePosition(); |
736 | 741 | |
… |
… |
|
842 | 847 | this.position = this.unitCollectionNoWarship.getCentrePosition(); |
843 | 848 | |
844 | 849 | // probably not too good. |
845 | | if (!this.position) |
| 850 | if (!this.position) { |
| 851 | Engine.ProfileStop(); |
846 | 852 | return undefined; // should spawn an error. |
847 | | |
| 853 | } |
| 854 | |
848 | 855 | // basically haven't moved an inch: very likely stuck) |
849 | 856 | if (SquareVectorDistance(this.position, this.position5TurnsAgo) < 10 && this.path.length > 0 && gameState.ai.playedTurn % 5 === 0) { |
850 | 857 | // check for stuck siege units |
… |
… |
|
882 | 889 | } else if (nexttoWalls) { |
883 | 890 | // abort plan. |
884 | 891 | debug ("Attack Plan " +this.type +" " +this.name +" has met walls and gives up."); |
| 892 | Engine.ProfileStop(); |
885 | 893 | return 0; |
886 | 894 | } |
887 | 895 | } |
… |
… |
|
911 | 919 | // okay we must load our units. |
912 | 920 | // check if we have some kind of ships. |
913 | 921 | var ships = this.unitCollection.filter(Filters.byClass("Warship")); |
914 | | if (ships.length === 0) |
| 922 | if (ships.length === 0) { |
| 923 | Engine.ProfileStop(); |
915 | 924 | return 0; // abort |
| 925 | } |
916 | 926 | |
917 | 927 | debug ("switch to boarding"); |
918 | 928 | this.state = "boarding"; |
… |
… |
|
936 | 946 | this.unitCollection.filter(Filters.byClass("Warship")).move(this.path[0][0][0], this.path[0][0][1]); |
937 | 947 | } else { |
938 | 948 | debug ("Attack Plan " +this.type +" " +this.name +" has arrived to destination, but it's still on the ship…"); |
| 949 | Engine.ProfileStop(); |
939 | 950 | return 0; // abort |
940 | 951 | } |
941 | 952 | } else if (this.path[0][1] === true) |
… |
… |
|
949 | 960 | this.position = this.unitCollectionNoWarship.getCentrePosition(); |
950 | 961 | |
951 | 962 | var ships = this.unitCollection.filter(Filters.byClass("Warship")); |
952 | | if (ships.length === 0) |
| 963 | if (ships.length === 0) { |
| 964 | Engine.ProfileStop(); |
953 | 965 | return 0; // abort |
| 966 | } |
954 | 967 | |
955 | 968 | var globalPos = this.unitCollectionNoWarship.getCentrePosition(); |
956 | 969 | var shipPos = ships.getCentrePosition(); |
… |
… |
|
993 | 1006 | } else if (this.state === "unboarding") { |
994 | 1007 | |
995 | 1008 | var ships = this.unitCollection.filter(Filters.byClass("Warship")); |
996 | | if (ships.length === 0) |
| 1009 | if (ships.length === 0) { |
| 1010 | Engine.ProfileStop(); |
997 | 1011 | return 0; // abort |
998 | | |
| 1012 | } |
| 1013 | |
999 | 1014 | this.position = ships.getCentrePosition(); |
1000 | 1015 | |
1001 | 1016 | // the procedure is pretty simple: we move the ships to the next point and try to unload until all units are over. |
… |
… |
|
1264 | 1279 | count++; |
1265 | 1280 | if (count > 1000){ |
1266 | 1281 | debug("No target with a valid position found"); |
| 1282 | Engine.ProfileStop(); |
1267 | 1283 | return false; |
1268 | 1284 | } |
1269 | 1285 | } |
diff -Nur a/trunk/binaries/data/mods/public/simulation/ai/qbot-wc/economy.js b/trunk/binaries/data/mods/public/simulation/ai/qbot-wc/economy.js
a
|
b
|
|
1184 | 1184 | }); |
1185 | 1185 | |
1186 | 1186 | Engine.ProfileStop(); |
| 1187 | Engine.ProfileStop(); |
1187 | 1188 | return; |
1188 | 1189 | } |
1189 | 1190 | |