Brief: //dnl ch67

- Throwing knives had tendency to magically disappear if hit some kind structure.
Details:
- For those who like Dimitri, throwing knives will not disappear anymore if hit some structure or flies into the sky, also using them affect their condition.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6378 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Kriplo
2013-09-08 17:20:27 +00:00
parent 5428ee5ae1
commit d05d130f33
2 changed files with 69 additions and 16 deletions
+61 -1
View File
@@ -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; i<MAXITEMS; i++)
if(Item[i].bloodieditem == pBullet->fromItem)
{
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 )