I'll be posting a more complicated example later, but here is a basic one used for my beacon triggers in my Civilization map. You can see the output of the script here. I realize that PHP is probably not the most efficient language (and hell, my code probably isn't maximally efficient) for something like this, but it is what I know how to use, I have access to SEN's server to run scripts here, and getting direct output in my browser is nice.
This method is also flexible: if I ever need to change the triggers for all the beacons at once, I just modify the script accordingly and paste the output over the old triggers. For example, I might decide that I want a certain government type to grant a special bonus for Banks, or that I want a death counter to count the number of beacons for a corruption mechanic or something. Then I just modify the triggers as needed and they're all generated for me.
What must be done:
- The map needs Protoss Beacons placed with a sequence of properly named locations. The sequence for my map was R1, R2, R3, ..., Rmax, where the max is the highest beacon number used in my map.
- Each beacon must change owners properly depending on who has buildings near them.
- Each beacon must give a specified amount of income when it's time to process income. In this map, it's when the Mineral Field (Type 1) deaths are 1. The amount of income is 100, though I could easily change that and run the script again for any amount I like.
- If the beacon has a "Bank", or Terran Academy next to it, it should give extra minerals. The amount of income from a Bank is 50, but again I can easily change that and run the script again for any amount I like.
The code:
Code
<?php
header("content-type:text/plain");
///////////
// The map already has locations R1, R2, R3, ... R(max)
// We want to make text triggers for each of them, incrementing the location number each time.
///////////
// Start at R1 and end at R157
$rnum = 1;
$rmax = 157;
while ($rnum <= $rmax)
{
$output .= <<<EOF
Trigger("Civs"){
Conditions:
Bring("Current Player", "Buildings", "R{$rnum}", At least, 1);
Bring("Player 8", "Buildings", "R{$rnum}", At most, 0);
Bring("Player 8", "Protoss Beacon", "R{$rnum}", At least, 1);
Actions:
Give Units to Player("Player 8", "Current Player", "Protoss Beacon", 1, "R{$rnum}");
Preserve Trigger();
}
//-----------------------------------------------------------------//
Trigger("Civs"){
Conditions:
Bring("Civs", "Buildings", "R{$rnum}", At most, 0);
Bring("Player 10", "Protoss Beacon", "R{$rnum}", At most, 0);
Bring("Current Player", "Protoss Beacon", "R{$rnum}", At Least, 1);
Actions:
Give Units to Player("All Players", "Player 8", "Protoss Beacon", 1, "R{$rnum}");
Preserve Trigger();
}
//-----------------------------------------------------------------//
Trigger("Civs"){
Conditions:
Deaths("Current Player", "Mineral Field (Type 1)", At least, 1);
Bring("Current Player", "Protoss Beacon", "R{$rnum}", At least, 1);
Actions:
Set Resources("Current Player", Add, 100, ore);
Preserve Trigger();
}
//-----------------------------------------------------------------//
Trigger("Civs"){
Conditions:
Deaths("Current Player", "Mineral Field (Type 1)", At least, 1);
Bring("Current Player", "Protoss Beacon", "R{$rnum}", At least, 1);
Bring("Current Player", "Terran Academy", "R{$rnum}", At least, 1);
Actions:
Set Resources("Current Player", Add, 50, ore);
Preserve Trigger();
}
//-----------------------------------------------------------------//
EOF;
$rnum++;
}
echo $output;
?>
header("content-type:text/plain");
///////////
// The map already has locations R1, R2, R3, ... R(max)
// We want to make text triggers for each of them, incrementing the location number each time.
///////////
// Start at R1 and end at R157
$rnum = 1;
$rmax = 157;
while ($rnum <= $rmax)
{
$output .= <<<EOF
Trigger("Civs"){
Conditions:
Bring("Current Player", "Buildings", "R{$rnum}", At least, 1);
Bring("Player 8", "Buildings", "R{$rnum}", At most, 0);
Bring("Player 8", "Protoss Beacon", "R{$rnum}", At least, 1);
Actions:
Give Units to Player("Player 8", "Current Player", "Protoss Beacon", 1, "R{$rnum}");
Preserve Trigger();
}
//-----------------------------------------------------------------//
Trigger("Civs"){
Conditions:
Bring("Civs", "Buildings", "R{$rnum}", At most, 0);
Bring("Player 10", "Protoss Beacon", "R{$rnum}", At most, 0);
Bring("Current Player", "Protoss Beacon", "R{$rnum}", At Least, 1);
Actions:
Give Units to Player("All Players", "Player 8", "Protoss Beacon", 1, "R{$rnum}");
Preserve Trigger();
}
//-----------------------------------------------------------------//
Trigger("Civs"){
Conditions:
Deaths("Current Player", "Mineral Field (Type 1)", At least, 1);
Bring("Current Player", "Protoss Beacon", "R{$rnum}", At least, 1);
Actions:
Set Resources("Current Player", Add, 100, ore);
Preserve Trigger();
}
//-----------------------------------------------------------------//
Trigger("Civs"){
Conditions:
Deaths("Current Player", "Mineral Field (Type 1)", At least, 1);
Bring("Current Player", "Protoss Beacon", "R{$rnum}", At least, 1);
Bring("Current Player", "Terran Academy", "R{$rnum}", At least, 1);
Actions:
Set Resources("Current Player", Add, 50, ore);
Preserve Trigger();
}
//-----------------------------------------------------------------//
EOF;
$rnum++;
}
echo $output;
?>
Post has been edited 4 time(s), last time on Nov 21 2012, 9:03 pm by Mini Moose 2707.
https://www.collaborativefund.com/blog/how-this-all-happened/
https://thelastpsychiatrist.com/2012/11/hipsters_on_food_stamps.html
https://youtu.be/vyiXaCRwZTs
https://thelastpsychiatrist.com/2011/09/how_to_be_mean_to_your_kids.html
http://lab.cccb.org/en/renata-avila-the-internet-of-creation-disappeared-now-we-have-the-internet-of-surveillance-and-control/
https://thelastpsychiatrist.com/2012/11/hipsters_on_food_stamps.html
https://youtu.be/vyiXaCRwZTs
https://thelastpsychiatrist.com/2011/09/how_to_be_mean_to_your_kids.html
http://lab.cccb.org/en/renata-avila-the-internet-of-creation-disappeared-now-we-have-the-internet-of-surveillance-and-control/