-
Notifications
You must be signed in to change notification settings - Fork 0
/
weapon.h
executable file
·127 lines (120 loc) · 3.34 KB
/
weapon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#define NUMWEAPONCLASSES 5
#define FIRSTWEAPONCLASSSPRITEID 802
struct Bullet
{
char* mName;
int mBulletDataSpriteGlobalGraphicsID;
int mFullBulletSpriteID;
int mTravelDelayPerFrame;
int mTravelGlobalGraphicsID;
int mHitGlobalGraphicsID;
int mHitGlobalSoundID;
int mHitWidth;
int mHitHeight;
int mShellCasingGlobalGraphicsID;
int mShellCasingBounceSoundID;
public:
Bullet() : mName(NULL) {}
Bullet(const Bullet& ref)
{
*this = ref;
if(ref.mName){
mName = new char[strlen(ref.mName) + 1];
strcpy(mName, ref.mName);
}
}
~Bullet()
{
if(mName)
delete [] mName;
}
};
struct Weapon
{
char* mName;
int mClass;
int mWeaponDataSpriteGlobalGraphicsID;
bool mUseShotEffects;
bool mSingleShot;
bool mTriggerDown;
int mTimeToNextShot;
int mNextShotTimer;
bool mClipLoaded;
bool mEjectRoundWhenFired;
bool mEjectAllRoundsWhenReloaded;
int mMaxRounds;
int mCurrentRounds;
int mTimeToReload;
int mReloadTimer;
double mHorizRecoil;
double mVertRecoil;
double mWeight;
int mGunshotGlobalSoundID;
int mReloadGlobalSoundID;
int mReloadRackGlobalSoundID;
int mBulletID;
bool mBoltBack;
bool mActionCycled;
Weapon() : mName(NULL) {}
Weapon(const Weapon& ref)
{
*this = ref; //HA HA NEAT TRIXXOR
if(ref.mName){
mName = new char[strlen(ref.mName) + 1];
strcpy(mName, ref.mName);
}
}
~Weapon()
{
if(mName)
delete [] mName;
}
};
class WeaponsSelector
{
//STATUS TYPES:
//0. STATIONARY OPEN
//1. EXTENDING
//2. RETRACTING
//3. STATIONARY CLOSED
Sprite WeaponClassSprites[NUMWEAPONCLASSES];
Sprite* BaseSelector;
Sprite* WeaponSprite;
int mXOrigin;
int mYOrigin;
int mStatus;
int mActiveTime;
int mActiveTimer;
public:
TypewriterText* BulletName;
WeaponsSelector() : BulletName(NULL), mXOrigin(0), mYOrigin(0), BaseSelector(NULL), WeaponSprite(NULL), mActiveTime(3500), mActiveTimer(3500) {}
~WeaponsSelector() { if(BaseSelector)delete BaseSelector; if(WeaponSprite)delete WeaponSprite; if(BulletName) delete BulletName;}
bool Init(Weapon* TheWeapon);
void Update(Weapon* TheWeapon, int timediff, CDisplay& DisplayRef);
void Draw(Weapon* TheWeapon, CDisplay& DisplayRef);
int GetStatus() {return mStatus;}
void SetStatus(int status) {mStatus = status;}
void UpdateWithNewData(Weapon* NewWeapon);
};
bool InitializeGameBullets();
bool InitializeGameWeapons();
void DestroyGameWeaponsAndBullets();
bool ChangeWeapon(int To, Weapon** ToFill);
bool CanWeaponFire(Weapon* ToFire);
void WeaponUpdate(Weapon* ToUpdate, int timediff);
FPOINT Recoil(POINT oldpoint, Weapon* weap);
Weapon* GetGlobalWeaponData(int index);
Bullet* GetGlobalBulletData(int index);
void DrawBulletsRemaining(Weapon* DrawMe, int timediff);
bool InitializeWeaponSelector(Weapon* TheWeapon);
void UpdateWeaponsSelector(Weapon* TheWeapon, int timediff, CDisplay& DisplayRef);
void ActivateWeaponSelector(Weapon* TheWeapon);
void DeactivateWeaponSelector();
void AllowAllWeapons();
bool IsWeaponAllowed(Weapon* TheWeapon);
void DisallowWeaponClass(int TypeToDisallow, int* CurrentWeaponID, Weapon** CurrentWeaponToFill);
void AllowWeaponClass(int TypeToAllow);
int ChangeToNextWeapon(int Current, Weapon** ToFill, bool Prev = false);
void ShowWeaponSelector();
double GetWeaponClassAccelRate(int Class);
double GetWeaponClassDragRate(int Class);