How to set shots remaining to zero?

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

How to set shots remaining to zero?

Post 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!
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
pipfromslitherine
Site Admin
Site Admin
Posts: 9881
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to set shots remaining to zero?

Post 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
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: How to set shots remaining to zero?

Post 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!
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
pipfromslitherine
Site Admin
Site Admin
Posts: 9881
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to set shots remaining to zero?

Post 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
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: How to set shots remaining to zero?

Post 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... :oops:
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
pipfromslitherine
Site Admin
Site Admin
Posts: 9881
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to set shots remaining to zero?

Post 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
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: How to set shots remaining to zero?

Post 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... :oops:
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
pipfromslitherine
Site Admin
Site Admin
Posts: 9881
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to set shots remaining to zero?

Post 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
Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: How to set shots remaining to zero?

Post 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);
	}
}
“Take care, my friend; watch your six, and do one more roll… just for me.”
pipfromslitherine
Site Admin
Site Admin
Posts: 9881
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to set shots remaining to zero?

Post 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
Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: How to set shots remaining to zero?

Post 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. :mrgreen:

Moreover it would be possible for nice modders :mrgreen: 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 :( ). :oops: :mrgreen:
“Take care, my friend; watch your six, and do one more roll… just for me.”
pipfromslitherine
Site Admin
Site Admin
Posts: 9881
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to set shots remaining to zero?

Post 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
Post Reply

Return to “Battle Academy : Modders Corner ”