Page 1 of 2
Airstrike/Artillery - Restrictions
Posted: Fri Jul 06, 2012 12:02 pm
by GottaLove88s
Pip/Iain, Is there any way that we can prevent airstrikes or artillery being used before a certain turn, eg. no airstrikes/artillery available before turn 3? A feedback has come up about experienced players knowing where the start positions are on the force selection maps. So I'd like to prevent airstrikes/artillery for the first 3 turns for the Meeting Engagement Fast N Sneaky version. Thanks!

Re: Airstrike/Artillery - Restrictions
Posted: Fri Jul 06, 2012 2:40 pm
by pipfromslitherine
You could hack it in by changing the global inside the script. E.g. if you had the USBattery bonus and wanted to alter the cooldown, you would use
SetScriptGlobal("USBattery", "gBombardment", newCooldownValue) ;
at the start of the mission, and it would then countdown as normal I believe.
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Fri Jul 06, 2012 3:54 pm
by GottaLove88s
Thanks Pip.
DOH, of course! That's a slick way to do it (doesn't require anything new and provides feedback to players of when it will be available. Ideal).
Is there a link to some sort of "dummies guide to scripting for BA"? I'll use that to drop these scripts straight into Fast & Sneaky for a v1.1.
Have a great weekend,
GL88
Re: Airstrike/Artillery - Restrictions
Posted: Fri Jul 06, 2012 5:07 pm
by enric
With the actual documentation scripting BA is a very hard task at least for me, or maybe I'm missing some docs.
The STUB engine Doc tells a general explanation and several functions but not all, the explanation is short, and a lot of things are not explained anywhere.
I found that all functions are in BATTLESCRIPT.txt with few explanation of function, and parameters.
Can you recommend some more documents?
Re: Airstrike/Artillery - Restrictions
Posted: Fri Jul 06, 2012 5:53 pm
by pipfromslitherine
We're definitely short on documentation for the engine. There are bits and pieces in the forum where I answer questions, but I think that the sheer number of things you can do with the scripting makes the documentation task very large. To some extent the best way to get some initial insight into the best way to do things is to look at existing scripts, such as the main game mission scripts.
If you can give me specifics on what you want to try and do, and where the docs fall short on helping you do that, then it gives me a place to focus any documentation time I get.
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Sat Jul 07, 2012 11:14 am
by enric
If you can give me specifics on what you want to try and do, and where the docs fall short on helping you do that, then it gives me a place to focus any documentation time I get.
Well let's try to make the script that GL asked before: to disable a out board bombard until x turn.
SetScriptGlobal("USBattery", "gBombardment", newCooldownValue) ;
I asume that USBattery should be a BSF file placed on the bonus folder...?
On the scenario.BSF use something like
FUNCTION StartTurn(side)
{
if( GetTurn() == -1 )
if( side == 0)
{
SetScriptGlobal("USBattery", "gBombardment", 3) ;
}
}
but no idea what should be put on USBattery.BSF
I will navigate inside the scripts made by others to try to understand.
The first thing I found is that these files (25pdfBattery.bsf) that they have some includes:
include "Tools.bsf"
include "Artillery.bsf"
Where are they?
Re: Airstrike/Artillery - Restrictions
Posted: Sat Jul 07, 2012 10:52 pm
by pipfromslitherine
No - you are avoiding needing to alter the bonus scripts at all by using the SetScriptGlobal command - it allows you reach into the existing scripts and tweak their globals while they run. So that segment of code would go into the StartTurn function of the mission script. Mission script files are BSF files with the same name as the mission BAM file. And that would be it (you might need an empty
FUNCTION Tick(side)
{
}
I don't recall if it is required if a script exists. And that is all you need to affect the bonus cooldowns.
Have you checked out the simple illustrated example?
viewtopic.php?f=105&t=18286 it has some useful info.
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Sun Jul 08, 2012 5:36 pm
by enric
So that segment of code would go into the StartTurn function of the mission
like:
FUNCTION StartTurn(side)
{
SetScriptGlobal("USBattery", "gBombardment", 3) ;
…
}
But do not work, the USBattery appear as placed but you can cancel and place again in the first turn.
Additional questions
At the beginning I want to check is there is a mortar and in that case place it on a tile.
What is wrong there:
if( GetTurn() == -1 )
{
if (side == 0)
{
for(i=0;i<GetUnitCount(side);i++)
{
id = GetUnitID(side, i) ;
//if ( GetAttrib(id, "name") == "US_mortar" ) // this did not work either
if ( id == 93) // is the id of US_mortar
{
SetUnitTile(id, 26, 18)
… etc.
One example of each Function on BATTLESCRIPTS will help a lot.
On Mac there no way of debug, every mistake is a BA crash.
Breakpoint exist?
Trace exists?
Re: Airstrike/Artillery - Restrictions
Posted: Sun Jul 08, 2012 9:38 pm
by pipfromslitherine
I haven't tested out the bonus global stuff, but it should work. It might depend on the order that the scripts get called, so you might need to do it at the start of turn 0.
GetAttrib returns a number, so comparing it to a string won't work. You need to use the function IsUnitType(id, "US_Mortar") (assuming US_Mortar is the typename in the squads file).
If you look at the sheer number of functions available, building a meaningful example for each one is a huge amount of work. I'm not sure who would have that kind of available bandwidth.
The fact that you can't deal with script errors and continue has been bugging me too for a while. But having it roll back all the script loading and let you carry on is very complex, so I haven't been able to make it work yet. Rest assured that a script error on PC means an error too

. You can use the Log command to output trace data as the script runs (F6 opens the debug pane when in debug mode). I'll check whether that info is in the docs (I thought it was) and add if needed.
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Mon Jul 09, 2012 8:06 am
by enric
GetAttrib returns a number
//return the value of the give attrib for the give unit
GetAttrib(id, string)
In the squads.csv file some of the fields or attributes are strings, for example: Type, assetFilename, made by,..., if not indicated, it can be assumed that in that case returns a string (I see now that's no).
-------
IsUnitType(id, string) return 1 if the string passed for that id is the name of the unit.
IsUnitType (0,"Sherman") return 1
Confusing no?, because
type is another field-attribute, for example type for Sherman is "tracked"
-------
I haven't tested out the bonus global stuff, but it should work. It might depend on the order that the scripts get called, so you might need to do it at the start of turn 0.
Nope, the US_artillery begins as assigned but you can cancel and place again in turn 1.
--------
Re: Airstrike/Artillery - Restrictions
Posted: Mon Jul 09, 2012 2:06 pm
by enric
Well I think we get a misunderstanding, the SetScriptGlobal("USBattery", "gBombardment", 5) ;, used on turn 0, set the turn to fire to 5 later but you can cancel and then reassign at two turns.
if( GetTurn() == 0 )
{
SetScriptGlobal("USBattery", "gBombardment", 5) ;
}
I would like to deactivate the icon of the us_artillery on turn 0, and be able to activate again in the turn I wish.
Re: Airstrike/Artillery - Restrictions
Posted: Mon Jul 09, 2012 3:18 pm
by pipfromslitherine
My apologies, I misread the script. The global that alters the timing is actually gCounter, gBombardment affects the delay before the attack happens once you initiate it. Sorry.
To set a bonus to its cooldown, you would use:
SetScriptGlobal("USBattery", "gCounter", 0) ;
If you do this in StartTurn at turn 0 then it should work fine (the bonus start turn functions are called before the scenario one, so you should override it correctly).
Sorry for the confusion.
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Mon Jul 09, 2012 3:30 pm
by pipfromslitherine
enric wrote:GetAttrib returns a number
//return the value of the give attrib for the give unit
GetAttrib(id, string)
In the squads.csv file some of the fields or attributes are strings, for example: Type, assetFilename, made by,..., if not indicated, it can be assumed that in that case returns a string (I see now that's no).
-------
IsUnitType(id, string) return 1 if the string passed for that id is the name of the unit.
IsUnitType (0,"Sherman") return 1
Confusing no?, because
type is another field-attribute, for example type for Sherman is "tracked"
-------
I haven't tested out the bonus global stuff, but it should work. It might depend on the order that the scripts get called, so you might need to do it at the start of turn 0.
Nope, the US_artillery begins as assigned but you can cancel and place again in turn 1.
--------
Some of the entries in the squads file are 'system' entries which are read in by different code. You can check out the SQUADDEFS.TXT file in AUTODOCS to see which ones are not attribs. Basically anything above REQUIRED is not an attrib. It's also useful to remember that the standard operators cannot work on strings (e.g. you can't do SomeFunction() == "some string").
Generally there are functions to work with the non-attrib entries in the squads file (e.g. IsUnitSquadType to check the TYPE entry for a unit).
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Tue Jul 10, 2012 10:32 am
by GottaLove88s
Thanks guys, Sorry to be a bit dim but I'm getting lost amid the clever stuff here. Which code of the above should I "copy" and where should I "paste" it to create this "wait three turns" restriction? If CoolDownValue can be set to 3 for all of US artillery, US fighter-bomber, German artillery and German Me262, and this can't be reset by the user, that's perfect.
Re: Airstrike/Artillery - Restrictions
Posted: Tue Jul 10, 2012 1:20 pm
by enric
SetScriptGlobal("USBattery", "gCounter", 0) ;
Works, thank you.
I founf USBatery.BSF also to understand why.
Another question is: should all these documents be all caps to work in the iPad?
Re: Airstrike/Artillery - Restrictions
Posted: Tue Jul 10, 2012 2:56 pm
by pipfromslitherine
Yes, ALL filenames and folder names need to be upper case if you are hacking them on to the file system yourself
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Tue Jul 10, 2012 3:36 pm
by enric
But, inside the BSF file, when referring to another document need also be in upper caps?
Ex.
include E_FUNCTIONS.BSF or could be also include e_functions.bsf
or
SetScriptGlobal("USBattery", "gCounter", 0) ; is accepted? or must be:
SetScriptGlobal("USBATTERY", "gCounter", 0) ;
On he release notes for IOS:
You should take steps on iOS to avoid creating files whose names differ only by case.
So the problem should be if there are one file named enric.bsf and another Enric.bsf, as for iOS they are different files, but it's not obliged to be all caps.
Re: Airstrike/Artillery - Restrictions
Posted: Tue Jul 10, 2012 3:45 pm
by pipfromslitherine
Ah - I see. It is case insensitive, as it is only actually referencing a stored filename so it can hook up to the correct script. So internally I make it all upper case.
Cheers
Pip
Re: Airstrike/Artillery - Restrictions
Posted: Tue Jul 10, 2012 4:09 pm
by enric
From:
https://developer.apple.com/library/ios ... index.html
File names are case-insensitive in OS X but case-sensitive in iOS. This can lead to problems when sharing files between the two using iCloud. You should take steps on iOS to avoid creating files whose names differ only by case.
Re: Airstrike/Artillery - Restrictions
Posted: Tue Jul 10, 2012 5:48 pm
by pipfromslitherine
We don't support iCloud sharing of files from iPad to Mac, so it's not an issue for BA - if that is what you are getting at?
Cheers
Pip