Difference between revisions of "Scripting Examples"

From theFarWilds
Jump to: navigation, search
(New page: Example Scripts: // Fortified AI void configGame() { addAIPlayer("Evil Fish","Crypt Doctor",0); } void beforeStart() { Player aiPlayer=getAIPlayer(0); createEntity("Earthwo...)
 
 
(6 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
[[Scripting]]
 
Example Scripts:
 
Example Scripts:
  
Line 17: Line 18:
  
  
  // Preset Scenario
+
  // Specifying the Deck
void configGame()
+
{
+
setMapSeed(12345);
+
addAIPlayer("Evil Fish","Crypt Doctor",0);
+
}
+
+
 
  void beforeStart()
 
  void beforeStart()
 
  {
 
  {
  Player aiPlayer=getAIPlayer(0);  
+
  Player player=getHumanPlayer(0);  
  Player HumanPlayer=getHumanPlayer(0);  
+
  int ds=player.deckSize();
+
  for(int n=0; n<ds; n++)
  setTerrain(createLocation(6,6),3,2);
+
  {
createEntity("Earthworks",6,6,aiPlayer);
+
player.removeDeckCard(0);
createEntity("Dwarven Hall",8,6,aiPlayer);
+
  createEntity("Gully Slingers",6,5,aiPlayer);
+
createEntity("Gully Slingers",6,7,aiPlayer);
+
createEntity("Axe Captain",7,5,aiPlayer);
+
createEntity("Axe Captain",7,6,aiPlayer);
+
createEntity("Flux Well",6,6,aiPlayer);
+
createEntity("Attrition",-1,-1,aiPlayer);
+
+
while(handSize(aiPlayer)>0){
+
removeHandCard(aiPlayer,0);
+
}
+
while(deckSize(aiPlayer)>0){
+
removeDeckCard(aiPlayer,0);
+
 
  }
 
  }
 
   
 
   
  while(handSize(HumanPlayer)>0){
+
  player.addToDeck("Graveyard",0);
  removeHandCard(HumanPlayer,0);
+
player.addToDeck("Red Imp",0);
  }
+
  player.addToDeck("Red Imp",0);
  while(deckSize(HumanPlayer)>0){
+
  player.addToDeck("Black Plague",0);
  removeDeckCard(HumanPlayer,0);
+
  player.addToDeck("Crypt Doctor",0);
  }
+
player.addToDeck("Hypnotic Banshee",0);
 +
  player.addToDeck("Nether Plasma",0);
 +
  player.addToDeck("Dank Pit",0);
 
   
 
   
  addToHand(HumanPlayer,"Graveyard");
+
  player.shuffleDeck();
addToHand(HumanPlayer,"Red Imp");
+
}
addToHand(HumanPlayer,"Red Imp");
+
 
addToHand(HumanPlayer,"Black Plague");
+
 
addToHand(HumanPlayer,"Crypt Doctor");
+
// Using entityCallback
addToHand(HumanPlayer,"Hypnotic Banshee");
+
// This removes the oldest building each round
  addToHand(HumanPlayer,"Nether Plasma");
+
void onNewRound()
addToHand(HumanPlayer,"Dank Pit");
+
{
 +
  forEachEntity(); // loop through all the Entities
 +
}
 
   
 
   
  addGlory(HumanPlayer,18);
+
bool entityCallback(Entity ent)
 +
{
 +
if(ent.isType(2)) // Is it a building
 +
{
 +
ent.remove();
 +
return(false); // don't need to call entityCallback anymore
 +
}
 +
  return(true); // we haven't found a building yet so keep checking
 
  }
 
  }
 +
 +
 +
// enchantEntity example
 +
Player aiPlayer=getAIPlayer(0);
 +
Entity entity1 = createEntity("Earthworks",6,6,aiPlayer);
 +
enchantEntity(entity1, "Iron Gate", aiPlayer);

Latest revision as of 23:30, 26 March 2010

Scripting 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);	
}


// Specifying the Deck
void beforeStart()
{
	Player player=getHumanPlayer(0); 
	int ds=player.deckSize();
	for(int n=0; n<ds; n++)
	{
		player.removeDeckCard(0);
	}

	player.addToDeck("Graveyard",0);
	player.addToDeck("Red Imp",0);
	player.addToDeck("Red Imp",0);
	player.addToDeck("Black Plague",0);
	player.addToDeck("Crypt Doctor",0);
	player.addToDeck("Hypnotic Banshee",0);
	player.addToDeck("Nether Plasma",0);
	player.addToDeck("Dank Pit",0);

	player.shuffleDeck();
}


// Using entityCallback
// This removes the oldest building each round
void onNewRound()
{
	forEachEntity(); // loop through all the Entities 
}

bool entityCallback(Entity ent)
{
	if(ent.isType(2)) // Is it a building
	{
		ent.remove();
		return(false); // don't need to call entityCallback anymore
	}	
	return(true); // we haven't found a building yet so keep checking
}


// enchantEntity example
Player aiPlayer=getAIPlayer(0); 
Entity entity1 = createEntity("Earthworks",6,6,aiPlayer);
enchantEntity(entity1, "Iron Gate", aiPlayer);