use the actor's metadata in PickupAmmo

This allows removing the AmmoItemData array.
Also make some tweaks to handle the nnext extension for customizable ammo amount given. Instead of tying it to gModernMap this now also uses a feature flag that will later be exposed to RMAPINFO.
This commit is contained in:
Christoph Oelckers 2023-10-03 23:04:11 +02:00
parent e8eb558025
commit 9340f39053
6 changed files with 17 additions and 257 deletions

View file

@ -131,6 +131,7 @@ struct MapRecord
CutsceneDef intro;
CutsceneDef outro;
int flags = 0;
int featureflags = 0;
int gameflags = 0;
int levelNumber = -1;
int cluster = -1;

View file

@ -658,239 +658,6 @@ const VECTORDATA gVectorData[] = {
},
};
const AMMOITEMDATA gAmmoItemData[] = {
{
0,
618,
-8,
0,
40,
40,
480,
6,
7
},
{
0,
589,
-8,
0,
48,
48,
1,
5,
6
},
{
0,
589,
-8,
0,
48,
48,
1,
5,
6
},
{
0,
809,
-8,
0,
48,
48,
5,
5,
6
},
{
0,
811,
-8,
0,
48,
48,
1,
10,
11
},
{
0,
810,
-8,
0,
48,
48,
1,
11,
12
},
{
0,
820,
-8,
0,
24,
24,
10,
8,
0
},
{
0,
619,
-8,
0,
48,
48,
4,
2,
0
},
{
0,
812,
-8,
0,
48,
48,
15,
2,
0
},
{
0,
813,
-8,
0,
48,
48,
15,
3,
0
},
{
0,
525,
-8,
0,
48,
48,
100,
9,
10
},
{
0,
814,
-8,
0,
48,
48,
15,
255,
0
},
{
0,
817,
-8,
0,
48,
48,
100,
3,
0
},
{
0,
548,
-8,
0,
24,
24,
32,
7,
0
},
{
0,
0,
-8,
0,
48,
48,
6,
255,
0
},
{
0,
0,
-8,
0,
48,
48,
6,
255,
0
},
{
0,
816,
-8,
0,
48,
48,
8,
1,
0
},
{
0,
818,
-8,
0,
48,
48,
8,
255,
0
},
{
0,
819,
-8,
0,
48,
48,
8,
255,
0
},
{
0,
801,
-8,
0,
48,
48,
6,
4,
0
},
{
0,
0,
0,
0,
0,
0,
0,
0,
0
},
};
const WEAPONITEMDATA gWeaponItemData[] = {
{

View file

@ -84,20 +84,6 @@ struct THINGINFO
double fClipdist() const { return clipdist * 0.25; }
};
struct AMMOITEMDATA
{
int16_t cstat;
int16_t picno;
int8_t shade;
uint8_t pal;
uint8_t xrepeat;
uint8_t yrepeat;
int16_t count;
uint8_t type;
uint8_t weaponType;
FTextureID textureID() const { return tileGetTextureID(picno); }
};
struct WEAPONITEMDATA
{
int16_t cstat;
@ -167,7 +153,6 @@ struct VECTORDATA {
double fMaxDist() const { return maxDist * maptoworld; }
};
extern const AMMOITEMDATA gAmmoItemData[];
extern const WEAPONITEMDATA gWeaponItemData[];
extern const MissileType missileInfo[];
extern const EXPLOSION explodeInfo[];

View file

@ -59,6 +59,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
enum EFeatureFlags
{
kFeatureCustomAmmoCount = 1,
};
constexpr int BMAX_PATH = 260;
struct INIDESCRIPTION {

View file

@ -173,6 +173,8 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, sectortype** cur
if ((LittleShort(header.version) & 0xff00) == 0x700) {
encrypted = 1;
currentLevel->featureflags = 0;
#ifdef NOONE_EXTENSIONS
// indicate if the map requires modern features to work properly
// for maps wich created in PMAPEDIT BETA13 or higher versions. Since only minor version changed,
@ -183,9 +185,11 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, sectortype** cur
switch (tmp) {
case 0x001:
gModernMap = 1;
currentLevel->featureflags = ~0;
break;
case 0x002:
gModernMap = 2;
currentLevel->featureflags = ~0;
break;
}
#endif

View file

@ -1255,18 +1255,16 @@ bool PickupItem(DBloodPlayer* pPlayer, DBloodActor* itemactor)
bool PickupAmmo(DBloodPlayer* pPlayer, DBloodActor* ammoactor)
{
const AMMOITEMDATA* pAmmoItemData = &gAmmoItemData[ammoactor->GetType() - kItemAmmoBase];
int nAmmoType = pAmmoItemData->type;
int nAmmoType = ammoactor->IntVar("type");
int nWeaponType = ammoactor->IntVar("weapontype");
int nCount = (currentLevel->featureflags & kFeatureCustomAmmoCount) && ammoactor->xspr.data1?
ammoactor->xspr.data1 : ammoactor->IntVar("count");
if (pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0;
#ifdef NOONE_EXTENSIONS
else if (gModernMap && ammoactor->hasX() && ammoactor->xspr.data1 > 0) // allow custom amount for item
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + ammoactor->xspr.data1, gAmmoInfo[nAmmoType].max);
#endif
else
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + pAmmoItemData->count, gAmmoInfo[nAmmoType].max);
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + nCount, gAmmoInfo[nAmmoType].max);
if (pAmmoItemData->weaponType) pPlayer->hasWeapon[pAmmoItemData->weaponType] = 1;
if (nWeaponType) pPlayer->hasWeapon[nWeaponType] = 1;
sfxPlay3DSound(pPlayer->GetActor(), 782, -1, 0);
return 1;
}