From 21bc685f8d08338fbb9418d789df679ce11e21aa Mon Sep 17 00:00:00 2001 From: MaddMugsy Date: Thu, 8 Jun 2006 00:14:23 +0000 Subject: [PATCH] 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 --- TacticalAI/AIUtils.cpp | 4 +- TacticalAI/DecideAction.cpp | 24 +++++++-- TileEngine/Explosion Control.cpp | 2 +- TileEngine/LightEffects.cpp | 84 ++++++++++++++------------------ TileEngine/LightEffects.h | 6 +-- TileEngine/Tile Animation.cpp | 25 +++------- TileEngine/physics.cpp | 4 +- 7 files changed, 69 insertions(+), 80 deletions(-) diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp index fee29d39..da5928a2 100644 --- a/TacticalAI/AIUtils.cpp +++ b/TacticalAI/AIUtils.cpp @@ -43,13 +43,13 @@ UINT16 MovementMode[LAST_MOVEMENT_ACTION + 1][NUM_URGENCY_STATES] = {WALKING, WALKING, WALKING }, // AI_ACTION_RANDOM_PATROL {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 {WALKING, RUNNING, RUNNING }, // AI_ACTION_GET_CLOSER {WALKING, WALKING, WALKING }, // AI_ACTION_POINT_PATROL, {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, {WALKING, RUNNING, RUNNING }, // AI_ACTION_RUN_AWAY, diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index ec16eb7f..02bb448a 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -1867,7 +1867,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier) //////////////////////////////////////////////////////////////////////////// // 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 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 - 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 // 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? @@ -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 (( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 1 && BestAttack.ubAimTime != BURSTING ) || Weapon[pSoldier->inv[BestAttack.bWeaponIn].usItem].NoSemiAuto) ) @@ -4591,10 +4603,12 @@ bCanAttack = FALSE; case ATTACKSLAYONLY:iChance += 30; break; } - if ( pSoldier->inv[BestAttack.bWeaponIn].ubGunShotsLeft > 50 ) 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 if ( PythSpacesAway( pSoldier->sGridNo, BestAttack.sTarget ) < 15 ) { diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index 238ee046..6352113e 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -2917,7 +2917,7 @@ void HandleExplosionQueue( void ) } 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 ); } else diff --git a/TileEngine/LightEffects.cpp b/TileEngine/LightEffects.cpp index 39663338..62ee0778 100644 --- a/TileEngine/LightEffects.cpp +++ b/TileEngine/LightEffects.cpp @@ -96,12 +96,10 @@ void UpdateLightingSprite( LIGHTEFFECT *pLight ) } -INT32 NewLightEffect( INT16 sGridNo, INT8 bType ) +INT32 NewLightEffect( INT16 sGridNo, UINT8 ubDuration, UINT8 ubStartRadius ) { LIGHTEFFECT *pLight; INT32 iLightIndex; - UINT8 ubDuration=0; - UINT8 ubStartRadius=0; if( ( iLightIndex = GetFreeLightEffect() )==(-1) ) return(-1); @@ -112,20 +110,9 @@ INT32 NewLightEffect( INT16 sGridNo, INT8 bType ) // Set some values... pLight->sGridNo = sGridNo; - pLight->bType = bType; pLight->iLight = -1; pLight->uiTimeOfLastUpdate = GetWorldTotalSeconds( ); - switch( bType ) - { - case LIGHT_FLARE_MARK_1: - - ubDuration = 6; - ubStartRadius = 6; - break; - - } - pLight->ubDuration = ubDuration; pLight->bRadius = ubStartRadius; pLight->bAge = 0; @@ -139,7 +126,7 @@ INT32 NewLightEffect( INT16 sGridNo, INT8 bType ) //Play the breaklight sound // PlayJA2Sample( BREAK_LIGHT_IGNITING, RATE_11025, SoundVolume( LOWVOLUME, sGridNo ), 1, SoundDir( sGridNo ) ); // 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... if ( ( uiTime - pLight->uiTimeOfLastUpdate ) > 350 ) { - usNumUpdates = ( UINT16 ) ( ( uiTime - pLight->uiTimeOfLastUpdate ) / 350 ); + usNumUpdates = ( UINT16 ) ( ( uiTime - pLight->uiTimeOfLastUpdate ) / 350 ); pLight->uiTimeOfLastUpdate = uiTime; - for ( cnt2 = 0; cnt2 < usNumUpdates; cnt2++ ) - { - pLight->bAge++; + for ( cnt2 = 0; cnt2 < usNumUpdates; cnt2++ ) + { + pLight->bAge++; - // if this cloud remains effective (duration not reached) - if ( pLight->bAge < pLight->ubDuration) - { - // calculate the new cloud radius - // cloud expands by 1 every turn outdoors, and every other turn indoors - if ( ( pLight->bAge % 2 ) ) - { - pLight->bRadius--; - } + // if this cloud remains effective (duration not reached) + if ( pLight->bAge < pLight->ubDuration) + { + // calculate the new cloud radius + // cloud expands by 1 every turn outdoors, and every other turn indoors + if ( ( pLight->bAge % 2 ) ) + { + pLight->bRadius--; + } - if ( pLight->bRadius == 0 ) - { - // Delete... - fDelete = TRUE; - break; - } - else - { - UpdateLightingSprite( pLight ); - } - } - else - { - fDelete = TRUE; - break; - } - } + if ( pLight->bRadius == 0 ) + { + // Delete... + fDelete = TRUE; + break; + } + else + { + UpdateLightingSprite( pLight ); + } + } + else + { + fDelete = TRUE; + break; + } + } if ( fDelete ) { @@ -238,10 +225,11 @@ void DecayLightEffects( UINT32 uiTime ) } } - // Handle sight here.... - AllTeamsLookForAll( FALSE ); + + // Handle sight here.... + AllTeamsLookForAll( FALSE ); } - } + } } } diff --git a/TileEngine/LightEffects.h b/TileEngine/LightEffects.h index 77df913e..bc752adc 100644 --- a/TileEngine/LightEffects.h +++ b/TileEngine/LightEffects.h @@ -2,13 +2,14 @@ #define __LIGHT_EFFECTS +/* // Light effect types enum { NO_LIGHT_EFFECT, LIGHT_FLARE_MARK_1, }; - +*/ typedef struct { @@ -18,7 +19,6 @@ typedef struct UINT8 bRadius; // the current radius INT8 bAge; // the number of turns light has been around BOOLEAN fAllocated; - INT8 bType; INT32 iLight; UINT32 uiTimeOfLastUpdate; @@ -35,7 +35,7 @@ void AddLightEffectToTile( INT8 bType, INT16 sGridNo ); void RemoveLightEffectFromTile( INT16 sGridNo ); -INT32 NewLightEffect( INT16 sGridNo, INT8 bType ); +INT32 NewLightEffect( INT16 sGridNo, UINT8 ubDuration, UINT8 ubStartRadius ); BOOLEAN SaveLightEffectsToSaveGameFile( HWFILE hFile ); diff --git a/TileEngine/Tile Animation.cpp b/TileEngine/Tile Animation.cpp index 212d2008..11e583e3 100644 --- a/TileEngine/Tile Animation.cpp +++ b/TileEngine/Tile Animation.cpp @@ -138,20 +138,7 @@ ANITILE *CreateAnimationTile( ANITILE_PARAMS *pAniParams ) if ( uiFlags & ANITILE_LIGHT ) { - if ( ubAmbientLightLevel >= MIN_AMB_LEVEL_FOR_MERC_LIGHTS ) - { - - 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)); - } - } - } + pNewAniNode->lightSprite = NewLightEffect(sGridNo, 1, 0); } if ( ( uiFlags & ANITILE_CACHEDTILE ) ) @@ -381,7 +368,7 @@ void DeleteAniTile( ANITILE *pAniTile ) break; } - if ( pAniNode->uiFlags & ANITILE_LIGHT && ubAmbientLightLevel >= MIN_AMB_LEVEL_FOR_MERC_LIGHTS ) + if ( pAniNode->uiFlags & ANITILE_LIGHT && pAniNode->lightSprite != NULL ) { LightSpriteDestroy(pAniNode->lightSprite); } @@ -614,10 +601,10 @@ void UpdateAniTiles( ) } else { - //if ( pNode->uiFlags & ANITILE_LIGHT ) - //{ - // LightSpriteDestroy(pNode->lightSprite); - //} + if ( pNode->uiFlags & ANITILE_LIGHT && pNode->lightSprite != NULL ) + { + LightSpriteDestroy(pNode->lightSprite); + } // Delete from world! DeleteAniTile( pNode ); diff --git a/TileEngine/physics.cpp b/TileEngine/physics.cpp index 58927bf1..b209d5c7 100644 --- a/TileEngine/physics.cpp +++ b/TileEngine/physics.cpp @@ -2495,7 +2495,6 @@ DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 2337")); if ( fDoImpact ) { -DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 2403")); if ( Item[pObject->Obj.usItem].flare ) { //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 { // 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 )