Page 3 of 4

Posted: Wed Aug 18, 2010 10:36 pm
by insidius
Ok, thanks Pip. I'll try to figure it out.

I'm giving you special mention in the credits for your troubles! I'd be lost without you buddy. :P

Posted: Wed Aug 18, 2010 10:43 pm
by insidius
For RemoveTextMarker, is it the same as ShowTextMarker? I couldn't find the command in the autodocs (battlescript).

So

RemoveTextMarker(1, 40, 33, "IDS_LOC_SOUTH_FARM", 8, "FFFFFF", 1) ;


for example?

Posted: Wed Aug 18, 2010 10:46 pm
by pipfromslitherine
Sorry - typo-ed it

HideTextMarker(id) // hide the specified text marker

Cheers

Pip

Posted: Wed Aug 18, 2010 11:18 pm
by insidius
Awesome. Putting in the hidemarkers and the showmarkers under per tick worked a charm. Everything is good to go now, thank you so much.

Posted: Thu Aug 19, 2010 12:36 am
by pipfromslitherine
Happy to help! Shows up the areas where the documentation is especially lacking.... :?

Cheers

Pip

Posted: Mon Aug 23, 2010 4:57 pm
by insidius
When bringing in reinforcements via a script, what command would I use to bring in a transport, a US halftrack, for example, with infantry already inside when it appears on the map?

Posted: Mon Aug 23, 2010 4:59 pm
by pipfromslitherine
If you check out the script for the survival missions, you'll see there is a PlaceUnit function, which also takes a loaded unit parameter to allow you to do exactly that. I'd suggest just grabbing that function and using it :)

Cheers

Pip

Posted: Mon Aug 23, 2010 5:12 pm
by insidius
Great, thanks. I'll do that.

While I have you here, what should I know about using my own squads.csv file in a custom scenario? Do I just have to put it in a Data folder in the Multiplayer/Maps_by_Insidius directory, or... where does it go?

Posted: Mon Aug 23, 2010 5:28 pm
by pipfromslitherine
It goes in the root of the campaign actually. Remember to check out the new file arrangement section of the engine docs, fresh from Friday :). Even I need help to remember where files live sometimes!

Cheers

Pip

Posted: Mon Aug 23, 2010 5:34 pm
by insidius
pipfromslitherine wrote:It goes in the root of the campaign actually. Remember to check out the new file arrangement section of the engine docs, fresh from Friday :). Even I need help to remember where files live sometimes!

Cheers

Pip
I'm sorry, where do I find the new docs? I must have missed them.

Posted: Mon Aug 23, 2010 5:46 pm
by pipfromslitherine
They are just updated on the Modding Portal, the Engine Documentation is what you want, near the bottom of the page.

http://www.slitherine.com/modding/bbc_ba_pc

Cheers

Pip

Posted: Mon Aug 23, 2010 6:37 pm
by adherbal
When bringing in reinforcements via a script, what command would I use to bring in a transport, a US halftrack, for example, with infantry already inside when it appears on the map?
if you are including Functions.BSF you can use PlaceUnit function:

PlaceUnit(x, y, facing, side, team, type) ;

The facing parameter allows you to define the unit's orientation (in steps of 45° with the values 0 to 7). But if you use "8" for the facing it will attempt to load the unit into the last unit created with a "PlaceUnit" command.

For example:

PlaceUnit(16, 16, 0, 0, 0, "SDKFZ251_HALFTRACK") ; // creates a halftrack
PlaceUnit(0, 0, 8, 0, 0, "GERMAN_ENGINEER") ; // creates german engineers and loads it into previous unit = the halftrack

Note that you must place the to-be-loaded infantry unit on an unoccupied tile. The best way is to use a tile outside of the map borders - for example (0,0) - because those are always unoccupied (unless you've actualy put a unit there). If a previous unit exists it will be loaded into that no matter how far away it is. If no previous unit exists the to-be-loaded unit will automatically be deleted (you'll never even see it).

Posted: Mon Aug 23, 2010 7:36 pm
by insidius
adherbal wrote:
When bringing in reinforcements via a script, what command would I use to bring in a transport, a US halftrack, for example, with infantry already inside when it appears on the map?
if you are including Functions.BSF you can use PlaceUnit function:

PlaceUnit(x, y, facing, side, team, type) ;

The facing parameter allows you to define the unit's orientation (in steps of 45° with the values 0 to 7). But if you use "8" for the facing it will attempt to load the unit into the last unit created with a "PlaceUnit" command.

For example:

PlaceUnit(16, 16, 0, 0, 0, "SDKFZ251_HALFTRACK") ; // creates a halftrack
PlaceUnit(0, 0, 8, 0, 0, "GERMAN_ENGINEER") ; // creates german engineers and loads it into previous unit = the halftrack

Note that you must place the to-be-loaded infantry unit on an unoccupied tile. The best way is to use a tile outside of the map borders - for example (0,0) - because those are always unoccupied (unless you've actualy put a unit there). If a previous unit exists it will be loaded into that no matter how far away it is. If no previous unit exists the to-be-loaded unit will automatically be deleted (you'll never even see it).
Beautiful, thank you! You made it so simple.

Here's a question for you:

I'm obviously no scripting genius, but I noticed something interesting. Between the SkipFirstPlayerTurn() command and the Rand(min, max) command, would it be possible to somehow create a random 'who goes first' in a (multiplayer) scenario mechanic?

Posted: Mon Aug 23, 2010 9:11 pm
by pipfromslitherine
I don't think so. The issue would be that who goes first in MP is actually defined by who gets the game first (if that makes sense) and that comes from which side each of you choose. There isn't a way in MP to force the first player to end their turn if it's not their turn (again, if that makes sense). So you could end up playing the wrong side. It's not something I've tried! :)

Cheers

Pip

Posted: Tue Aug 24, 2010 1:20 pm
by insidius
Any idea why I can't get both of these reinforcements to come in?

Note that the turns I have them coming in on are just for testing purposes.

Code: Select all

include "Functions.BSF"
// called at the start of every turn.
// You would tend to use this for events
FUNCTION StartTurn(side)
{
int i ;
int x ;
int y ;
int id ;
int playerCount ;

if (GetTurn() == -1 )
{
// Setup VPs, damaged tiled, ...
PreBattleSetup() ;
}
else
{
// Check if any victory conditions are met
VictoryConditions() ;
}

// Reinforcements	
	if( (GetTurn() == 1) )
	{
		if(side == 1)
		{
			// AddUnit with more options : FUNCTION PlaceUnit(x, y, facing, side, team, type)
			PlaceUnit(42, 62, 4, 1, 0, "German_truck") ;
			PlaceUnit(42, 79, 8, 1, 0, "German_Infantry") ;			
			PlaceUnit(42, 63, 4, 1, 0, "German_truck") ;
			PlaceUnit(42, 78, 8, 1, 0, "German_Infantry") ;
			
			
		
			ShowUIScreenX( "BattleHead0", "Anim1", "IDS_REINF", "BHead0Image:pilot_head") ;
			AddVizCamCenter(42, 62);
		
		}   
	}
	
	if( (GetTurn() == 2) )
	{
		if(side == 1)
		{
			// AddUnit with more options : FUNCTION PlaceUnit(x, y, facing, side, team, type)
			
			PlaceUnit(24, 48, 7, 1, 0, "GERMAN_INFANTRY") ;		
			PlaceUnit(26, 48, 7, 1, 0, "GERMAN_INFANTRY") ;
			PlaceUnit(24, 50, 4, 1, 0, "WAFFEN_SS") ;		
			PlaceUnit(26, 50, 4, 1, 0, "WAFFEN_SS") ;
			
			
		
			ShowUIScreenX( "BattleHead0", "Anim1", "IDS_REINF", "BHead0Image:pilot_head") ;
			AddVizCamCenter(25, 49);
		  
		}   
	}
	
if(side == 1)
{
}

if(side == 0)
{
}

}


FUNCTION PreBattleSetup()
{

//For instance, play with the us (1) and german (4) sides
SetGlobal("gNation0", 1) ;
SetGlobal("gNation1", 4) ; 
		
//Victory Points
SetGlobal("vp1", 0) ;
SetGlobal("vp2", 1) ;
SetGlobal("vp3", 1) ;
SetGlobal("vp4", 1) ;
		
//Here we place the flags and the text in the vp
//x1,x2,x3 are the coordinates
//you must add to the text1 file these lines:
//example: IDS_LOC_German_Base, "GERMAN BASE",
//example: IDS_LOC_US_Base, "US BASE",
//changing the names and the content at will
ShowTextMarker(1, 37, 18, "IDS_LOC_US_FWD_BASE", 8, "FFFFFF", 1);
ShowTextMarker(2, 40, 35, "IDS_LOC_BRIDGE_RED", 8, "FFFFFF", 1);
ShowTextMarker(3, 28, 34, "IDS_LOC_BRIDGE_GOLD", 8, "FFFFFF", 1);
ShowTextMarker(4, 34, 59, "IDS_LOC_GERMAN_HQ", 8, "FFFFFF", 1);
	

// Amount of VPs held by player:
SetGlobal("vps", 1) ;
} 


FUNCTION VictoryConditions()
{
int i ;
int j ;
int id ;
int counter ;

if (GetGlobal("vps") == 3)
{
EndBattle(0) ;
}


if (GetGlobal("vps") == 0)
{
EndBattle(1) ;
}


} 



// called every game tick.
// You would tend to use this for reactive logic and
// win situations etc
FUNCTION Tick(side)
{
CheckVP(-1, GetGlobal("vp1"), 37, 18) ;
CheckVP(-2, GetGlobal("vp2"), 40, 35) ;
CheckVP(-3, GetGlobal("vp3"), 28, 34) ;
CheckVP(-4, GetGlobal("vp4"), 34, 59) ;



} 

// this callback allows us to display any misc data we want on the screen
FUNCTION DrawScenarioUI()
{
int turns ;
int i ;
int id ;
int kills ;
 
	// only draw in our turn
	if( GetCurrentSide() == 0 )
	{
		// work out how many of the enemy we have killed
		// we will display it later
		for(i=0; i<GetUnitCount> 0 )
		{
			PrintString("IDS_TURNS") ;
			PrintStringLiteral(": ") ;
  
			turns = GetGlobal("gSkirmishTurns") - GetTurn() ;
			turns /= 2 ;
  
			// deal with any overflow
			if(turns < 0)
			{
				turns = 0 ;
			}
			
			// print out the value of the variable to the string
			PrintInt(turns) ;			
		}
		else
		{
			// otherwise just show a normal turn counter
			PrintString("IDS_TURN_COUNTER") ;
			PrintStringLiteral(": ") ;
			turns = GetTurn() ;
			// remember - a turn for each side
			turns /= 2 ;
			
			PrintInt(turns) ;
		}

		// add our kill count to the string
		
		// 2 newlines
		PrintStringLiteral("\n\n") ;
		PrintString("IDS_KILL_COUNTER") ;
		PrintStringLiteral(": ")
		PrintInt(kills) ;
 
		// 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 ;
}

Here's a copy of the .BSF file if needed; it's still work in progress.

http://dl.dropbox.com/u/10165676/RIVER_OF_BLOOD.BSF

Posted: Tue Aug 24, 2010 1:34 pm
by adherbal
The problem is this:

if( (GetTurn() == 2) )
{
if(side == 1)
{
...
}
}

GetTurn() returns:
0 = first player turn
1 = first AI turn
2 = second player turn
3 = second AI turn
4 = third player turn
...

So, during GetTurn() == 2, it is always a side 0 (player) turn. So the "if(side == 1)" condition is never true. If you remove this condition the reinforcements will arrive, albeit during the second player's turn, not during an AI turn.
Using both the GetTurn and then the if(side == x) conditions is probably vest avoided, because any specific turn ALWAYS belongs to a specific side. So either both conditions are true or - if not - nothing will happen.

Posted: Tue Aug 24, 2010 1:39 pm
by insidius
Aha, ok. Thank you very much :)

I thought the GetTurn was the game turns... So in a multiplayer only scenario, how would I have reinforcements come in on side 1's 2nd and 4th turns, for example?

Would GetTurn be 2 and 6, respectively if side 1?

Posted: Tue Aug 24, 2010 1:49 pm
by insidius
Nevermind, I got it. I used GetTurn 1 and 3 respectively and it worked fine. I guess side 1 is considered the "AI Turn" in a MP game.

I'm learning, slowly but surely lol.

Posted: Tue Aug 24, 2010 1:50 pm
by adherbal
it begins with turn 0 (first side 0 turn) and 1 (first side 1 turn) so 2nd and 4th side 1 turns would be 3 and 7 actualy.

I guess you could say
for side 0: GetTurn = (turn - 1) * 2
0 > 2 > 4 > 6 > 8 > ...
for side 1: GetTurn = (turn - 1) * 2 +1
1 > 3 > 5 > 7 > 9 > ...

Posted: Tue Aug 24, 2010 1:54 pm
by insidius
Yeah. *laughs*

I meant I used 1 and 3 for turns 1 and 2 (for testing to see if it worked). You're right for turns 2 and 4 (which is what I asked you). It's still early here and I haven't had my coffee yet lol.