Changes between Initial Version and Version 1 of Random_Map_Scripting_Interface


Ignore:
Timestamp:
Feb 23, 2008, 4:18:58 AM (16 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Random_Map_Scripting_Interface

    v1 v1  
     1The RMSI details the functionality of Random Map Scripting which will be used to allow scripters to create the environment that players will need to play in.
     2[[BR]][[BR]]
     3== TODO ==
     4Add the Trigger Reference[[BR]]
     5
     6== Generic ==
     7==== randInt(min, max) ====
     8This function returns a random number between min and max.
     9==== randFloat(min, max) ====
     10This function returns a random decimal between min and max.
     11==== chooseRand(multi) ====
     12This function returns one of the variable multiple parameters.
     13==== abs(x), acos(x), asin(x), atan(x), atan2(y, x), ceil(x), cos(x), exp(x), floor(x), log(x), max(a, b), min(a, b), pow(x, y), round(x), sin(x), sqrt(x), tan(x) ====
     14Mathematic wrappers to the Math object.
     15==== isArray(var) ====
     16This function returns whether the variable is an array or not.
     17[[BR]][[BR]]
     18
     19== Preinitialized Features ==
     20Session and Triggers are pre-initialized objects to handle session data and condition/effects respectively. Scripters access their functionality using the with() construct as shown below:
     21
     22{{{
     23 with(Session) {
     24 }
     25 with(Triggers) {
     26 }
     27}}}
     28
     29This keeps the code clean since it forces newbies to keep it in one area, and makes sense to them as they read the code.
     30[[BR]][[BR]]
     31
     32== Players ==
     33The Player feature simply returns a player specifier(s). It can be used by triggers, objects, and other appropriate features to specify what player(s) they pertain to. They currently also hold player placement data for use by the !PlayerPlacement object.
     34[[BR]][[BR]]
     35==== Player(int) ====
     36This is the constructor. It sets the player you want it to associate with.
     37==== getPlacement() ====
     38This method returns an x,y array specifying the player's placement.
     39[[BR]][[BR]]
     40==== !PlayerTeam(int) ====
     41This is the constructor. It sets the team you want it to associate with.
     42==== getPlacementArray() ====
     43This method returns a multi-dimensional array specifying the placement of each player in team.
     44==== getPlayerCount() ====
     45This method returns the number of players in team.
     46==== getPlayers() ====
     47This method returns an array of Player objects.
     48[[BR]][[BR]]
     49==== !PlayerAll() ====
     50This is the constructor. It currently does nothing because you want to associate with all players.
     51==== getPlacementArray() ====
     52This method returns a multi-dimensional array specifying the placement of each player in game.
     53==== getPlayerCount() ====
     54This method returns the number of players in game.
     55==== getTeamCount() ====
     56This method returns the number of teams in game.
     57==== getPlayers() ====
     58This method returns an array of Player objects.
     59==== getTeams() ====
     60This method returns an array of !PlayerTeam objects.
     61[[BR]][[BR]]
     62
     63== Sessions ==
     64The Session feature returns and defines session data specified by the host usually the player himself when in SP mode.
     65[[BR]][[BR]]
     66==== Session() ====
     67This is the constructor. It currently does nothing except initialize the object.
     68==== hasSeasons() ====
     69This method returns whether the map should have seasons.
     70==== hasTeams() ====
     71This method returns whether the players will team together.
     72==== hasTeamsLocked() ====
     73This method returns whether the players are permanently teamed.
     74==== getMap() ====
     75This method returns the predefined area that specifies the map itself.
     76==== getType() ====
     77This method returns the game type.
     78==== getAllPlayers() ====
     79This method returns the !PlayerAll object.
     80==== getSettlementCount() ====
     81This method returns the requested number of settlements per player
     82==== getSize() ====
     83This method returns the requested map size.
     84==== getDifficulty() ====
     85This method returns the requested AI difficulty.
     86==== getSpeed() ====
     87This method returns the requested game speed.
     88==== getBorderTimer() ====
     89This method returns the requested border timer.
     90==== getMaxCenters() ====
     91This method returns the requested maximum amount of military centers.
     92==== getPopCap() ====
     93This method returns the requested population capacity.
     94==== getStartingResources() ====
     95This method returns the requested amount of resources to start with.
     96==== getStartingSeason() ====
     97This method returns the requested season to start with.
     98==== getStartingPhase() ====
     99This method returns the requested phase to start in.
     100==== getVisibility() ====
     101This method returns the requested visibility.
     102==== setUserDefined() ====
     103This method grabs all the session data and sets them. (used if the scripter doesn't want to ignore user session data)
     104==== setType(type) ====
     105This method sets the game type for map.
     106==== setSettlementCount(int) ====
     107This method sets the number of settlements per player.
     108==== setSize(int) ====
     109This method sets the size of map.
     110==== setDifficulty(string) ====
     111This method sets the difficulty of AI.
     112==== setSpeed(int) ====
     113This method sets the game's speed.
     114==== setBorderTimer(int) ====
     115This method sets the length in seconds Territory borders are activated.
     116==== setMaxCenters(int) ====
     117This method sets the maximum amount of military centers.
     118==== setPopCap(int) ====
     119This method sets the population capacity.
     120==== setStartingResources(string) ====
     121This method sets the amount of starting resources.
     122==== setStartingSeason(string) ====
     123This method sets the season the game starts in.
     124==== setStartingPhase(string) ====
     125This method sets the phase every player starts in.
     126==== setVisibility(string) ====
     127This method sets the visibility of the map.
     128==== loadAI(ai) ====
     129This method loads a specific ai script.
     130[[BR]][[BR]]
     131
     132== Areas ==
     133The Area feature is the parent of most basic functionality that would be inherited by the other more specific objects such as Water, Connection, and Constraint. If it's something that all objects share, it would be put in the Area object. In fact, The map itself is a predefined area whose size is set from 0 to 1 (the center being 0.5).
     134[[BR]][[BR]]
     135==== Area(parentArea ====
     136null)====
     137This is the constructor. It recieves the parent area because each area is required to be within another area. If no parent area is given, the area is created anywhere within the map itself rather than another area.
     138==== getSize() ====
     139This method returns the size of the area.
     140==== getLoc() ====
     141This method returns the location of the area in an array: array(x,y).
     142==== getCenter() ====
     143This method returns the center of the area in an array: array(x,y).
     144==== getRandom() ====
     145This method returns a random location within the area in an array: array(x,y).
     146==== getBorder(num ====
     1471, distance = null)====
     148This method returns an array of random locations within the area border. If distance isn't set, it returns equidistant locations.
     149==== setSize(min, max) ====
     150This method sets the size of the area. The size is restricted between 0 to 1.
     151==== setLoc(x, y) ====
     152This method defines where the area will be placed. X and Y is restricted between 0 to 1.
     153==== setCluster(min, max) ====
     154This method sets the number of area patches (Blob in AOM) to create.
     155==== setClusterDist(min, max) ====
     156This method sets the allowed distance the patches can be from eachother. Distance is restricted between 0 to 1.
     157==== setRadius(int) ====
     158This method sets the radius of an area to create a circle.
     159==== newVertex(x, y) ====
     160This method defines coordinates for a vertex to create a polygon.
     161==== rotate(int) ====
     162This method is used to rotate the area by a certain amount of degrees (1-359).
     163==== create(int=1) ====
     164This method registers the area(s) after everything has been configured. If int is specified, it creates int number of copies of the area.
     165[[BR]][[BR]]
     166
     167== Area Groups ==
     168The !AreaGroup feature is simply a wrapper for an area array. They can be used to implement the same surfaces on the same areas, connect them using !AreaConnection, and whereever else you would otherwise define one area in.
     169[[BR]][[BR]]
     170==== !AreaGroup(multi) ====
     171This is the constructor. It recieves a variable amount of parameters containing each area you want to group.
     172==== addArea(area) ====
     173This method adds a new area to the array to allow for individual additions.
     174[[BR]][[BR]]
     175
     176== Surfaces ==
     177The Surface feature is simple. It applies, modifies, and removes terrain from a specified area. It also sets the elevation of land from the parent area, or the depth of water. It can be implemented on any predefined area.
     178[[BR]][[BR]]
     179==== Surface(area) ====
     180This is the constructor. It recieves the area the terrain references.
     181==== setTerrain(terrain) ====
     182This method defines the main terrain to apply or change within the area.
     183==== addTerrainLayer(terrain, percent) ====
     184This method adds a new terrain layer which borders the area. For example, going from shallow to deep water.
     185==== addElevationAlignment(blendFloat) ====
     186This method defines a smooth alignment from one elevation to the next within the areas it overlaps. The highest point must gradually blend with the lowest point by defining distance in percentage.
     187==== replaceTerrain(old, new) ====
     188This method is used when you want a certain terrain type to be replaced with another in the case of overlapping areas.
     189==== setForestType(type, percent) ====
     190This method is used to set a forest type and a percentage of how much of the land it takes up.
     191==== setElevation(min, max) ====
     192This method defines the variable height of the area.
     193==== setDepth(min, max) ====
     194This method defines the variable depth of the water area.
     195==== modifyElevation(int, blendRadius) ====
     196This method raises/lowers the elevation of each tile by the specified int.
     197==== modifyDepth(int, blendRadius) ====
     198This method raises/lowers the depth of each tile by the specified int.
     199==== clearDepth() ====
     200This method clears depth of area.
     201==== clearElevation() ====
     202This method clears elevation of area.
     203[[BR]][[BR]]
     204
     205== Constraints ==
     206The Constraint feature is used to define restrictions. It applies strict rules to make the map work in a specific way.
     207[[BR]][[BR]]
     208==== Constraint(area) ====
     209This is the constructor. It defines the area the constraint(s) will pertain to using an area.
     210==== preventOverlap() ====
     211This method prevents an area from overlapping the defined area.
     212==== preventExit() ====
     213This method forces an object or area to remain within the defined area.
     214==== preventWalk() ====
     215This method prevents units from entering the area.
     216==== preventBuild() ====
     217This method prevents players from building on the area.
     218==== avoidTerrain(terrain, min, max) ====
     219This method defines the minimum and maximum distance the defined area can be from a specified terrain.
     220==== avoidAreas(min, max) ====
     221This method defines the minimum and maximum distance the defined area can be from other defined areas.
     222==== avoidArea(area, min, max) ====
     223This method defines the minimum and maximum distance the defined area can be from a specific area or areagroup
     224==== avoidPassable(min, max) ====
     225This method defines the minimum and maximum distance the defined area can be from a passable area.
     226==== avoidImpassable(min, max) ====
     227This method defines the minimum and maximum distance the defined area can be from an impassable area.
     228==== addObject(object) ====
     229This method defines the object(s) that must adhere to the constraints.
     230[[BR]][[BR]]
     231
     232== Connections ==
     233Connections are special areas used to "connect" 2 or more areas.
     234[[BR]][[BR]]
     235==== !PlayerConnection(players), !AreaConnection(areas) ====
     236These constructors define the type of connection. !PlayerConnection connects players by placement while !AreaConnection connects individual areas within an !AreaGroup or array.
     237==== setPercentage(float) ====
     238This method is used to cut down on how many connections are generated. So, if there are 10 possible connections and you use this method with the number .5 then only 5 connections will be generated randomly.
     239[[BR]][[BR]]
     240
     241== Water ==
     242The Water feature is used to create water. The surface object defines the water's depth. If terrain is set, it's used as the bottom level of the water which can be used to create some cool effects. Maybe we can add some more methods like making stronger waves and other graphical goodies like that if the engine will support it.
     243
     244==== Water(parentArea) ====
     245This is the constructor. it simply defines its parent area.
     246==== setType() ====
     247This method defines the type of water to use.
     248[[BR]][[BR]]
     249
     250== Territories ==
     251The Territory feature is a self-defined area that's generated to divide the parent area equally by the amount specified by the scripter. The parent area can be any defined area (Area, Connection, or Water). Each territory is given an ID according to position. IDs are generated clockwise starting from the territory positioned to the topleft of the area.
     252[[BR]][[BR]]
     253==== Territory(parentArea) ====
     254This is the constructor. It defines the parent area.
     255==== divide(int) ====
     256This method equally divides the territory a specified number of times.
     257==== getNext() ====
     258This method equally divides the territory a specified number of times.
     259==== rewind() ====
     260This method resets and goes back to the first dividend.
     261[[BR]][[BR]]
     262Here's how the territories would be implemented as documented:
     263{{{
     264 mapTerr = new Territory(MAP);
     265 mapTerr.divide(PlayerAll.getPlayerCount());
     266 mapTerr.create;
     267 
     268 mapProv = new Territory(mapTerr);
     269 mapProv.divide(4);
     270 mapProv.create;
     271 
     272 function attrition() {
     273     // triggers are too sketchy to complete example currently
     274 }
     275 
     276 trigAttrition = new Trigger(attrition());
     277 trigAttrition.enable;
     278}}}
     279[[BR]]
     280
     281== Objects ==
     282The Object feature places objects of any kind on the map. It works similar to areas and can be applied constraints just like areas. An object type can be a specific object, a unit type (archer/infantry/cavalry), or an array of either for specialized conditions.
     283[[BR]][[BR]]
     284==== Object(player) ====
     285This is the constructor. It uses the Player feature to tell who owns the object.
     286==== isOverlap(bool) ====
     287This method defines whether the object(s) are capable of overlapping.
     288==== setType(object) ====
     289This method sets the object type.
     290==== setArea(area) ====
     291This optional method allows you to place them within a specific area.
     292==== setAmount(min, max) ====
     293This method defines a minimum and maximum amount of objects you want created.
     294==== setDistance(min, max) ====
     295This method defines the minimum and maximum distance between each object defined.
     296==== setLoc(x, y) ====
     297This optional method defines the general location of the object(s).
     298==== setLocArray(array) ====
     299This optional method is used if more than one player was defined in the constructor and you'd like to give each a certain location.
     300==== create() ====
     301This method registers the object(s) after everything has been configured.
     302[[BR]][[BR]]
     303== Object Groups ==
     304The !ObjectGroup feature is simply a wrapper for an object array. They can be used to implement the same constraints when placing several objects.
     305[[BR]][[BR]]
     306==== !ObjectGroup(multi) ====
     307This is the constructor. It recieves a variable amount of parameters containing each area you want to group.
     308==== addObject(object) ====
     309This method adds a new object to the array to allow for individual additions.
     310==== create(int=1) ====
     311This method registers the objects after everything has been configured. If int is specified, it creates int number of copies of the objects.
     312[[BR]][[BR]]
     313== Triggers ==
     314A trigger is an indefinate iteration that can be stopped and restarted. Triggers are "described" in regular functions. They are necessary to allow for dynamic actions and reactions using conditions and effects. But you don't even need triggers and functions to take advantage of conditions and effects. Conditions and effects are regular functions that can be used globally within the script, and if you need to run it once at startup with no iteration, you are free to do so.
     315[[BR]][[BR]]
     316==== Trigger(func) ====
     317This is the constructor. It defines the function that will be called iteratively and registers it.
     318==== priority(int=1) ====
     319This method defines the priority the trigger has.
     320==== enable() ====
     321This method activates the trigger.
     322==== disable() ====
     323This method deactivates the trigger.
     324[[BR]][[BR]]
     325Every trigger starts with a preceding function that contains the code we want "triggered". To make it a trigger, you would create a new Trigger object specifying the function you want to work with:
     326{{{
     327 function trigName() {
     328     if(accumulated("food") >= 500) {
     329         sendchat("this player has 500+ food!");
     330     }
     331 }
     332 
     333 trigger = new Trigger(trigName());
     334}}}
     335Now, The trigger is registered and recognized by the engine. You, then, have to activate it to make it work. To activate/deactivate triggers, you use the enable and disable methods. For optimization, you can also set a priority for triggers within 4 different levels (1 being default). Priority must be called before enabling it.
     336[[BR]][[BR]]
     337
     338== Trigger Groups ==
     339The !TriggerGroup object is simply a wrapper for a trigger array. They can be used to implement the same.
     340[[BR]][[BR]]
     341==== !TriggerGroup(multi) ====
     342This is the constructor. It recieves a variable amount of parameters containing each trigger you want to group.
     343==== addTrigger(trig) ====
     344This method adds a new trigger to the array to allow for individual additions.
     345[[BR]][[BR]]
     346
     347== [wiki:Trigger_Reference Trigger Reference] ==
     348The Trigger Reference lists the comprehensive condition and effect libraries that are included in the RMSI for dynamic execution.
     349[[BR]][[BR]]
     350== [wiki:Biome_Reference Biome Reference] ==
     351The Biome Reference lists the many Biome features and their functions which standardizes the environment using compatible limitations.