Tutorial: How to place Victory Points.
Posted: Tue Aug 10, 2010 9:50 pm
First of all, victory points (VPs) are not an integrated part of the engine, but entirely scripted. This means the way to place them I am explaining here is not the "only" way, but the way it is done in most of the scenarios.
Here is an example mission script. It requires some knowledge of scripting/programming logic. Copy paste this into a BSF file with the same name as your BAM scenario to link it to that scenario. For example:
Scenario name = MyScenario.BAM
Script name = MyScenario.BSF
Also note that because VPs basically just "scripted effects" the AI will NOT hunt for them if you do not tell them to. You need to assign an AI point to each VP location and set up the AI properly to go for those AI points. This post does not cover that.
I know this is all a bit brief but hopefully it's useful enough for those of you who are looking at creating additional scenarios.
Here is an example mission script. It requires some knowledge of scripting/programming logic. Copy paste this into a BSF file with the same name as your BAM scenario to link it to that scenario. For example:
Scenario name = MyScenario.BAM
Script name = MyScenario.BSF
Code: Select all
// Include all functions from the functions.bsf script. These include the bulk of the VP logic.
// This script lives in Data\Scripts
include "Functions.BSF"
// This function is called at the start of every turn (both player and enemy turns).
// You would tend to use this for events that happen at the start of a turn
FUNCTION StartTurn(side)
{
// GetTurn() returns the current turn number,
// -1 is a special "turn" that is called in the beginning when the scenario is loaded.
if (GetTurn() == -1 )
{
// Setup VPs
PreBattleSetup() ;
}
else
{
// Check if any victory conditions are met
VictoryConditions() ;
}
}
// Custom function to set up VPs and anything else you want to set up at the start of a mission
FUNCTION PreBattleSetup()
{
// Define nations numbers. These global variables are used by the VP script functions.
// Note that they do NOT correspond with the nation numbers in the editor
// 0 = UK, 1 = USA, 2 = Canada, 3 = Poland, 4 = Germany, 5 = Italy
SetGlobal("gNation0", 0) ;
SetGlobal("gNation1", 4) ;
// Define which side controls which VP at the start of the mission
// By default they start at 0 so you only need to set the VPs controlled by side 1
// The current functions script allows up to 9 VPs, named vp1, vp2, vp3, vp4, vp5, vp6, vp7, vp8 and vp9
// In this example we are giving vp2 to side 1, which is defined as Germans ("gNation1" = 4)
SetGlobal("vp2", 1) ;
// Set the a mount of VPs held by player (side 0) at the start of the mission
// In this example we will be placing two VPs. vp1 is owned by the player, vp2 by the enemy.
// So "vps" should be = 1.
SetGlobal("vps", 1) ;
}
// Custom script to check if victory conditions are met at the start of every turn
FUNCTION VictoryConditions()
{
// Declare victory when all VPs are captured
if ( GetGlobal("vps") == 2 )
{
// Declare victory for side 0
EndBattle(0);
}
}
// The Tick function is called every game tick.
// Use this for things that have to be checked in real-time (instead of only at the start of a turn)
FUNCTION Tick(side)
{
// Place two VPs and run through VP capturing logic
// format is:
// CheckVP(-<x>, GetGlobal("vp<x>"), x coordinate, y coordinate) ;
// <x> is the number of the victory point (1 to 9)
CheckVP(-1, GetGlobal("vp1"), 25, 20) ;
CheckVP(-2, GetGlobal("vp2"), 20, 20) ;
}I know this is all a bit brief but hopefully it's useful enough for those of you who are looking at creating additional scenarios.