From ce1b1220b78e69e8c8e27cb59483ee6803095e2c Mon Sep 17 00:00:00 2001 From: lalien Date: Mon, 5 Jun 2006 22:37:34 +0000 Subject: [PATCH] - new feature: manual reload - update readme git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@177 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.cpp | 2 +- JA2.vcproj | 4 ++-- Tactical/Item Types.h | 11 +++++++---- Tactical/Items.cpp | 23 ++++++++++++++++++++++- Tactical/Points.cpp | 17 +++++++++++++++++ Tactical/Points.h | 1 - Tactical/Weapons.cpp | 27 ++++++++++++++++++++++----- Tactical/Weapons.h | 4 +++- TacticalAI/Attacks.cpp | 36 +++++++++++++++++++++++++++++------- 9 files changed, 103 insertions(+), 22 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index a7257ecda..46d5a3476 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -23,7 +23,7 @@ INT16 zVersionLabel[256] = { L"Beta v. 0.98" }; #else //RELEASE BUILD VERSION - INT16 zVersionLabel[256] = { L"Release v1.13.174" }; + INT16 zVersionLabel[256] = { L"Release v1.13.177" }; #endif diff --git a/JA2.vcproj b/JA2.vcproj index 0c1278301..ddfa91a33 100644 --- a/JA2.vcproj +++ b/JA2.vcproj @@ -43,7 +43,7 @@ bGunAmmoStatus = 100; } + pGun->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // Madd: reloading should automatically put cartridge in chamber + return( TRUE ); } @@ -2854,6 +2855,12 @@ INT8 FindAmmoToReload( SOLDIERTYPE * pSoldier, INT8 bWeaponIn, INT8 bExcludeSlot return( NO_SLOT ); } pObj = &(pSoldier->inv[bWeaponIn]); + +// manual recharge + if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + return bWeaponIn; +// + if ( Item[pObj->usItem].usItemClass == IC_GUN && !Item[pObj->usItem].cannon ) { // look for same ammo as before @@ -2918,6 +2925,19 @@ BOOLEAN AutoReload( SOLDIERTYPE * pSoldier ) CHECKF( pSoldier ); pObj = &(pSoldier->inv[HANDPOS]); +// manual recharge + if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + { + pObj->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + + DeductPoints(pSoldier, Weapon[Item[(pObj)->usItem].ubClassIndex].APsToReloadManually, 0); + + PlayJA2Sample( Weapon[ Item[pObj->usItem].ubClassIndex ].ManualReloadSound, RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + + return TRUE; + } +// + if (Item[pObj->usItem].usItemClass == IC_GUN || Item[pObj->usItem].usItemClass == IC_LAUNCHER) { bSlot = FindAmmoToReload( pSoldier, HANDPOS, NO_SLOT ); @@ -4646,6 +4666,7 @@ BOOLEAN CreateGun( UINT16 usItem, INT8 bStatus, OBJECTTYPE * pObj ) pObj->ubGunAmmoType = Magazine[ Item[ usAmmo ].ubClassIndex].ubAmmoType; pObj->bGunAmmoStatus = 100; pObj->ubGunShotsLeft = Magazine[ Item[ usAmmo ].ubClassIndex ].ubMagSize; + pObj->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // Madd: new guns should have cartridge in chamber /* if (usItem == CAWS) { diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index 152a6e1df..7768671a3 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -1583,6 +1583,16 @@ BOOLEAN EnoughAmmo( SOLDIERTYPE *pSoldier, BOOLEAN fDisplay, INT8 bInvPos ) } return( FALSE ); } + + // manual recharge + if( pSoldier->bTeam == OUR_TEAM ) + { + if ( !( pSoldier->inv[ bInvPos ].ubGunState & GS_CARTRIDGE_IN_CHAMBER ) ) + { + return( FALSE ); + } + } + // } } @@ -1756,6 +1766,13 @@ INT8 GetAPsToAutoReload( SOLDIERTYPE * pSoldier ) CHECKF( pSoldier ); pObj = &(pSoldier->inv[HANDPOS]); +// manual recharge + if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) + { + return Weapon[Item[(pObj)->usItem].ubClassIndex].APsToReloadManually; + } +// + if (Item[pObj->usItem].usItemClass == IC_GUN || Item[pObj->usItem].usItemClass == IC_LAUNCHER) { bSlot = FindAmmoToReload( pSoldier, HANDPOS, NO_SLOT ); diff --git a/Tactical/Points.h b/Tactical/Points.h index 16ad3dead..e302b2ac6 100644 --- a/Tactical/Points.h +++ b/Tactical/Points.h @@ -1,7 +1,6 @@ #ifndef __POINTS_H_ #define __POINTS_H_ - #define AP_MINIMUM 10 // no merc can have less for his turn #define AP_MAXIMUM 25 // no merc can have more for his turn #define AP_MONSTER_MAXIMUM 40 // no monster can have more for his turn diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 90f7ce377..d6577e293 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -394,8 +394,10 @@ weaponStartElementHandle(void *userData, const char *name, const char **atts) strcmp(name, "NoSemiAuto") == 0 || strcmp(name, "MaxDistForMessyDeath") == 0 || strcmp(name, "SilencedSound") == 0 || // Lesh: add new field (OR operand) - strcmp(name, "BurstAniDelay") == 0)) // Lesh: add new field (field itself) - + strcmp(name, "BurstAniDelay") == 0 || // Lesh: add new field (field itself) + strcmp(name, "APsToReloadManually") == 0 || + strcmp(name, "ManualReloadSound") == 0) + ) { pData->curElement = WEAPON_ELEMENT_WEAPON_PROPERY; @@ -611,6 +613,16 @@ weaponEndElementHandle(void *userData, const char *name) pData->curWeapon.sAniDelay = (INT16) atol(pData->szCharData); } // Lesh: end + else if(strcmp(name, "APsToReloadManually") == 0) + { + pData->curElement = WEAPON_ELEMENT_WEAPON; + pData->curWeapon.APsToReloadManually = (UINT8) atol(pData->szCharData); + } + else if(strcmp(name, "ManualReloadSound") == 0) + { + pData->curElement = WEAPON_ELEMENT_WEAPON; + pData->curWeapon.ManualReloadSound = (UINT16) atol(pData->szCharData); + } pData->maxReadDepth--; } @@ -758,11 +770,13 @@ BOOLEAN ReadInWeaponStats(STR fileName) FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].ubHitVolume); FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].sSound); FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].sBurstSound); - FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].sSilencedBurstSound); + FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].sSilencedBurstSound); FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].sReloadSound); FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].sLocknLoadSound); - FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].bBurstAP); + FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].bBurstAP); FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].bAutofireShotsPerFiveAP); + FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].ManualReloadAPs); + FilePrintf(hFile,"\t\t%d\r\n", Weapon[cnt].ManualReloadSound); FilePrintf(hFile,"\t\r\n"); } FilePrintf(hFile,"\r\n"); @@ -1914,7 +1928,10 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) pSoldier->bMonsterSmell--; } - +// manual recharge + if (Weapon[Item[usItemNum].ubClassIndex].APsToReloadManually > 0) + pSoldier->inv[ pSoldier->ubAttackingHand ].ubGunState &= ~GS_CARTRIDGE_IN_CHAMBER; +// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("UseGun: done")); return( TRUE ); } diff --git a/Tactical/Weapons.h b/Tactical/Weapons.h index e40d55511..4080969ca 100644 --- a/Tactical/Weapons.h +++ b/Tactical/Weapons.h @@ -266,8 +266,10 @@ typedef struct UINT8 APsToReload; UINT8 maxdistformessydeath; BOOLEAN NoSemiAuto; - UINT8 AutoPenalty; + UINT8 AutoPenalty; INT16 sAniDelay; // Lesh: for burst animation delay + UINT8 APsToReloadManually; + UINT16 ManualReloadSound; } WEAPONTYPE; typedef struct diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 6f3844e77..d0486267d 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -1852,18 +1852,40 @@ INT32 EstimateStabDamage( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT8 TryToReload( SOLDIERTYPE * pSoldier ) { - INT8 bSlot; - WEAPONTYPE * pWeapon; + INT8 bSlot; + WEAPONTYPE *pWeapon; + OBJECTTYPE *pObj; pWeapon = &(Weapon[pSoldier->inv[HANDPOS].usItem]); bSlot = FindAmmo( pSoldier, pWeapon->ubCalibre, pWeapon->ubMagSize, NO_SLOT ); - if (bSlot != NO_SLOT) + + //if (bSlot != NO_SLOT) + //{ + // if (ReloadGun( pSoldier, &(pSoldier->inv[HANDPOS]), &(pSoldier->inv[bSlot]) )) + // { + // return( TRUE ); + // } + //} + +// manual recharge + pObj = &(pSoldier->inv[HANDPOS]); + + if (pObj->ubGunShotsLeft && !(pObj->ubGunState & GS_CARTRIDGE_IN_CHAMBER) ) { - if (ReloadGun( pSoldier, &(pSoldier->inv[HANDPOS]), &(pSoldier->inv[bSlot]) )) - { - return( TRUE ); - } + pObj->ubGunState |= GS_CARTRIDGE_IN_CHAMBER; + + DeductPoints(pSoldier, Weapon[Item[(pObj)->usItem].ubClassIndex].APsToReloadManually, 0); + + //PlayJA2Sample( Weapon[ Item[pObj->usItem].ubClassIndex ].ManualReloadSound, RATE_11025, SoundVolume( HIGHVOLUME, pSoldier->sGridNo ), 1, SoundDir( pSoldier->sGridNo ) ); + return TRUE; } +// + + if (bSlot != NO_SLOT && ReloadGun( pSoldier, &(pSoldier->inv[HANDPOS]), &(pSoldier->inv[bSlot]) )) + { + return( TRUE ); + } + return( NOSHOOT_NOAMMO ); }