How to restrict units from turning?

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 restrict units from turning?

Post by GottaLove88s »

Is there a way to prevent certain units (or all units of a given class, eg.152mm Coast Guns) from turning?

And then limiting their firing angle to, say, 60 degrees either side of front? (ie. blind to the sides and behind).

The 152mm Coastal Guns that I've added to Ouistreham and Sword beaches are, frankly, too nimble at shooting behind and to their sides, so they're proving indecently good at taking out tanks that should be able to sneak up from non-facing directions... Players would be able to choose the facing direction during deployment, but once they're deployed, that's the way they'll face...
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 restrict units from turning?

Post by Amaris »

GottaLove88s wrote:Is there a way to prevent certain units (or all units of a given class, eg.152mm Coast Guns) from turning?
Yes with changing the script TURN.BSF:

original CHECK_ALL_TURN:

Code: Select all

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

	// turns are free
	ret = 0 ;
	
	if( GetDistanceFromUnit(me, tilex, tiley) != 1)
	{
		ret = -2 ;
	}
	
	// StartString() ;
	// PrintStringLiteral("LOS CHECK") ;
	// PrintInt( GetUnitLOS( me, tilex, tiley) ) ;
	// AddTileTooltip() ;
	
	// ret = -1 ;
	
	return ret ;
}
So modify it for have :

Code: Select all

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

	// turns are free
	ret = 0 ;
	
	if( GetDistanceFromUnit(me, tilex, tiley) != 1)
	{
		ret = -2 ;
	}
	
	if ((IsUnitType(me, "XXXXXXX") == 1)
	{
		ret = -2;
	}
	
	// StartString() ;
	// PrintStringLiteral("LOS CHECK") ;
	// PrintInt( GetUnitLOS( me, tilex, tiley) ) ;
	// AddTileTooltip() ;
	
	// ret = -1 ;
	
	return ret ;
}
}
Where 'XXXX' is the name of desired unit in squad.csv.
“Take care, my friend; watch your six, and do one more roll… just for me.”
Post Reply

Return to “Battle Academy : Modders Corner ”