How to set shots remaining to zero?
Moderators: Slitherine Core, BA Moderators
-
- Lieutenant-General - Do 217E
- Posts: 3151
- Joined: Fri Apr 06, 2012 6:18 pm
- Location: Palau
How to set shots remaining to zero?
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!
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!
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
-
- Site Admin
- Posts: 9881
- Joined: Wed Mar 23, 2005 10:35 pm
Re: How to set shots remaining to zero?
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
Cheers
Pip
-
- Lieutenant-General - Do 217E
- Posts: 3151
- Joined: Fri Apr 06, 2012 6:18 pm
- Location: Palau
Re: How to set shots remaining to zero?
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!
What would that look like in code form? Where's the smartest place to put it?
Thanks Pip!
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
-
- Site Admin
- Posts: 9881
- Joined: Wed Mar 23, 2005 10:35 pm
Re: How to set shots remaining to zero?
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

You could then just add extra code to ALL_INDIRECT_FIRE
Cheers
Pip
-
- Lieutenant-General - Do 217E
- Posts: 3151
- Joined: Fri Apr 06, 2012 6:18 pm
- Location: Palau
Re: How to set shots remaining to zero?
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?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.
At the moment, am still confused... Due to my lack of intelligence rather than your explanation... Sorry...

SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
-
- Site Admin
- Posts: 9881
- Joined: Wed Mar 23, 2005 10:35 pm
Re: How to set shots remaining to zero?
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
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
-
- Lieutenant-General - Do 217E
- Posts: 3151
- Joined: Fri Apr 06, 2012 6:18 pm
- Location: Palau
Re: How to set shots remaining to zero?
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...

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...

SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
-
- Site Admin
- Posts: 9881
- Joined: Wed Mar 23, 2005 10:35 pm
Re: How to set shots remaining to zero?
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
// 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
-
- Captain - Heavy Cruiser
- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
Re: How to set shots remaining to zero?
Using Tick function is not greedy? This would not it be better to change the bombard script?
With add into
With add into
Code: Select all
FUNCTION ALL_INDIRECT_FIRE(me, tilex, tiley)
{
....
if (IsUnitType(me, "MYUNIT") == 1)
{
SetAttrib(me, "Shots", 0);
}
}
“Take care, my friend; watch your six, and do one more roll… just for me.”
-
- Site Admin
- Posts: 9881
- Joined: Wed Mar 23, 2005 10:35 pm
Re: How to set shots remaining to zero?
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
Doing normal logic in Tick will not affect game performance

Cheers
Pip
-
- Captain - Heavy Cruiser
- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
Re: How to set shots remaining to zero?
Oh yeah I know that.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

Moreover it would be possible for nice modders

I know this is a lot of work but less than for the modder (comparing each script one by one



“Take care, my friend; watch your six, and do one more roll… just for me.”
-
- Site Admin
- Posts: 9881
- Joined: Wed Mar 23, 2005 10:35 pm
Re: How to set shots remaining to zero?
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

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