-reduced # of guys getting sniper orders - restricted to just the onguard and stationary guys. Hopefully, this will keep them out of the city assault teams & patrols.

-added some more raise weapon code for snipers who have nothing to do.  This shouldn't really be required since less snipers will be present in assaults.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@259 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
MaddMugsy
2006-06-18 02:29:45 +00:00
parent 2a98cc4994
commit 8f53acf606
2 changed files with 62 additions and 31 deletions
+11 -9
View File
@@ -127,20 +127,22 @@ void DecideToAssignSniperOrders( SOLDIERCREATE_STRUCT * pp )
{
//Madd: decide if soldier should be a sniper
// 30% of anybody w/a scope and decent range being a sniper, 80% chance of a guy w/a sniper rifle being a sniper
if ( (GunRange(&pp->Inv[HANDPOS]) >= 40 && IsScoped(&pp->Inv[HANDPOS]) && Random(100) < 30) || ( Weapon[pp->Inv[HANDPOS].usItem].ubWeaponType == GUN_SN_RIFLE && Random(100) < 80 ) )
if ( pp->bOrders == STATIONARY || pp->bOrders == ONGUARD )
{
pp->bOrders = SNIPER;
// 30% of anybody w/a scope and decent range being a sniper, 80% chance of a guy w/a sniper rifle being a sniper
if ( (GunRange(&pp->Inv[HANDPOS]) >= 40 && IsScoped(&pp->Inv[HANDPOS]) && Random(100) < 30) || ( Weapon[pp->Inv[HANDPOS].usItem].ubWeaponType == GUN_SN_RIFLE && Random(100) < 80 ) )
{
pp->bOrders = SNIPER;
if (pp->bAttitude == BRAVEAID)
pp->bAttitude = BRAVESOLO;
if (pp->bAttitude == BRAVEAID)
pp->bAttitude = BRAVESOLO;
if (pp->bAttitude == CUNNINGAID)
pp->bAttitude = CUNNINGSOLO;
if (pp->bAttitude == CUNNINGAID)
pp->bAttitude = CUNNINGSOLO;
DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("Sniper Created") );
DebugMsg ( TOPIC_JA2AI , DBG_LEVEL_3 , String("Sniper Created") );
}
}
}
SOLDIERTYPE* TacticalCreateSoldier( SOLDIERCREATE_STRUCT *pCreateStruct, UINT8 *pubID )
+51 -22
View File
@@ -981,21 +981,6 @@ BOOLEAN fCivilian = (PTR_CIVILIAN && (pSoldier->ubCivilianGroup == NON_CIV_GROUP
}
/////////////////////////////////////////////////////////////////////////////
// SNIPERS GET TO COVER, EVERYONE INTO THE DARK
/////////////////////////////////////////////////////////////////////////////
if ( (pSoldier->bOrders == SNIPER || InLightAtNight( pSoldier->sGridNo, pSoldier->bLevel )) && pSoldier->bActionPoints >= MinPtsToMove(pSoldier) )
{
pSoldier->usActionData = FindNearbyDarkerSpot( pSoldier );
if ( pSoldier->usActionData != NOWHERE )
{
// move as if leaving water or gas
return( AI_ACTION_LEAVE_WATER_GAS );
}
}
////////////////////////////////////////////////////////////////////////////
// RANDOM PATROL: determine % chance to start a new patrol route
////////////////////////////////////////////////////////////////////////////
@@ -1029,7 +1014,7 @@ BOOLEAN fCivilian = (PTR_CIVILIAN && (pSoldier->ubCivilianGroup == NON_CIV_GROUP
*/
case FARPATROL: iChance += +25; break;
case SEEKENEMY: iChance += -10; break;
case SNIPER: iChance += -15; break;
case SNIPER: iChance += -10; break;
}
// modify chance of patrol (and whether it's a sneaky one) by attitude
@@ -1099,7 +1084,7 @@ BOOLEAN fCivilian = (PTR_CIVILIAN && (pSoldier->ubCivilianGroup == NON_CIV_GROUP
case POINTPATROL: iChance = -10; break;
case FARPATROL: iChance += +20; break;
case SEEKENEMY: iChance += -10; break;
case SNIPER: iChance += -15; break;
case SNIPER: iChance += -10; break;
}
// modify for attitude
@@ -1343,7 +1328,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
if ((pSoldier->bDirection != ubNoiseDir) && PythSpacesAway(pSoldier->sGridNo,sNoiseGridNo) <= MaxDistanceVisible() )
{
// set base chance according to orders
if ((pSoldier->bOrders == STATIONARY) || (pSoldier->bOrders == ONGUARD) || pSoldier->bOrders == SNIPER )
if ((pSoldier->bOrders == STATIONARY) || (pSoldier->bOrders == ONGUARD) )
iChance = 50;
else // all other orders
iChance = 25;
@@ -1359,7 +1344,13 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
sprintf((CHAR *)tempstr,"%s - TURNS TOWARDS NOISE to face direction %d",pSoldier->name,pSoldier->usActionData);
AIPopMessage(tempstr);
#endif
if ( pSoldier->bOrders == SNIPER )
{
if (!gfTurnBasedAI || GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) <= pSoldier->bActionPoints)
{
pSoldier->bNextAction = AI_ACTION_RAISE_GUN;
}
}
return(AI_ACTION_CHANGE_FACING);
}
}
@@ -1542,7 +1533,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
case POINTPATROL: break;
case FARPATROL: iChance += 10; break;
case SEEKENEMY: iChance += 25; break;
case SNIPER: iChance += -15; break;
case SNIPER: iChance += -10; break;
}
// modify chance of patrol (and whether it's a sneaky one) by attitude
@@ -1688,7 +1679,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
case POINTPATROL: iChance += -10; break;
case FARPATROL: break;
case SEEKENEMY: iChance += 10; break;
case SNIPER: iChance += -15; break;
case SNIPER: iChance += -10; break;
}
// modify chance of patrol (and whether it's a sneaky one) by attitude
@@ -1894,6 +1885,8 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
(pSoldier->bNeutral && gTacticalStatus.fCivGroupHostile[pSoldier->ubCivilianGroup] == CIV_GROUP_NEUTRAL) ||
(pSoldier->ubBodyType >= FATCIV && pSoldier->ubBodyType <= CRIPPLECIV) ) );
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("DecideActionRed: soldier orders = %d",pSoldier->bOrders));
// if we have absolutely no action points, we can't do a thing under RED!
if (!pSoldier->bActionPoints)
{
@@ -3137,10 +3130,24 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"decideactionred: radio red alert?");
sprintf((CHAR *)tempstr,"%s - TURNS TOWARDS CLOSEST ENEMY to face direction %d",pSoldier->name,pSoldier->usActionData);
AIPopMessage(tempstr);
#endif
if ( pSoldier->bOrders == SNIPER )
{
if (!gfTurnBasedAI || GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) <= pSoldier->bActionPoints)
{
pSoldier->bNextAction = AI_ACTION_RAISE_GUN;
}
}
return(AI_ACTION_CHANGE_FACING);
}
}
else if ( pSoldier->bDirection == ubOpponentDir && pSoldier->bOrders == SNIPER )
{
if (!gfTurnBasedAI || GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) <= pSoldier->bActionPoints)
{
return AI_ACTION_RAISE_GUN;
}
}
}
}
@@ -3321,9 +3328,31 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"decideactionred: radio red alert?");
////////////////////////////////////////////////////////////////////////////
// If sniper and nothing else to do then raise gun, and if that doesn't find somebody then goto green
////////////////////////////////////////////////////////////////////////////
if ( pSoldier->bOrders == SNIPER )
{
if ( pSoldier->sniper == 0 )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("DecideActionRed: sniper raising gun..."));
if (!gfTurnBasedAI || GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) <= pSoldier->bActionPoints)
{
pSoldier->sniper = 1;
return AI_ACTION_RAISE_GUN;
}
}
else
{
pSoldier->sniper = 0;
pSoldier->bBypassToGreen = 30;
return(DecideActionGreen(pSoldier));
}
}
////////////////////////////////////////////////////////////////////////////
// DO NOTHING: Not enough points left to move, so save them for next turn
////////////////////////////////////////////////////////////////////////////
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("DecideActionRed: do nothing at all..."));
#ifdef DEBUGDECISIONS
AINameMessage(pSoldier,"- DOES NOTHING (RED)",1000);
#endif