You must be logged in to post messages.
Please login or register

The University
Moderated by Popeychops, Leif Ericson

Hop to:    
Welcome! You are not logged in. Please Login or Register.71 replies
Age of Kings Heaven » Forums » The University » PHP SCX Editor - Make scenarios using PHP script (Approved)
Bottom
Topic Subject:PHP SCX Editor - Make scenarios using PHP script (Approved)
« Previous Page  1 2  Next Page »
AzZzRu
Squire
posted 11-11-14 11:09 AM CT (US)         
This article has been approved and can also be read at the University. - Leif Ericson

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. It's A LOT more powerful than aokts, you have the ability to build your own editor fonctionnalities very easily and organize your scenario how you want. That is very accessible to people who like programming and know it already a little bit. For others, you can still try it, programming is an intuitive skill and can be innate ! You could love it as you could hate it, it depends of people. Aoc triggers is a crap programming language which is boring and quite repetitive, if you can like that, you will love to practice a real programming language like PHP that allows you to build anything faster and smarter.

Don't be scared about complexity, the functions that are available are very intuitive and easy to use. It's much more smooth than an UI, but it takes more time to handle that, of course. When you'll handle the script you will have more time to think to your scenario instead of writing triggers, you could create fast almost whatever you think, and modify result very easily. You can contact me at voobly, if you are motivated I will help you by Skype: My profile

Original version is made by AOHH. Thanks to him for allowing me to modify and publish its code.

Compatibility: 1.0c / 1.4 RC / FE / HD*

(*) 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.

Download the script to the blacksmith: http://aok.heavengames.com/blacksmith/showfile.php?fileid=12246

Project is shared on GitLab if you want to contribute you are welcome: https://gitlab.com/sychavanne/php-scx-editor

Features
- 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...!

Algorithms examples


If you are not used to programmation you won't see why it is so much awesome. Some examples:

=> In a RPG map where you can pick berries you could write with few lines:

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

=> In a SP map you are lazy to handle conversation between player and actors ? You could create a custom trigger to achieve this with only one line, instead of creating 1 trigger + 1 condition + 1 effect. The function prototype would looks like:

TrigConversation($actor, $whatHeSay);

Then you will use it like this:

$Unit["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["The King"] = 10;", and in your whole scenario triggers will adapt. Or if finally you want the conversation starts when the player select the actor instead of reaching close area, you will just have to change the function TrigConversation.

Another interesting point: You think that your custom trigger is great, post it here in this thread, and I will add it in the standard library of PHP SCX Editor, and everybody could use it ! You could also share it with your friends. Aoc scenarios designing could become much easier and funny to handle. It's very cool that people can share mods, graphics, etc... now it is possible to share triggers too.

=> In a MP map you could handle teams in much more intuitive ways, by creating your own condition:

Condition: player A is enemy to player B
Effects...

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.

=> Creating team detector with palissade walls and sabs is quite boring work right ? You can know create a function that can do it with only one line !

Create a team detector at X,Y

=> Or create an anti-deleter is also quite boring ! Automate it !

Build anti-deleter for buildings

=> You want to play a sound to all players for each instructions displayed ? Then instead of writing 1 + 8 effects always, customize your display instruction effect ! Then it will do it by default, and you will need to write only one effect. Your code will looks like:

Effect: Display instruction "blabla"

=> And so on !

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
etc...

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 => $tech){
Trig("Spawn Player $p - Civ $civ",1,1);
Cond_Researched($p,$tech);
Cond_Timer(4);
Cond_NotOwnY($p,Y_MILITARY,40);
foreach($spawns as $spawn)Efft_Create($p,LIB::$CivEliteUnit[$civ],AreaPlayer($p,$spawn));}
Trig("Tasks",1,1);
foreach(range(1,8) as $p)foreach($spawns as $spawn)Efft_TaskO($p,AreaPlayer($p,$spawn),$meetPoint[$p]);

Example of maps made by programming:
=> Roll The Dice
=> Death Crossroads Blood
=> Dynamo Castle Blood Arena
=> Squad blood (old map coded in LuaTrig)

These four maps are almost impossible to make without a programming method and show you the power of scripting.

Requirements / Installation


Installation should be very easy, however if you have any troubles ask help in this thread.

1/ You need a PHP IDE, I advise you to use the same as me, it has nice features and nice code completion: PHP Designer 8. But it is not free.
You can also download PHP Designer 2007, the personal version is free: http://download.cnet.com/PHP-Designer-2007-Personal/3000-10248_4-10575026.html
A PHP IDE is an advanced text editor to write PHP a lot more easily with nice features, it would be possible to write PHP with notepad, but it's not worth it.

2/ You need a PHP compiler, take v5.6 Non Thread Safe x86 or x64 depending of your system (as zip): http://windows.php.net/download#php-5.6
A PHP compiler is a program that can interpret and execute what you wrote with your PHP IDE.

3/ Install your PHP IDE.

4/ Unzip PHP compiler files in a folder without space at the root of your hard drive. EG: "C:/PHP-5.6.9/". You also need to rename "php.ini-development" file to "php.ini".

5/ Configure your PHP IDE, for PHP Designer 8: Go to "Tools / Preferences / Run" and specify paths to your compiler php.exe and configuration file php.ini which are in the PHP compiler folder. Do the same in "Tools / Preferences / Debugger".

6/ Open php.ini with notepad and edit "max_execution_time" and "memory_limit" values (ctrl + F to find them):

max_execution_time = 300000
memory_limit = 4294967296

php.ini is a configuration file for the php compiler.

7/ All is ready. To use PHP SCX Editor open the 3 files in your PHP IDE: Compiler.php, Scenario.php and Library.php. You will use those 3 files to build a scenario.

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:
Compiler.php: It decompress the input scenario and compress it after you did your modifications. You have to run two times Compiler.php to generate the output scenario.
Scenario.php: This is here you write your scenario modifications. You always start from an input scenario and edit it. In fact PHP SCX Editor doesn't create scenarios, it edits existing ones.
Library.php: It is the standard PHP SCX Editor library to make scenarios. It contains the essential functions to read / write properties, and triggers. You should create your own library in addition depending of your needs, sharing it could be nice too.
data_aok.php: It's exactly like data_aok.xml, it contains all aoc constants. It's useful because you can specify units, techs, ressources, groups, types, terrains ID with names.

Steps to edit a scenario:
1/ Duplicate "New Project" folder where you want and rename it to your scenario name or whatever.
2/ Configure compiler constants in Compiler.php. (aok path and input/output scenario filename)
3/ As examples, write triggers, terrain modifications, etc... in Scenario.php ( inside Scenario() ).
4/ Run two times Compiler.php. (On PD8 click on "Run" button in toolbar)
5/ Done, you can test it.

There are some examples by default in Scenario.php which show you how to make triggers, place objects, modify terrain and other constants of your scenario.

Feel free to organize your code as you want, keep in mind that all you write is reusable code by you or other people. You can create your own framework specialized in RPGs, Bloods, SP maps, or whatever you want, just include files in Scenario.php.

You don't need to understand how works Compiler.php to use this script, you just need to understand Library.php which is quite intuitive. However it is good to know how works Compiler.php to do really all you want with scenario designing.

From this point (with examples), you have all tools to learn more by yourself and get used to scripting. It will need time but worth it, scripting is very powerful and funny to handle to design complex mechanics maps.

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 [Integer]
E = Target Player ID [Integer]
U = Object Constant ID [Integer]
G = Object Group ID [Integer]
Y = Object Type ID [Integer]
A = Area [Array(Array(X,Y),Array(X,Y))]
L = Location [Array(X,Y)]
Q = Quantity [Integer]
R = Resource [Integer]
H = Technology ID [Integer]
I = Trigger Name [String]
X = Text [String]
T = Time [Integer]
N = Panel [Integer 0 | 1 | 2]
S = Objects IDs [Array(ID_1,ID_2,ID_3,...,ID_n)]
F = Object Source ID [Integer]
O = Object Location ID [Integer]
D = Sound [String]
M = Diplomacy [Integer 0 | 1 | 2 | 3]
Z = AI Signal / AI Goal [Integer]
K = Inverted condition (Only for 1.4 RC) [Boolean]

Important:

- 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


Requirements: You need to enable GD library, to do that open php.ini and replace these lines:

; extension_dir = "ext"
;extension=php_gd2.dll

by these lines:

extension_dir = "./ext"
extension=php_gd2.dll

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:

SetTerrainFromImage('C:/MyImage.png', array(
0 => 4, # Bind color 0 to Shallows
1 => 0, # Bind color 1 to Grass 1
2 => 5 # Bind color 2 to Leaves
));


When you done that just run it and you have your awesome design.

Example:



Library Functions


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.

General:

out($data)
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)
Color($P)

Triggers:

Cond_AISignal($Z)
Cond_Accumulate($P, $Q, $R)
Cond_AccumulateExactly($P, $Q, $R)
Cond_Alive($P)
Cond_BringOToA($F, $A)
Cond_BringOToO($F, $O)
Cond_Capture($P, $F)
Cond_Destroy($F)
Cond_Died($P)
Cond_Difficulty($difficultyName)
Cond_False($P, $R)
Cond_Garrisoned($F)
Cond_HasTarget($F, $O)
Cond_InAreaG($P, $Q, $G, $A)
Cond_InAreaO($P, $Q, $A)
Cond_InAreaU($P, $Q, $U, $A)
Cond_InAreaY($P, $Q, $Y, $A)
Cond_NotAISignal($Z)
Cond_NotAccumulate($P, $Q, $R)
Cond_NotBringOToA($F, $A)
Cond_NotBringOToO($F, $O)
Cond_NotCapture($P, $F)
Cond_NotDestroy($F)
Cond_NotDifficulty($difficultyName)
Cond_NotGarrisoned($F)
Cond_NotHasTarget($F, $O)
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_NotOwnO($P, $Q)
Cond_NotOwnU($P, $Q, $U)
Cond_NotOwnY($P, $Q, $Y)
Cond_NotResearched($P, $H)
Cond_NotResearching($P, $H)
Cond_NotSelected($F)
Cond_NotTimer($T)
Cond_NotVisible($F)
Cond_OwnG($P, $Q, $G)
Cond_OwnO($P, $Q)
Cond_OwnU($P, $Q, $U)
Cond_OwnY($P, $Q, $Y)
Cond_Researched($P, $H)
Cond_Researching($P, $H)
Cond_Selected($F)
Cond_Timer($T)
Cond_True($P, $R)
Cond_Visible($F)
Efft_AIGoal($P, $Z)
Efft_APG($P, $Q, $G, $A = null)
Efft_APO($P, $Q, $A = null)
Efft_APS($Q, $S)
Efft_APU($P, $Q, $U, $A = null)
Efft_APY($P, $Q, $Y, $A = null)
Efft_Act($I)
Efft_ArmorG($P, $Q, $G, $A = null)
Efft_ArmorO($P, $Q, $A = null)
Efft_ArmorS($Q, $S)
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_ChangeView($P, $L)
Efft_Chat($P, $X)
Efft_Clear($N)
Efft_Create($P, $U, $L)
Efft_DamageG($P, $Q, $G, $A = null)
Efft_DamageO($P, $Q, $A = null)
Efft_DamageS($Q, $S)
Efft_DamageU($P, $Q, $U, $A = null)
Efft_DamageY($P, $Q, $Y, $A = null)
Efft_Deact($I)
Efft_DeclareVictory($P)
Efft_Display($T, $N, $X)
Efft_False($R, $R)
Efft_FreezeG($P, $G, $A = null)
Efft_FreezeO($P, $A = null)
Efft_FreezeS($S)
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_HPS($Q, $S)
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_KillS($S)
Efft_KillU($P, $U, $A = null)
Efft_KillY($P, $Y, $A = null)
Efft_LockGate($S)
Efft_MSG($P, $Q, $G, $A = null)
Efft_MSO($P, $Q, $A = null)
Efft_MSS($Q, $S)
Efft_MSU($P, $Q, $U, $A = null)
Efft_MSY($P, $Q, $Y, $A = null)
Efft_NameO($P, $X, $A = null)
Efft_NameS($S, $X)
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_PatrolS($S, $L)
Efft_PatrolU($P, $U, $A = null, $L)
Efft_PatrolY($P, $Y, $A = null, $L)
Efft_PlaceFoundation($P, $U, $L)
Efft_PlaySound($P, $D)
Efft_RangeG($P, $Q, $G, $A = null)
Efft_RangeO($P, $Q, $A = null)
Efft_RangeS($Q, $S)
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_RemoveS($S)
Efft_RemoveU($P, $U, $A = null)
Efft_RemoveY($P, $Y, $A = null)
Efft_Research($P, $H)
Efft_Reset($P, $R)
Efft_Set($P, $Q, $R)
Efft_StopG($P, $G, $A = null)
Efft_StopO($P, $A = null)
Efft_StopS($S)
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_TaskS($S, $LO)
Efft_TaskU($P, $U, $A = null, $LO)
Efft_TaskY($P, $Y, $A = null, $LO)
Efft_Tribute($P, $Q, $R, $E = 0)
Efft_True($P, $R)
Efft_UnloadG($P, $G, $A = null, $L)
Efft_UnloadO($P, $A = null, $L)
Efft_UnloadS($S, $L)
Efft_UnloadU($P, $U, $A = null, $L)
Efft_UnloadY($P, $Y, $A = null, $L)
Efft_UnlockGate($S)

Triggers - Advanced:

Efft_Boost($P, $Params)
Efft_DeactPlayerTriggers($P)
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)

Properties:

GetAllTech()
GetMapSize()
GetMessageFailure()
GetMessageHints()
GetMessageHistory()
GetMessageObjective()
GetMessageScouts()
GetMessageVictory()
GetPlayerCiv($player)
GetPlayerDiplomacy($player)
GetPlayerDisabilityBuildingList($player)
GetPlayerDisabilityTechList($player)
GetPlayerDisabilityUnitList($player)
GetPlayerMaxPop($player)
GetPlayerName($player)
GetPlayerObjects($player)
GetPlayerStartAge($player)
GetPlayerStartFood($player)
GetPlayerStartGold($player)
GetPlayerStartStone($player)
GetPlayerStartView($player)
GetPlayerStartWood($player)
GetPlayersCount()
GetTerrainCell($x,$y)
SetAllTech($boolean)
SetMapSize($size)
SetMessageFailure($text)
SetMessageHints($text)
SetMessageHistory($text)
SetMessageObjective($text)
SetMessageScouts($text)
SetMessageVictory($text)
SetPlayerCiv($player, $civName)
SetPlayerDiplomacy($player, $diplomacyStates)
SetPlayerDisabilityBuildingList($player, $idsArray)
SetPlayerDisabilityTechList($player, $idsArray)
SetPlayerDisabilityUnitList($player, $idsArray)
SetPlayerMaxPop($player, $maxPop)
SetPlayerName($player, $name)
SetPlayerObjects($player, $objects)
SetPlayerStartAge($player, $ageName)
SetPlayerStartFood($player, $quantity)
SetPlayerStartGold($player, $quantity)
SetPlayerStartStone($player, $quantity)
SetPlayerStartView($player, $location, $objectIdAvailable, $objectConstantId)
SetPlayerStartWood($player, $quantity)
SetPlayersCount($playersCount)
SetTerrainCell($x,$y,$cell)
SetTerrainFromImage($filename, $terrainIds)

Areas:

Area($X1, $Y1, $X2, $Y2)
AreaAdvanced($L, $Axe, $Width = 3, $Depth = 2)
AreaCut($A, $Cuts = 1)
AreaMerge($Areas)
AreaOffset($A, $OffsetX = 0, $OffsetY = 0)
AreaPlayer($P, $A)
AreaPlayers($Area, $StepX = 0, $StepY = 0, $Players = 0)
AreaPts($A)
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).]

AuthorReplies:
AzZzRu
Squire
posted 02-10-16 05:20 AM CT (US)     51 / 71       
Wimski I noticed in aokts that there are hundreds of trees with same ID: 0. I think it's because of that.

Movinup, what version of aoc are you using ? Those functions works only with voobly 1.4 RC patch or HD. It's like all functions:

Efft_RangeU(1,1,U_MILITIA); +1 Range to all militia of player 1
Efft_ArmorU(1,array(1,1),U_MILITIA); +1/+1 Armor to all militia of player 1
Efft_ArmorU(1,array(1,2),U_MILITIA); +1/+2 Armor to all militia of player 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 AzZzRu (edited 02-12-2016 @ 02:00 PM).]

Movinup
Squire
posted 02-10-16 11:11 AM CT (US)     52 / 71       
OHHHH..... Yeah, that's the problem... wrong version. lol.


However, I have played a scenario in either 1.0 or 1.0c that had a unit with +1000/+1000 armor. Do you know what they used to do this?

Also, in the custom map "Wonder Defense" they have a thing that makes villagers mine gold first 25% faster, and then 50% faster. besides the two researches that you do at the mining camp. It's really cool to watch the vills go.
Then they make relic gold 50% faster too.
They also mess with the build speed of towers. upgrading it to somewhere around 100% faster.
Do you know how they managed this is 1.0 and 1.0c?

Thanks for getting back to me.
AzZzRu
Squire
posted 02-10-16 12:50 PM CT (US)     53 / 71       
Most of the bonus in wonder defense are made with negative tribute to gaia, there is ressource called "Relic gold rate" for example, if you tribute -10 then it's 10 time faster or something like this... Look ressources constants in data_aok.php or .xml from aokts.

In 1.0c you can't boost armor, what you saw is an hidden unit that have +1000 / +1000 armor by default, I don't remenber which one.

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
Wimski
Squire
posted 02-12-16 11:51 AM CT (US)     54 / 71       
I noticed in aokts that there are hundreds of trees with same ID: 0. I think it's because of that.
I did have 0 for the ID parameter when calling the NewObject function, because I didn't know what to put there.

I have added the following to get the trees on the map:

Tree mapping
I added an array in the Lib class to map the tree objects to the corresponding terrain types. For every terrain type (which should have trees), I mapped the corresponding tree object plus the number of frames in that object so I can randomize the graphics.


static $TerrainTrees = array(
TERRAIN_BAMBOO => array(U_FOREST_BAMBOO, 3),
TERRAIN_FOREST => array(U_FOREST_TREE, 13),
TERRAIN_FOREST_OAK => array(U_FOREST_OAK, 13),
TERRAIN_JUNGLE => array(U_JUNGLE_TREE, 13),
TERRAIN_PALM_DESERT => array(U_FOREST_PALM, 12),
TERRAIN_PINE_FOREST => array(U_FOREST_PINE, 8),
TERRAIN_SNOW_PINE_FOREST => array(U_SNOW_PINE_TREE, 8)
);


SetTerrainFromImage function
I added the following code to set the trees when encountering a terrain type that should have trees on them.


$objID = 1;
...
if ( array_key_exists($terrain_type, LIB::$TerrainTrees) ) {
$tree = LIB::$TerrainTrees[$terrain][0];
$max = LIB::$TerrainTrees[$terrain][1];
NewObject($objID, 0, $tree, array($col, $row), 0, -1, rand(0, $max));
++$objID;
}


So now I start the tree ID at 1 and then increment the ID. For the player parameter I used 0, because anything else (1 for example) didn't produce any trees.
But even now when supplying unique ID's that are not 0, the map still crashes when starting a standard game. The ingame map editor still works fine. Any further tips?
AzZzRu
Squire
posted 02-12-16 12:11 PM CT (US)     55 / 71       
Your code seems good, I have no idea. At least, does it work if you don't generate trees ?

If you want you can send me your whole project + image + input scenario and I will see what is wrong.

Edit1: Wait I found ! Your map is 256*256, the maximum is 255*255 for aoc.

Edit2: Updated to v2.4.3:
- SCX::editor_version added to compiler parameters to easily swap between 1.4 RC / HD triggers compatibility.
- SetTerrainFromImage works also with forest terrains, $forestDensity parameter added.
- NewObject uses next available object id by default for $ID parameter.

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 AzZzRu (edited 02-12-2016 @ 01:57 PM).]

Wimski
Squire
posted 02-12-16 07:10 PM CT (US)     56 / 71       
Edit1: Wait I found ! Your map is 256*256, the maximum is 255*255 for aoc.
That seems to be it, 255x255 does work! I always thought the count was 0-255, which is 256 in total, but I was wrong. Thanks for all your help. I'll be generating lovely tree-filled maps now!
PeljattyMiksu
Squire
posted 11-14-16 02:15 PM CT (US)     57 / 71       
Hello!

When I try to run Compile.php, I get this message

Warning: unpack(): Type c: not enough input, need 1, have 0 in C:\***\Compiler.php on line 575
PHP Warning: unpack(): Type c: not enough input, need 1, have 0 in C:\***\Compiler.php on line 575

uncountable times and nothing else happens. I have installed all just like AzZzur said, except I use Notepad++ and run with cmd. I haven't edited Scenario.php, there is original example project. Any help?
AzZzRu
Squire
posted 11-19-16 05:18 AM CT (US)     58 / 71       
Hey!

This error means the script try to read input file but it doesn't find expected datas.

I think there is an issue with input scenario, is it 1.0c map ? Or there is something wrong with your PHP installation.

You can send me the whole project, with input file, and your PHP installation. I'll see what's wrong.

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 AzZzRu (edited 11-19-2016 @ 12:31 PM).]

PeljattyMiksu
Squire
posted 11-19-16 01:51 PM CT (US)     59 / 71       
Yes, scenario version was wrong but it still doesn't work. I tried to save empty scenario with trigger studio (I have only HD) in 1.0c and 1.4RC file format, but I get the same error. Can I load working input scenario somewhere?

E: Sorry, little fail, all works now fine. Thank you!

E2: When I try to play the test scenario with AI, I get this error:

An error occurred while trying to start the game. AI file Error: 'Promisory' Line 3467 water-islands No file line information

In multiplayer all works fine.

[This message has been edited by PeljattyMiksu (edited 11-19-2016 @ 02:24 PM).]

AzZzRu
Squire
posted 11-21-16 12:56 PM CT (US)     60 / 71       
I don't know much about AI.

But is it PSE which add the error on the output map ? AI should passthrough compilation without being modified.

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
PeljattyMiksu
Squire
posted 11-23-16 00:57 AM CT (US)     61 / 71       
You are right, PSE isn't causing the problem but TS and input scenario. Thank you again.
Shuvro
Squire
posted 11-30-16 01:00 PM CT (US)     62 / 71       
Can someone expert in using PHP SCX editor convert this image into a scx file. The green will be replaced by grass 1 and the blue will be replaced by deep water.

Many many thanks in advance for the task.

Battle_of_Chelsea_Creek.png

[This message has been edited by Shuvro (edited 12-01-2016 @ 09:28 AM).]

AzZzRu
Squire
posted 11-30-16 04:18 PM CT (US)     63 / 71       
Hey, there you go: https://www.dropbox.com/s/0nigi1v51a5hcmq/Battle_of_Chelsea_Creek_NO_BEACH.zip?dl=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 AzZzRu (edited 11-30-2016 @ 04:20 PM).]

Shuvro
Squire
posted 12-01-16 09:20 AM CT (US)     64 / 71       
Great Job! Can you please share the PHP SCX editor files you have written for generating the map? This will help me do such kind of cool conversions myself.

Please send the files for both with and without beach terrain.
AzZzRu
Squire
posted 12-02-16 12:41 PM CT (US)     65 / 71       
Just put this code in Scenario.php, if you don't want beach just remove code under # Add beach:

# Examples:

# Set terrain from image
SetMapSize(139);
SetTerrainFromImage('D:\Desktop\Battle_of_Chelsea_Creek2.gif', array(
1 => TERRAIN_GRASS_1,
0 => TERRAIN_WATER_DEEP
));

# Add beach
$mapSize = GetMapSize();
for($y = 0; $y < $mapSize; $y++){
for($x = 0; $x < $mapSize; $x++){
if(SCX::$data_serial['terrain']['data'][$x.','.$y][1] !== TERRAIN_WATER_DEEP){
$neighbors = array(
($x - 1).','.($y - 1),
($x - 1).','.($y),
($x - 1).','.($y + 1),
($x).','.($y - 1),
($x).','.($y),
($x).','.($y + 1),
($x + 1).','.($y - 1),
($x + 1).','.($y),
($x + 1).','.($y + 1),
);
foreach($neighbors as $n){
if(isset(SCX::$data_serial['terrain']['data'][$n]) && SCX::$data_serial['terrain']['data'][$n][1] === TERRAIN_WATER_DEEP){
SCX::$data_serial['terrain']['data'][$x.','.$y][1] = TERRAIN_BEACH;
break;
}
}
}
}
}

But I did some treatments to your image with gimp, I switched to two indexed colors and rotated it by 45 to have a square. See the tutorial I explained how to do this.

Here the final image I used: http://img11.hostingpics.net/pics/254033BattleofChelseaCreek2.gif

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 AzZzRu (edited 12-02-2016 @ 12:46 PM).]

devagrawal09
Squire
posted 03-27-17 08:04 AM CT (US)     66 / 71       
Excellent work! I am totally going to start using this!

By the way, can this framework be created for any other language, say Javascript? Js is getting great developments now and is one of the most popular languages. Is there any way the framework code can be transpiled?

|E)\/
AzZzRu
Squire
posted 04-01-17 03:37 PM CT (US)     67 / 71       
PHP is very good language for triggers purposes, error handling / debugging is easy.

But yea you could transcode this to other coding language easily, just find equivalent read / write scx format functions (pack, unpack, etc...).

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 AzZzRu (edited 04-16-2017 @ 02:21 AM).]

RikyRich
Squire
posted 04-20-17 12:47 PM CT (US)     68 / 71       
Hey,

I have been trying to wrap my head around using an image to create a scenario. I was wondering if it is possible to create a ludakris map and also if I upload the image would someone be willing to create the map for me?

I just have no idea what I am doing

Kindest Regards
AzZzRu
Squire
posted 04-23-17 03:54 AM CT (US)     69 / 71       
Hey,

Yea send me the image i'll make it !

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
Shuvro
Squire
posted 01-19-18 07:20 PM CT (US)     70 / 71       
@AzZzRu, bro can you tell me how to use this awesome tool for HD DLCs? If it currently supports only AOC and AOE II HD Edition, how can I incorporate the data and constants for HD to this editor? Like, I saw a file data_aok.php, which basically holds the constants for AOC. How did you make this file? If you could please share the process, then I can try the same for unpacking the HD DLC data. That way, this can be a great tool for HD also. At least I will be using this programming tool for all my scenarios now on.

I used this tool for converting an image to AOC terrain before. And now I am planning to use this for trigger work. The "Siege of Lahore" took a hell lot of time to design just for the 180+ triggers, though I designed it using Trigger Studio, another awesome tool, it was still very repetitive. As a programmer myself, I would really love to open the opportunities of PHP SCX editor to HD scenarios also.
Jineapple
Squire
posted 04-05-18 01:58 PM CT (US)     71 / 71       
Hi, I've been considering using this for a tool to convert HD scenarios to WololoKingdoms ones. However, as I understand it, currently the triggers of a loaded map are deleted? Is that avoidable?
« Previous Page  1 2  Next Page »
You must be logged in to post messages.
Please login or register

Hop to:    

Age of Kings Heaven | HeavenGames