Examples of Orders

Examples for all commands:

#begin
login myemail@gmail.com/passsword9329;

activate ColManager; // activates colonization manager
activate RepairManager; // activates repair manager
deactivate AttackManager; // disables attack manager

#end
#begin
login myemail@gmail.com/passsword9329;

// Adding science 'TotalDrive' with proportions 40 for drive,
// 25 for weapon, 25 for shield and 10 for cargo technologies
add science
	--name TotalDrive
	--prop 40, 25, 25, 10;

#end
#begin
login myemail@gmail.com/passsword9329;

// Adds 'Solaris' for colonization by ColManager
add star for manager --name ColManager --id Solaris;
// Adds star 67 for exploration by ExplManager
add star for manager --name ExplManager --id #67;

#end
#begin
login myemail@gmail.com/passsword9329;

add trigger
  --type OnStarBeforeTurn
  --name ProduceDefenceShips
  --code
#{ // star code macro
    if (_star.IsReachedMax))
      cmd produce ships
        --type DefenceShip
        --where &_star.Id // using & is a way
                          // to pass variable into command
        --number 10;
#} // end code macro
; // semicolon must be on the new line after closing #}


#end
#begin
login myemail@gmail.com/passsword9329;

// Adds trigger ‘BuildStaticDefence’ to all star systems
add trigger to object
  --type OnStarBeforeTurn
  --name BuildStaticDefence --id *;

// Adds trigger ‘BuildInd’ to star system 3443
add trigger to object
  --type OnStarBeforeTurn
  --name BuildInd --id 3443;

// Adds trigger ‘BuildInd’ to star system Moon
add trigger to object
  --type OnStarBeforeTurn
  --name BuildInd --id Moon;

#end
#begin
login myemail@gmail.com/passsword9329;

// Remove 'Solaris' from restricted area
allow access to --star Solaris;
// Remove star 67 from restricted area
allow access to --star 67;

#end
#begin
login myemail@gmail.com/passsword9329;

// Resumes bombing the 'Solaris' star system
allow bombing --star Solaris;
// Resumes bombing #67 star system
allow bombing --star 67;
allow bombing --star #67; // the same as above

#end
#begin
login myemail@gmail.com/myPassword;

// attaches a ship with id 10 to another ship with name Carrier
// ship ‘Carrier’ must have a tow unit, capable to attach the ship
attach --ship 10 --to Carrier;

#end
#begin
login myemail@gmail.com/passsword9329;

// Buying 50 clones units on Solaris
buy clones --amount 50 --where Solaris;

// Buying 150 clones units on the star system 123
// with priority 1
buy clones --amount 150 --where 123 --priority 1;

#end
#begin
login myemail@gmail.com/passsword9329;

// Buying 50 industry units on Solaris
buy industry --amount 50 --where Solaris;

#end
#begin
login myemail@gmail.com/passsword9329;

// Buying 50 materials units on #123;
buy materials --amount 50 --where 123;

#end
#begin
login myemail@gmail.com/passsword9329;

// Buying 10 'Scout' ship on star system #32;
buy ships --where 32 --type Scout --number 10;

// Buying 1 'Transport Ship' ship on star system #32;
buy ships --where 32 --type Transport Ship --number 1;
// Buying 1 'Transport Ship' ship on star system #32;
// (note: '--number' by default is 1)
buy ships --where 32 --type Transport Ship;

// Buying 1 'AttackLineShip' on star system #32
// with priority 7 and sending it to star 'New Paris'
buy ships
	--where 32
	--type AttackLineShip
	--sendto star: New Paris
	--priority 7;

// Buying 1 'AttackLineShip' on star system #32
// and ordering it to join fleet 'Fleet 7'
buy ships
	--where 32
	--type AttackLineShip
	--sendto fleet: Fleet 7;

#end
#begin
login myemail@gmail.com/passsword9329;

// Buying star Zodiak
buy star --name Zodiak;

// Buying star system #123
buy star --name 123;

#end
#begin
login myemail@gmail.com/passsword9329;

// Buying investment of 1000 PUs for technology DRIVE on star #10
buy tech --name DRIVE --amount 1000 --where 10;

// Buying development tech WEAPON to level 3 on star Solaris
// with priority 1
buy tech --name DRIVE --tolevel 3 --where Solaris --priority 1;

#end
#begin
login myemail@gmail.com/passsword9329;

// Cancel assignment for ship ‘Death Star’
cancel assignment for --ship Death Star;

// Cancel assignment for ship 123
cancel assignment for --ship 123;

// Cancel assignment for fleet F VIII
cancel assignment for --fleet F VIII;

#end
#begin
login myemail@gmail.com/passsword9329;

// Cancel production order with id #123
cancel prod order 123;

#end
#begin
login myemail@gmail.com/passsword9329;

// Cancel transport order with id #123
cancel transport order 123;

#end
#begin
login myemail@gmail.com/passsword9329;

// Changing email, password and gender
change user
	--email vicont@home.su
	--password sg388nnQwQ
	--gender M
    --code 34556; // it is supposed the confirmation code is known

// Changing all fields
change user
	--email vicont@home.su
	--password sg388nnQwQ
	--name Victoria
	--gender F;

#end
#begin
login myemail@gmail.com/passsword9329;

claim bonus --id 939259037T1707500;

#end
#begin
login myemail@gmail.com/passsword9329;

// Removes all stars assigned to ColManager
clear stars for manager --name ColManager;

#end
#begin
login myemail@gmail.com/passsword9329;

// Order ship 12 to colonize system #234
colonize --star 234 --ship 12;

#end
#begin
login myemail@gmail.com/passsword9329;

// Create a combat ship type Fighter with drive=10, shield=5
// and one laser with power 3 (L3 = L3x1);
create ship type --name Fighter --code D10,S5,L3;

// Adding 'TransportShip' ship type with drive=10, cargo=5 and
// one laser cannon with power 1
// Note parameter 'service' explicitly states that the ship
// should be 'Service', not 'Combat'. Without this parameter,
// the ship would be created as a 'Combat' ship, because it
// has weapon (L1x1)
create ship type
	--name TransportShip
	--code D10,C5,L1x1
	--service;

// Adding another transport ship type like above
// But beware! Missed parameter 'service' – the ship will be
// treated as a 'Combat' ship.
create ship type
	--name TransportShip2
	--code D10,C5,L1x1;

// Adding another ship type 'Transport Ship 3'
// Same components as above, but without laser
// Such a type is automatically created as 'Service' ship type
// because it has no weapons
create ship type
	--name Transport Ship 3
	--code D10,C5;

// This command is equivalent to above
create ship type
	--name Transport Ship 3
	--code D10,C5
	--service;

#end
#begin
login myemail@gmail.com/passsword9329;

// Declaring a peace to nation 'Dodgy Runners'
declare peace --to Dodgy Runners;

#end
#begin
login myemail@gmail.com/passsword9329;

// Declaring a war to nation 'Dodgy Runners'
declare war --to Dodgy Runners;

#end
#begin
login myemail@gmail.com/passsword9329;

delete bonus --id 939259037T1707500;

#end
#begin
login myemail@gmail.com/passsword9329;

// Removing science 'TotalDrive'
delete science	--name TotalDrive;

#end
#begin
login myemail@gmail.com/passsword9329;

// Removing ship type 'TransportShip1'
delete ship type --name TransportShip1;

#end
#begin
login myemail@gmail.com/passsword9329;

delete trigger
  --type OnStarBeforeTurn
  --name ProduceDefenceShips;

#end
#begin
login myemail@gmail.com/myPassword;

// detaches a ship attached to Carrier
detach --from Carrier;
#end
#begin
login myemail@gmail.com/passsword9329;

// Places a common order to develop an anonymous science
// investing 30000 PUs with priority 0 (default)
// (with proportions drive:10,weapon:15,shield:25,cargo:50)
dev science --prop 10,15,25,50 --amount 30000;

// Another anonymous order with priority 3 and
// with hedge specification:
// resource levels from 0 till 0.3
// sizes: up to 700
dev science
	--prop 50,15,25,5
	--amount 60000
	--priority 3
	--hedge res:..0.3,sizes:..700;

// Another anonymous order with priority 0 (default)
// assigned to colony Moon
dev science
	--prop 10,12,21,4
	--amount 10000
	--where Moon;

// Order to develop science TotalDrive with priority 5
// investing 48000PUs
// with hedge specification:
// resource levels from 0 till 0.3
// and list of stars
dev science
	--name TotalDrive
	--amount 48000
	--priority 5
	--hedge res:..0.5,stars:1|12|#45|Orion|Stella|78;

// Order to develop science Transport Hit with priority 2
// investing 10000PUs
// assigned to colony 342
dev science
	--name Transport Hit
	--amount 10000
	--priority 2
	--where 342;

#end
#begin
login myemail@gmail.com/passsword9329;

// Placing an order to invest 1000 PUs for technology DRIVE
// on star #10
dev tech --name DRIVE --amount 1000 --where 10;

// Order to develop tech WEAPON to level 3 on star Solaris
// with priority 1
dev tech --name DRIVE --tolevel 3 --where Solaris --priority 1;

// 'Common' order to develop tech CARGO to level 3
dev tech --name CARGO --tolevel 3;

// Order to develop tech SHIELD with priority 5
// investing 48000PUs
// with hedge specification:
// resource levels from 0 till 0.3
// stars can be selected from the list of ids 1,12,45,101,56,78
dev tech
	--name SHIELD
	--amount 48000
	--priority 5
	--hedge res:..0.5,stars:1|12|45|101|56|78;

#end
#begin
login myemail@gmail.com/passsword9329;

disband fleet --name Fleet 7;

#end
#begin
login myemail@gmail.com/passsword9329;

execute script --code
#{
  void f(long start, long end)
  {
     for (long i = start; i <= end; ++i)
     {
        cmd cancel assignment for --fleet STAR WALL &i;
     }
  };

  f(1506, 1516);
  f(1548, 1552);
//… many more calls of f()
#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

add trigger
  --type OnStarBeforeTurn
  --name BuildStaticDefence --code
#{
if (_star.IsOwn)
{
  branch def = _app.CalcDefenceForStar(_star.Id);
  if (def.DefenceMassToProduce > 0)
  {
    if (_star.ResourceFactor >= 0.1)
    {
      double dnum = def.DefenceMassToProduce/typeInfo.Mass;
      trace << “number of ships=” << dnum;
    } // if (_star.ResourceFactor >= 0.1)
    else
    {
      trace << "Static defence rejected: too low resources";
    } // else 
  } // if (def.RequiredDefenceMass > 0)
} // if (_star.IsOwn)

#}
;

// TEST EXECUTE FOR ALL STARS
force execute trigger
  --type OnStarBeforeTurn
  --name BuildStaticDefence --id *;

// TEST EXECUTE FOR Solaris
force execute trigger
  --type OnStarBeforeTurn
  --name BuildStaticDefence --id Solaris;

// TEST EXECUTE BeforeTurn trigger
// (this trigger does not accept any ids)
force execute trigger
  --type BeforeTurn
  --name BuildStaticDefence;

#end
#begin
login myemail@gmail.com/passsword9329;

// Forces the server to send a report for turn 5
get report --turn 5;

// Forces the server to send a report for current turn
get report;

#end
#begin

get turns schedule;

#end
#begin
login myemail@gmail.com/passsword9329;

// Assign ship 17 to guard the star system #345
guard --star 345 --ship 17;

// Assign ship 'Victory' to guard the star system 'Alpha'
guard --star Alpha --ship Victory;

// Assign fleet 'F VII' to guard the star system #345
guard --star 345 --fleet F VII;

#end
#begin
login myemail@gmail.com/passsword9329;

// Joining 2 ships to 'Fleet1'
join --ship 10 --to Fleet1;
join --ship 11 --to Fleet1;
// Now, ships #10 and #11 belong to Fleet1

// Joining Fleet1 to Fleet2
join --fleet Fleet1 --to Fleet2;
// Now, ships #10 and #11 belong to Fleet2 and
// Fleet1 doesn't exist

// Removing ship #10 from fleet
join --ship 10;
// Now, ship #11 belongs to Fleet2;
// ship #10 doesn't belong to any fleet

#end
#begin

// Joining the game as a new race 'England' in random location
join game 
	--name Victoria The First
	--gender F 
	--password qwertty 
	--email victoria@gmx.de
	--nation England;

// Joining the game as a new race 'Grand Germania' with home world #2112
join the game as 
	 --name Fon Zauerbach
	 --gender M 
	 --password 12jjj3332 
	 --email zauerbach@deutschetelecom.de
	 --nation Grand Germania
     --hw 2112;

// Joining the game as existing race 'Grand Germania'
join the game as 
	 --name Fon Zauerbach
	 --gender M 
	 --password 12jjj3332 
	 --email zauerbach@deutschetelecom.de
	 --nation Grand Germania
	 -e;

#end
#begin

join minigame 
	--id g20210203
	--name Victoria The First
	--gender F 
	--password qwertty 
	--email victoria@gmx.de
	--nation England;

#end
#begin
login myemail@gmail.com/passsword9329;

keep current borders;

#end
#begin
login myemail@gmail.com/passsword9329;

// loading the ship #1 by cargo MAT, amount 3.23 units
load --ship 1 --cargo MAT --amount 3.23;
// Loading 2 units of IND into the same ship
load --ship 1 --cargo IND --amount 2;
// Loading the rest of cargo bay capacity by POP
load --ship 1 --cargo POP;
// Now, ship has loaded 3.23MAT, 2IND and some POP

// Unloading cargo one unit of IND
unload --ship 1 --cargo IND --amount 1;
// Now, ship has loaded 3.23MAT, 1IND and some POP

// Unload whole MAT
unload --ship 1 --cargo MAT;
// Now, ship has loaded 1IND and some POP

// Unload the rest of the cargo
unload --ship 1;
// Now, ship is empty

// Loading fleet by 10 units of COL
load --fleet F III --cargo COL --amount 10;

// Loading fleet by all available COL
load --fleet F III --cargo COL;

// Unloading one unit of cargo (expected all ships in the fleet
// are loaded by the same type of cargo)
unload --fleet F III --amount 1;

// Unloading 3 units of MAT
unload --fleet F III --cargo MAT --amount 1;

// Unloads all cargo from all ships of a fleet
unload --fleet F III;


#end
#begin
login myemail@gmail.com/passsword9329;

#end
#begin
login myemail@gmail.com/passsword9329;

// Moving 300 industry units from star #13 to #56
move cargo --type IND --amount 300 --from 13 --to 56;

// Moving 100 COL units (here: population) from star Solaris
// to #113
move cargo --type POP --amount 100 --from Solaris --to 113;

#end
#begin
login myemail@gmail.com/passsword9329;

// naming star #1235 as 'Luna'
name --star 1235 --as Luna;
// Renaming star 'Luna' to 'Moon'
name --star Luna --as Moon;


// Naming ship #156 as BSG
name --ship 156 --as BSG;
// Renaming BSG to Battle Star Galactica
name --ship BSG --as Battle Star Galactica;

#end
#begin
nop
#end
#begin
login myemail@gmail.com/passsword9329;

// Prints out the trigger code in trace
print trigger
  --type OnStarBeforeTurn
  --name ProduceDefenceShips;

#end
#begin
login myemail@gmail.com/passsword9329;

// Placing an order to produce 1788 clone units
// on system Solaris with priority 4
produce clones --amount 1788 --where Solaris --priority 4;

// Placing an order to produce 100 clone units on system #15
// with default priority 0
produce clones --amount 100 --where 15;

#end
#begin
login myemail@gmail.com/passsword9329;

// Placing an order to produce 1788 industry units
// on system Solaris with priority 4
produce industry --amount 1788 --where Solaris --priority 4;

// Placing an order to produce 100 industry units on system #15
// with default priority 0
produce industry --amount 100 --where 15;
#end
#begin
login myemail@gmail.com/passsword9329;

// Placing an order to produce 1788 materials units
// on system Solaris with priority 4
produce materials --amount 1788 --where Solaris --priority 4;

// Placing an order to produce 100 materials units on system #15
// with default priority 0
produce materials --amount 100 --where 15;

#end
#begin
login myemail@gmail.com/passsword9329;

// Placing an order to produce 100 money units
// on system Solaris with priority 4
produce money --amount 100 --where Solaris --priority 4;

// Placing an order to produce 100 money units on system #15
// with default priority 0
produce money --amount 100 --where 15;

#end
#begin
login myemail@gmail.com/passsword9329;

// Placing an order to build 10 'Scout' ship on star system #32;
produce ships --where 32 --type Scout --number 10;

// Producing 1 'Transport Ship' ship on star system #32;
produce ships --where 32 --type Transport Ship --number 1;
// Producing 1 'Transport Ship' ship on star system #32;
// (note: '--number' by default is 1)
produce ships --where 32 --type Transport Ship;

// Producing 1 'AttackLineShip' on star system #32
// with priority 7 and sending it to star 'New Paris'
// when it is ready
produce ships
	--where 32
	--type AttackLineShip
	--sendto star: New Paris
	--priority 7;

// Producing 1 'AttackLineShip' on star system #32
// and ordering it to join fleet 'Fleet 7' when it is ready
produce ships
	--where 32
	--type AttackLineShip
	--sendto fleet: Fleet 7;

// Placing a common order to build 10 'AttackLineShip'
// and ordering the built ships to join fleet 'Fleet 7'
// (Note: no parameter 'where')
produce ships
	--type AttackLineShip
	--sendto fleet: Fleet 7;

// Placing a common order to build 100 'Fregate'
// and ordering the built ships to move to Klandatu system
// (Note: parameter 'hedge' demands the colonies selected for
// production must have size >=800 and resource factor >=0.5)
produce ships
	--type Fregate
	--sendto star: Klandatu
	--hedge res:0.5..,sizes:800..;

#end
#begin
login myemail@gmail.com/passsword9329;

// Prevent bombing the 'Solaris' star system
prevent bombing --star Solaris;
// Prevent bombing #67 star system
prevent bombing --star 67;
prevent bombing --star #67; // the same as above

#end
#begin

quit minigame --id g20210203 --email adolf@gmx.de –password 1234567

#end
#begin
login myemail@gmail.com/passsword9329;

quit the game;

#end
#begin
login myemail@gmail.com/passsword9329;

// Removes 'Solaris' from by ColManager
remove star for manager --name ColManager --id Solaris;

// Removed star 67 from by ExplManager
remove star for manager --name ExplManager --id #67;

#end
#begin
login myemail@gmail.com/passsword9329;

// Removes trigger ‘BuildStaticDefence’ from all star systems
remove trigger from object
  --type OnStarBeforeTurn
  --name BuildStaticDefence --id *;

// Removes trigger ‘BuildInd’ from star system 3443
remove trigger from object
  --type OnStarBeforeTurn
  --name BuildInd --id 3443;

// Removes trigger ‘BuildInd’ frpm star system Moon
remove trigger from object
  --type OnStarBeforeTurn
  --name BuildInd --id Moon;

#end
#begin
login myemail@gmail.com/passsword9329;

ename nation --newname Grand Britania;

#end
#begin
login myemail@gmail.com/passsword9329;

rename ship type --name Scout Ship --newname spy;

#end
#begin
login myemail@gmail.com/passsword9329;

// Repairing ship #174
repair ship --id 174;
// Repairing ship Aurora with priority 5
repair ship --id Aurora --priority 5;

#end
#begin
login myemail@gmail.com/passsword9329;

// Add 'Solaris' to restricted area
restrict access to --star Solaris;
// Add star 67 to restricted area
restrict access to --star 67;

#end
#begin
login myemail@gmail.com/passsword9329;

// Routing ship #2 to Solaris star system.
// This is equivalent to the same ‘send’ command.
// The route consists of one star only
route --ship 2 --to Solaris;

// Routing ship Belfast to star systems #123, Solaris and #2
route --ship Belfast --to 123, Solaris, 2;

// Patrolling star systems #123, #34, #89 by
// fleet 'Fleet One'
route --fleet Fleet One --to 123, 34, 89 --loop;

// Routing fleet 'Fleet One' to star system #123, #89 using 'leg'
// parameters: max jump = 5 years, not own and unknown star  
// systems can be used to find the path
route
	--fleet Fleet One --to 123, 89
	--MaxYearsInSpace 5
	--DontUseOnlyOwnStars
	--DontAvoidUnknownStars;
#end
#begin
login myemail@gmail.com/passsword9329;

// Scrapping ship #174
scrap ship --id 174;

#end
#begin
login myemail@gmail.com/passsword9329;

// Sending ship #2 to Solaris star system
send --ship 2 --to Solaris;

// Sending ships 2,3,4,5,6,7,8 to Solaris star system
send --ship 2..8 --to Solaris;

// Sending ships 1,2,3 to Solaris star system
send --ship 1,2,3 --to Solaris;

// Sending ships 1,2,3, 20,21,30,31,32 to Solaris star system
send --ship 1,2,3, 30..32, 20..21  --to Solaris;

// Sending ship 1 to Solaris star system
// (this is stupid, but finally specifies just ship 1)
send --ship 1..1, 1,1,1  --to Solaris;

// Sending ship Belfast to star system #123
send --ship Belfast --to 123;

// Sending ship Esel to star system #12 and unload whole cargo
send --ship Esel --to 12 -u;

// Sending 17 ships of type Discovery from #234 to #189
send --ship #234:Discovery::17 --to #189;

// Sending all ships of type Discovery from #234 to #189
send --ship #234:Discovery --to #189;

// Sending fleet 'Fleet One' to star system #123
send --fleet Fleet One --to 123;

// Sending fleet 'Fleet One' to star system #123 using 'leg'
// parameters: max jump = 5 years, not own and unknown star  
// systems can be used to find the path
send
	--fleet Fleet One --to 123
	--MaxYearsInSpace 5
	--DontUseOnlyOwnStars
	--DontAvoidUnknownStars;

#end
#begin
login myemail@gmail.com/passsword9329;

// sets a black mono-colour flag (note – template name is missing)
set nation flag :000000;

// sets a blue mono-colour flag
set nation flag :0000FF;

// sets a French tri-colour (note: template name is '3x3' with white background colour 'FFFFFF';
// template sections '1','4' and '7' are set in blue (0000FF), sections '3','6' and '9'
// are set in red (FF0000). The 'middle' sections '2','5','8' are not mentioned – 
// they simply take the background colour)
set nation flag 3x3:FFFFFF:1=0000FF|4=0000FF|7=0000FF|3=FF0000|6=FF0000|9=FF0000;

// sets a German tri-colour in a similar way (note: template name is '3x3' with black background colour '000000'; 
// template sections '4','5' and '6' are set in red (FF0000), sections '7','8' and '9' are set in yellow (FFFF00). 
// The 'top' sections '1','2','3' are not mentioned – they simply take the background colour)
set nation flag 3x3:000000:4=FF0000|5=FF0000|6=FF0000|7=FFFF00|8=FFFF00|9=FFFF00;

// creates the St.George's (English) flag (note: template name is 'cross' with white background colour 'FFFFFF'; 
// the template section '.' (dot) which is the 'cross' is set in red 'FF0000' – fairly easy!)
set nation flag cross:FFFFFF:.=FF0000;

// creates the Scottish flag (note: template name is 'scots_cross' with blue background colour '0000FF'; 
// the template section '.' (dot) which is the 'cross' is set in white 'FFFFFF')
set nation flag scots_cross:0000FF:.=FFFFFF;

#end
#begin

login myemail@gmail.com/passsword9329;
set player mode permanent;

#end
#begin
login myemail@gmail.com/passsword9329;

// Changing prod order priority with id 123 to -255
set prod order priority --id 123 --priority “-255”;

// Changing prod order priority with id 124 to 200
set prod order priority --id 123 --priority 200;

#end
#begin
login myemail@gmail.com/passsword9329;

// Changing ship class for type 'Esel' from 'combat' to 'service'
set ship class service for --type Esel;

// Changing ship class for type 'dk' from 'service' to 'combat'
set ship class combat for --type dk;

#end
#begin
login myemail@gmail.com/passsword9329;

// disables showing all information fields:
show rating for --all 0;

// disables showing all information fields except average tech level and colonies number:
show rating for --all 0 --tech --coloniesNumber;

// enables showing all information fields
show rating for --all 1;

// enables showing all information fields except money, tech weapon and tech shield:
show rating for --all 1 --money --techWeapon --techShield;

#end
#begin
login myemail@gmail.com/passsword9329;

// Setting new ship type for the Transport Manager
set ship type --name Horsa --for TranspManager;

// Setting new ship type for the Exploration Manager
set ship type --name Drone --for ExplManager;

#end
#begin
login myemail@gmail.com/myPassword;

// orders ship Carrier to tow ship 23 to star system Solaris
tow --ship #23 --to Solaris --by Carrier;

#end
#begin
login myemail@gmail.com/passsword9329;

// Transferring 100 CREG to Warlocks
transfer money --amount 100 --to Warlocks;

#end
#begin
login myemail@gmail.com/passsword9329;

update trigger
  --type OnStarBeforeTurn
  --name ProduceDefenceShips
  --code
#{ // star code macro
    if (_star.IsReachedMax))
      cmd produce ships
        --type DefenceShip
        --where &_star.Id // using & is a way
                          // to pass variable into command
        --number 10;
#} // end code macro
; // semicolon must be on the new line after closing #}

#end
#begin
login myemail@gmail.com/passsword9329;

// Upgrade drive and weapons for ship #1
upgrade ship --id 1 --tech DRIVE --priority 5;
upgrade ship --id 1 --tech WEAPON --priority 4;

// Upgrade all techs for ship 2 with default priority
upgrade ship --id 2;

#end

Common:

#begin

login myemail@gmail.com/passsword9329;

join --ship 22940;
colonize --star 1674 --ship 22940;
add star for manager --name ColManager --id 1674;
cancel assignment for --fleet QRF LC I;

name --ship 5762 --as Dormagen II;
name --ship 5763 --as Herr Peter II;
name --ship 5764 --as Die Koenigin;
name --ship 5765 --as Die Prinzessin;
name --ship 5766 --as Saint Johan;
name --ship 5767 --as Saint Anton;
name --ship 5768 --as Kutzbeul;
name --ship 5769 --as Monschau;
name --ship 5770 --as Aachen;
name --ship 5771 --as Der Fuhrer;
name --ship 5772 --as Grand Germania;

name --ship 5773 --as Sluis;
name --ship 5774 --as Brugge;
name --ship 5775 --as Ghent;
name --ship 5776 --as Antwerpen;
name --ship 5777 --as Maastricht;
name --ship 5778 --as Der Witze;
name --ship 5779 --as Nebelwerfer;
name --ship 5780 --as Raum Ghost;
name --ship 6301 --as Uberraschung;
name --ship 6995 --as Burg Katz;
name --ship 7753 --as Bingen;
name --ship 27416 --as Die Letzte Hoffnung;

#end
#begin
login myemail@gmail.com/passsword9329;

colonize --star 125 --ship 25445;
colonize --star 137 --ship 25292;

produce ships --type Kolonia --where 138 --priority 3000 --sendto fleet: FOR 85;
produce ships --type Kolonia --where 77 --priority 3000 --sendto fleet: FOR 115;

send --fleet F SLOW --to #691;

execute script --code
#{

for (long i = 1; i <= 19; ++i)
{
   string name = "F PATROL " + i;
   cmd cancel assignment for --fleet &name;
}

#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

// Joins all ships on star system #626 of type VMAntiAvenger to fleet 'FG II'
join --ship 626:VMAntiAvenger --to FG II;

// Two commands below move 100 ships of specific type from one fleet to another:
// Removes 100 ships of type 'Line3' belogning to fleet 'FReserve' on star system 'Sol'
join --ship Sol:Line3:FReserve:100;
// Joins 100 ships of type 'Line3' on star system 'Sol' to another fleet 'F SLOW'
join --ship Sol:Line3::100 --to F SLOW;

// These two commands cancel current assignment of all ships of type 'VMAntiAvenger' on star system #497
// and send them to star system #503
cancel assignment for --ship 497:VMAntiAvenger;
send --ship 497:VMAntiAvenger --to 503;

#end

Triggers and Scripts:

#begin
login myemail@gmail.com/passsword9329;

--- bulk cancelling assignments for ships of specified type in location using execute script
execute script --code
#{
  branch filter;
  filter.Add("VMAntiAvenger", "Type"); // effective for ships of type VMAntiAvenger
  filter.Add("1726", "Location");      // located in the star system 1726
  branch ships = _app.GetShips(filter);
  trace << "Found "<< ships.Size() << " ships";
  long counter;
  for (long i = 0; i < ships.Size(); ++i)
  {
       cmd cancel assignment for --ship &ships[i].Id;
       ++counter;
       catch (string err, long code)
       {
          trace << "@@@ignored error " << err;
          --counter;
          return true;
       }
  } // for
  trace << "----totally canceled " << counter << " assignments";
#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type OnStarBeforeTurn --name BuildStaticDefence --code
#{
string DefenceShipType;
string OldDefenceShipType;
bool IsDefenceShip(branch aShip)
{
  return aShip.Type == DefenceShipType || aShip.Type == OldDefenceShipType;
};

if (_star.IsOwn && _star.Size >= 800 &&_star.ResourceFactor >= 0.1)
{
  double industryLevel;
  long minNumberOfShips;
  long maxNumberOfShips;
  bool isGiant = _star.Size > 2500;

  if (isGiant)
  {
    industryLevel = _star.Size/2;
    OldDefenceShipType = "VMAntiAvengerDefence";
    DefenceShipType = "LineDefence";
    minNumberOfShips = 3;
    maxNumberOfShips = 10;
  }
  else
  {
    industryLevel = _star.Size - 1;
    DefenceShipType = "VM2733oneDefence";
    minNumberOfShips = 2;
    maxNumberOfShips = 7;
  }

  if (_star.IsReachedMax || _star.Industry >= industryLevel)
  {
    branch fastFilter;
    fastFilter.Add(_star.Id, "Location");
    long numberOfDefenceShipsOnOrbit = _app.CalcShips(fastFilter, "IsDefenceShip");
    long numberOfDefenceShipsInProduction =

    _app.CalcShipTypeInProd(_star.Id, DefenceShipType);

    long planned = numberOfDefenceShipsOnOrbit + numberOfDefenceShipsInProduction;
    branch shipTypeInfo = _app.GetShipTypeInfo(DefenceShipType);
    long requeredNumberOfShips = _star.Size/shipTypeInfo.Mass;
    long adjustedNumberOfShips = requeredNumberOfShips;

    if (requeredNumberOfShips < minNumberOfShips)
     adjustedNumberOfShips = minNumberOfShips;

    if (requeredNumberOfShips > maxNumberOfShips)
      adjustedNumberOfShips = maxNumberOfShips;

    if (planned < adjustedNumberOfShips)
    {
      trace << "--------------------------------";
      trace << "*** BuildStaticDefence for star #" << _star.Id
            << ", industry=" << _star.Industry
            << ", industryLevel=" << industryLevel
            << ", star.ResourceFactor=" << _star.ResourceFactor;

      trace << "defenceShipType=" << DefenceShipType
            << " (mass=" << shipTypeInfo.Mass << ")"
            << ", numberOfDefenceShipsOnOrbit=" << numberOfDefenceShipsOnOrbit
            << ", numberOfDefenceShipsInProduction=" << numberOfDefenceShipsInProduction
            << ", planned=" << planned;

      trace << "requeredNumberOfShips=" << requeredNumberOfShips
            << ", adjustedNumberOfShips=" << adjustedNumberOfShips;

      long toProduce = adjustedNumberOfShips - planned;
      trace << "*** Adding order to produce " << toProduce
            << " number of ships of type " << DefenceShipType << "...";

      cmd login myemail@gmail.com/passsword9329;
      cmd produce ships --type &DefenceShipType
                        --number &toProduce
                        --where &_star.Id
                        --priority "-888"
                        --sendto fleet: DEFENCE_FLEET;
      trace << "...Ok";
    }
  }
}

#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type OnStarBeforeTurn --name BuildLightDefence --code
#{
  void PrintHeader()
  {
    trace << "--------------------------------";
    trace << "*** BuildLightDefence for star #" << _star.Id;
  };

  string DefenceShipType = "LeichtAbwehrShiff";
  bool IsDefenceShip(branch aShip)
  {
    return aShip.Type == DefenceShipType;
  };

  branch fastFilter;
  fastFilter.Add("Guarding star #" + _star.Id, "Assignment");
  branch shipsAssignedToGuard = _app.GetShips(fastFilter, "IsDefenceShip");

  if (_star.IsOwn ||
      _app.CheckStarBelongsToManager(_star.Id, "ColManager"))
  {
    branch defence;
    if (_star.IsOwn)
      defence = _app.CalcDefenceForStar(_star.Id);
    else
      defence.Add(0, "CurrentDefenceShipsMass");
    if (defence.CurrentDefenceShipsMass == 0)
    {
      if (!shipsAssignedToGuard.Size())
      {
        PrintHeader();
        trace << "Star #" << _star.Id
              << " has been scheduled for the Light Defence";
        _app.SendTriggerMessage("StarForLightDefence", _star.Id);
      }

      quit;
    }
  }

  if (shipsAssignedToGuard.Size())
  {
    PrintHeader();
    trace << "The star has no need in light defence.";
    if (!_star.IsOwn)
      trace << "(does not belong to the nation)";

    trace << "Cancelling " << shipsAssignedToGuard.Size()
          << " ships assigned to guard the star:";
    cmd login myemail@gmail.com/passsword9329;
    for (long i = 0; i < shipsAssignedToGuard.Size(); ++i)
    {
      branch ship = shipsAssignedToGuard[i];
      if (!ship.AssignmentCancelled)
      {
        trace << "Ship #" << ship.Id
              << ", location=" << ship.Location << ":";
        cmd cancel assignment for --ship &ship.Id;
        trace << "...Ok";
      }
    }
  }

#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type BeforeTurn --name BuildLightDefence --code
#{

  trace << "--------------------------------";
  trace << "*** BeforeTurn@BuildLightDefence";

  string DefenceShipType = "LeichtAbwehrShiff";
  bool IsDefenceShip(branch aShip)
  {
    return aShip.Type == DefenceShipType;
  };

  branch stars = _app.ReceiveTriggerMessages("StarForLightDefence");
  trace << "Found " << stars.Size()
        << " stars scheduled for light defence";
  if (stars.Size())
  {
    branch fastFilter;
    fastFilter.Add("", "Assignment");
    fastFilter.Add("", "Fleet");
    branch availableShips = _app.GetShips(fastFilter, "IsDefenceShip");
    if (availableShips.Size() < stars.Size())
    {
      long required = stars.Size() - availableShips.Size();
      trace << "To defend " << stars.Size()
            << " required " << required << " ships";
      long alreadyInProd = _app.CalcShipTypeInProd(0, DefenceShipType);
      if (alreadyInProd)
        trace << "  already in production: " << alreadyInProd;
      long toBuild = required - alreadyInProd;
      if (toBuild > 0)
      {
        trace << "Need to build " << toBuild
              << " defence ships of type " << DefenceShipType;

        cmd login myemail@gmail.com/passsword9329;
        trace << "*** Adding order to produce " << toBuild
              << " number of ships of type "
              << DefenceShipType << "...";
        cmd produce ships
          --type &DefenceShipType
          --number &toBuild --priority "-666"
          --hedge sizes:1000.., res: 0.5..;
        trace << "...Ok";
      }
    }

    branch matched =
      _app.FindBestMatchSendingShipsToStars(availableShips, stars);
    trace << "Found " << matched.Size() << " matches";

    cmd login myemail@gmail.com/passsword9329;
    for (long i = 0; i < matched.Size(); i++)
    {
      branch info = matched[i];
      trace << "Assigning ship #" << info.ShipId
            << " to guard star #" << info.StarId << "...";
      cmd guard --star &info.StarId --ship &info.ShipId;
      trace << "...Ok";
    }
  }

#}
;


#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type OnStarBeforeTurn --name BuildMobileDefence --code
#{
  void PrintHeader()
  {
    trace << "--------------------------------";
    trace << "*** BuildMobileDefence for star #" << _star.Id;
  };

  long requiredNumberOfShips = 10;

  string DefenceShipType = "MobileDefenceT1";
  bool IsDefenceShip(branch aShip)
  {
    return aShip.Type == DefenceShipType ||
           aShip.Type == "VM2476one" ||
           aShip.Type == "VM1309" ||
           aShip.Type == "Fregate";
  };

  branch fastFilter;
  fastFilter.Add("Guarding star #" + _star.Id, "Assignment");
  branch shipsAssignedToGuard = _app.GetShips(fastFilter, "IsDefenceShip");

  if (_star.IsOwn ||
      _app.CheckStarBelongsToManager(_star.Id, "ColManager"))
  {
    branch defence;
    if (_star.IsOwn)
      defence = _app.CalcDefenceForStar(_star.Id);
    else
      defence.Add(0, "CurrentDefenceShipsMass");
    if (defence.CurrentDefenceShipsMass == 0)
    {
      if (shipsAssignedToGuard.Size() < requiredNumberOfShips)
      {
        PrintHeader();
        long numberOfShipsToAssign =
          requiredNumberOfShips - shipsAssignedToGuard.Size();
        trace << "Star #" << _star.Id
              << " needs " << numberOfShipsToAssign
              << " mobile defence ships";

        string msg = _star.Id;
        _app.SendTriggerMessage(
          "MobileDefenceRequest", msg + "," + numberOfShipsToAssign);
      }

      quit;
    }
  }

  if (shipsAssignedToGuard.Size())
  {
    PrintHeader();
    trace << "The star has no need in mobile defence.";
    if (!_star.IsOwn)
      trace << "(does not belong to the nation)";

    trace << "Cancelling " << shipsAssignedToGuard.Size()
          << " ships assigned to guard the star:";
    cmd login myemail@gmail.com/passsword9329;
    for (long i = 0; i < shipsAssignedToGuard.Size(); ++i)
    {
      branch ship = shipsAssignedToGuard[i];
      if (!ship.AssignmentCancelled)
      {
        trace << "Ship #" << ship.Id
              << ", location=" << ship.Location << ":";
        cmd cancel assignment for --ship &ship.Id;
        trace << "...Ok";
      }
    }
  }

#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type BeforeTurn --name BuildMobileDefence --code
#{
  trace << "--------------------------------";
  trace << "*** BeforeTurn@BuildMobileDefence";

  string DefenceShipType = "MobileDefenceT1";
  bool IsDefenceShip(branch aShip)
  {
    return aShip.Type == DefenceShipType ||
           aShip.Type == "VM2476one" ||
           aShip.Type == "VM1309" ||
           aShip.Type == "Fregate";
  };

  branch request = _app.ReceiveTriggerMessages("MobileDefenceRequest");
  trace << "Found " << request.Size()
        << " mobile defence requests";

  if (request.Size())
  {
    long requestedShipsNumber = 0;
    for (long i = 0; i < request.Size(); ++i)
    {
      string r = request[i];
      branch tok = r.Split(",");
      if (tok.Size() != 2)
        throw ("Invalid request format: '" + r + "'");
      requestedShipsNumber += tok[1];
    }

    branch fastFilter;
    fastFilter.Add("", "Assignment");
    fastFilter.Add("", "Fleet");
    branch availableShips = _app.GetShips(fastFilter, "IsDefenceShip");
    if (availableShips.Size() < requestedShipsNumber)
    {
      long required = requestedShipsNumber - availableShips.Size();
      trace << "To build mobile defence for " << request.Size()
            << " stars required " << required << " ships";
      long alreadyInProd = _app.CalcShipTypeInProd(0, DefenceShipType);
      if (alreadyInProd)
        trace << "  already in production: " << alreadyInProd;
      long toBuild = required - alreadyInProd;
      if (toBuild > 0)
      {
        trace << "Need to build " << toBuild
              << " defence ships of type " << DefenceShipType;

        cmd login myemail@gmail.com/passsword9329;
        trace << "*** Adding order to produce " << toBuild
              << " number of ships of type "
              << DefenceShipType << "...";
        cmd produce ships
          --type &DefenceShipType
          --number &toBuild --priority "-1111"
          --hedge sizes:1000.., res: 0.5..;
        trace << "...Ok";
      }
    }

    branch matched =
      _app.FindBestMatchSendingShipsToStarsExt(availableShips, request);
    trace << "Found " << matched.Size() << " matches";

    cmd login myemail@gmail.com/passsword9329;
    for (long i = 0; i < matched.Size(); i++)
    {
      branch info = matched[i];
      trace << "Assigning ship #" << info.ShipId
            << " to guard star #" << info.StarId << "...";
      cmd guard --star &info.StarId --ship &info.ShipId;
      trace << "...Ok";
    }
  }

#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type OnStarBeforeTurn --name STAR_WALL --code
#{
  void PrintHeader()
  {
    trace << "--------------------------------";
    trace << "*** BuildStarWall for star #" << _star.Id;
  };

  string oldDefenceShipType = "VMAntiAvenger";
  string oldDefenceShipType2 = "Line";
  string oldDefenceShipType3 = "Line2";
  string oldDefenceShipType4 = "Line3";
  string defenceShipType = "Line3ext_SW";

  long requiredNumberOfShips = 12;
  bool IsDefenceShip(branch aShip)
  {
    return aShip.Type == defenceShipType ||
      aShip.Type == oldDefenceShipType ||
      aShip.Type == oldDefenceShipType2 ||
      aShip.Type == oldDefenceShipType3 ||
      aShip.Type == oldDefenceShipType4;
  };

  branch fastFilter;

  fastFilter.Add("Guarding star #" + _star.Id, "Assignment");

  long shipsAssignedToGuard = _app.CalcShips(fastFilter, "IsDefenceShip");

  if (shipsAssignedToGuard < requiredNumberOfShips)
  {
    PrintHeader();
    long numberOfShipsToAssign =
      requiredNumberOfShips - shipsAssignedToGuard;

    if (numberOfShipsToAssign > 0)
    {
      trace << "Star #" << _star.Id
            << " needs " << numberOfShipsToAssign
            << " star wall defence ships";

      string msg = _star.Id;
      _app.SendTriggerMessage(
        "StarWallRequest", msg + "," + numberOfShipsToAssign);
    }
  }


#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type BeforeTurn --name BuildStarWall --code
#{
  trace << "--------------------------------";
  trace << "*** BeforeTurn@BuildStarWall";

  string oldDefenceShipType = "VMAntiAvenger";
  string oldDefenceShipType2 = "Line";
  string oldDefenceShipType3 = "Line2";
  string oldDefenceShipType4 = "Line3";
  string defenceShipType = "Line3ext_SW";
  bool IsDefenceShip(branch aShip)
  {
    return aShip.Type == defenceShipType ||
      aShip.Type == oldDefenceShipType ||
      aShip.Type == oldDefenceShipType2 ||
      aShip.Type == oldDefenceShipType3 ||
      aShip.Type == oldDefenceShipType4;
  };

  branch request = _app.ReceiveTriggerMessages("StarWallRequest");
  trace << "Found " << request.Size()
        << " star wall requests";

  if (request.Size())
  {
    long requestedShipsNumber = 0;
    for (long i = 0; i < request.Size(); ++i)
    {
      string r = request[i];
      branch tok = r.Split(",");
      if (tok.Size() != 2)
        throw ("Invalid request format: '" + r + "'");

      requestedShipsNumber += tok[1];
    }

    branch fastFilter;
    fastFilter.Add("", "Assignment");
    fastFilter.Add("", "Fleet");
    branch availableShips = _app.GetShips(fastFilter, "IsDefenceShip");

    if (availableShips.Size() < requestedShipsNumber)
    {
      long required = requestedShipsNumber - availableShips.Size();
      trace << "To build star wall for " << request.Size()
            << " stars required " << required << " ships";

      long alreadyInProd = _app.CalcShipTypeInProd(0, defenceShipType);

      if (alreadyInProd)
        trace << "  already in production: " << alreadyInProd;

      long toBuild = required - alreadyInProd;

      if (toBuild > 0)
      {
        trace << "Need to build " << toBuild
              << " defence ships of type " << defenceShipType;

        cmd login myemail@gmail.com/passsword9329;

        trace << "*** Adding order to produce " << toBuild
              << " number of ships of type "
              << defenceShipType << "...";

        cmd produce ships
          --type &defenceShipType
          --number &toBuild --priority "-2222"
          --hedge sizes:1000.., res: 0.5..;

        trace << "...Ok";
      }
    }

    branch matched = _app.FindBestMatchSendingShipsToStarsExt(availableShips, request);
    trace << "Found " << matched.Size() << " matches";
    cmd login myemail@gmail.com/passsword9329;

    for (long i = 0; i < matched.Size(); i++)
    {
      branch info = matched[i];
      trace << "Assigning ship #" << info.ShipId
            << " to guard star #" << info.StarId << "...";

      cmd guard --star &info.StarId --ship &info.ShipId;
      trace << "...Ok";
    }
  }

#}
;


#end
#begin
login myemail@gmail.com/passsword9329;

update trigger --type WhenRemovedFromObject --name CancelStarWall --code
#{

  trace << "--------------------------------";
  trace << "*** WhenRemovedFromObject@CancelStarWall";
  trace << "Called for "
        << _trigger.Type << "@" << _trigger.Name
        << ", id=" << _trigger.Id;

  string oldDefenceShipType = "VMAntiAvenger";
  string oldDefenceShipType2 = "Line";
  string oldDefenceShipType3 = "Line2";
  string oldDefenceShipType4 = "Line3";
  string defenceShipType = "Line3ext_SW";

  bool IsDefenceShip(branch aShip)
  {
    return aShip.Type == defenceShipType ||
      aShip.Type == oldDefenceShipType ||
      aShip.Type == oldDefenceShipType2 ||
      aShip.Type == oldDefenceShipType3 ||
      aShip.Type == oldDefenceShipType4;
  };

  branch fastFilter;
  fastFilter.Add("Guarding star #" + _trigger.Id, "Assignment");
  branch shipsAssignedToGuard = _app.GetShips(fastFilter, "IsDefenceShip");
  trace << "shipsAssignedToGuard=" << shipsAssignedToGuard.Size();

  if (shipsAssignedToGuard.Size())
  {
    trace << "Cancelling " << shipsAssignedToGuard.Size()
          << " ships assigned to guard the star "
          << _trigger.Id << ":";

    cmd login myemail@gmail.com/passsword9329;

    for (long i = 0; i < shipsAssignedToGuard.Size(); ++i)
    {
      branch ship = shipsAssignedToGuard[i];

      if (!ship.AssignmentCancelled)
      {
        trace << "Ship #" << ship.Id
              << ", location=" << ship.Location << ":";

        cmd cancel assignment for --ship &ship.Id;
        trace << "...Ok";
      }
    }
  }

#}
;

#end
#begin
login myemail@gmail.com/passsword9329;

// This command adds star 1416 to the STAR WALL
add trigger to object --type OnStarBeforeTurn --name STAR_WALL --id 1416;

// This command removes star 562 from the STAR WALL
remove trigger from object --type OnStarBeforeTurn --name STAR_WALL --id 562;

#end

Messages:

#message
login: myemail@gmail.com/7password98349
to: All

Hello All,

On response to Dima's message:

>For those interested, one of my brave voyagers entered one of Shadow’s
>home planets to see the nest. Their single, and actually the last,
>message was about seeing one of the biggest fleet ever:
...
>And my only hope that we don’t have a race who can think supporting
>them by attacking any of us.


We are solid and not planning any attack against anyone.
We are for peace and prosperity in the galaxy.
Although, we haven't met the Shadow's yet, but we will be
ready to fight them and send our fleets if necessary.

With best regards,
Maximus

#end
#message
login: myemail@gmail.com/837477748
to: Mystica

Greetings Myst,


You have attacked us and destroyed our colony, millions have died.
Will you remove your ship from our sector of the Galaxy or your race will be eliminated.
We don't want this war...

Maximus

#end
#message
login: myemail@gmail.com/837477748
to: Atlanta, Big Bunnies, French Republic

Dear All,
Let's unite our efforts to destroy the extremely annoying Gremlins.
I can send my fleet to destroy their colony #145 and then move further to #156 and #172.
Please let me know if your areinterested.
In any case please keep this in secret from Gremlins

Maximus

#end
#message
login: myemail@gmail.com/837477748
to: GM

Dear GM,
It would be great to improve the Ship Designer in the Report Viewer
to make it possible to freeze shield or speed when changingother parameters.

Thank you,
Maximus

#end