diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index 755d2e02..880429dd 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -2364,30 +2364,23 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend if (pBullet->usFlags & BULLET_FLAG_KNIFE) { + //dnl ch67 080913 // Place knife on guy.... - + UINT16 usItem = (Item[pBullet->fromItem].bloodieditem>0 ? Item[pBullet->fromItem].bloodieditem : pBullet->fromItem); + UINT16 usItemStatus = (pBullet->ubItemStatus>1 ? pBullet->ubItemStatus-Random(2) : pBullet->ubItemStatus); // See if they have room ( and make sure it's not in hand pos? // CHRISL: bSlot = FindEmptySlotWithin( pTarget, BIGPOCKSTART, NUM_INV_SLOTS ); - if (bSlot == NO_SLOT) + if(bSlot == NO_SLOT) { // Add item - - CreateItem( pBullet->fromItem, (INT8) pBullet->ubItemStatus, &gTempObject ); - - AddItemToPool( pTarget->sGridNo, &gTempObject, -1 , pTarget->pathing.bLevel, 0, 0 ); - + CreateItem(usItem, usItemStatus, &gTempObject); + AddItemToPool(pTarget->sGridNo, &gTempObject, -1, pTarget->pathing.bLevel, 0, 0); // Make team look for items - NotifySoldiersToLookforItems( ); + NotifySoldiersToLookforItems(); } else - { - if ( Item[pBullet->fromItem].bloodieditem > 0 ) - CreateItem( Item[pBullet->fromItem].bloodieditem, (INT8) pBullet->ubItemStatus, &(pTarget->inv[bSlot]) ); - else - CreateItem( pBullet->fromItem, (INT8) pBullet->ubItemStatus, &(pTarget->inv[bSlot]) ); - } - + CreateItem(usItem, usItemStatus, &pTarget->inv[bSlot]); ubAmmoType = AMMO_KNIFE; } else if (pBullet->fFragment) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 6f55f61d..1df70ec9 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -4601,6 +4601,39 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN // When it hits the ground, leave on map... if ( Item[ usWeaponIndex ].usItemClass == IC_THROWING_KNIFE ) { + //dnl ch67 080913 + INT8 bMaxLeft, bMaxRight, bMaxUp, bMaxDown, bXOffset, bYOffset, ubSearchRange; + INT32 iGridNo = NOWHERE; + for(ubSearchRange = 0; ubSearchRange < 4 && iGridNo == NOWHERE; ubSearchRange++) + { + bMaxLeft = bMaxRight = ubSearchRange;// determine maximum horizontal limits + bMaxUp = bMaxDown = ubSearchRange;// determine maximum vertical limits + for(bYOffset = -bMaxUp; bYOffset <= bMaxDown && iGridNo == NOWHERE; bYOffset++)// evaluate every tile until find first reachable one + for(bXOffset = -bMaxLeft; bXOffset <= bMaxRight; bXOffset++) + { + iGridNo = pBullet->sGridNo + bXOffset + (MAXCOL * bYOffset);// calculate the next potential gridno near this opponent + if(!TileIsOutOfBounds(iGridNo) && !FindStructure(iGridNo, STRUCTURE_BLOCKSMOVES)) + break; + iGridNo = NOWHERE; + } + } + if(iGridNo != NOWHERE) + { + UINT16 usItem = pBullet->fromItem; + if(usStructureID == INVALID_STRUCTURE_ID) + { + for(int i=0; ifromItem) + { + usItem = Item[i].uiIndex;// clean the blood from knife, actually this should be done during repair + break; + } + } + CreateItem(usItem, (pBullet->ubItemStatus>1 ? pBullet->ubItemStatus-Random(2) : pBullet->ubItemStatus), &gTempObject); + AddItemToPool(iGridNo, &gTempObject, -1, 0, 0, -1); + NotifySoldiersToLookforItems(); + } +/* // OK, have we hit ground? if ( usStructureID == INVALID_STRUCTURE_ID ) { @@ -4612,7 +4645,7 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN // Make team look for items NotifySoldiersToLookforItems( ); } - +*/ if ( !fHitSameStructureAsBefore ) { PlayJA2Sample( MISS_KNIFE, RATE_11025, uiMissVolume, 1, SoundDir( sGridNo ) ); @@ -10019,6 +10052,33 @@ void ShotMiss( UINT8 ubAttackerID, INT32 iBullet ) case MONSTERCLASS: PlayJA2Sample( SPIT_RICOCHET, RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); break; + + case KNIFECLASS://dnl ch67 080913 + if((pBullet=GetBulletPtr(iBullet)) != NULL) + { + INT8 bMaxLeft, bMaxRight, bMaxUp, bMaxDown, bXOffset, bYOffset, ubSearchRange; + INT32 iGridNo = NOWHERE; + for(ubSearchRange = 0; ubSearchRange < 4 && iGridNo == NOWHERE; ubSearchRange++) + { + bMaxLeft = bMaxRight = ubSearchRange;// determine maximum horizontal limits + bMaxUp = bMaxDown = ubSearchRange;// determine maximum vertical limits + for(bYOffset = -bMaxUp; bYOffset <= bMaxDown && iGridNo == NOWHERE; bYOffset++)// evaluate every tile until find first reachable one + for(bXOffset = -bMaxLeft; bXOffset <= bMaxRight; bXOffset++) + { + iGridNo = pBullet->sGridNo + bXOffset + (MAXCOL * bYOffset);// calculate the next potential gridno near this opponent + if(!TileIsOutOfBounds(iGridNo) && !FindStructure(iGridNo, STRUCTURE_BLOCKSMOVES)) + break; + iGridNo = NOWHERE; + } + } + if(iGridNo != NOWHERE) + { + CreateItem(pBullet->fromItem, (pBullet->ubItemStatus>1 ? pBullet->ubItemStatus-Random(2) : pBullet->ubItemStatus), &gTempObject); + AddItemToPool(iGridNo, &gTempObject, -1, 0, 0, -1); + NotifySoldiersToLookforItems(); + } + } + break; } if ( fDoMissForGun )