WARNING: I haven't tested these changes yet, since I'm still at work :p I'll be testing them and making updates as needed tonight.

- updated breaklight effect to use the radius and duration values from Explosives.xml
- updated tracer bullet lighting effect (will probably require more tweaking)
- updated AI - when trapped in gas in Insane the AI goes nuts instead of getting scared.  AI in all levels is more likely to use autofire over burst/single fire when in gas (panicking).


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@190 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
MaddMugsy
2006-06-08 00:14:23 +00:00
parent ea7e68297c
commit 21bc685f8d
7 changed files with 69 additions and 80 deletions
+2 -2
View File
@@ -43,13 +43,13 @@ UINT16 MovementMode[LAST_MOVEMENT_ACTION + 1][NUM_URGENCY_STATES] =
{WALKING, WALKING, WALKING }, // AI_ACTION_RANDOM_PATROL {WALKING, WALKING, WALKING }, // AI_ACTION_RANDOM_PATROL
{WALKING, RUNNING, RUNNING }, // AI_ACTION_SEEK_FRIEND {WALKING, RUNNING, RUNNING }, // AI_ACTION_SEEK_FRIEND
{WALKING, RUNNING, RUNNING }, // AI_ACTION_SEEK_OPPONENT {WALKING, WALKING, SWATTING }, // AI_ACTION_SEEK_OPPONENT
{RUNNING, RUNNING, RUNNING }, // AI_ACTION_TAKE_COVER {RUNNING, RUNNING, RUNNING }, // AI_ACTION_TAKE_COVER
{WALKING, RUNNING, RUNNING }, // AI_ACTION_GET_CLOSER {WALKING, RUNNING, RUNNING }, // AI_ACTION_GET_CLOSER
{WALKING, WALKING, WALKING }, // AI_ACTION_POINT_PATROL, {WALKING, WALKING, WALKING }, // AI_ACTION_POINT_PATROL,
{WALKING, RUNNING, RUNNING }, // AI_ACTION_LEAVE_WATER_GAS, {WALKING, RUNNING, RUNNING }, // AI_ACTION_LEAVE_WATER_GAS,
{WALKING, RUNNING, RUNNING }, // AI_ACTION_SEEK_NOISE, {WALKING, WALKING, SWATTING }, // AI_ACTION_SEEK_NOISE,
{RUNNING, RUNNING, RUNNING }, // AI_ACTION_ESCORTED_MOVE, {RUNNING, RUNNING, RUNNING }, // AI_ACTION_ESCORTED_MOVE,
{WALKING, RUNNING, RUNNING }, // AI_ACTION_RUN_AWAY, {WALKING, RUNNING, RUNNING }, // AI_ACTION_RUN_AWAY,
+19 -5
View File
@@ -1867,7 +1867,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// SWITCH TO GREEN: determine if soldier acts as if nothing at all was wrong // SWITCH TO GREEN: determine if soldier acts as if nothing at all was wrong
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
if ((INT16)PreRandom(100) < 1) if ((INT16)PreRandom(100) < 30 )
{ {
#ifdef RECORDNET #ifdef RECORDNET
fprintf(NetDebugFile,"\tDecideActionYellow: guynum %d ignores noise, switching to GREEN AI...\n",pSoldier->ubID); fprintf(NetDebugFile,"\tDecideActionYellow: guynum %d ignores noise, switching to GREEN AI...\n",pSoldier->ubID);
@@ -3625,7 +3625,13 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier)
} }
// REALLY tired, can't get away, force soldier's morale to hopeless state // REALLY tired, can't get away, force soldier's morale to hopeless state
pSoldier->bAIMorale = MORALE_HOPELESS; if ( gGameOptions.ubDifficultyLevel == DIF_LEVEL_INSANE )
{
pSoldier->bBreath = pSoldier->bBreathMax; //Madd: backed into a corner, so go crazy like a wild animal...
pSoldier->bAIMorale = MORALE_FEARLESS;
}
else
pSoldier->bAIMorale = MORALE_HOPELESS;
} }
} }
@@ -3668,7 +3674,13 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier)
// GIVE UP ON LIFE! MERCS MUST HAVE JUST CORNERED A HELPLESS ENEMY IN A // GIVE UP ON LIFE! MERCS MUST HAVE JUST CORNERED A HELPLESS ENEMY IN A
// GAS FILLED ROOM (OR IN WATER MORE THAN 25 TILES FROM NEAREST LAND...) // GAS FILLED ROOM (OR IN WATER MORE THAN 25 TILES FROM NEAREST LAND...)
pSoldier->bAIMorale = MORALE_HOPELESS; if ( bInGas && gGameOptions.ubDifficultyLevel == DIF_LEVEL_INSANE )
{
pSoldier->bBreath = pSoldier->bBreathMax;
pSoldier->bAIMorale = MORALE_FEARLESS; // Can't move, can't get away, go nuts instead...
}
else
pSoldier->bAIMorale = MORALE_HOPELESS;
} }
// offer surrender? // offer surrender?
@@ -4550,7 +4562,7 @@ bCanAttack = FALSE;
} }
} }
if (IsGunAutofireCapable( pSoldier, BestAttack.bWeaponIn /*, FALSE*/ ) && if (IsGunAutofireCapable( pSoldier, BestAttack.bWeaponIn ) &&
!(Menptr[BestShot.ubOpponent].bLife < OKLIFE) && // don't burst at downed targets !(Menptr[BestShot.ubOpponent].bLife < OKLIFE) && // don't burst at downed targets
(( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 1 && (( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 1 &&
BestAttack.ubAimTime != BURSTING ) || Weapon[pSoldier->inv[BestAttack.bWeaponIn].usItem].NoSemiAuto) ) BestAttack.ubAimTime != BURSTING ) || Weapon[pSoldier->inv[BestAttack.bWeaponIn].usItem].NoSemiAuto) )
@@ -4591,10 +4603,12 @@ bCanAttack = FALSE;
case ATTACKSLAYONLY:iChance += 30; break; case ATTACKSLAYONLY:iChance += 30; break;
} }
if ( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 50 ) if ( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 50 )
iChance += 30; iChance += 30;
if ( bInGas )
iChance += 50; //Madd: extra chance of going nuts and autofiring if stuck in gas
// increase chance based on proximity and difficulty of enemy // increase chance based on proximity and difficulty of enemy
if ( PythSpacesAway( pSoldier->sGridNo, BestAttack.sTarget ) < 15 ) if ( PythSpacesAway( pSoldier->sGridNo, BestAttack.sTarget ) < 15 )
{ {
+1 -1
View File
@@ -2917,7 +2917,7 @@ void HandleExplosionQueue( void )
} }
else if ( pObj->usBombItem == TRIP_FLARE ) else if ( pObj->usBombItem == TRIP_FLARE )
{ {
NewLightEffect( sGridNo, LIGHT_FLARE_MARK_1 ); NewLightEffect( sGridNo, Explosive[pObj->usItem].ubDuration, Explosive[pObj->usItem].ubStartRadius );
RemoveItemFromPool( sGridNo, gWorldBombs[ uiWorldBombIndex ].iItemIndex, ubLevel ); RemoveItemFromPool( sGridNo, gWorldBombs[ uiWorldBombIndex ].iItemIndex, ubLevel );
} }
else else
+36 -48
View File
@@ -96,12 +96,10 @@ void UpdateLightingSprite( LIGHTEFFECT *pLight )
} }
INT32 NewLightEffect( INT16 sGridNo, INT8 bType ) INT32 NewLightEffect( INT16 sGridNo, UINT8 ubDuration, UINT8 ubStartRadius )
{ {
LIGHTEFFECT *pLight; LIGHTEFFECT *pLight;
INT32 iLightIndex; INT32 iLightIndex;
UINT8 ubDuration=0;
UINT8 ubStartRadius=0;
if( ( iLightIndex = GetFreeLightEffect() )==(-1) ) if( ( iLightIndex = GetFreeLightEffect() )==(-1) )
return(-1); return(-1);
@@ -112,20 +110,9 @@ INT32 NewLightEffect( INT16 sGridNo, INT8 bType )
// Set some values... // Set some values...
pLight->sGridNo = sGridNo; pLight->sGridNo = sGridNo;
pLight->bType = bType;
pLight->iLight = -1; pLight->iLight = -1;
pLight->uiTimeOfLastUpdate = GetWorldTotalSeconds( ); pLight->uiTimeOfLastUpdate = GetWorldTotalSeconds( );
switch( bType )
{
case LIGHT_FLARE_MARK_1:
ubDuration = 6;
ubStartRadius = 6;
break;
}
pLight->ubDuration = ubDuration; pLight->ubDuration = ubDuration;
pLight->bRadius = ubStartRadius; pLight->bRadius = ubStartRadius;
pLight->bAge = 0; pLight->bAge = 0;
@@ -139,7 +126,7 @@ INT32 NewLightEffect( INT16 sGridNo, INT8 bType )
//Play the breaklight sound //Play the breaklight sound
// PlayJA2Sample( BREAK_LIGHT_IGNITING, RATE_11025, SoundVolume( LOWVOLUME, sGridNo ), 1, SoundDir( sGridNo ) ); // PlayJA2Sample( BREAK_LIGHT_IGNITING, RATE_11025, SoundVolume( LOWVOLUME, sGridNo ), 1, SoundDir( sGridNo ) );
// MAdd: for some reason this crashes the game! // MAdd: for some reason this crashes the game!
return( iLightIndex ); return( pLight->iLight );
} }
@@ -192,41 +179,41 @@ void DecayLightEffects( UINT32 uiTime )
// ATE: Do this every so ofte, to acheive the effect we want... // ATE: Do this every so ofte, to acheive the effect we want...
if ( ( uiTime - pLight->uiTimeOfLastUpdate ) > 350 ) if ( ( uiTime - pLight->uiTimeOfLastUpdate ) > 350 )
{ {
usNumUpdates = ( UINT16 ) ( ( uiTime - pLight->uiTimeOfLastUpdate ) / 350 ); usNumUpdates = ( UINT16 ) ( ( uiTime - pLight->uiTimeOfLastUpdate ) / 350 );
pLight->uiTimeOfLastUpdate = uiTime; pLight->uiTimeOfLastUpdate = uiTime;
for ( cnt2 = 0; cnt2 < usNumUpdates; cnt2++ ) for ( cnt2 = 0; cnt2 < usNumUpdates; cnt2++ )
{ {
pLight->bAge++; pLight->bAge++;
// if this cloud remains effective (duration not reached) // if this cloud remains effective (duration not reached)
if ( pLight->bAge < pLight->ubDuration) if ( pLight->bAge < pLight->ubDuration)
{ {
// calculate the new cloud radius // calculate the new cloud radius
// cloud expands by 1 every turn outdoors, and every other turn indoors // cloud expands by 1 every turn outdoors, and every other turn indoors
if ( ( pLight->bAge % 2 ) ) if ( ( pLight->bAge % 2 ) )
{ {
pLight->bRadius--; pLight->bRadius--;
} }
if ( pLight->bRadius == 0 ) if ( pLight->bRadius == 0 )
{ {
// Delete... // Delete...
fDelete = TRUE; fDelete = TRUE;
break; break;
} }
else else
{ {
UpdateLightingSprite( pLight ); UpdateLightingSprite( pLight );
} }
} }
else else
{ {
fDelete = TRUE; fDelete = TRUE;
break; break;
} }
} }
if ( fDelete ) if ( fDelete )
{ {
@@ -238,10 +225,11 @@ void DecayLightEffects( UINT32 uiTime )
} }
} }
// Handle sight here....
AllTeamsLookForAll( FALSE ); // Handle sight here....
AllTeamsLookForAll( FALSE );
} }
} }
} }
} }
+3 -3
View File
@@ -2,13 +2,14 @@
#define __LIGHT_EFFECTS #define __LIGHT_EFFECTS
/*
// Light effect types // Light effect types
enum enum
{ {
NO_LIGHT_EFFECT, NO_LIGHT_EFFECT,
LIGHT_FLARE_MARK_1, LIGHT_FLARE_MARK_1,
}; };
*/
typedef struct typedef struct
{ {
@@ -18,7 +19,6 @@ typedef struct
UINT8 bRadius; // the current radius UINT8 bRadius; // the current radius
INT8 bAge; // the number of turns light has been around INT8 bAge; // the number of turns light has been around
BOOLEAN fAllocated; BOOLEAN fAllocated;
INT8 bType;
INT32 iLight; INT32 iLight;
UINT32 uiTimeOfLastUpdate; UINT32 uiTimeOfLastUpdate;
@@ -35,7 +35,7 @@ void AddLightEffectToTile( INT8 bType, INT16 sGridNo );
void RemoveLightEffectFromTile( INT16 sGridNo ); void RemoveLightEffectFromTile( INT16 sGridNo );
INT32 NewLightEffect( INT16 sGridNo, INT8 bType ); INT32 NewLightEffect( INT16 sGridNo, UINT8 ubDuration, UINT8 ubStartRadius );
BOOLEAN SaveLightEffectsToSaveGameFile( HWFILE hFile ); BOOLEAN SaveLightEffectsToSaveGameFile( HWFILE hFile );
+6 -19
View File
@@ -138,20 +138,7 @@ ANITILE *CreateAnimationTile( ANITILE_PARAMS *pAniParams )
if ( uiFlags & ANITILE_LIGHT ) if ( uiFlags & ANITILE_LIGHT )
{ {
if ( ubAmbientLightLevel >= MIN_AMB_LEVEL_FOR_MERC_LIGHTS ) pNewAniNode->lightSprite = NewLightEffect(sGridNo, 1, 0);
{
if( ( pNewAniNode->lightSprite=LightSpriteCreate("L-R03.LHT", 0 ) )!=(-1))
{
LightSpritePower(pNewAniNode->lightSprite, TRUE);
{
INT16 sXPos, sYPos;
ConvertGridNoToCenterCellXY( sGridNo, &sXPos, &sYPos );
LightSpritePosition( pNewAniNode->lightSprite, (INT16)(sXPos/CELL_X_SIZE), (INT16)(sYPos/CELL_Y_SIZE));
}
}
}
} }
if ( ( uiFlags & ANITILE_CACHEDTILE ) ) if ( ( uiFlags & ANITILE_CACHEDTILE ) )
@@ -381,7 +368,7 @@ void DeleteAniTile( ANITILE *pAniTile )
break; break;
} }
if ( pAniNode->uiFlags & ANITILE_LIGHT && ubAmbientLightLevel >= MIN_AMB_LEVEL_FOR_MERC_LIGHTS ) if ( pAniNode->uiFlags & ANITILE_LIGHT && pAniNode->lightSprite != NULL )
{ {
LightSpriteDestroy(pAniNode->lightSprite); LightSpriteDestroy(pAniNode->lightSprite);
} }
@@ -614,10 +601,10 @@ void UpdateAniTiles( )
} }
else else
{ {
//if ( pNode->uiFlags & ANITILE_LIGHT ) if ( pNode->uiFlags & ANITILE_LIGHT && pNode->lightSprite != NULL )
//{ {
// LightSpriteDestroy(pNode->lightSprite); LightSpriteDestroy(pNode->lightSprite);
//} }
// Delete from world! // Delete from world!
DeleteAniTile( pNode ); DeleteAniTile( pNode );
+2 -2
View File
@@ -2495,7 +2495,6 @@ DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 2337"));
if ( fDoImpact ) if ( fDoImpact )
{ {
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 2403"));
if ( Item[pObject->Obj.usItem].flare ) if ( Item[pObject->Obj.usItem].flare )
{ {
//if the light object will ber created OFF the ground //if the light object will ber created OFF the ground
@@ -2507,7 +2506,8 @@ DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 2403"));
else else
{ {
// Add a light effect... // Add a light effect...
NewLightEffect( pObject->sGridNo, LIGHT_FLARE_MARK_1 );
NewLightEffect( pObject->sGridNo, Explosive[Item[pObject->Obj.usItem].ubClassIndex].ubDuration , Explosive[Item[pObject->Obj.usItem].ubClassIndex].ubStartRadius );
} }
} }
else if ( Item[ pObject->Obj.usItem ].usItemClass & IC_GRENADE ) else if ( Item[ pObject->Obj.usItem ].usItemClass & IC_GRENADE )