Custom campaign with skirmish and carryover

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Custom campaign with skirmish and carryover

Post by rf900 » Mon Nov 02, 2015 2:58 pm

Hi

After playing another run of the original BA I have renewed interest in BA2 modding. There was one idea I had way back then that I want to retake and I think I have all the elements needed but would like to get confirmation from Devs. (You're gonna hate me)

So looking into the custom campaign functionality I have been able to launch a skirmish from a custom campaign view.

From that point I want to add another twist and be able to keep track of units used in those skirmishes, so that the next one launched from the campaign "view" will take them into account. Not sure if I can use the prebuilt carryover variables or will have to use campaign variables for it. Even if I will be able to use the PreStartBattle callback to change the skirmish generated map with them.

Anyway another crazy idea putting the engine to the limit.

Here is a draft design for the campaign view:

Image
Last edited by rf900 on Tue Nov 03, 2015 3:11 pm, edited 1 time in total.

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Custom campaign with skirmish and carryover

Post by rf900 » Mon Nov 02, 2015 3:04 pm

This is a high level view or what I was thinking of...

Code: Select all

FUNCTION UI_OBJ_HANDLE(data, event, id)
{
	//user changes options for next skirmish...
}

FUNCTION UI_OBJ_INIT()
{	
	//read all campaign variables to update the campaign view...	
}

FUNCTION PreStartBattle()
{	
	//Redefine skirmish map based on options selected in custom campaign view...	
}

FUNCTION BattleEndedCallback(winner)
{	
	//Update campaign vars
}

pipfromslitherine
Site Admin
Site Admin
Posts: 8977
Joined: Wed Mar 23, 2005 10:35 pm

Re: Custom campaign with skirmish and carryover

Post by pipfromslitherine » Mon Nov 02, 2015 4:28 pm

It should be doable. That is somewhat what the campaign variables are for. Check out Get/SetCampaignVar in the autodocs.

Cheers

Pip
follow me on Twitter here

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Custom campaign with skirmish and carryover

Post by rf900 » Tue Nov 03, 2015 3:13 pm

First issues:
  • How can I set the skirmish map to use farmland? It always uses city style
  • SkirmishSetType(index); doesn't seem to do anything
  • SkirmishSetOpen(value); doesn't seem to do anything
  • SkirmishSetStyle(index); not sure what it does, with index=0 fills all map with tracks
  • Can I alter the force selection screen of the skirmish missions. I would like to add fixed units to it with a script. I guess not as I haven't seen anything in the documentation.
  • Can/Should I use this callback FUNCTION PreStartBattle() with skirmish battles? It appears I can do the same with the CORE.BSF functions. I have included PreStartBattle() in the main campaign BSF file but it doens't seem to be triggering.
  • FUNCTION BattleEndedCallback(winner) doesn't seem to be triggering for skirmish missions. I have tried placing it in CORE.BSF and in the main CAMPAIGN.BSF files.

pipfromslitherine
Site Admin
Site Admin
Posts: 8977
Joined: Wed Mar 23, 2005 10:35 pm

Re: Custom campaign with skirmish and carryover

Post by pipfromslitherine » Tue Nov 03, 2015 5:03 pm

Both the functions needs to be in the scenario script.

The skirmish functions are designed for you to set up the skirmish params, then call StartBattle.

For force selection, errrr. Not sure you can combine it with the skirmish setup, but if you can then you would need to use the Get/SetMapUnit* functions in the PreStartBattle function (as you say).

Cheers

Pip
follow me on Twitter here

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Custom campaign with skirmish and carryover

Post by rf900 » Wed Nov 04, 2015 7:08 am

The skirmish functions are designed for you to set up the skirmish params, then call StartBattle.
Yes I'm doing that, most of the functions work to generate the skirmish map. But the ones I mention seem to do nothing. Also I am not able to set the farmland map type via parameters.

pipfromslitherine
Site Admin
Site Admin
Posts: 8977
Joined: Wed Mar 23, 2005 10:35 pm

Re: Custom campaign with skirmish and carryover

Post by pipfromslitherine » Wed Nov 04, 2015 4:06 pm

I'll be honest I'm not entirely sure how the skirmish generation works as I didn't write it. But I think to change from city you need to use SkirmishSetScenarioType. I'm certain they all do something, but it may be that you need to order the calls correctly. If you have access to Pike & Shot Campaigns then they use these calls to build their maps.

Cheers

Pip
follow me on Twitter here

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Custom campaign with skirmish and carryover

Post by rf900 » Thu Nov 05, 2015 10:21 am

SkirmishSetScenarioType changes the kind of scenario, defense, attack, meeting_eng, symmetric.
I haven't been able to get the snow terrain or the farm/wild map styles with the available parameters.

You are going to make me buy a copy of P&S :roll: Guess I will probably like it.
Both the functions needs to be in the scenario script.
I guess you are talking about this one also, BattleEndedCallback. As there is no actual scenario script (unless I am mistaken) as it is a skirmish. I have added it to the campaign.bsf and alternatively to the core.bsf files but it is not triggering. Tried also with WIN_SCENARIO_CALLBACK but with same result, guess that one is only for normal scenarios. I can probably do without it but it would help.

I saw this in the documentation and was hoping that it worked including it in the CORE.BSF file.

Code: Select all

End Battle Debugging
The debug CTRL+W functionality now correctly calls via the WIN_SCENARIO_CALLBACK function (if necessary) to allow for any campaign or other variables to be set.  If the callback prevents the mission from ending it will report as such. 

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Custom campaign with skirmish and carryover

Post by rf900 » Thu Nov 05, 2015 3:50 pm

SkirmishSetType works, was probably something to do with the order
//set the map type [0,255] 0=city, 1=wild, 2=farm
SkirmishSetType(1);

I haven't managed to get the style working, to show Russia Snow (or custom styles if possible??)
SkirmishSetStyle(style);

I have tried all sort of values, numeric, strings (GENERIC STYLE IDS_TERRAIN_STYLE_RUSSIA_SNOW RUSSIA_SNOW) and nothing.

Can I override the random map creating scripts? I have tried copying Slith_RandomMap2.BSF to my campaign but I am getting errors.

pipfromslitherine
Site Admin
Site Admin
Posts: 8977
Joined: Wed Mar 23, 2005 10:35 pm

Re: Custom campaign with skirmish and carryover

Post by pipfromslitherine » Thu Nov 05, 2015 4:26 pm

The SetStyle call takes a numeric value. It is the index of the style as defined in the tile data.

You should indeed be able to overload the scripts themselves. Copy the random map files into your campaign's DATA/SCRIPTS IIRC.

Cheers

Pip
follow me on Twitter here

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Custom campaign with skirmish and carryover

Post by rf900 » Fri Nov 06, 2015 10:40 am

Yep works... will see how the index is defined to see how to add other terrain-map types

Code: Select all

//set the style 0,1,=messes all with tracks 2=russia, 3=russia_snow			
SkirmishSetStyle(3);
Think I have all the pieces to do what I want... Lets rock! Thanks Pip

Edited: Where does that ID come from? How do I create a "new" style with other tiles? I added STYLE Desert in the two desert tiles text files, but apart from that what else? How does it get assigned an ID?

pipfromslitherine
Site Admin
Site Admin
Posts: 8977
Joined: Wed Mar 23, 2005 10:35 pm

Re: Custom campaign with skirmish and carryover

Post by pipfromslitherine » Fri Nov 06, 2015 5:11 pm

Check out:

https://sites.google.com/site/battleaca ... llfeatures

Start by going to the Auto-Edging section.

Cheers

Pip
follow me on Twitter here

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Custom campaign with skirmish and carryover

Post by rf900 » Mon Nov 09, 2015 8:17 pm

Wow, I think I start to see what needs to be changed... all tiles and objects text files... too much work.

I have started working on the battle simulator as the player will be able to do only certain skirmishes and simulate the others. It will also help with the balance and testing. I have put between 60%-90% losses in each skirmish depending on mission type and forces (is this realistic?).

http://anyone.hol.es/basim/sim.html

For the first version I will do the campaign script with force points only, without carryover units for simplicity.

Post Reply

Return to “Battle Academy 2: Modders Corner”