Victory Based on Point Values for Objectives?
Moderators: Slitherine Core, BA Moderators
-
Navaronegun
- Captain - Heavy Cruiser

- Posts: 946
- Joined: Sun Sep 22, 2013 5:39 pm
- Location: Arizona, USA -7 GMT
Victory Based on Point Values for Objectives?
All,
Does anyone know how to script the use of varying point values for different victory flags? Say there were three objectives, and you wanted to weight their values, one at 3, one at 2 and one at 1. 4 points total required for victory at game's end. This is just an example, Obviously, there are simpler options to gain the above effect, but how would you script that? Does anyone have any thoughts?
Nav
Does anyone know how to script the use of varying point values for different victory flags? Say there were three objectives, and you wanted to weight their values, one at 3, one at 2 and one at 1. 4 points total required for victory at game's end. This is just an example, Obviously, there are simpler options to gain the above effect, but how would you script that? Does anyone have any thoughts?
Nav
I think the best way to describe our operations to date is that they have violated every recognized principle of war.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
-
Amaris
- Captain - Heavy Cruiser

- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
Re: Victory Based on Point Values for Objectives?
Here is a script doing this (written for solo part, ie the side 0 must capture 4 values of VPS):
Here we have three VPs with different victory values, defined by:
The victory condition is to side 0 to have 4 victory points:
'Et voilà' ! 
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"
// called at the start of every turn.
// You would tend to use this for events
FUNCTION StartTurn(side)
{
if( GetTurn() < 1 )
{
PreBattleSetup();
}
else
{
// Check if any victory conditions are met
VictoryConditions() ;
}
}
// Setup VPs, damaged tiled, ...
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("vp1", 1) ;
SetGlobal("vp2", 1) ;
SetGlobal("vp3", 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", 0) ;
//Define the values of each VPs for Victory score.
SetGlobal("score_vp1", 3) ;
SetGlobal("score_vp2", 2) ;
SetGlobal("score_vp3", 1) ;
}
FUNCTION VictoryConditions()
{
int score;
score = Calculate_Score(0);
if (score >= 4)
{
// Declare victory for side 0
SetGlobal("victory", 1) ;
EndBattle(0);
}
}
// called every game tick.
// You would tend to use this for reactive logic and
// win situations etc
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"), 20, 30) ;
CheckVP(-2, GetGlobal("vp2"), 21, 30) ;
CheckVP(-3, GetGlobal("vp3"), 22, 30) ;
}
// this callback allows us to display any misc data we want on the screen
FUNCTION DrawScenarioUI()
{
int score;
//draw the victory score
if( GetCurrentSide() == 0 )
{
score = Calculate_Score(0);
// start the string we are going to use
StartString() ;
PrintStringLiteral("Victory Score: ") ;
PrintInt(score) ;
// now render the string to the screen, remembering that all coordinates
// are based on a nominal 1024x768 screen size.
RenderString(12, 90, 5, "fffee37c", "ff000000") ;
}
}
FUNCTION WIN_SCENARIO_CALLBACK(winner)
{
// use the normal logic of last man standing
// if we win because of the turn limit, we will never call this
return winner ;
}
FUNCTION Calculate_Score(side)
{
int score;
score = 0;
if (GetGlobal("vp1") == side)
{
score += GetGlobal("score_vp1");
}
if (GetGlobal("vp2") == side)
{
score += GetGlobal("score_vp2");
}
if (GetGlobal("vp3") == side)
{
score += GetGlobal("score_vp3");
}
return score;
}
Code: Select all
//Define the values of each VPs for Victory score.
SetGlobal("score_vp1", 3) ;
SetGlobal("score_vp2", 2) ;
SetGlobal("score_vp3", 1) ;
Code: Select all
FUNCTION VictoryConditions()
{
int score;
score = Calculate_Score(0);
if (score >= 4)
{
// Declare victory for side 0
SetGlobal("victory", 1) ;
EndBattle(0);
}
}
“Take care, my friend; watch your six, and do one more roll… just for me.”
-
Navaronegun
- Captain - Heavy Cruiser

- Posts: 946
- Joined: Sun Sep 22, 2013 5:39 pm
- Location: Arizona, USA -7 GMT
Re: Victory Based on Point Values for Objectives?
Merci! Amaris, what would need to change to make it multiplayer? So side 1 as well? And the victor would be the side with the greater score? Ultimately, what I'd like to do is provide a total for each side at game's end and then add in the total of casualties which the player inflicted. Lets say there were 8 total objectives, worth 3400 points total. And casualties would be counted for victory using the campaign's squads.csv file. So at the end of the game on turn 24 side 0 had 4 Flags, which totaled 1800 points and caused 600 points of casualties ( from squads.csv). These would be added for 2400 points. Then side 1 had 1600 points from 4 objectives, and inflicted 900 points of casualties (from squads.csv), which totaled 2500 points. Then at game's end these would be compared, and side 1 would be the winner. How would you script that?
I think the best way to describe our operations to date is that they have violated every recognized principle of war.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
-
morge4
- Brigadier-General - Elite Grenadier

- Posts: 2114
- Joined: Fri Apr 29, 2011 2:56 pm
- Location: Penalty Box
- Contact:
Re: Victory Based on Point Values for Objectives?
Interesting idea...Steel Panthers uses a system like that. Each Victory Hex is worth x points and casualties inflicted are calculated by how much damage was done to INF, Armor, Air, etc and it gives you a point score.
Yes, I realize SP is a different game but, I would think what you want to do would be feasible...
Yes, I realize SP is a different game but, I would think what you want to do would be feasible...
-
Navaronegun
- Captain - Heavy Cruiser

- Posts: 946
- Joined: Sun Sep 22, 2013 5:39 pm
- Location: Arizona, USA -7 GMT
Re: Victory Based on Point Values for Objectives?
There are a few stock scenarios which calculate the amount of damage done, but in BA you are tied to the cost of the units which are present in your Squads.csv file. In GJS-style multiplayer games, we utilize weighted objectives, but the nature of the tournament prevents and discourages reckless or gamey play, so we don't include casualties in our victory determinations, as the effect of "having another day to fight for" takes care of that. Utilizing a weighted objective system, combined with a score for casualties as a modifier would have the same effect on a stand-alone game.
I think the best way to describe our operations to date is that they have violated every recognized principle of war.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
-
Amaris
- Captain - Heavy Cruiser

- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
Re: Victory Based on Point Values for Objectives?
Well I'm pretty sure that can be do in MP game with modify the script to take in account the two side.
I've no free time for this now but if you provide me the complete victory condition, I'll make the script.
I've no free time for this now but if you provide me the complete victory condition, I'll make the script.
“Take care, my friend; watch your six, and do one more roll… just for me.”
-
Navaronegun
- Captain - Heavy Cruiser

- Posts: 946
- Joined: Sun Sep 22, 2013 5:39 pm
- Location: Arizona, USA -7 GMT
Re: Victory Based on Point Values for Objectives?
Amaris wrote:Well I'm pretty sure that can be do in MP game with modify the script to take in account the two side.![]()
I've no free time for this now but if you provide me the complete victory condition, I'll make the script.
Emailed.
I think the best way to describe our operations to date is that they have violated every recognized principle of war.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
-
Amaris
- Captain - Heavy Cruiser

- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
Re: Victory Based on Point Values for Objectives?
A more 'complex' script with a turn limit (30 here) and the cost of the dead units is added to the final score.
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"
// called at the start of every turn.
// You would tend to use this for events
FUNCTION StartTurn(side)
{
if( GetTurn() < 1 )
{
PreBattleSetup();
}
if( GetTurn() == 30 )
{
// Check if any victory conditions are met
VictoryConditions() ;
}
}
// Setup VPs, damaged tiled, ...
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("vp1", 1) ;
SetGlobal("vp2", 1) ;
SetGlobal("vp3", 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", 0) ;
//Define the values of each VPs for Victory score.
SetGlobal("score_vp1", 200) ;
SetGlobal("score_vp2", 200) ;
SetGlobal("score_vp3", 200) ;
}
FUNCTION VictoryConditions()
{
int score_side0;
int score_side1;
score_side0 = Calculate_Score(0);
score_side1 = Calculate_Score(1);
if (score_side0 > score_side1)
{
// Declare victory for side 0
SetGlobal("victory", 1) ;
EndBattle(0);
}
else
{
// Declare victory for side 1
SetGlobal("victory", 1) ;
EndBattle(1);
}
}
// called every game tick.
// You would tend to use this for reactive logic and
// win situations etc
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"), 20, 30) ;
CheckVP(-2, GetGlobal("vp2"), 21, 30) ;
CheckVP(-3, GetGlobal("vp3"), 22, 30) ;
}
// this callback allows us to display any misc data we want on the screen
FUNCTION DrawScenarioUI()
{
int score;
int side;
//draw the victory score
side = GetCurrentSide();
score = Calculate_Score_Flag(side);
// start the string we are going to use
StartString() ;
PrintStringLiteral("Victory Flag Score: ") ;
PrintInt(score) ;
PrintStringLiteral("/600") ;
score = Calculate_Score_Damage(side);
PrintStringLiteral(" - Damage Score: ") ;
PrintInt(score) ;
PrintStringLiteral("\n\n") ;
side += 1 ;
side = side % 2 ;
PrintStringLiteral("Enemy Victory Flag Score: ") ;
PrintInt(score) ;
PrintStringLiteral("/600") ;
score = Calculate_Score_Damage(side);
PrintStringLiteral(" - Damage Score: ") ;
PrintInt(score) ;
// now render the string to the screen, remembering that all coordinates
// are based on a nominal 1024x768 screen size.
RenderString(12, 90, 5, "fffee37c", "ff000000") ;
}
FUNCTION WIN_SCENARIO_CALLBACK(winner)
{
// use the normal logic of last man standing
// if we win because of the turn limit, we will never call this
return winner ;
}
FUNCTION Calculate_Score(side)
{
int score;
score = 0;
score += Calculate_Score_Flag(side);
score += Calculate_Score_Damage(side);
return score;
}
FUNCTION Calculate_Score_Flag(side)
{
int score;
if (GetGlobal("vp1") == side)
{
score += GetGlobal("score_vp1");
}
if (GetGlobal("vp2") == side)
{
score += GetGlobal("score_vp2");
}
if (GetGlobal("vp3") == side)
{
score += GetGlobal("score_vp3");
}
return score;
}
FUNCTION Calculate_Score_Damage(side)
{
int score;
int enemy_side;
int unit;
int count;
score = 0;
enemy_side = side;
enemy_side += 1 ;
enemy_side = enemy_side % 2 ;
for (count = 0 ; count < GetUnitCount(enemy_side) ; count++)
{
unit = GetUnitID(enemy_side, count);
if (unit != -1)
{
if (GetUnitDead(unit) == 1)
{
score += GetUnitCost(unit);
}
}
}
return score;
}
“Take care, my friend; watch your six, and do one more roll… just for me.”
-
Navaronegun
- Captain - Heavy Cruiser

- Posts: 946
- Joined: Sun Sep 22, 2013 5:39 pm
- Location: Arizona, USA -7 GMT
Re: Victory Based on Point Values for Objectives?
Merci! I will "test-drive" it this week, and include in the next closed beta release for playtesting.
I think the best way to describe our operations to date is that they have violated every recognized principle of war.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.
General Eisenhower, Supreme Commander Allied Expeditionary Force, on the Tunisian Campaign, 27 DEC 1942.