How to prevent bombard unit firing behind?

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 prevent bombard unit firing behind?

Post by GottaLove88s »

Is there a way to limit the arc of bombardment so that a certain unit-type can only bombard 75 degrees either side of the direction that it is facing...?
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: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to prevent bombard unit firing behind?

Post by pipfromslitherine »

Hmmm - I don't think so. There isn't really any concept of fixed orientation units IIRC. You could potentially do it by re-writing its scripts to remove any attempts to turn-to-face the enemy, but that's not a simple job :)

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 prevent bombard unit firing behind?

Post by Amaris »

Um well I would not want to contradict Pip :oops: but I think it's easy to make.

Just modify the CHECK_ALL_INDIRECT_FIRE() function in the IndirectFire.BSF:

Code: Select all

FUNCTION CHECK_ALL_INDIRECT_FIRE(me, tilex,tiley, unit)
{
int ret ;
int distance ;

	ret = -2 ;
	
	//NO REAR BOMBARD FOR MYUNIT
	
	if (IsUnitType(me, "MYUNIT") == 1)
	{
		if (GetAngleFromTile(tilex,tiley, me) > 90)
		{
			return ret;
		}
	}
	
	//END OF NO REAR BOMBARD FOR MYUNIT

		
	if ( ( GetAttrib(me, "BOMBARD_SHOTS") > 0 ) && ( GetAttrib(me, "AP") >= GetBaseAttrib (me, "AP")  ) ) 
	{			
		if( (GetUnitSide(me) != GetUnitSide(unit) ) && ( IsUnitSuppressed(me) == 0 ) )
		{	
			ret = -1 ;
			if ( ( GetAttrib (me, "Shots") >=  GetBaseAttrib (me, "Shots") ) && ( GetAttrib (me, "BombardReload") == 0 ) ) 
			{			
				distance = GetDistanceFromUnit(me, tilex, tiley) ; 
				if ( (  distance <= GetAttrib(me, "BombardRange") ) && ( distance >= GetAttrib(me, "MinRange") ) )
				{
					ret = GetAttrib(me, "BOMBARD_SHOTS") ;
				}
			}
		}
	}
	
	return ret ;
}
And remplace MYUNIT by your string unit desired.

:mrgreen:
“Take care, my friend; watch your six, and do one more roll… just for me.”
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to prevent bombard unit firing behind?

Post by pipfromslitherine »

Yes, that would work I think. But that does require custom scripts.

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 prevent bombard unit firing behind?

Post by GottaLove88s »

That's pretty cute code, Amaris! Nice.

How is GetAngleFromTile calculated? Is 0 degrees the DirectionFacing?
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
Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: How to prevent bombard unit firing behind?

Post by Amaris »

0: looking straight me
90: side
180: behind
“Take care, my friend; watch your six, and do one more roll… just for me.”
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: How to prevent bombard unit firing behind?

Post by GottaLove88s »

So all we need to do is...

...combine the limitation on bombardment angles above...
...with your limitation on turning (here -> viewtopic.php?f=104&t=42205#p397971)...
...and a defender will never be able to bombard behind.

PERFECT!!

Is there an equivalent code to put the same limitation on direct fire in AP or HE mode?
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
Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: How to prevent bombard unit firing behind?

Post by Amaris »

GottaLove88s wrote:So all we need to do is...

...combine the limitation on bombardment angles above...
...with your limitation on turning (here -> viewtopic.php?f=104&t=42205#p397971)...
...and a defender will never be able to bombard behind.

PERFECT!!

Is there an equivalent code to put the same limitation on direct fire in AP or HE mode?
Well, well. Yes I suppose.

Simply add to CHECK_UNIT_FIREAP function (Fire_AP.BSF) and CHECK_UNIT_FIREHE function (Fire_HE.BSF) the following code:

Code: Select all

   if (IsUnitType(me, "MYUNIT") == 1)
   {
      if (GetAngleFromTile(tilex,tiley, me) > 90)
      {
         return ret;
      }
   }
“Take care, my friend; watch your six, and do one more roll… just for me.”
Post Reply

Return to “Battle Academy : Modders Corner ”