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:
Taichi San
Squire
posted 11-11-14 11:44 AM CT (US)     1 / 71       
Can you also make elevations imported from height bitmaps?
Then you could import real world terrains!
AzZzRu
Squire
posted 11-11-14 12:01 PM CT (US)     2 / 71       
Yes you can if php have functions to read height bmp images, php have much functions and libraries, you can search for it on google or php manual.

All the terrain is stored in $serial['terrain']['data'][$x.','.$y], each point of the map contains an array that contains two data. The key 1 is for terrain id, elevation is stored in key 2.

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-11-2014 @ 12:04 PM).]

DJeronimo
Banned
posted 11-11-14 12:50 PM CT (US)     3 / 71       
i do not have the time to learn this awsome tool! what should i do - i hate programmaking!
rewaider
Squire
posted 11-11-14 02:15 PM CT (US)     4 / 71       
So with that I could like... Use variables on effects/conditions textfields?

Example:
Display instructions
"There are "timeremaing "seconds remaing"


?

The Fall of Hummaria -- Teaser [4.2] -- Project's Thread
Cavern Pirates -- The Treasure Hunt [4.6] -- Captain's Revenge
My Blacksmith
AzZzRu
Squire
posted 11-11-14 02:42 PM CT (US)     5 / 71       
If you mean the value of the field change during the map is playing, no you absolutely can't do that. You can't make something that is impossible to make in the classic editor like putting variables into fields instead constants ! This could be possible with hard modding i guess, but this script have nothing to deal with modding.

You can use variables to create and modify elements of your scenario, but you can't do that during the game of course !

Using variables you can do for example, this:

$Time = 100;
Trig("Display Time",1,0);
Cond_Timer($Time);
Efft_Display(10,0,"The game started $Time secondes ago.");

Compile this and go look at the triggers generated in aokts, there aren't variables in fields ! You will see the number 100.

Edit:
There is a wrong comment in Triggers.php:
// By default only creating triggers function is activated ( SCX_Triggers() ).

This is false, by default SCX_Attributes and SCX_Instructions are called line 1286, put them in comment if you still want set properties and instructions in the input scenario with aokts or aoc.

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-11-2014 @ 05:37 PM).]

Mr Wednesday
Cavalier
(id: matty12345)
posted 11-11-14 05:49 PM CT (US)     6 / 71       
This is counter intuitive and mostly pointless for SP scenarios. For the MP design community I can see it being really useful though.

"And Matt is a prolific lurker, watching over the forum from afar in silence, like Batman. He's the president TC needs, and possibly also the one it deserves." - trebuchet king
AzZzRu
Squire
posted 11-11-14 06:37 PM CT (US)     7 / 71       
Why do you think it isn't intuitive for SP ? I did the example for a blood map but you can code your scenario in completely different ways, and optimize all functions for SP scenarios. Actually avialable functions are optimized for MP.

Programmation is much more flexible than any GUI programs (Aoc editor, Aokts), but harder to handle as well.

I didn't made SP scenarios since a long time but i think it's also useful for making them.

It is a lot easier to describe any sequences of triggers. One of the cool thing is that you see the whole code together, so you have an overview much wider. You don't have to click and click to check effects, conditions fields, etc...

And you can duplicate blocks of triggers or some effects, and put them in another project.

A thing that you couldn't like is that you have to specify any coordinates or objects id with numbers, but really it is not a problem. When i have to specify an area i use a function which calculate it for me or in the worst case, i set the area in aoc editor with a condition object in area, then i go in aokts and i copy the coordinates.

With scripting you could also create some cool triggers into your scenario, like giving ability to the player to launch a spell which kills units around him wherever he is on the map, with four or five lines. It would take a year to do it in aokts !

Like this:

For each points of the map
Make a looped trigger
Condition player trigger his spell
Condition player is in the point
Effect kill enemy units in an area of size = 3 around the point

On a tiny map it will generate 14400 triggers, AOHH made maps with more 100k triggers and it work so it's not a problem ^^.

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-11-2014 @ 07:03 PM).]

Basse
Squire
posted 11-12-14 09:55 AM CT (US)     8 / 71       
like giving ability to the player to launch a spell which kills units around him wherever he is on the map
Haha, instantly what I thought of when I thought of how this could be used for SP scenarios!

This is an AWESOME tool, and I hope to use it sometime. I'm very occupied with university right now, but man, this makes me want to create some awesome scenarios! It's such a powerful tool, using simple programming!
Mr Wednesday
Cavalier
(id: matty12345)
posted 11-12-14 04:55 PM CT (US)     9 / 71       
See, unless you are part of the 1% of the populace who adores code, it's just not worth it. This is something I've always noticed about coders. They would write a program to paint Picasso's in Photoshop if they could. Scenario design is like 99% artistic. You can't make a scenario looking at a wall of text. Well clearly now you can, but not the kind I would play. To me it's only useful for large trigger systems or stuff like that, which in my opinion is one of the worst things AoKH has invented and it's ruined a ton of scenarios and designers. But that's just my opinion. If your scenario has over a thousand triggers you are doing it wrong. So this is just a tool to do more of what I already think is counter intuitive and pointless.

I have better memories of the ES scenarios than 95% of the custom campaigns I played from here. And they are all super simple. The problem is the target audience on this forum is other designers. As such, 'good' actually came to mean 'technically proficient', instead of fun. I'm guilty too. I won the cutscene competition with a technical dazzler. Show all the cutscenes to someone who doesn't know the limits of the editor and it's probably not the most entertaining.

I digress from the TP. But that's why I say what I said.

"And Matt is a prolific lurker, watching over the forum from afar in silence, like Batman. He's the president TC needs, and possibly also the one it deserves." - trebuchet king
Mr Wednesday
Cavalier
(id: matty12345)
posted 11-12-14 04:57 PM CT (US)     10 / 71       
With scripting you could also create some cool triggers into your scenario, like giving ability to the player to launch a spell which kills units around him wherever he is on the map, with four or five lines. It would take a year to do it in aokts !

Like this:

For each points of the map
Make a looped trigger
Condition player trigger his spell
Condition player is in the point
Effect kill enemy units in an area of size = 3 around the point

On a tiny map it will generate 14400 triggers, AOHH made maps with more 100k triggers and it work so it's not a problem ^^.
Kill me now.

"And Matt is a prolific lurker, watching over the forum from afar in silence, like Batman. He's the president TC needs, and possibly also the one it deserves." - trebuchet king

[This message has been edited by Mr Wednesday (edited 11-12-2014 @ 04:58 PM).]

DJeronimo
Banned
posted 11-12-14 05:12 PM CT (US)     11 / 71       
so many triggers, one could mimic a cataclism or a very complex situation!!! wow!
AzZzRu
Squire
posted 11-12-14 05:42 PM CT (US)     12 / 71       
I don't care so much about coding a program which paint a picasso ^^. But i think it is possible to make something artistic looking at a wall of text.

It is your idea which is artistic, and you have much ways to show it

But i understand what you mean, if you focus mainly on history and map design / landscape of your scenario you don't need this script.

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-12-2014 @ 07:40 PM).]

HockeySam18
Dúnadan
posted 11-12-14 09:33 PM CT (US)     13 / 71       
I have better memories of the ES scenarios than 95% of the custom campaigns I played from here. And they are all super simple. The problem is the target audience on this forum is other designers. As such, 'good' actually came to mean 'technically proficient', instead of fun. I'm guilty too. I won the cutscene competition with a technical dazzler. Show all the cutscenes to someone who doesn't know the limits of the editor and it's probably not the most entertaining.
I can also identify with this. I think that over the years this community has refined scenario design to such a point that it has raised the bar too high, and designers feel pressured to find something new and exemplary that blows everyone's mind when simpler is usually better, as Julius has probably most aptly shown. Huge trigger systems and technical tricks usually end up killing motivation and producing a less fun result anyway. Naturally, as AzZzRu has shown, MP scenarios with large trigger systems can be awesome. But SP is a different animal entirely, which is probably what Matt is trying to say anyway

It's also funny because you look at the different tastes of the overall AoE2 community and it varies A LOT. People who aren't designers might not necessarily appreciate the finer points that the more experienced folks here do, like Matt said. Some folks might prefer generated random maps packaged as campaigns

Storm on the Steppe | Galderton Hill RP | Proud member of Stormwind Studios

"Cattle die, kindred die, every man is mortal:
But the good name never dies of one who has done well." - Hávamál

"Hockey is the only sport left for true men." - ax_man1
nhoobish_est
Squire
posted 11-13-14 07:31 AM CT (US)     14 / 71       
Would just like to point out that most people aren't motivated enough to learn programming. What you created here opens up new paths and possibly for the next generation of AoK scenario designers, who would be brought up by programming lessons starting from elementary school (this is just an example from Estonia, where children start to learn programming at the age of 7). But for us, most are too old to learn something entirely new and get used to it.
Jatayu
Squire
(id: Sword_of_STORM)
posted 11-13-14 08:54 PM CT (US)     15 / 71       
I have better memories of the ES scenarios than 95% of the custom campaigns I played from here. And they are all super simple. The problem is the target audience on this forum is other designers. As such, 'good' actually came to mean 'technically proficient', instead of fun. I'm guilty too. I won the cutscene competition with a technical dazzler. Show all the cutscenes to someone who doesn't know the limits of the editor and it's probably not the most entertaining.
Haha yes agreed.
What AzZzRu said about the effect that hurts units around you? In warcraft 3, that's called immolation aura and any unit can have it. It is a trivial thing to do in WC3. And apparently you need 14000 triggers to do that in AOK. Script or no script, I don't think this is worth it.

About programming, I was a professional programmer for three years. One of the reasons (there were many ) I quit was that I felt it was really stifling my creativity and I couldn't think straight.

,
Jatayu O===|¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯/
`
Battle of Saraighat, 1671|Atlantis, the Lost Realm|AOE Roman Modpack|My profile
ि
StormWind Studios
AOHH
Squire
posted 11-13-14 10:07 PM CT (US)     16 / 71       
I want to point out a few things about dynamic scenario designing...

Most designers in this community focus on SP maps, whereas Voobly designers focus on MP maps, therefore criticism is expected on this topic. I definitely agree that scripted triggers are not suitable for SP maps in most cases, but as for MP maps they are essential. MP map designers thirst for scripted triggers and scripted objects, especially for a repetitive criteria that would otherwise require weeks and months of manual work (such as; kill counters, spawns, player iterations, ect).

Scripted triggers does not destroy artistic values (in my opinion), because scripting itself is another level of art. And besides the artistic values, scripting is necessary for short-cuts (as I mentioned above). SP designers have recently acknowledged the terrain image conversion, and MP designers love scripted triggers. In general, most map designers love pushing the boundaries in whatever way. Dynamic scenario designing has revolutionized the methods and limitations of designers.

As for PHP, any language would have been used for casting triggers. Yet PHP is actually one of the most simple languages to use; its syntax is great. It would not take much time to learn at least the basics, especially when many examples are provided. LUA is another simple language, and PHP offers an extension that provides a sandbox for LUA scripting. If PHP alone becomes a problem for amateur programmers; then embedding a LUA sandbox is not a problem either. This will present the opportunity for many designers to share their ideas; by exchanging each other's scripts and improve their functions.

Love it or hate it... either way, we have completely killed scenario designing to its deepest boundaries! MMMOOOOOOHAHAHAHA !!!! Everything evolves and everything should evolve for the better. The Genie-Engine has existed for well over 15 years, and it's about time we evolve and revolutionize it.

GENIE-STUDIO (manipulate Genie-Engine files with JSON)

[This message has been edited by AOHH (edited 11-13-2014 @ 10:16 PM).]

Jan dc
Squire
(id: Den cekke)
posted 11-14-14 03:52 AM CT (US)     17 / 71       
I'm with the SP designers on this. I program myself but designing a scenario is something artistic and not technical in my opinion. When I design something I like to see what I'm doing and not just look at a wall of text. The image to scenario converter however is something every designer can use and I don't see why there shouldn't be a user interface for that.
Basse
Squire
posted 11-14-14 09:19 AM CT (US)     18 / 71       
I program myself but designing a scenario is something artistic and not technical in my opinion. When I design something I like to see what I'm doing and not just look at a wall of text
The thing is, writing trigger after trigger is, in my opinion, basically the same thing. Most people even use Trigger Studio nowadays (even people who create Single-player scenarios), which is ANOTHER tool to make trigger creation easier. If I was fluent with script-triggering, I'd much much rather do that than spending hour after hours, manually creating new triggers to achieve what I want in my scenario. The most fun part of creating a scenario, I think, is the scenario design, not the trigger creating. Designing a scenario is where you visualize your ideas. You add areas to the map where you picture events to happen. Then to actually make those events happen can take several hours to trigger, and if it's a complex event involving plenty of triggers, you can now make it even more complex and fun (to play), with the same effort through scripting.

I think the "artistic" part of scenario design, is actually designing the scenario, not spending what feels like an eternity in the very very limited trigger editor and doing every single trigger by hand. After a while you just go in to auto-pilot, not thinking about what you are doing, but you're just sitting there clicking hour after hour. I'd much rather spend that time scripting, since if you're fluent with it, it could save you a lot of time, and enable a lot of new stuff to be added to a scenario.

I also like to learn new stuff, and I do some programming myself, which probably is why I really love this!
Mr Wednesday
Cavalier
(id: matty12345)
posted 11-14-14 04:09 PM CT (US)     19 / 71       
I think the "artistic" part of scenario design, is actually designing the scenario, not spending what feels like an eternity in the very very limited trigger editor and doing every single trigger by hand. After a while you just go in to auto-pilot, not thinking about what you are doing, but you're just sitting there clicking hour after hour. I'd much rather spend that time scripting, since if you're fluent with it, it could save you a lot of time, and enable a lot of new stuff to be added to a scenario.
See, you should never need more than a few hundred triggers. I have more than once done 100+ triggers in an evening. So trigger work shouldn't be so exhausting. Endless triggers come from trying to force gameplay that isn't natural to AoK. A lot of 'cool' gameplay can be achieved with 15 minutes in AGE. But in my opinion, anything that takes more than a couple sittings to implement is a bad idea.

"And Matt is a prolific lurker, watching over the forum from afar in silence, like Batman. He's the president TC needs, and possibly also the one it deserves." - trebuchet king
Basse
Squire
posted 11-14-14 04:25 PM CT (US)     20 / 71       
See, you should never need more than a few hundred triggers. I have more than once done 100+ triggers in an evening. So trigger work shouldn't be so exhausting. Endless triggers come from trying to force gameplay that isn't natural to AoK. A lot of 'cool' gameplay can be achieved with 15 minutes in AGE. But in my opinion, anything that takes more than a couple sittings to implement is a bad idea.
Working with natural AoK when such powerful tools exist? Sure, be my guest. But to be able to expand on the possibilities in scenarios, I think these kinds of tools are necessary. Forcing different types of gameplay using AGE is the same thing as you described it, not the natural AoK. A lot of "cool" gameplay as you put it, can be achieved with 15 minutes of scripting as well. Which also removes the requirement of data mods. I don't see the different from using this to using AGE or TS. Different ways to achieve "unnatural" gameplay for the AoK engine.

AoK is a very powerful engine with lots of possibilities (at least for its age!). I think it's cool that we have all these programs so that we are NOT limited to the "natural" aok gameplay. We can have a much wider range of different kinds of scenarios. If you don't like scenarios with too advanced trigger-tricks or data mods, fine, don't play them. I, however, am a huge fan of them and their creativity.
Mr Wednesday
Cavalier
(id: matty12345)
posted 11-14-14 08:52 PM CT (US)     21 / 71       
Forcing different types of gameplay using AGE is the same thing as you described it, not the natural AoK. A lot of "cool" gameplay as you put it, can be achieved with 15 minutes of scripting as well. Which also removes the requirement of data mods. I don't see the different from using this to using AGE or TS. Different ways to achieve "unnatural" gameplay for the AoK engine.
Okay first, this has nothing to do now with the quite solid tool discussed in the TP,and is in no way an attack on it, so excuse the off topic monologue:

You didn't understand me. I'm not a purist for the sake of purity. If anything I've always been for modding and aokts and anything else. But the example given, 14000+ triggers (on a tiny map, increase that exponentially as you increase size), that huge massive system adds zero fun to a scenario. So you've created a new effect that will wow other designers who know how hard it is to create. But it doesn't make the scenario any more fun to play. You could just do something else with like 5 triggers or a bit of data editing, and if you balanced it right and made the gameplay fun with it, it would be every bit as good.

See, this took me forever to realize. What are the things you remember about Ulio? Probably the twist ending. Maybe those eerie beginning and ending cutscenes. Some really cool but simple innovations maybe. In my opinion the pressure to be unique and to dazzle got too great afterwards, and you can see it in scenarios like WTWB. The duel with the spear guy is gimmicky and unwieldy. It probably took forever to do and a simpler battle with more solid mechanics would have been better. So you have a 14000 trigger system that provides a new effect. So what? It gets you no where. Trust me I know what I'm talking about. People like me and Luke and newIdea and oliver and zayank and several others I can't be bothered to mention were all in a crazy arms race trying to outdo each other. And most of our inventions, discoveries, and ideas died out with us because we were so focused on pushing the engine that not one decent scenario was produced by one of the more talented groups of designers AoKH had. One ridiculous example was chat boxes. Both Luke and I separately invented the idea of having an individual graphic for every line said in the scenario. That graphic would be chatbox that would pop up on the map when triggered at a location. I had the good sense at least to drop the idea, but Luke was actually going to implement it. In a scenario with seven different paths to play, no less. We are talking thousands of added chat box graphics, and countless hours of work. He just forgot one tiny thing. Display instructions is better than a stupid chatbox.

I sort of came to get all this by the end when I made The Quiet Dawn, which despite having less than 300 triggers and being on one small (medium?) map was very well liked. I'm trying to design a scenario again finally, and I'm still finding the urge to go big is strong. Why mod in a dozen extra bushes and plants when you can mod in 100 variations of each one, so that you never have to place the same plant twice on the entire map? But again, that adds nothing. The scenario won't be worse if the same bush gets used 10 times or once.

I guess the point is that if you need over 100 triggers to implement something, there's probably a 5 trigger solution out there which works just as well once you get over having to be teh coolest inventer evah.

"And Matt is a prolific lurker, watching over the forum from afar in silence, like Batman. He's the president TC needs, and possibly also the one it deserves." - trebuchet king

[This message has been edited by Mr Wednesday (edited 11-14-2014 @ 09:03 PM).]

John the Late
Knight
posted 11-14-14 09:56 PM CT (US)     22 / 71       
Not talking about whether SP scenarios need many triggers or not, I really like to see advances like this being made. They will help many people, and I fully agree to Basse that there are better ways to waste your time than do it with monotoneous repetetive trigger work in an sometimes instable and inconvenient editor.

That MP map making can greatly benefit from this is yet another (probably undisputed) thing.


Keep it up guys!
PhatFish
Mr. Beta
posted 11-15-14 02:57 PM CT (US)     23 / 71       
This is absolutely amazing. I have a burning question though: Is an online version being developed which can be accessed through a browser? And does it come complete with a nice frontend interface? Especially for newbies/beginners PHP can be very confusing, so that would be ideal and very convenient, if it's possible that is.
destroyo64
Squire
posted 11-16-14 01:14 AM CT (US)     24 / 71       
Thank you so much AzzzRu and AoHH! Ignore the naysayers, this is an amazing tool!

My question is how can I use this for Ludakris maps in AoF (Steam)? Every time I load a 480x480 gif to generate terrains and run the created file in AoF, the game crashes. Works great with 255x255 though

Also- is it possible to paint trees onto the map through a gif? Whenever I select the forest terrain ID, it simply creates the ground terrain, not the actual trees themselves.

Memories are like footprints. If you don't revisit them, they are soon enveloped by new snow...

[This message has been edited by destroyo64 (edited 11-16-2014 @ 01:19 AM).]

AOHH
Squire
posted 11-16-14 03:20 AM CT (US)     25 / 71       
Is an online version being developed which can be accessed through a browser?
I did intend to make an online accessibility for a big community of designers, but that will have to wait at least until next year when I have more (this year and last year has been busy as hell for me).
And does it come complete with a nice frontend interface?
As for this version, it only is scripting, but Genie-Studio will have a powerful interface! Azzzru and I intend to work together on GS to hasten the building process.
My question is how can I use this for Ludakris maps
HD Edition allows maximum size 480x480 maps. I don't see why it would crash.
Also- is it possible to paint trees onto the map through a gif?
Yes, you use the function that creates an object; you select the location X/Y and unitID, ect, and set the rotation to random. You can even add a random range of 0.1 to 0.9 to location X/Y to make each tree offset so it looks realistic. And if you want the forests to look more concentrated, you simply place 2 trees per tile. Either that or you could use randomization of Oak and Oak-Snow trees.

GENIE-STUDIO (manipulate Genie-Engine files with JSON)
AzZzRu
Squire
posted 11-16-14 07:48 AM CT (US)     26 / 71       
Also- is it possible to paint trees onto the map through a gif?
As AOHH said yes you can by creating trees with the function NewObject().

But you will have troubles if you call NewObject() inside format(). You can see NewObject() write on $data_serial, which is copied in $serial at begin of format(), so it will be ignored because the new data won't be copied in $serial.

So to fix it, modify NewObject() to write directly in $serial. You will have to set a new parametter to specify its adress, it's the only way to access it i guess.

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-16-2014 @ 08:00 AM).]

Al_Kharn the Great
Squire
posted 11-16-14 09:24 AM CT (US)     27 / 71       
Easier? I have no idea what any of that means!
Jan dc
Squire
(id: Den cekke)
posted 11-16-14 01:19 PM CT (US)     28 / 71       
As AOHH said yes you can by creating trees with the function NewObject().

But you will have troubles if you call NewObject() inside format(). You can see NewObject() write on $data_serial, which is copied in $serial at begin of format(), so it will be ignored because the new data won't be copied in $serial.

So to fix it, modify NewObject() to write directly in $serial. You will have to set a new parametter to specify its adress, it's the only way to access it i guess.
Someone with no or little programming knowledge will have no idea what any of this means. I think you should use more clear variable names and provide documentation.
AzZzRu
Squire
posted 11-16-14 06:31 PM CT (US)     29 / 71       
Sure, a complete documentation would be nice.

Actually there is this thread and comments in the script which explain almost all.

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
destroyo64
Squire
posted 11-28-14 09:30 PM CT (US)     30 / 71       
HD Edition allows maximum size 480x480 maps. I don't see why it would crash.
Also- is it possible to paint trees onto the map through a gif?
Yes, you use the function that creates an object; you select the location X/Y and unitID, ect, and set the rotation to random. You can even add a random range of 0.1 to 0.9 to location X/Y to make each tree offset so it looks realistic. And if you want the forests to look more concentrated, you simply place 2 trees per tile. Either that or you could use randomization of Oak and Oak-Snow trees.
Perhaps I am not following the procedure correctly for AoF maps? I simply generate a 480x480 blank Ludakris map, and select it as the .scx2 file as the file to load in Script.php. Then I select an 8 color 480x480 .gif file in imagecreatefromgif. I run, get the output map, and open up AoF. When I try to edit the scenario, the game crashes to desktop.

The same steps above work fine for 255x255 blank maps with a 255x255 gif.

As to the object generation- can I map these created objects to their respective terrains as opposed to location?

For random- can we have random objects that vary each time the scenario is played?

Thanks!
Also- is it possible to paint trees onto the map through a gif?
As AOHH said yes you can by creating trees with the function NewObject().

But you will have troubles if you call NewObject() inside format(). You can see NewObject() write on $data_serial, which is copied in $serial at begin of format(), so it will be ignored because the new data won't be copied in $serial.

So to fix it, modify NewObject() to write directly in $serial. You will have to set a new parametter to specify its adress, it's the only way to access it i guess.
On this line:
$packed .= pack ( 'c3' , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 1 ] , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 2 ] , 0 ) ;

Is it possible to specify an object to $serial (just like the terrain) to place it at the x and y coordinates?

Memories are like footprints. If you don't revisit them, they are soon enveloped by new snow...

[This message has been edited by destroyo64 (edited 11-28-2014 @ 09:44 PM).]

AzZzRu
Squire
posted 11-29-14 05:26 PM CT (US)     31 / 71       
$packed .= pack ( 'c3' , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 1 ] , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 2 ] , 0 ) ;

Is it possible to specify an object to $serial (just like the terrain) to place it at the x and y coordinates?
No, when we do this we modify properties of terrain data. To add an object you have to create it following the object format, that you can see at # objects / player / object. Then when you done that you add it in serial [ 'object' ] [ $player ].

But this is manual method which is crap to handle !

As i told you just use NewObject function, following the specified parameters.

I never did forest generation so i tried for the fun, you can see this example which is simple: Cannabis Forest

I generate my forest and terrain in Function.php.

In Triggers.php at # terrain / data, I added some lines to put beach everywhere there is water next to desert.

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-29-2014 @ 05:40 PM).]

destroyo64
Squire
posted 11-29-14 06:06 PM CT (US)     32 / 71       
$packed .= pack ( 'c3' , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 1 ] , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 2 ] , 0 ) ;

Is it possible to specify an object to $serial (just like the terrain) to place it at the x and y coordinates?
No, when we do this we modify properties of terrain data. To add an object you have to create it following the object format, that you can see at # objects / player / object. Then when you done that you add it in serial [ 'object' ] [ $player ].

But this is manual method which is crap to handle !

As i told you just use NewObject function, following the specified parameters.

I never did forest generation so i tried for the fun, you can see this example which is simple: Cannabis Forest

I generate my forest and terrain in Function.php.

In Triggers.php at # terrain / data, I added some lines to put beach everywhere there is water next to desert.
Excellent- thanks for the files- I'll take a look at them and see what I can do. This is what I have so far:
http://aok.heavengames.com/cgi-bin/forums/display.cgi?action=ct&f=4,42192,0,30

I think you will understand why I want forest generation and other object generation

Memories are like footprints. If you don't revisit them, they are soon enveloped by new snow...
AzZzRu
Squire
posted 11-29-14 06:20 PM CT (US)     33 / 71       
Beautiful design

I just noticed in my example that i didn't randomized objects frames, you will get more variation of the palm tree if you do it.

Frame is $Animated parameter.

Edit: Finally i remade the tutorial, i think it will be easier to get it like this, just with few examples.

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-01-2014 @ 09:18 AM).]

Rashneish
Squire
posted 12-15-14 01:23 PM CT (US)     34 / 71       
Heyas,

The image to map function is just what I've been looking for, but I found the tutorial extremely confusing and have no prior experience with PHP or coding in general.

Is anyone aware of a suitably simple tutorial that pertains directly to the image conversion or an alternative method?

Thanks in advance.

PS. Does anyone know what the Ludacris map dimensions are? I've read various answers and I'm not sure what to believe.

[This message has been edited by Rashneish (edited 12-15-2014 @ 01:55 PM).]

AOHH
Squire
posted 12-17-14 05:58 PM CT (US)     35 / 71       
The script does not have a documentation and is difficult to understand because it does not follow the standard PHP coding (http://pear.php.net/manual/en/standards.php). Sorry, but it is still a beta version; functions and variables are not clear. Other than that, if you know how to use it, you can make amazing maps.

GENIE-STUDIO (manipulate Genie-Engine files with JSON)
AzZzRu
Squire
posted 12-18-14 05:43 AM CT (US)     36 / 71       
Heyas,

The image to map function is just what I've been looking for, but I found the tutorial extremely confusing and have no prior experience with PHP or coding in general.

Is anyone aware of a suitably simple tutorial that pertains directly to the image conversion or an alternative method?

Thanks in advance.
What point you don't understand about using this feature ? Where are you blocked ? It should be very easy to achieve.

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-18-2014 @ 05:49 AM).]

Ahti
Squire
posted 01-21-15 04:08 PM CT (US)     37 / 71       
Hello,

Thank you both so much for this editor - this is absolutely incredible! The potential this has really is off the charts.

I do have one question regarding the 'convert image as terrain' function, however, in particular this step:
First line you choose your image, it should be a .gif and its resolution have to be the same as your map.
Then you have two methods:
- By color index (the best): 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. In the switch specify which terrain is assigned to the color id.
- By color: No need touch your image, just use imagecolorsforindex instead of imagecolorat, it will return value RVB of the pixel. Then do the switch on $color['blue']. Then assign to the pixel color bleu intensity a terrain id.
The first step (choosing the .gif image) is self-explanatory. The image I use is a 255x255 pixels .gif image and I'm trying to paste it onto a giant map. The next step - assigning terrain to the colors - confuses me a lot. I'm no veteran scripter so I apologize if this is obvious, but how exactly do you perform this step? I mean: where exactly do you specify which terrain is assigned to which color id?

I just can't seem to get this to work. I can succesfully run the script without errors, but when I load the map in the AoE2HD editor it just crashes every time. I presume the problem is with the colors. I'm just not doing it right.

Can you please explain how you do the following particular step?
- By color: No need touch your image, just use imagecolorsforindex instead of imagecolorat, it will return value RVB of the pixel. Then do the switch on $color['blue']. Then assign to the pixel color bleu intensity a terrain id.
I presume the result should look something like this:


$color = imagecolorsforindex($image,imagecolorat( $image , $x , $y )); # Using pixel color RGB
//$color = imagecolorat( $image , $x , $y ); # Using pixel color index
$id = null;
switch ($color['blue']){ # Using pixel color RGB
//switch ($color){ # Using pixel color index
case 0: $id = 12; break;
case 1: $id = 3; break;
case 2: $id = 41; break;
case 3: $id = 12; break;
case 4: $id = 23; break;
}


But then what? Where and how do I assign the pixel color blue a terrain ID?

I know regular water is ID 1 while regular grass is ID 0. But where do I put that? I've tried putting them in the color switch but that doesn't work. Something like this:

case 0: $id = 0; break;
case 1: $id = 1; break;

Replacing the null with 1 doesn't do the trick either.

No matter what I do, it just keeps crashing.

Again, I apologize if this is a stupid question to ask. The solution is probably really simply but unfortunately my experience with scripts is extremely limited. I got everything else in this editor working through trial and error but this particular aspect has been bugging me for several days now. I just can't seem to get it right, no matter what I do. The script runs just fine but when I load the map it crashes.

[This message has been edited by Ahti (edited 01-21-2015 @ 04:11 PM).]

AOHH
Squire
posted 01-21-15 05:15 PM CT (US)     38 / 71       
This is what your code should look like in the terrain section:

for ( $y = 0 ; $y < $length [ 2 ] ; $y ++ ) for ( $x = 0 ; $x < $length [ 1 ] ; $x ++ )
{
$colorID = imageColorAt( $image , $x , $y ); // Using pixel color index
// var_dump($colorID);
$trrnID = NULL ;
switch ($colorID)
{
case 0: $trrnID = 12; break;
case 1: $trrnID = 3; break;
case 2: $trrnID = 41; break;
case 3: $trrnID = 12; break;
case 4: $trrnID = 23; break;
}

if ( isset ( $trnnID ) ) $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 1 ] = $trrnID ;
$packed .= pack ( 'c3' , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 1 ] , $serial [ 'terrain' ] [ 'data' ] [ $x . ',' . $y ] [ 2 ] , 0 ) ;
}

The imageColorAt() function returns the index of the pixel. If you want to see what index all the pixels are, uncomment the var_dump($colorID); and that will show you a huge list of color IDs so you can see what IDs are being used. Sometimes, the image contains IDs that do not necessarily start from 0.

GENIE-STUDIO (manipulate Genie-Engine files with JSON)
AzZzRu
Squire
posted 01-22-15 09:24 AM CT (US)     39 / 71       
Hi Ahti,

AOHH is showing you the method using pixels IDs, it's easier to handle.

I tried your code and I can open the map in aoc editor and in aokts, so I think there is something wrong with AoE2HD editor.

Your code compile fine and it should work.

If you can't open it in aokts can you send me your whole php project + input scenario + image you are using, and I will see what you have broken ^^.
But then what? Where and how do I assign the pixel color blue a terrain ID?
In your switch, this line:

case X1: $id = X2; break;

Means literally:
If the bleu intensity of one pixel is equal to X1, then the terrain id in aoc will be X2.

Or if you are using pixel IDs it means literally:
If id of the pixel color is equal to X1, then the terrain id in aoc will be X2.

Are you sure in your image there are 5 kind of pixel with blue intensity 0,1,2,3 and 4 ? I don't think so, this sound more like color IDs. You know, blue intensity value range is from 0 to 255. If you assigned IDs to your colors use imagecolorat() or imageColorAt() like AOHH did, and do the switch on $color.

Anyway even if none of pixels match with cases that you defined in your switch, your map won't crash, the terrain just won't be 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

[This message has been edited by AzZzRu (edited 01-22-2015 @ 10:22 AM).]

Leif Ericson
Seraph Emeritus
posted 01-22-15 06:37 PM CT (US)     40 / 71       
Moved upon request. This will likely be an update to the existing article that uses the same utility.

~`o´~|\  Join the fresh and exciting AI Ladder for its fourth season!
´ `  |_\
       |    Learn the joy of AI scripting in my guide: The World of AI Scripting
______|______
 \        /
   .....Hinga Dinga Durgen! - SpongeBob
  `-=<.__.>=-´
AzZzRu
Squire
posted 05-07-15 02:14 PM CT (US)     41 / 71       
Updated, easier to use. Library.php added to the script.

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
Ashrzr
Battle of the Forums EEH winning team
(id: normandy887)
posted 06-16-15 01:00 AM CT (US)     42 / 71       
I know nothing about AoKH, but as a programmer, this is really cool.

"Cue gang-rape music!" - Rotaretilbo
"What the f*** is gang-rape music?" - Cheddar Chap
AzZzRu
Squire
posted 07-31-15 02:52 PM CT (US)     43 / 71       
2.2 released, much news and more informations

Generate terrain from image is now easier to do with the function SetTerrainFromImage.

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 07-31-2015 @ 03:04 PM).]

bumis
Squire
posted 08-01-15 01:24 AM CT (US)     44 / 71       
This is incredible, I'm going to start playing with it. Your algorithms are amazing sounding I'll see what I can come up with.
Alchemisterius
Squire
posted 01-10-16 11:36 AM CT (US)     45 / 71       
Before I start using his I have three questions:
1. How do I configure my PHP IDE in PHP Designer 2007? I went to tools, then Preferences, but I didn't see Run anywhere. Could it go by another name? In fact, how do I do all of the instalation step 5 in 2007?
2. Based on my system, how do I know which PHP compiler should I download?
3. Is it okay if the PHP compiler folder is in my desktop?
AzZzRu
Squire
posted 01-11-16 11:49 AM CT (US)     46 / 71       
Hi Alchemisterius.
1. It is "Debug & Preview" - Fields "PHP Interpreter" / "Settings"
2. What is your system ? It's x86 or x64.
3. I don't know, it should be okay if there is no spaces in path.

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-01-16 02:02 PM CT (US)     47 / 71       
Hi AzZzRu,

Thanks for the great tool!

I'm using it at the moment to generate maps from PNG files made in Photoshop. I create a file of let's say 256x256 pixels and then create shapes with shades of grey. Those shades are then mapped via a PHP array to different kind of terrain tiles. PHP loads the image, loops through the pixels and creates the map I want.
So that works great. I just noticed that when I use the TERRAIN_JUNGLE, only the textured tile gets placed on the map, whereas in the AoE editor it also places actual trees.

Is there a fix for this? Should I add some extra code to get the trees?
AzZzRu
Squire
posted 02-04-16 04:47 AM CT (US)     48 / 71       
Hi Wimski,

Are you using SetTerrainFromImage() from last version to generate the terrain ?

It only generate terrain, to generate trees you have to customize the function: For a range of colors, in addition to terrain, add a random tree with NewObject().

You can generate custom forest with various density using rand() !

For example in SetTerrainFromImage at this line:

if($id !== false && isset($terrainIds[$id]))SCX::$data_serial['terrain']['data'][$x.','.$y][1] = $terrainIds[$id];

Replace it by this:

if($id !== false && isset($terrainIds[$id])){
// Set terrain
SCX::$data_serial['terrain']['data'][$x.','.$y][1] = $terrainIds[$id];
// Add tree
if($id == $id_for_forest && rand(1,2) == 1){ // Density 50%
NewObject(...) // Randomize also unit Id
}
}

Anyway I think I'll add an easy function to do this, it should be with image to terrain.

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-04-2016 @ 04:50 AM).]

Wimski
Squire
posted 02-07-16 04:39 AM CT (US)     49 / 71       
Are you using SetTerrainFromImage() from last version to generate the terrain ?
No, I rolled my own, but only because I didn't know there already was a function to do this.
It only generate terrain, to generate trees you have to customize the function: For a range of colors, in addition to terrain, add a random tree with NewObject().
Question about the NewObject function: is the $ID or the $U parameter the reference to one of the defined constants (a tree from the library)? And what is the other?
Okay, I've got the trees figured out!
Anyway I think I'll add an easy function to do this, it should be with image to terrain.
I'm already doing all kinds of customizations on the SetTerrainFromImage function and the editor in general

One more thing. I am playing AoE II HD and everytime I try to use a custom map in single player/standard game, the game crashes when the map is loaded. Any idea how that happens? I can load it into the editor of the game to put in details.
For instance this custom map: maze.scx

[This message has been edited by Wimski (edited 02-08-2016 @ 08:59 AM).]

Movinup
Squire
posted 02-08-16 06:44 PM CT (US)     50 / 71       
Hey, I really like using this, but I'm coming against a problem when trying to Efft_ArmorU and Range. Trying to modify the armor the game crashes, and when doing the range it does nothing.

Can you post a correct example of these?

And is there any way to make newly created units get the AP or HP or Armor or range that you've previously given to other units?
« 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