Page 1 of 1
How to set shots remaining to zero?
Posted: Tue May 21, 2013 7:16 am
by GottaLove88s
Gents, Does anybody know how to set shots remaining to zero?
At the moment, the 152mm Coastal Guns in Dieppe can fire a bombard shot, taking out an Allied landing craft if they're well targeted, but they also seem to keep their full number of 'shots remaining' (they can't direct fire, if they bombard the same turn, but they can use them in response fire during the Allied turn). I'd like to fix that, so if Coastal Guns bombard, they lose their remaining shots...
Thanks!
Re: How to set shots remaining to zero?
Posted: Tue May 21, 2013 3:51 pm
by pipfromslitherine
Hmmm - tricky! You could add a check in Tick to set Shots to zero if the AP for a gun drops to zero (which is a side effect of bombarding).
Cheers
Pip
Re: How to set shots remaining to zero?
Posted: Tue May 21, 2013 4:03 pm
by GottaLove88s
Could I do something to INDIRECTFIRE.BSF instead? Maybe add some condition that if the unit firing is a Coastal Gun, then set shots remaining to zero...?
What would that look like in code form? Where's the smartest place to put it?
Thanks Pip!
Re: How to set shots remaining to zero?
Posted: Tue May 21, 2013 4:08 pm
by pipfromslitherine
I was trying to work out an approach that wouldn't require you to over-ride any scripts. You can of course have a custom version of the script

.
You could then just add extra code to ALL_INDIRECT_FIRE
Cheers
Pip
Re: How to set shots remaining to zero?
Posted: Tue May 21, 2013 4:35 pm
by GottaLove88s
pipfromslitherine wrote:I was trying to work out an approach that wouldn't require you to over-ride any scripts. You can of course have a custom version of the script

.
Approach without overrides definitely much better please... but when you started with "Hmmm - tricky!", my 'cannot code to save my life' brain started ringing complexity alarm bells... Happy to attempt whichever method you recommend?
At the moment, am still confused... Due to my lack of intelligence rather than your explanation... Sorry...

Re: How to set shots remaining to zero?
Posted: Tue May 21, 2013 5:25 pm
by pipfromslitherine
pseudocode alert! But in theory, something like this in Tick should work
if( is a gun )
if(AP == 0)
SetAttrib(Shots, 0) ;
when they fire indirect their AP is set to zero, and I don't think they can move (so nothing else should affect their AP). Only issue would be if their AP defaults to zero, but I guess you could hack that by setting it to be non-zero in a PostStartTurn pass!
Cheers
Pip
Re: How to set shots remaining to zero?
Posted: Wed May 22, 2013 2:04 pm
by GottaLove88s
Thanks Pip, Psuedocode appreciated...
Can you recommend any function that already sits within Tick, where I could review how it works, to understand the general idea, while sprinkling on your pseudocode?
I've put an 'L' plate on the back of my MacBook, honest...

Re: How to set shots remaining to zero?
Posted: Wed May 22, 2013 3:24 pm
by pipfromslitherine
Pretty much any scenario will have a Tick function in it, or (if your scenario doesn't) just add
// called every game tick.
// You would tend to use this for reactive logic and
// win situations etc
FUNCTION Tick(side)
{
}
to your BSF file and then insert code that you want to run every tick.
Cheers
Pip
Re: How to set shots remaining to zero?
Posted: Wed May 22, 2013 4:11 pm
by Amaris
Using Tick function is not greedy? This would not it be better to change the bombard script?
With add into
Code: Select all
FUNCTION ALL_INDIRECT_FIRE(me, tilex, tiley)
{
....
if (IsUnitType(me, "MYUNIT") == 1)
{
SetAttrib(me, "Shots", 0);
}
}
Re: How to set shots remaining to zero?
Posted: Wed May 22, 2013 5:45 pm
by pipfromslitherine
Using custom scripts has all kinds of issues (not least if we update the main game and suddenly your mod is incompatible!).
Doing normal logic in Tick will not affect game performance

. The only things that tend to cause slowdowns are large changes to LOS data, or adding/removing lots of objects.
Cheers
Pip
Re: How to set shots remaining to zero?
Posted: Thu May 23, 2013 3:47 pm
by Amaris
pipfromslitherine wrote:Using custom scripts has all kinds of issues (not least if we update the main game and suddenly your mod is incompatible!).
Doing normal logic in Tick will not affect game performance

. The only things that tend to cause slowdowns are large changes to LOS data, or adding/removing lots of objects.
Cheers
Pip
Oh yeah I know that.
Moreover it would be possible for nice modders

to have a list of changed files in the patch log?
I know this is a lot of work but less than for the modder (comparing each script one by one

).

Re: How to set shots remaining to zero?
Posted: Thu May 23, 2013 5:14 pm
by pipfromslitherine
To be honest it's not really about whether modders can fix it, but more about dealing with people who have downloaded (esp "official" mods) that then don't work (usually with a crash error). While we try and test most official mods for this kind of thing, it's something of a bother. So basically if something simple can be dealt with without doing main script tweaks then I tend to encourage people toward it
Listing every change in the scripts just isn't practical. If you are having to compare scripts, then I would recommend downloading something like WinDiff which can do whole folders at once and show you the differences.
Cheers
Pip