Page 1 of 1

How to prevent bombard unit firing behind?

Posted: Tue May 21, 2013 9:53 am
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...?

Re: How to prevent bombard unit firing behind?

Posted: Tue May 21, 2013 3:56 pm
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

Re: How to prevent bombard unit firing behind?

Posted: Wed May 22, 2013 4:05 pm
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:

Re: How to prevent bombard unit firing behind?

Posted: Wed May 22, 2013 4:08 pm
by pipfromslitherine
Yes, that would work I think. But that does require custom scripts.

Cheers

Pip

Re: How to prevent bombard unit firing behind?

Posted: Thu May 23, 2013 9:42 am
by GottaLove88s
That's pretty cute code, Amaris! Nice.

How is GetAngleFromTile calculated? Is 0 degrees the DirectionFacing?

Re: How to prevent bombard unit firing behind?

Posted: Thu May 23, 2013 9:50 am
by Amaris
0: looking straight me
90: side
180: behind

Re: How to prevent bombard unit firing behind?

Posted: Thu May 23, 2013 9:55 am
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?

Re: How to prevent bombard unit firing behind?

Posted: Thu May 23, 2013 3:52 pm
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;
      }
   }