Difference between revisions of "Scripting"
From theFarWilds
Line 13: | Line 13: | ||
void afterAction(); // not yet | void afterAction(); // not yet | ||
− | void playersTurn( | + | void playersTurn(Player player); // not yet |
− | bool canPass( | + | bool canPass(Player player); // not yet |
// called when the real players try to pass. | // called when the real players try to pass. | ||
// This is so you can ensure they do a particular action before passing. | // This is so you can ensure they do a particular action before passing. | ||
Line 21: | Line 21: | ||
Functions you can call: | Functions you can call: | ||
− | + | Entity createEntity(string CardName, int x_coord , int y_coord,Player controller ); | |
− | + | Entity createEntity(string CardName ,Location loc,Player controller); | |
− | + | Entity createEntity(string CardName ,Location loc); | |
− | + | Location createLocation(int x,int y); | |
− | + | Player getAIPlayer(int index) | |
+ | Player getHumanPlayer(int index) | ||
void addAIPlayer(string PlayerName,string Avatar,int teamID); | void addAIPlayer(string PlayerName,string Avatar,int teamID); | ||
// can only call this from configGame() | // can only call this from configGame() | ||
// all parameters are ignored for now | // all parameters are ignored for now | ||
+ | void setTerrain(Location loc,int topo,int veg) | ||
+ | // topo: ocean=1, soggy=2, flat=3, hills=4, mountain=5 | ||
+ | // veg: desert=1 ,grass=2 ,forest=3 | ||
+ | Player Functions: | ||
+ | void addToHand(Player,string cardName) | ||
+ | void addToDeck(Player,string cardName,int index) | ||
+ | Card getDeckCard(Player,int index) | ||
+ | Card getHandCard(Player,int index) | ||
+ | void removeHandCard(Player,int index) | ||
+ | void removeDeckCard(Player,int index) | ||
+ | void drawCard(Player) | ||
+ | int deckSize(Player) | ||
+ | int handSize(Player) | ||
+ | void addFlux(Player,int delta) | ||
+ | void addGlory(Player,int delta) | ||
+ | int getFlux(Player) | ||
+ | int getGlory(Player) | ||
---- | ---- | ||
Line 43: | Line 61: | ||
void beforeStart() | void beforeStart() | ||
{ | { | ||
− | + | Player aiPlayer=getAIPlayer(0); | |
createEntity("Earthworks",6,6,aiPlayer); | createEntity("Earthworks",6,6,aiPlayer); | ||
createEntity("Earthworks",10,10,aiPlayer); | createEntity("Earthworks",10,10,aiPlayer); |
Revision as of 03:18, 17 March 2010
This is the start of the scripting API. It will be expanded over time. If you want something ask for it in the forum. Create your scripts here: [1]. Scripts are written in AngelScript, it has syntax similar to C.
Functions you can implement:
void setupGame(); // Sets up the game state such as # of players, Map Size, if they need to set a deck or not, etc void beforeStart(); // Do things here before any action. Place creatures and buildings, change their decks etc. void afterAction(); // not yet void playersTurn(Player player); // not yet bool canPass(Player player); // not yet // called when the real players try to pass. // This is so you can ensure they do a particular action before passing.
Functions you can call:
Entity createEntity(string CardName, int x_coord , int y_coord,Player controller ); Entity createEntity(string CardName ,Location loc,Player controller); Entity createEntity(string CardName ,Location loc); Location createLocation(int x,int y); Player getAIPlayer(int index) Player getHumanPlayer(int index) void addAIPlayer(string PlayerName,string Avatar,int teamID); // can only call this from configGame() // all parameters are ignored for now void setTerrain(Location loc,int topo,int veg) // topo: ocean=1, soggy=2, flat=3, hills=4, mountain=5 // veg: desert=1 ,grass=2 ,forest=3
Player Functions:
void addToHand(Player,string cardName) void addToDeck(Player,string cardName,int index) Card getDeckCard(Player,int index) Card getHandCard(Player,int index) void removeHandCard(Player,int index) void removeDeckCard(Player,int index) void drawCard(Player) int deckSize(Player) int handSize(Player) void addFlux(Player,int delta) void addGlory(Player,int delta) int getFlux(Player) int getGlory(Player)
Example Scripts:
// Fortified AI void configGame() { addAIPlayer("Evil Fish","Crypt Doctor",0); } void beforeStart() { Player aiPlayer=getAIPlayer(0); createEntity("Earthworks",6,6,aiPlayer); createEntity("Earthworks",10,10,aiPlayer); createEntity("Axe Captain",6,7,aiPlayer); createEntity("Attrition",-1,-1,aiPlayer); }
Coordinate System : Coordinates here is a bit unusual since TFW have hexagonal field. This page explains it a bit.