diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index ae98eaca2..be09bf887 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -6538,27 +6538,27 @@ void MoveBullet( INT32 iBullet ) { if (pStructure->fFlags & STRUCTURE_PERSON) { - if(!(UsingNewCTHSystem() || pBullet->fFragment || (pBullet->usFlags & BULLET_FLAG_BUCKSHOT)) && fIntended && pBullet->sHitBy < 0 && pBullet->pFirer->ubTargetID == pStructure->usStructureID)//dnl ch60 010913 don't hit target if CTH roll decide to miss - { - gpLocalStructure[iStructureLoop] = NULL; -//SendFmtMsg("shoot me, miss me, lucky me :-)"); - } - else - { - // hit someone! - fStopped = BulletHitMerc( pBullet, pStructure, fIntended ); - if (fStopped) + if(!(UsingNewCTHSystem() || pBullet->fFragment || (pBullet->usFlags & BULLET_FLAG_BUCKSHOT)) && fIntended && pBullet->sHitBy < 0 && pBullet->pFirer->ubTargetID == pStructure->usStructureID)//dnl ch60 010913 don't hit target if CTH roll decide to miss { - // remove bullet function now called from within BulletHitMerc, so just quit - return; + gpLocalStructure[iStructureLoop] = NULL; +//SendFmtMsg("shoot me, miss me, lucky me :-)"); } else { - // set pointer to null so that we don't consider hitting this person again - gpLocalStructure[iStructureLoop] = NULL; + // hit someone! + fStopped = BulletHitMerc( pBullet, pStructure, fIntended ); + if (fStopped) + { + // remove bullet function now called from within BulletHitMerc, so just quit + return; + } + else + { + // set pointer to null so that we don't consider hitting this person again + gpLocalStructure[iStructureLoop] = NULL; + } } } - } else if (pStructure->fFlags & STRUCTURE_WALLNWINDOW && pBullet->qCurrZ >= qWindowBottomHeight && pBullet->qCurrZ <= qWindowTopHeight) { fResolveHit = ResolveHitOnWall( pStructure, iGridNo, pBullet->bLOSIndexX, pBullet->bLOSIndexY, pBullet->ddHorizAngle ); @@ -6573,7 +6573,9 @@ void MoveBullet( INT32 iBullet ) iRemainingImpact = HandleBulletStructureInteraction( pBullet, pStructure, &fHitStructure ); if ( iRemainingImpact <= 0 ) { - // check angle of knife and place on ground appropriately + // silversurfer: Bugfix for JaggZilla Bug #637 + // This is now done in function BulletHitStructure(). Otherwise we would create two items. +/* // check angle of knife and place on ground appropriately OBJECTTYPE Object; INT32 iKnifeGridNo; @@ -6616,7 +6618,7 @@ void MoveBullet( INT32 iBullet ) } // Make team look for items - NotifySoldiersToLookforItems( ); + NotifySoldiersToLookforItems( );*/ // bullet must end here! StopBullet( pBullet->iBullet ); diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 1e426f8d0..5108ea415 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -4621,8 +4621,10 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN // When it hits the ground, leave on map... if ( Item[ usWeaponIndex ].usItemClass == IC_THROWING_KNIFE ) { + // silversurfer: We better don't do this randomly. It looks strange when the knife suddenly appears at the other side of a wall + // or other structure that it can't pass. We want the knife on that side of the structure where it hit. //dnl ch67 080913 - INT8 bMaxLeft, bMaxRight, bMaxUp, bMaxDown, bXOffset, bYOffset, ubSearchRange; +/* INT8 bMaxLeft, bMaxRight, bMaxUp, bMaxDown, bXOffset, bYOffset, ubSearchRange; INT32 iGridNo = NOWHERE; for(ubSearchRange = 0; ubSearchRange < 4 && iGridNo == NOWHERE; ubSearchRange++) { @@ -4636,7 +4638,61 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN break; iGridNo = NOWHERE; } + }*/ + + // by default knife at same tile as structure + INT32 iGridNo = sGridNo; + + // we hit a wall structure + if ( pStructure != NULL ) + { + if (pStructure->ubWallOrientation == INSIDE_TOP_RIGHT || pStructure->ubWallOrientation == OUTSIDE_TOP_RIGHT) + { + if ( pBullet->qIncrX > 0) + { + // heading east so place knife on west, in same tile + } + else + { + // place to east of structure + iGridNo += 1; + } + } + else + { + if (pBullet->qIncrY > 0) + { + // heading south so place knife to north, in same tile of structure + } + else + { + iGridNo += WORLD_ROWS; + } + } } + // something else that blocks our way + else if ( FindStructure(iGridNo, STRUCTURE_BLOCKSMOVES) ) + { + if ( pBullet->qIncrX > 0) + { + // heading east + } + else + { + // heading west, place to east of structure + iGridNo += 1; + } + if (pBullet->qIncrY > 0) + { + // heading south + } + else + { + // heading north, place to south of structure + iGridNo += WORLD_ROWS; + } + } + if(iGridNo != NOWHERE) { UINT16 usItem = pBullet->fromItem; @@ -4650,7 +4706,19 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN } } CreateItem(usItem, (pBullet->ubItemStatus>1 ? pBullet->ubItemStatus-Random(2) : pBullet->ubItemStatus), &gTempObject); - AddItemToPool(iGridNo, &gTempObject, -1, 0, 0, -1); + + if ( pBullet->bEndCubesAboveLevelZ >= 3 ) + { + // roof + AddItemToPool( iGridNo, &gTempObject, -1, 1, 0, -1 ); + } + else + { + // ground level + AddItemToPool( iGridNo, &gTempObject, -1, 0, 0, -1 ); + } + +// AddItemToPool(iGridNo, &gTempObject, -1, 0, 0, -1); NotifySoldiersToLookforItems(); } /*