Page 1 of 2

Tutorial: How to place Victory Points.

Posted: Tue Aug 10, 2010 9:50 pm
by adherbal
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

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

Posted: Tue Aug 10, 2010 10:01 pm
by insidius
Thanks! Hopefully I can figure out how to use this. :P

which software creates BSF file?

Posted: Wed Aug 11, 2010 2:44 am
by pomakli
Thank you very much for this info.

One question:

When I create a scenario, "Bam" file is automaticly created by the system.

With which software could I create "BSF" file?

I used, "open.org", NO!

or I failed!

:cry:

Posted: Wed Aug 11, 2010 2:49 am
by junk2drive
Notepad++

Got it!

Posted: Wed Aug 11, 2010 2:52 am
by pomakli
Got it!

PIP's template guide!

Sorry!

:?

Read afterwards! Thanks junk2drive!

Posted: Wed Aug 11, 2010 2:55 am
by junk2drive
In my MyDocuments\MyGames\BBCBA folder I created a folder for the documents that have been posted in these forums.

For the one above I copied and pasted to Windows Notepad and saved as a txt file. That way I'll have a copy handy if I need the example above and I don't have internet connection or the Slitherine website is down.

Posted: Wed Aug 11, 2010 4:16 am
by insidius
Someone should write a script that awards points for holding a VP each turn and when a certain number of points has been awarded, that side wins the scenario.

Re: Tutorial: How to place Victory Points.

Posted: Wed Aug 11, 2010 4:41 am
by pomakli
adherbal wrote: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
When I copy it and let the game run, 2 error msgs appear!

https://www.dropbox.com/home#:::

Open pls. "error placing VP's"

Thanks in advance!

Posted: Wed Aug 11, 2010 10:54 am
by adherbal
Someone should write a script that awards points for holding a VP each turn and when a certain number of points has been awarded, that side wins the scenario.
That should be something like:

Code: Select all

FUNCTION VictoryConditions()
{
   // Give points to side 0 and 1
   // Note: change the "2" to the amount of VPs you have placed
   SetGlobal("points0", GetGlobal("points0") + GetGlobal("vps") ) ;
   SetGlobal("points1", GetGlobal("points1") + 2 - GetGlobal("vps") )

   // Declare victory when certain amount of points reached (10 in this example)
   if ( GetGlobal("points0") >= 10 )
   {
      // Declare victory for side 0
      EndBattle(0);
   }
   if ( GetGlobal("points1") >= 10 )
   {
      // Declare victory for side 1
      EndBattle(1);
   }
}

Posted: Wed Aug 11, 2010 11:00 am
by adherbal
When I copy it and let the game run, 2 error msgs appear!
What are the error messages?

I just tested it myself because it was mostly written from the top of my head, by I had no errors?

One note is that I used (10,10) as VP coordinates in my example, which is actualy out of the map borders. But that shouldn't cause any errors.

Posted: Sat Aug 14, 2010 1:01 pm
by junk2drive
// 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
Can we add nations to this list?

Posted: Sat Aug 14, 2010 1:16 pm
by adherbal
Can we add nations to this list?
Make a local copy of Functions.BSF

I think all you need to do is add:

Code: Select all

	if( nation == <x> ) // new nation, x = lowest value not yet used in the script
	{
		ShowEffectMarker(marker, x, y, "<newnation>_victory_marker", 0) ;
	}

Posted: Sat Aug 14, 2010 1:33 pm
by junk2drive
Thanks.

I don't think I will ever figure the scripts out. There are scripts all over the place.

Posted: Fri Aug 20, 2010 2:22 pm
by ostwind
I've been testing, and I can't manage to add a brand new vp flag to the game.
I can add new units without problem, but I don't know how can I do for the flag.
I have a folder MyDocs/BBCBA/Campaigns/My campaign/core/anim with the dds and the sf4 generated from the exported sf3 files.
In functions.BSF, the lines from the posts above for the new nation and the victory marker, and in the scenario.BSF, the call to the flag with ShowEffectMarker.

I'm missing something for sure, but I can't guess what's it....any idea?

Thank you and regards

Posted: Fri Aug 20, 2010 2:47 pm
by adherbal
Hm not sure. I think you should first try to replace an existing effect (flag) with your new model by replacing the file(s), and if that works add it as a new flag by editing the scripts. With the current info I can't tell if the problem is related to the 3D file or the scripting.

Posted: Fri Aug 20, 2010 3:12 pm
by pipfromslitherine
It shouldn't be CORE\ANIM within your campaign, just ANIM.

So,

My Docs\My Games\BBCBA\Campaigns\MyCampaign\ANIM

Cheers

Pip

Posted: Fri Aug 20, 2010 10:33 pm
by ostwind
Yes, Pip, you are right, thanks ; :)
I've been trying to replace the standard german flag, but with no luck...
In a scenario with germans and americans, I've made a simple form (a cone) with a texture, to replace the german flag. Exported without problems, in the anim folder. There are two files :

$german_victory_marker.s4f
textura.dds ( the one used in 3ds max as material)

The scenario script recalls the marker with this sentence:

ShowEffectMarker(-1, 17, 16, "german_victory_marker", 0)

but when I play the scenario, appears an italian flag ( or some other random marker) sharing the position with a bombing marker in the place where the german marker should be, and the us marker doesn't appear.

...????....If you want my files for test or someting else, just ask.

Regards

Posted: Fri Aug 20, 2010 11:05 pm
by pipfromslitherine
It might be a good idea to zip up the campaign, yes. Then I can dig down and see what's going on! :)

Cheers

Pip

Posted: Sat Aug 21, 2010 9:12 am
by ostwind
pipfromslitherine wrote:It might be a good idea to zip up the campaign, yes. Then I can dig down and see what's going on! :)

Cheers

Pip
I've sent the download link to you by pm. :)

Posted: Sat Aug 21, 2010 6:44 pm
by pipfromslitherine
Gah - well done! You found a bug. A missing ! means that you could never correctly over-ride animations.

A solution for now would be to just rename the file to something that isn't used, and then it should show up. It doesn't have to be named the same as some existing one.

Cheers

Pip