Air raids?[message #160630]
|
Fri, 05 October 2007 13:18
|
|
Tyco |
|
Messages:188
Registered:September 2001 Location: Be'er Sheva, Israel |
|
|
Whatever happened to the air raids? Is there a way to recover that script from the source code?
Report message to a moderator
|
Staff Sergeant
|
|
|
|
|
|
|
|
Re: Air raids?[message #295739]
|
Mon, 26 December 2011 21:25
|
|
public1983 |
|
Messages:125
Registered:February 2006 |
|
|
I have found a sometimes endless loop in the vanilla air-raid code, which has not been fixed in 1.13 so far.
INT32 PickRandomLocationAtMinSpacesAway( INT32 sGridNo, INT16 sMinValue, INT16 sRandomVar )
{
INT32 sNewGridNo = NOWHERE;
INT16 sX, sY, sNewX, sNewY;
INT32 cnt = 0;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"PickRandomLocationAtMinSpacesAway");
sX = CenterX( sGridNo );
sY = CenterY( sGridNo );
while(TileIsOutOfBounds(sNewGridNo))
{
sNewX = sX + sMinValue + (INT16)Random( sRandomVar );
sNewY = sY + sMinValue + (INT16)Random( sRandomVar );
if ( Random( 2 ) )
{
sNewX = -1 * sNewX;
}
if ( Random( 2 ) )
{
sNewY = -1 * sNewY;
}
// Make gridno....
sNewGridNo = GETWORLDINDEXFROMWORLDCOORDS( sNewY, sNewX );
// Check if visible on screen....
if(!GridNoOnVisibleWorldTile(sNewGridNo))//dnl ch56 141009
sNewGridNo = NOWHERE;
cnt++;
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("PickRandomLocationAtMinSpacesAway: grid no = %d",sNewGridNo));
return( sNewGridNo );
}
If sX and sY are too great, i.e. the target is too close to the lower right corner of the map this function never returns. It is called before every dive. My proposal:
static INT16 PickRandomLocationAtMinSpacesAway(INT16 sGridNo, INT16 sMinValue, INT16 sRandomVar)
{
INT16 sNewGridNo = NOWHERE;
INT16 sX, sY, sNewX, sNewY;
sX = CenterX( sGridNo );
sY = CenterY( sGridNo );
while( sNewGridNo == NOWHERE )
{
//HB: never return if sX or sY too great, i.e. about sMinValue near the upper bounds?
if ( Random( 2 ) )
{
sNewX = sX + sMinValue + (INT16)Random( sRandomVar );
}
else
{
sNewX = sX - sMinValue - (INT16)Random( sRandomVar );
}
if ( Random( 2 ) )
{
sNewY = sY + sMinValue + (INT16)Random( sRandomVar );
}
else
{
sNewY = sY - sMinValue - (INT16)Random( sRandomVar );
}
// Make gridno....
sNewGridNo = GETWORLDINDEXFROMWORLDCOORDS( sNewY, sNewX );
// Check if visible on screen....
if ( !GridNoOnVisibleWorldTile( sNewGridNo ) )
{
sNewGridNo = NOWHERE;
}
}
return( sNewGridNo );
}
I see here is not really the right place, but I do not want to bug anybody with PMs either.
I am experimenting with air raids with Stracciatella. My notion of a good integration into the strategic setting is that they are called before attack group arrivals to discourage player mercs to lie in ambush for defending a town sector. This makes perfectly sense, when passive militia defense is discouraged by greater loyalty penalization of losses, i.e. only Pyrrhic victories for passive defence. The time window is between 10 and 1 minutes before the attack, so the player has not the time to both dodge and defend.
The risk of friendly fire seemed unrealistic to me in the last realization of air raids in 1.13. I see, though, that they can be stopped by SAMs. I do not see a reactivation of SAM repair without more technical insight. In Vanilla the damaged radar leaves a pile of debris, but there must be a "damaged radar" tile somewhere in the tilesets to replace the radar after damage by a bomb. I did not locate it so far. Only thus the commented code makes sense to me. Without, it is a decision between a silent take out of the SAM with a well placed bomb and no watchman injured, so it is never repaired but also does not work for the player, or otherwise an occupation of the SAM defense for running cost and the benefit of less air raids.
Sorry for the long post. I am happy to see this topical.
[Updated on: Mon, 26 December 2011 21:26] by Moderator Report message to a moderator
|
Sergeant
|
|
|
|
|
|
Re: Air raids?[message #295954]
|
Thu, 29 December 2011 22:32
|
|
Callahan |
|
Messages:63
Registered:May 2006 Location: Germany |
|
|
I am using air raids on enemies extensively, but do not allow enemy air raids.
I had no crashes, and the only difference between my own and enemy air raids is the targeting function.
So there 'should' be no crashes on enemy raids.
But if I
Report message to a moderator
|
Corporal JA2 DoM Creator
|
|
|