From 9592be9122bbdad663089c45f8320ebf216a7a47 Mon Sep 17 00:00:00 2001 From: Flugente Date: Thu, 21 Mar 2013 23:13:39 +0000 Subject: [PATCH] - Fix: random items > 200 were not read - Fix: preplaced random items turned guns did not have ammo (WIP) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5946 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Item Types.cpp | 40 +++++++++++++++++++++++++++++++++++++ Tactical/Item Types.h | 4 +++- Tactical/XML_RandomItem.cpp | 4 ++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Tactical/Item Types.cpp b/Tactical/Item Types.cpp index fe9fcca2..721124b6 100644 --- a/Tactical/Item Types.cpp +++ b/Tactical/Item Types.cpp @@ -1465,6 +1465,46 @@ OBJECTTYPE& OBJECTTYPE::operator=(const OLD_OBJECTTYPE_101& src) (*this)[0]->data.gun.usGunAmmoItem = src.ugYucky.usGunAmmoItem; (*this)[0]->data.gun.bGunAmmoStatus = src.ugYucky.bGunAmmoStatus; (*this)[0]->data.gun.ubGunState = src.ugYucky.ubGunState; + + // Flugente: if we resolved a random item, we have to give it ammo... + if ( Item[newitemfromrandom].usItemClass == IC_GUN ) + { + (*this)[0]->data.ubImprintID = NO_PROFILE; + + if (Weapon[ this->usItem ].ubWeaponClass == MONSTERCLASS) + { + (*this)[0]->data.gun.ubGunShotsLeft = 1; + (*this)[0]->data.gun.ubGunAmmoType = AMMO_MONSTER; + (*this)[0]->data.gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // 0verhaul: Monsters don't have to reload! + } + else if ( EXPLOSIVE_GUN( this->usItem ) ) + { + if ( Item[this->usItem].singleshotrocketlauncher ) + { + (*this)[0]->data.gun.ubGunShotsLeft = 1; + } + else + { + // cannon + (*this)[0]->data.gun.ubGunShotsLeft = 0; + } + (*this)[0]->data.gun.bGunAmmoStatus = 100; + (*this)[0]->data.gun.ubGunAmmoType = 0; + } + else + { + UINT16 usAmmo = DefaultMagazine( this->usItem ); + if ( usAmmo ) + { + (*this)[0]->data.gun.usGunAmmoItem = usAmmo; + (*this)[0]->data.gun.ubGunAmmoType = Magazine[ Item[ usAmmo ].ubClassIndex].ubAmmoType; + (*this)[0]->data.gun.bGunAmmoStatus = 100; + (*this)[0]->data.gun.ubGunShotsLeft = Magazine[ Item[ usAmmo ].ubClassIndex ].ubMagSize; + (*this)[0]->data.gun.ubGunState |= GS_CARTRIDGE_IN_CHAMBER; // Madd: new guns should have cartridge in chamber + } + } + } + break; } diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h index 03eea876..07d15b6c 100644 --- a/Tactical/Item Types.h +++ b/Tactical/Item Types.h @@ -1162,7 +1162,9 @@ typedef struct RANDOM_ITEM_CHOICE_TYPE } RANDOM_ITEM_CHOICE_TYPE; -extern RANDOM_ITEM_CHOICE_TYPE gRandomItemClass[200]; +#define RANDOM_ITEM_MAX_CATEGORIES 1000 + +extern RANDOM_ITEM_CHOICE_TYPE gRandomItemClass[RANDOM_ITEM_MAX_CATEGORIES]; // CHRISL: Added new structures to handle LBE gear and the two new XML files that will be needed to deal // with the IC pockets and the new inventory system. diff --git a/Tactical/XML_RandomItem.cpp b/Tactical/XML_RandomItem.cpp index c414e08f..2cdee198 100644 --- a/Tactical/XML_RandomItem.cpp +++ b/Tactical/XML_RandomItem.cpp @@ -9,7 +9,7 @@ #include "Item Types.h" #endif -RANDOM_ITEM_CHOICE_TYPE gRandomItemClass[200]; +RANDOM_ITEM_CHOICE_TYPE gRandomItemClass[RANDOM_ITEM_MAX_CATEGORIES]; struct { @@ -272,7 +272,7 @@ BOOLEAN ReadInRandomItemStats(STR fileName) memset(&pData,0,sizeof(pData)); pData.curArray = gRandomItemClass; - pData.maxArraySize = 200; + pData.maxArraySize = RANDOM_ITEM_MAX_CATEGORIES; XML_SetUserData(parser, &pData);