2016-11-30 11:24:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-18 13:18:17 +00:00
|
|
|
#include "a_pickups.h"
|
2017-02-07 18:02:27 +00:00
|
|
|
class PClassActor;
|
2016-11-30 11:24:50 +00:00
|
|
|
class AWeapon;
|
2018-11-24 07:17:30 +00:00
|
|
|
class APlayerPawn;
|
2016-11-30 11:24:50 +00:00
|
|
|
|
|
|
|
class FWeaponSlot
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FWeaponSlot() { Clear(); }
|
|
|
|
FWeaponSlot(const FWeaponSlot &other) { Weapons = other.Weapons; }
|
|
|
|
FWeaponSlot &operator= (const FWeaponSlot &other) { Weapons = other.Weapons; return *this; }
|
|
|
|
void Clear() { Weapons.Clear(); }
|
|
|
|
bool AddWeapon (const char *type);
|
2017-02-07 18:02:27 +00:00
|
|
|
bool AddWeapon (PClassActor *type);
|
2016-11-30 11:24:50 +00:00
|
|
|
void AddWeaponList (const char *list, bool clear);
|
|
|
|
int Size () const { return (int)Weapons.Size(); }
|
2017-02-07 18:02:27 +00:00
|
|
|
int LocateWeapon (PClassActor *type);
|
2016-11-30 11:24:50 +00:00
|
|
|
|
2017-02-07 18:02:27 +00:00
|
|
|
inline PClassActor *GetWeapon (int index) const
|
2016-11-30 11:24:50 +00:00
|
|
|
{
|
|
|
|
if ((unsigned)index < Weapons.Size())
|
|
|
|
{
|
|
|
|
return Weapons[index].Type;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
friend struct FWeaponSlots;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct WeaponInfo
|
|
|
|
{
|
2017-02-07 18:02:27 +00:00
|
|
|
PClassActor *Type;
|
2016-11-30 11:24:50 +00:00
|
|
|
int Position;
|
|
|
|
};
|
|
|
|
void SetInitialPositions();
|
|
|
|
void Sort();
|
|
|
|
TArray<WeaponInfo> Weapons;
|
|
|
|
};
|
|
|
|
// FWeaponSlots::AddDefaultWeapon return codes
|
|
|
|
enum ESlotDef
|
|
|
|
{
|
|
|
|
SLOTDEF_Exists, // Weapon was already assigned a slot
|
|
|
|
SLOTDEF_Added, // Weapon was successfully added
|
|
|
|
SLOTDEF_Full // The specifed slot was full
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FWeaponSlots
|
|
|
|
{
|
|
|
|
FWeaponSlots() { Clear(); }
|
|
|
|
FWeaponSlots(const FWeaponSlots &other);
|
|
|
|
|
2018-11-24 21:03:56 +00:00
|
|
|
private:
|
2016-11-30 11:24:50 +00:00
|
|
|
FWeaponSlot Slots[NUM_WEAPON_SLOTS];
|
2018-11-24 21:03:56 +00:00
|
|
|
public:
|
2016-11-30 11:24:50 +00:00
|
|
|
|
|
|
|
void Clear ();
|
2017-02-07 18:02:27 +00:00
|
|
|
bool LocateWeapon (PClassActor *type, int *const slot, int *const index);
|
|
|
|
ESlotDef AddDefaultWeapon (int slot, PClassActor *type);
|
2016-11-30 11:24:50 +00:00
|
|
|
void AddExtraWeapons();
|
|
|
|
void SetFromGameInfo();
|
2017-02-08 18:42:24 +00:00
|
|
|
void SetFromPlayer(PClassActor *type);
|
|
|
|
void StandardSetup(PClassActor *type);
|
2016-11-30 11:24:50 +00:00
|
|
|
void LocalSetup(PClassActor *type);
|
|
|
|
void SendDifferences(int playernum, const FWeaponSlots &other);
|
|
|
|
int RestoreSlots (FConfigFile *config, const char *section);
|
|
|
|
void PrintSettings();
|
2018-11-24 07:17:30 +00:00
|
|
|
static void SetupWeaponSlots(APlayerPawn *pp);
|
2016-11-30 11:24:50 +00:00
|
|
|
|
2017-02-07 18:02:27 +00:00
|
|
|
void AddSlot(int slot, PClassActor *type, bool feedback);
|
|
|
|
void AddSlotDefault(int slot, PClassActor *type, bool feedback);
|
2018-11-24 21:03:56 +00:00
|
|
|
// Abstract access interface to the slots
|
|
|
|
|
|
|
|
void AddWeapon(int slot, PClassActor *type)
|
|
|
|
{
|
|
|
|
if (slot >= 0 && slot < NUM_WEAPON_SLOTS)
|
|
|
|
{
|
|
|
|
Slots[slot].AddWeapon(type);
|
|
|
|
}
|
|
|
|
}
|
2016-11-30 11:24:50 +00:00
|
|
|
|
2018-11-24 21:03:56 +00:00
|
|
|
void AddWeapon(int slot, const char *type)
|
|
|
|
{
|
|
|
|
if (slot >= 0 && slot < NUM_WEAPON_SLOTS)
|
|
|
|
{
|
|
|
|
Slots[slot].AddWeapon(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearSlot(int slot)
|
|
|
|
{
|
|
|
|
if (slot >= 0 && slot < NUM_WEAPON_SLOTS)
|
|
|
|
{
|
|
|
|
Slots[slot].Weapons.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int SlotSize(int slot) const
|
|
|
|
{
|
|
|
|
if (slot >= 0 && slot < NUM_WEAPON_SLOTS)
|
|
|
|
{
|
|
|
|
return Slots[slot].Weapons.Size();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PClassActor *GetWeapon(int slot, int index) const
|
|
|
|
{
|
|
|
|
if (slot >= 0 && slot < NUM_WEAPON_SLOTS && (unsigned)index < Slots[slot].Weapons.Size())
|
|
|
|
{
|
|
|
|
return Slots[slot].GetWeapon(index);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-11-30 11:24:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void P_PlaybackKeyConfWeapons(FWeaponSlots *slots);
|
2017-02-07 18:02:27 +00:00
|
|
|
void Net_WriteWeapon(PClassActor *type);
|
2017-03-08 17:44:37 +00:00
|
|
|
PClassActor *Net_ReadWeapon(uint8_t **stream);
|
2016-11-30 11:24:50 +00:00
|
|
|
|
|
|
|
void P_SetupWeapons_ntohton();
|
2017-03-08 17:44:37 +00:00
|
|
|
void P_WriteDemoWeaponsChunk(uint8_t **demo);
|
|
|
|
void P_ReadDemoWeaponsChunk(uint8_t **demo);
|
2016-11-30 11:24:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AWeapon : public AStateProvider
|
|
|
|
{
|
2017-02-07 18:02:27 +00:00
|
|
|
DECLARE_CLASS(AWeapon, AStateProvider)
|
2016-11-30 11:24:50 +00:00
|
|
|
HAS_OBJECT_POINTERS
|
|
|
|
public:
|
2017-03-08 17:44:37 +00:00
|
|
|
uint32_t WeaponFlags;
|
2017-02-08 17:11:23 +00:00
|
|
|
PClassActor *AmmoType1, *AmmoType2; // Types of ammo used by this weapon
|
2016-11-30 11:24:50 +00:00
|
|
|
int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon
|
|
|
|
int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon
|
|
|
|
int AmmoUse1, AmmoUse2; // How much ammo to use with each shot
|
|
|
|
int Kickback;
|
|
|
|
float YAdjust; // For viewing the weapon fullscreen (visual only so no need to be a double)
|
|
|
|
FSoundIDNoInit UpSound, ReadySound; // Sounds when coming up and idle
|
2017-02-07 18:02:27 +00:00
|
|
|
PClassActor *SisterWeaponType; // Another weapon to pick up with this one
|
2016-11-30 11:24:50 +00:00
|
|
|
int SelectionOrder; // Lower-numbered weapons get picked first
|
|
|
|
int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo
|
|
|
|
int ReloadCounter; // For A_CheckForReload
|
|
|
|
int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double)
|
|
|
|
float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs.
|
|
|
|
float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction.
|
|
|
|
|
|
|
|
// In-inventory instance variables
|
2017-03-08 12:34:26 +00:00
|
|
|
TObjPtr<AInventory*> Ammo1, Ammo2;
|
|
|
|
TObjPtr<AWeapon*> SisterWeapon;
|
2016-11-30 11:24:50 +00:00
|
|
|
float FOVScale;
|
|
|
|
int Crosshair; // 0 to use player's crosshair
|
2018-11-24 19:32:12 +00:00
|
|
|
bool GivenAsMorphWeapon; // *** only accessed from ZScript.
|
2016-11-30 11:24:50 +00:00
|
|
|
|
2018-11-24 19:32:12 +00:00
|
|
|
bool bAltFire; // *** only accessed from ZScript. Set when this weapon's alternate fire is used.
|
2018-11-25 06:21:02 +00:00
|
|
|
bool bDehAmmo;
|
2016-11-30 11:24:50 +00:00
|
|
|
|
2017-02-07 17:12:38 +00:00
|
|
|
void Serialize(FSerializer &arc) override;
|
2017-01-19 16:40:34 +00:00
|
|
|
|
2016-11-30 11:24:50 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PrimaryFire,
|
|
|
|
AltFire,
|
|
|
|
EitherFire
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
BobNormal,
|
|
|
|
BobInverse,
|
|
|
|
BobAlpha,
|
|
|
|
BobInverseAlpha,
|
|
|
|
BobSmooth,
|
|
|
|
BobInverseSmooth
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
WIF_NOAUTOFIRE = 0x00000001, // weapon does not autofire
|
|
|
|
WIF_READYSNDHALF = 0x00000002, // ready sound is played ~1/2 the time
|
|
|
|
WIF_DONTBOB = 0x00000004, // don't bob the weapon
|
|
|
|
WIF_AXEBLOOD = 0x00000008, // weapon makes axe blood on impact (Hexen only)
|
|
|
|
WIF_NOALERT = 0x00000010, // weapon does not alert monsters
|
|
|
|
WIF_AMMO_OPTIONAL = 0x00000020, // weapon can use ammo but does not require it
|
|
|
|
WIF_ALT_AMMO_OPTIONAL = 0x00000040, // alternate fire can use ammo but does not require it
|
|
|
|
WIF_PRIMARY_USES_BOTH = 0x00000080, // primary fire uses both ammo
|
|
|
|
WIF_ALT_USES_BOTH = 0x00000100, // alternate fire uses both ammo
|
|
|
|
WIF_WIMPY_WEAPON = 0x00000200, // change away when ammo for another weapon is replenished
|
|
|
|
WIF_POWERED_UP = 0x00000400, // this is a tome-of-power'ed version of its sister
|
|
|
|
WIF_AMMO_CHECKBOTH = 0x00000800, // check for both primary and secondary fire before switching it off
|
|
|
|
WIF_NO_AUTO_SWITCH = 0x00001000, // never switch to this weapon when it's picked up
|
|
|
|
WIF_STAFF2_KICKBACK = 0x00002000, // the powered-up Heretic staff has special kickback
|
|
|
|
WIF_NOAUTOAIM = 0x00004000, // this weapon never uses autoaim (useful for ballistic projectiles)
|
|
|
|
WIF_MELEEWEAPON = 0x00008000, // melee weapon. Used by bots and monster AI.
|
2018-11-25 06:21:02 +00:00
|
|
|
//WIF_DEHAMMO = 0x00010000,
|
2016-11-30 11:24:50 +00:00
|
|
|
WIF_NODEATHDESELECT = 0x00020000, // Don't jump to the Deselect state when the player dies
|
|
|
|
WIF_NODEATHINPUT = 0x00040000, // The weapon cannot be fired/reloaded/whatever when the player is dead
|
|
|
|
WIF_CHEATNOTWEAPON = 0x08000000, // Give cheat considers this not a weapon (used by Sigil)
|
|
|
|
};
|
|
|
|
|