Page 1 of 1
Scripting List
Posted: Wed Aug 11, 2010 1:49 pm
by junk2drive
I have no programming experience. I have read the STUB doc and the recent script docs and it comes to mind that there may be a standard format.
Does the sequence matter. Such as does briefing need to be before start turn? Can victory points be pasted anywhere in a script?
I would like a list of necessary functions and if need be, the order of placement. Also a list of optional functions and conflicting functions.
TA
Posted: Wed Aug 11, 2010 1:58 pm
by adherbal
There are no "necessary" functions, but there are a number of "hardcoded" ones, of which the most important are:
StartTurn(side) : This is executed at the start of each turn, before the player makes his moves. "side" is a local variable that holds the ID of the current turn's side (0 or 1). So you can use if( side == 0 ) ... to do things when it's the player's turn. Note that the first turn == 0. So the first AI turn == 1, the second player's turn == 2, and so on. So player turns are always even and AI turns are always odd. For example use if( GetTurn() == 4 ) ... to do something at the start of the player's third turn.
Tick(side) : this is executed each "tick". I'm not sure how many ticks per second, but that doesn't really matter. It's used to track things in real time, like if you capture a VP it needs to chance side right away. "side" is a local variable that holds the ID of the current turn's side (0 or 1).
DrawScenarioUI() : this function is used to set up the information shown in the objectives info display.
ACHIEVEMENT_<name>() : These functions are used to add achievements. Place the achievement's conditions in here and use "return 1" when those conditions are met in order to award the achievement. These are also executed automatically each tick. Quick example:
Code: Select all
FUNCTION ACHIEVEMENT_MyNewAchievement()
{
// if player has captured 3 VPs, award achievement
if( GetGlobal("vps") == 3 )
{
return 1 ;
}
// return 0 when achievement conditions are not met
return 0 ;
}
The last 2 functions are a bit more complex but not really required to create a nice mission. So when you don't have much experience with scripting/modding it's best to ignore these for now.
Posted: Wed Aug 11, 2010 2:36 pm
by junk2drive
Thanks
I guess I was looking for a list of don'ts as much as do's. Trying to cut down on the number of "my campaign crashed, why?" posts.
So far the victory locations and ai behavior docs have been nice to have but when I open an existing bsf I'm not sure where to place the new items and what old/conflicting items to delete.
Posted: Wed Aug 11, 2010 2:53 pm
by pipfromslitherine
The sequence doesn't matter in the script, so long as you trigger things in the turn you want to (using GetTurn() ). StartTurn is a function called at the beginning of every turn, so you can trigger UI as and when you want.
Cheers
Pip
Posted: Wed Aug 11, 2010 3:02 pm
by adherbal
I guess I was looking for a list of don'ts as much as do's. Trying to cut down on the number of "my campaign crashed, why?" posts.
I'm guessing most crashes will be related to syntax errors? That's something you'll have to get used to.
Posted: Wed Aug 11, 2010 3:05 pm
by pipfromslitherine
As the tutorial states, it's generally best to develop scenarios in a window so you can see any fatal errors which might pop up. If you come across anything you do which causes an error without a helpful message, let me know and I will add in a check, but most things should be covered, as I try and make it as foolproof as I can, as they are the same tools we use!
Cheers
Pip
Posted: Wed Aug 11, 2010 3:24 pm
by junk2drive
When I hear the boink, I alt tab and look at the message. They have been helpful.
Posted: Wed Aug 11, 2010 3:45 pm
by adherbal
Agree on running windowed when working on scripts. It allows you to see game, debug windows & script simultaniously.
Posted: Wed Aug 11, 2010 4:38 pm
by insidius
Is there a way to make the starting turn random (for multiplayer games)? i.e. US might go first or Germans might go first.
Posted: Wed Aug 11, 2010 4:44 pm
by adherbal
Multiplayer currently does not support any scripting.
Posted: Wed Aug 11, 2010 4:53 pm
by pipfromslitherine
Well, it does, but the problem is that the current MP implementation is very twitchy if you make any scripting errors, or even do something which is not 'deterministic' in terms of the playback.
I am currently working on a new approach that will allow for much easier script usage and such, but it's very complex, and we also want to make it backward compatible so it won't force people to restart games. So it's no iminent, but just giving you a heads-up.
Cheers
Pip