PHP SCX Editor
PHP SCX Editor is a powerful tool / framework to edit aoc scenarios with PHP programming language. If you handle it you could make anything very easily.
Original version is made by
(*) For HD designer: Set SCX::$editor_version parameter to 'HD' to use new triggers effects. Also PSE can't read HD scenarios yet, so you need to use 1.0c or 1.4 RC maps as input scenario.
Project is shared on GitLab if you want to contribute you are welcome:
- Design scenarios how you want with PHP programmation. You can build them in smoother and faster ways, no more boring repetive tasks.
- Use ready to use simple and intuitive functions to read / write scenarios properties and write triggers.
- Use conditions, loops and any classic programming feature to generate triggers or anything in a scenario.
- Create complex custom conditions / effects / triggers sequence / macros.
- Assign any fields to values calculated by algorithm and variables.
- Copy paste triggers or any reusable code in new scenarios.
- Have a great overview of your triggers and your whole scenario in a single page.
- Build your own aoc editor framework to fill your needs.
- Modify your scenario by changing variables, no more need to edit triggers one per one.
- Change triggers order as you want, just cut paste code.
- Scenarios that would need 100 hours to make could need only 10 hours now !
- And more...!
If you are not used to programmation you won't see why it is so much awesome. Some examples:
For each berries in the whole map
If a player is next to it
Give him 5 food
Remove the berry
So now, you can start thinking where to put berries, just place it, and triggers are made ! And you want to move one by 1 tile ? Do it ! Triggers will adapt ! It's only a fraction of what you can do now
Then you will use it like this:
"The King"] = 10; # The unit id that is the king
TrigConversation("The King", "Hello, Im the king.");
This code will in fact generate this trigger:
Trigger: Conversation with The King
Condition: Bring object in the area around unit 10
Effect: Display instruction "The King: Hello, Im the king."
So, you can see it's much faster and clearer with PHP. It gives you an overview and prevent you doing mistakes, and if one day you want to change "The King" unit, you will have to change only the line "$Unit
Condition: player A is enemy to player B
This condition will in fact check if the palissade wall from the team detector is destroyed, but it will be unseen in your code ! All logics is more clear.
Create a team detector at X,Y
Build anti-deleter for buildings
Effect: Display instruction "blabla"
Condition: If player X is level 10
Condition: If player X is alive
Effect: Send chat to all player
Effect: Play sound to all player
Effect: Deactivate all triggers assigned to player X (useful for boot)
Effect: Boot player X
Here is the power of PHP, you can share code, save lot of time and create your scenario in much more intuitive ways.
A last example to show you how would really looks code to create all CBA spawns triggers with tasks for 8 players, with only 12 lines, 5 minutes of work if you are used to PSE:
$spawns = array(array(22,48),array(22,52),array(22,55),array(22,59));
$meetPoint = AreaPlayers(array(29,53));
Trig("Research Civ Techs");
foreach(range(1,8) as $p)foreach(LIB::$CivTechs as $tech)Efft_Research($p,$tech);
foreach(range(1,8) as $p)foreach(LIB::$CivTechs as $civ =>
Trig("Spawn Player $p - Civ $civ",1,1);
foreach($spawns as $spawn)Efft_Create($p,LIB::$CivEliteUnit[
foreach(range(1,8) as $p)foreach($spawns as $spawn)Efft_TaskO($p,AreaPlayer($p,$spawn),$meetPoint[
These four maps are almost impossible to make without a programming method and show you the power of scripting.
Requirements / Installation
1/ You need a
You can also download PHP Designer 2007, the personal version is free:
2/ You need a
3/ Install your
5/ Configure your PHP IDE, for PHP Designer 8: Go to "Tools / Preferences / Run" and specify paths to your compiler
6/ Open php.ini with notepad and edit "max_execution_time" and "memory_limit" values
max_execution_time = 300000
memory_limit = 4294967296
7/ All is ready. To use PHP SCX Editor open the 3 files in your PHP IDE:
8/ To check if your installation is good, try to compile the example:
- In aoc create a blank map called "My Map"
- In Compiler.php, specify your scenarios folder path in $scenarios_path
- Run two times Compiler.php (On PHP Designer 8 click on "Run" button in toolbar / For PHP Designer 7 it's called "Debug" I think.)
- A new map is created: "My Compiled Map", you can open it in aoc and see the result
How to make maps
The script loads an existing map, edits it, and exports it. It will ignore all triggers of the input file.
The script is divided in 4 files:
Feel free to organize your code as you want, keep in mind that all you write is
From this point (with examples), you have all tools to learn more by yourself and get used to scripting. It will need time but
Also you have to know keys for conditions and effects fields, don't worry with time you will know them by heart:
P = Source Player ID
E = Target Player ID
U = Object Constant ID
G = Object Group ID
Y = Object Type ID
A = Area
L = Location
Q = Quantity
R = Resource
H = Technology ID
I = Trigger Name
X = Text
T = Time
N = Panel
S = Objects IDs
F = Object Source ID
O = Object Location ID
D = Sound
M = Diplomacy
Z = AI Signal / AI Goal
K = Inverted condition (Only for 1.4 RC)
- Activation / Deactivation are set with trigger name, not id. So you have to be sure you don't have multiple triggers with same name else it won't work. Also you have to compile your code 2 times always to make these effects working.
Convert images as terrain
; extension_dir = "ext"
by these lines:
extension_dir = "./ext"
It will unlock functions to read images.
1/ Put your image in indexed colors mode and save it as .png or .gif, to achieve this: Open your image in gimp 2 and switch in indexed color mode, now your image will have an id assigned to each colour. You can know this id by loading indexed color palette. The image should have same size as your map.
2/ In Scenario.php write SetTerrainFromImage('path_to_your_image', terrain_ids). terrain_ids is an array that contains the terrains ids bound to colors ids. For example with an image that contains 3 colors we can do:
4, # Bind color 0 to Shallows
0, # Bind color 1 to Grass 1
5 # Bind color 2 to Leaves
When you done that just run it and you have your awesome design.
You should need this list if your IDE doesn't have intelligent code completion or you are a notepad purist. This list is up to date, new functions should be added frequently. As well, any new stuff is notified in changelog. To know how to use them you can look them in Library.php, there are help comments for complex ones.
Trig($N = '', $S = 1, $L = 0, $P = 0, $E = 0, $D = '', $R = '')
NewObject($ID, $P, $U, $L, $R = 0, $G = -1, $F = 0)
Area($X1, $Y1, $X2, $Y2)
Cond_Accumulate($P, $Q, $R)
Cond_AccumulateExactly($P, $Q, $R)
Cond_InAreaG($P, $Q, $G, $A)
Cond_InAreaO($P, $Q, $A)
Cond_InAreaU($P, $Q, $U, $A)
Cond_InAreaY($P, $Q, $Y, $A)
Cond_NotAccumulate($P, $Q, $R)
Cond_NotInAreaG($P, $Q, $G, $A)
Cond_NotInAreaO($P, $Q, $A)
Cond_NotInAreaU($P, $Q, $U, $A)
Cond_NotInAreaY($P, $Q, $Y, $A)
Cond_NotOwnG($P, $Q, $G)
Cond_NotOwnU($P, $Q, $U)
Cond_NotOwnY($P, $Q, $Y)
Cond_OwnG($P, $Q, $G)
Cond_OwnU($P, $Q, $U)
Cond_OwnY($P, $Q, $Y)
Efft_APG($P, $Q, $G, $A = null)
Efft_APO($P, $Q, $A = null)
Efft_APU($P, $Q, $U, $A = null)
Efft_APY($P, $Q, $Y, $A = null)
Efft_ArmorG($P, $Q, $G, $A = null)
Efft_ArmorO($P, $Q, $A = null)
Efft_ArmorU($P, $Q, $U, $A = null)
Efft_ArmorY($P, $Q, $Y, $A = null)
Efft_ChangeDiplomacy($P, $E, $stateName)
Efft_ChangeOwnerG($P, $G, $A = null, $E = 0)
Efft_ChangeOwnerO($P, $A = null, $E = 0)
Efft_ChangeOwnerS($S, $E = 0)
Efft_ChangeOwnerU($P, $U, $A = null, $E = 0)
Efft_ChangeOwnerY($P, $Y, $A = null, $E = 0)
Efft_Create($P, $U, $L)
Efft_DamageG($P, $Q, $G, $A = null)
Efft_DamageO($P, $Q, $A = null)
Efft_DamageU($P, $Q, $U, $A = null)
Efft_DamageY($P, $Q, $Y, $A = null)
Efft_Display($T, $N, $X)
Efft_FreezeG($P, $G, $A = null)
Efft_FreezeO($P, $A = null)
Efft_FreezeU($P, $U, $A = null)
Efft_FreezeY($P, $Y, $A = null)
Efft_Give($P, $Q, $R)
Efft_HPG($P, $Q, $G, $A = null)
Efft_HPO($P, $Q, $A = null)
Efft_HPU($P, $Q, $U, $A = null)
Efft_HPY($P, $Q, $Y, $A = null)
Efft_KillG($P, $G, $A = null)
Efft_KillO($P, $A = null)
Efft_KillU($P, $U, $A = null)
Efft_KillY($P, $Y, $A = null)
Efft_MSG($P, $Q, $G, $A = null)
Efft_MSO($P, $Q, $A = null)
Efft_MSU($P, $Q, $U, $A = null)
Efft_MSY($P, $Q, $Y, $A = null)
Efft_NameO($P, $X, $A = null)
Efft_NameU($P, $X, $U, $A = null)
Efft_NameY($P, $X, $Y, $A = null)
Efft_PatrolG($P, $G, $A = null, $L)
Efft_PatrolO($P, $A = null, $L)
Efft_PatrolU($P, $U, $A = null, $L)
Efft_PatrolY($P, $Y, $A = null, $L)
Efft_PlaceFoundation($P, $U, $L)
Efft_RangeG($P, $Q, $G, $A = null)
Efft_RangeO($P, $Q, $A = null)
Efft_RangeU($P, $Q, $U, $A = null)
Efft_RangeY($P, $Q, $Y, $A = null)
Efft_RemoveG($P, $G, $A = null)
Efft_RemoveO($P, $A = null)
Efft_RemoveU($P, $U, $A = null)
Efft_RemoveY($P, $Y, $A = null)
Efft_Set($P, $Q, $R)
Efft_StopG($P, $G, $A = null)
Efft_StopO($P, $A = null)
Efft_StopU($P, $U, $A = null)
Efft_StopY($P, $Y, $A = null)
Efft_TaskG($P, $G, $A = null, $LO)
Efft_TaskO($P, $A = null, $LO)
Efft_TaskU($P, $U, $A = null, $LO)
Efft_TaskY($P, $Y, $A = null, $LO)
Efft_Tribute($P, $Q, $R, $E = 0)
Efft_UnloadG($P, $G, $A = null, $L)
Efft_UnloadO($P, $A = null, $L)
Efft_UnloadU($P, $U, $A = null, $L)
Efft_UnloadY($P, $Y, $A = null, $L)
Efft_Explosion($L, $Rayon = 0, $Filled = false)
Efft_InvincibleG($P, $G, $HP_For_Buildings = null, $A = null)
Efft_InvincibleO($P, $HP_For_Buildings = null, $A = null)
Efft_InvincibleS($S, $HP_For_Buildings = null)
Efft_InvincibleU($P, $U, $HP_For_Buildings = null, $A = null)
Efft_InvincibleY($P, $Y, $HP_For_Buildings = null, $A = null)
SetPlayerStartView($player, $location, $objectIdAvailable, $objectConstantId)
Area($X1, $Y1, $X2, $Y2)
AreaAdvanced($L, $Axe, $Width = 3, $Depth = 2)
AreaCut($A, $Cuts = 1)
AreaOffset($A, $OffsetX = 0, $OffsetY = 0)
AreaPlayers($Area, $StepX = 0, $StepY = 0, $Players = 0)
AreaSet($L, $Size = 1)
Make maps and triggers much faster with PHP SCX Editor
Follow Roll The Dice news, updates and guide HERE
All multiplayer CS maps by AzZzRu available HERE
[This message has been edited by Leif Ericson (edited 03-16-2017 @ 00:59 AM).]