From 57dd52a83917c027d7fc4fb6954b3c0f76fb3e5a Mon Sep 17 00:00:00 2001 From: Wanne Date: Fri, 15 Nov 2013 19:51:12 +0000 Subject: [PATCH] Small changes and fixes for grenades and explosives (by Sevenfm) 1) Fixed small bug when MAPELEMENT_PLAYER_MINE_PRESENT was set after planting explosives with remote detonator. 2) Arming bomb with only remote defuse attached is not allowed. 3) Showing item locator before "add blueflag" messagebox is disabled for our mines as it was annoying and you anyway know that it is here. 4) Total weight for throwing range is calculated for all items (previously it was calculated only for grenades). 5) Grenade-throwing formula and demolitions bonus applied only for hand-thrown grenades (check for TOSSCURS). Previously it was applied for launched grenades too. 6) Changed grenade throwing range formula from git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6606 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Handle Items.cpp | 26 +++++++++++++++++++------- Tactical/Weapons.cpp | 24 +++++++++++++++--------- TileEngine/Explosion Control.cpp | 12 ++++++++++-- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 70eaf454..adda3a5f 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -1820,7 +1820,9 @@ void HandleSoldierDropBomb( SOLDIERTYPE *pSoldier, INT32 sGridNo ) gTempObject[0]->data.bDefuseFrequency = 0; // we now know there is something nasty here - gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT; + // sevenfm: do not add mine present flag if remote detonator attached + if(! HasAttachmentOfClass( &(pSoldier->inv[ HANDPOS ] ), (AC_REMOTEDET | AC_DEFUSE) ) ) + gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT; if (pSoldier->inv[ HANDPOS ].MoveThisObjectTo(gTempObject, 1) == 0) { AddItemToPool( sGridNo, &gTempObject, BURIED, pSoldier->pathing.bLevel, WORLD_ITEM_ARMED_BOMB, 0 ); @@ -4844,7 +4846,9 @@ void StartBombMessageBox( SOLDIERTYPE * pSoldier, INT32 sGridNo ) } else { - DoMessageBox( MSG_BOX_BASIC_SMALL_BUTTONS, TacticalStr[ CHOOSE_REMOTE_DEFUSE_FREQUENCY_STR ], GAME_SCREEN, MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS, BombMessageBoxCallBack, NULL ); + // sevenfm: do not allow arming bombs with only REMOTE_DET attached +// DoMessageBox( MSG_BOX_BASIC_SMALL_BUTTONS, TacticalStr[ CHOOSE_REMOTE_DEFUSE_FREQUENCY_STR ], GAME_SCREEN, MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS, BombMessageBoxCallBack, NULL ); + DoMessageBox( MSG_BOX_BASIC_STYLE, L"No detonator or remote detonator found!", GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_OK, NULL, NULL ); } } else if ( HasAttachmentOfClass( &(pSoldier->inv[ HANDPOS ] ), (AC_DETONATOR ) ) ) @@ -5073,12 +5077,14 @@ void BombMessageBoxCallBack( UINT8 ubExitValue ) // Flugente: tripwire was called through a messagebox, but has to be buried nevertheless if ( Item[ (&gTempObject)->usItem ].tripwire == 1 ) + { AddItemToPool( gsTempGridNo, &gTempObject, BURIED, gpTempSoldier->pathing.bLevel, WORLD_ITEM_ARMED_BOMB, 0 ); + // sevenfm: set flag only if planting tripwire + gpWorldLevelData[ gsTempGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT; + } else AddItemToPool( gsTempGridNo, &gTempObject, VISIBLE, gpTempSoldier->pathing.bLevel, WORLD_ITEM_ARMED_BOMB, 0 ); - } - // sevenfm: we now know there is something nasty here - gpWorldLevelData[ gsTempGridNo ].uiFlags |= MAPELEMENT_PLAYER_MINE_PRESENT; + } } } } @@ -5930,14 +5936,20 @@ void MineSpottedDialogueCallBack( void ) // WDS - Automatically flag mines if (gGameExternalOptions.automaticallyFlagMines) { // play a locator at the location of the mine - SetItemPoolLocator( pItemPool ); + // sevenfm: only if it's not our mine + if (! gpWorldLevelData[ pItemPool->sGridNo ].uiFlags & MAPELEMENT_PLAYER_MINE_PRESENT ) + SetItemPoolLocator( pItemPool ); AddBlueFlag( gsBoobyTrapGridNo, gbBoobyTrapLevel ); } else { guiPendingOverrideEvent = LU_BEGINUILOCK; // play a locator at the location of the mine - SetItemPoolLocatorWithCallback( pItemPool, MineSpottedLocatorCallback ); + // sevenfm: only if it's not our mine + if (gpWorldLevelData[ pItemPool->sGridNo ].uiFlags & MAPELEMENT_PLAYER_MINE_PRESENT ) + MineSpottedLocatorCallback(); + else + SetItemPoolLocatorWithCallback( pItemPool, MineSpottedLocatorCallback ); } } diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 7b16dad8..8268e100 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -11095,6 +11095,7 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"calcmaxtossrange"); INT32 iRange = 0; UINT16 usSubItem = NOTHING; + UINT16 itemWeight; if ( EXPLOSIVE_GUN( usItem ) ) { @@ -11134,29 +11135,33 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O } else { + // sevenfm: calculate total weight of object with all attachments + if(pObject!= NULL) + itemWeight = CalculateObjectWeight(pObject); + else + itemWeight=Item[usItem].ubWeight; // if ( Item[ usItem ].fFlags & ITEM_UNAERODYNAMIC ) if ( Item[ usItem ].unaerodynamic ) { DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"calcmaxtossrange: not aerodynamic"); iRange = 1; } - else if ( Item[ usItem ].usItemClass == IC_GRENADE ) - { + // sevenfm: this formula should be used only for hand grenades and not launched grenades + else if ( Item[ usItem ].usItemClass == IC_GRENADE && Item[usItem].ubCursor == TOSSCURS) + { DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"calcmaxtossrange: grenade"); // start with the range based on the soldier's strength and the item's weight // Altered by Digicrab on 14 March, 2004 // Reversed a Ja2Gold change that made grenades of weight 3 or more have the same throw distance as those of weight 3. INT32 iThrowingStrength = ( EffectiveStrength( pSoldier, FALSE ) * 2 + 100 ) / 3; - // sevenfm: calculate total weight of object with all attachments - if(pObject!= NULL) - iRange = 2 + ( iThrowingStrength / (3 + (CalculateObjectWeight(pObject)) / 3 )); - else - iRange = 2 + ( iThrowingStrength / (3 + (Item[usItem].ubWeight) / 3 )); + // sevenfm: changed weight ratio from 3 to 2.5, also new formula will give more steps of range + //iRange = 2 + ( iThrowingStrength / (3 + itemWeight / 3 )); + iRange = 2 + ( iThrowingStrength * 5 ) / ( 15 + itemWeight * 2 ); } else { // not as aerodynamic! // start with the range based on the soldier's strength and the item's weight - iRange = 2 + ( ( EffectiveStrength( pSoldier, FALSE ) / ( 5 + Item[usItem].ubWeight) ) ); + iRange = 2 + ( ( EffectiveStrength( pSoldier, FALSE ) / ( 5 + itemWeight) ) ); } // adjust for thrower's remaining breath (lose up to 1/2 of range) @@ -11171,7 +11176,8 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O // better max range due to expertise iRange += ((iRange * gSkillTraitValues.ubTHBladesMaxRange ) / 100); } - else if ( (Item[ usItem ].usItemClass == IC_GRENADE) && (HAS_SKILL_TRAIT( pSoldier, DEMOLITIONS_NT )) ) + // sevenfm: add range only for hand grenades and not launched grenades + else if ( (Item[ usItem ].usItemClass == IC_GRENADE) && Item[usItem].ubCursor == TOSSCURS && (HAS_SKILL_TRAIT( pSoldier, DEMOLITIONS_NT )) ) { // better max range due to expertise iRange += ((iRange * gSkillTraitValues.ubDEMaxRangeToThrowGrenades) / 100); diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index b7ff2b7d..94968132 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -5476,8 +5476,16 @@ void HandleAttachedExplosions(UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT32 if(Item[iter->usItem].directional && ubDirection == DIRECTION_IRRELEVANT) direction=Random(8); else - direction=ubDirection; - IgniteExplosion( ubOwner, sX, sY, sZ, sGridNo, Item[iter->usItem].uiIndex, bLevel, direction , NULL ); + direction=ubDirection; + if( Item[iter->usItem].uiIndex == TRIP_KLAXON ) + { + PlayJA2Sample( KLAXON_ALARM, RATE_11025, SoundVolume( MIDVOLUME, sGridNo ), 5, SoundDir( sGridNo ) ); + CallAvailableEnemiesTo( sGridNo ); + } else if( Item[iter->usItem].uiIndex == TRIP_FLARE ) + { + NewLightEffect( sGridNo, (UINT8)Explosive[iter->usItem].ubDuration, (UINT8)Explosive[iter->usItem].ubStartRadius ); + } else + IgniteExplosion( ubOwner, sX, sY, sZ, sGridNo, Item[iter->usItem].uiIndex, bLevel, direction , NULL ); } } if ( binderFound && gGameExternalOptions.bAllowSpecialExplosiveAttachments && iter->exists() && Item[iter->usItem].usItemClass & IC_MISC )