-
Notifications
You must be signed in to change notification settings - Fork 21
/
bot_weapons.h
225 lines (186 loc) · 8.2 KB
/
bot_weapons.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//
// JK_Botti - be more human!
//
// bot_weapons.h
//
#ifndef BOT_WEAPONS_H
#define BOT_WEAPONS_H
#define NOSKILL 0 // better than best required == N/A
#define SKILL1 1 // best
#define SKILL2 2
#define SKILL3 3
#define SKILL4 4
#define SKILL5 5 // worst
// waypoint item flags
#define W_IFL_CROWBAR (1<<0)
#define W_IFL_HANDGRENADE (1<<1)
#define W_IFL_SNARK (1<<2)
#define W_IFL_EGON (1<<3)
#define W_IFL_GAUSS (1<<4)
#define W_IFL_SHOTGUN (1<<5)
#define W_IFL_PYTHON (1<<6)
#define W_IFL_HORNETGUN (1<<7)
#define W_IFL_MP5 (1<<8)
#define W_IFL_CROSSBOW (1<<9)
#define W_IFL_RPG (1<<10)
#define W_IFL_GLOCK (1<<11)
#define W_IFL_AMMO_GAUSS (1<<12)
#define W_IFL_AMMO_BUCKSHOT (1<<13)
#define W_IFL_AMMO_357 (1<<14)
#define W_IFL_AMMO_9MM (1<<15)
#define W_IFL_AMMO_ARGRENADES (1<<16)
#define W_IFL_AMMO_CROSSBOW (1<<17)
#define W_IFL_AMMO_RPG (1<<18)
#define W_IFL_GRAPPLE (1<<19)
#define W_IFL_EAGLE (1<<20)
#define W_IFL_PIPEWRENCH (1<<21)
#define W_IFL_M249 (1<<22)
#define W_IFL_DISPLACER (1<<23)
#define W_IFL_SHOCKRIFLE (1<<24)
#define W_IFL_SPORELAUNCHER (1<<25)
#define W_IFL_SNIPERRIFLE (1<<26)
#define W_IFL_KNIFE (1<<27)
#define W_IFL_AMMO_556 (1<<28)
#define W_IFL_AMMO_762 (1<<29)
#define W_IFL_AMMO_SPORE (1<<30)
// weapon types
#define WEAPON_FIRE (1<<0)
#define WEAPON_MELEE (1<<1)
#define WEAPON_THROW (1<<2)
#define WEAPON_ZOOM (1<<3)
#define WEAPON_FIRE_ZOOM (WEAPON_FIRE|WEAPON_ZOOM)
#define WEAPON_AT_FEET (1<<4)
#define WEAPON_FIRE_AT_FEET (WEAPON_FIRE|WEAPON_AT_FEET)
// submod support flags
#define WEAPON_SUBMOD_HLDM (1<<0)
#define WEAPON_SUBMOD_SEVS (1<<1)
#define WEAPON_SUBMOD_BUBBLEMOD (1<<2)
#define WEAPON_SUBMOD_XDM (1<<3)
#define WEAPON_SUBMOD_OP4 (1<<4)
#define WEAPON_SUBMOD_ALL (WEAPON_SUBMOD_HLDM|WEAPON_SUBMOD_SEVS|WEAPON_SUBMOD_BUBBLEMOD|WEAPON_SUBMOD_XDM|WEAPON_SUBMOD_OP4)
typedef struct
{
int iId; // the weapon ID value
int supported_submods; // supported submods
char weapon_name[64]; // name of the weapon when selecting it
int type;
float aim_speed; // aim speed, 0.0 worst, 1.0 best.
int primary_skill_level; // bot skill must be less than or equal to this value
int secondary_skill_level; // bot skill must be less than or equal to this value
qboolean avoid_this_gun; // bot avoids using this weapon if possible
qboolean prefer_higher_skill_attack; // bot uses better of primary and secondary attacks if both avaible
float primary_min_distance; // 0 = no minimum
float primary_max_distance; // 9999 = no maximum
float secondary_min_distance; // 0 = no minimum
float secondary_max_distance; // 9999 = no maximum
float opt_distance; // optimal distance from target
int use_percent; // times out of 100 to use this weapon when available
qboolean can_use_underwater; // can use this weapon underwater
int primary_fire_percent; // times out of 100 to use primary fire
int min_primary_ammo; // minimum ammout of primary ammo needed to fire
int min_secondary_ammo; // minimum ammout of seconday ammo needed to fire
qboolean primary_fire_hold; // hold down primary fire button to use?
qboolean secondary_fire_hold; // hold down secondary fire button to use?
qboolean primary_fire_charge; // charge weapon using primary fire?
qboolean secondary_fire_charge; // charge weapon using secondary fire?
float primary_charge_delay; // time to charge weapon
float secondary_charge_delay; // time to charge weapon
qboolean secondary_use_primary_ammo; //does secondary fire use primary ammo?
int low_ammo_primary;
int low_ammo_secondary;
int waypoint_flag;
int ammo1_waypoint_flag;
int ammo2_waypoint_flag;
qboolean ammo1_on_repickup; // getting same weapon gives ammo instead
qboolean ammo2_on_repickup;
} bot_weapon_select_t;
typedef struct
{
int iId;
float primary_base_delay;
float primary_min_delay[5];
float primary_max_delay[5];
float secondary_base_delay;
float secondary_min_delay[5];
float secondary_max_delay[5];
} bot_fire_delay_t;
typedef struct
{
int waypoint_flag;
char ammoName[64];
} bot_ammo_names_t;
#define NUM_OF_WEAPON_SELECTS 22
extern bot_weapon_select_t weapon_select[NUM_OF_WEAPON_SELECTS];
extern bot_fire_delay_t fire_delay[NUM_OF_WEAPON_SELECTS];
extern bot_ammo_names_t ammo_names[];
enum ammo_low_t {
AMMO_NO = 1,
AMMO_LOW = 2,
AMMO_OK = 3,
};
// weapon ID values for Valve's Half-Life Deathmatch
#define VALVE_WEAPON_CROWBAR 1
#define VALVE_WEAPON_GLOCK 2
#define VALVE_WEAPON_PYTHON 3
#define VALVE_WEAPON_MP5 4
#define VALVE_WEAPON_CHAINGUN 5
#define VALVE_WEAPON_CROSSBOW 6
#define VALVE_WEAPON_SHOTGUN 7
#define VALVE_WEAPON_RPG 8
#define VALVE_WEAPON_GAUSS 9
#define VALVE_WEAPON_EGON 10
#define VALVE_WEAPON_HORNETGUN 11
#define VALVE_WEAPON_HANDGRENADE 12
#define VALVE_WEAPON_TRIPMINE 13
#define VALVE_WEAPON_SATCHEL 14
#define VALVE_WEAPON_SNARK 15
// weapon ID values for extra weapons from Gearbox's Opposing Force
#define GEARBOX_WEAPON_GRAPPLE 16
#define GEARBOX_WEAPON_EAGLE 17
#define GEARBOX_WEAPON_PIPEWRENCH 18
#define GEARBOX_WEAPON_M249 19
#define GEARBOX_WEAPON_DISPLACER 20
#define GEARBOX_WEAPON_UNKNOWN21 21
#define GEARBOX_WEAPON_SHOCKRIFLE 22
#define GEARBOX_WEAPON_SPORELAUNCHER 23
#define GEARBOX_WEAPON_SNIPERRIFLE 24
#define GEARBOX_WEAPON_KNIFE 25
// in normal gravity, how far the longjump hurls us
#define LONGJUMP_DISTANCE 540
#define VALVE_MAX_NORMAL_HEALTH 100
#define VALVE_MAX_NORMAL_BATTERY 100
#define VALVE_HORNET_MAX_CARRY 8
typedef struct
{
char szClassname[64];
int iAmmo1; // ammo index for primary ammo
int iAmmo1Max; // max primary ammo
int iAmmo2; // ammo index for secondary ammo
int iAmmo2Max; // max secondary ammo
int iSlot; // HUD slot (0 based)
int iPosition; // slot position
int iId; // weapon ID
int iFlags; // flags???
} bot_weapon_t;
float ValveWeaponMP5_GetBestLaunchAngleByDistanceAndHeight(float distance, float height);
int SubmodToSubmodWeaponFlag(int submod);
bot_weapon_select_t * GetWeaponSelect(int id);
void InitWeaponSelect(int submod_id);
int GetAmmoItemFlag(const char * classname);
int GetWeaponItemFlag(const char * classname);
qboolean BotSkilledEnoughForPrimaryAttack(bot_t &pBot, const bot_weapon_select_t &select);
qboolean BotSkilledEnoughForSecondaryAttack(bot_t &pBot, const bot_weapon_select_t &select);
qboolean BotCanUseWeapon(bot_t &pBot, const bot_weapon_select_t &select);
ammo_low_t BotPrimaryAmmoLow(bot_t &pBot, const bot_weapon_select_t &select);
ammo_low_t BotSecondaryAmmoLow(bot_t &pBot, const bot_weapon_select_t &select);
int BotGetLowAmmoFlags(bot_t &pBot, int *weapon_flags, const qboolean OnlyCarrying);
qboolean BotAllWeaponsRunningOutOfAmmo(bot_t &pBot, const qboolean GoodWeaponsOnly);
void BotSelectAttack(bot_t &pBot, const bot_weapon_select_t &select, qboolean &use_primary, qboolean &use_secondary);
qboolean IsValidWeaponChoose(bot_t &pBot, const bot_weapon_select_t &select);
qboolean IsValidPrimaryAttack(bot_t &pBot, const bot_weapon_select_t &select, const float distance, const float height, const qboolean always_in_range);
qboolean IsValidSecondaryAttack(bot_t &pBot, const bot_weapon_select_t &select, const float distance, const float height, const qboolean always_in_range);
int BotGetBetterWeaponChoice(bot_t &pBot, const bot_weapon_select_t ¤t, const bot_weapon_select_t *pSelect, const float distance, const float height, qboolean *use_primary, qboolean *use_secondary);
qboolean IsValidToFireAtTheMoment(bot_t &pBot, const bot_weapon_select_t &select);
qboolean BotWeaponCanAttack(bot_t &pBot, const qboolean GoodWeaponsOnly);
qboolean BotGetGoodWeaponCount(bot_t &pBot, const int stop_count);
#endif // BOT_WEAPONS_H