Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ammo.qc
Go to the documentation of this file.
1#include "ammo.qh"
2
3#ifdef SVQC
5{
7 || IS_DEAD(toucher) || STAT(FROZEN, toucher))
8 return;
9
10 float new_load;
11 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
12 {
13 .entity weaponentity = weaponentities[slot];
14 if (toucher.(weaponentity).clip_size)
15 {
16 new_load = (SAME_TEAM(toucher, this.realowner))
17 ? toucher.(weaponentity).clip_size
18 : max(0, toucher.(weaponentity).clip_load - toucher.(weaponentity).clip_size * (autocvar_g_nades_ammo_clip_empty_rate * frametime * 0.5));
19
20 toucher.(weaponentity).clip_load = toucher.(weaponentity).(weapon_load[toucher.(weaponentity).m_switchweapon.m_id]) = new_load;
21 }
22 }
23
24 float ammo_factor = autocvar_g_nades_ammo_rate * frametime * 0.5;
25 if (toucher != this.realowner)
26 ammo_factor *= (SAME_TEAM(toucher, this))
29
30 if (ammo_factor > 0)
31 {
32 bool gave = false;
33 #define GIVE_AMMO_RESOURCE(res_resource, max_resource) \
34 if (GetResource(toucher, res_resource) < max_resource) \
35 { \
36 GiveResourceWithLimit(toucher, res_resource, ammo_factor, max_resource); \
37 gave = true; \
38 }
39
44 #undef GIVE_AMMO_RESOURCE
45
46 if (gave && this.nade_show_particles)
47 Send_Effect(EFFECT_AMMO_REGEN, toucher.origin, vec2(toucher.velocity), 1);
48 }
49 else if (ammo_factor < 0) // Foe drops ammo points
50 {
51 float amresource;
52 #define DROP_AMMO_RESOURCE(res_resource) \
53 amresource = GetResource(toucher, res_resource); \
54 if (amresource > 0) \
55 SetResource(toucher, res_resource, max(0, amresource + ammo_factor));
56
57 DROP_AMMO_RESOURCE(RES_SHELLS);
58 DROP_AMMO_RESOURCE(RES_BULLETS);
59 DROP_AMMO_RESOURCE(RES_ROCKETS);
60 DROP_AMMO_RESOURCE(RES_CELLS);
61 #undef DROP_AMMO_RESOURCE
62
63 return;
64 }
65}
66
72#endif // SVQC
73#ifdef MENUQC
75
76METHOD(AmmoNade, describe, string(AmmoNade this))
77{
78 TC(AmmoNade, this);
80 PAR(_("The %s detonates after a short delay, temporarily creating an orb around the point where it detonated for several seconds. "
81 "If your team members enter the orb they will recover ammo, and if enemies enter the sphere they will lose ammo."), COLORED_NAME(this));
82 PAR(_("Similar to the %s buff, your weapon magazines remain full while you are inside the orb, so you don't need to reload."), COLORED_NAME(BUFF_AMMO));
83 return PAGE_TEXT;
84}
85#endif // MENUQC
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define COLORED_NAME(this)
Definition color.qh:195
int autocvar_g_pickup_rockets_max
Definition ammo.qh:116
int autocvar_g_pickup_shells_max
Definition ammo.qh:44
int autocvar_g_pickup_cells_max
Definition ammo.qh:152
int autocvar_g_pickup_nails_max
Definition ammo.qh:80
#define DROP_AMMO_RESOURCE(res_resource)
void nade_ammo_touch(entity this, entity toucher)
Definition ammo.qc:4
void nade_ammo_boom(entity this)
Definition ammo.qc:67
#define GIVE_AMMO_RESOURCE(res_resource, max_resource)
float autocvar_g_nades_ammo_rate
Definition ammo.qh:8
float autocvar_g_nades_ammo_radius
Definition ammo.qh:12
float autocvar_g_nades_ammo_time
Definition ammo.qh:7
float autocvar_g_nades_ammo_clip_empty_rate
Definition ammo.qh:11
float autocvar_g_nades_ammo_foe
Definition ammo.qh:10
float autocvar_g_nades_ammo_friend
Definition ammo.qh:9
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
float frametime
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
#define TC(T, sym)
Definition _all.inc:82
#define STAT(...)
Definition stats.qh:82
float max(float f,...)
#define METHOD(cname, name, prototype)
Definition oo.qh:269
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
#define PAGE_TEXT
Definition string.qh:642
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:648
#define PAGE_TEXT_INIT()
Definition string.qh:641
entity nades_spawn_orb(entity this, float orb_lifetime, float orb_rad)
Spawns an orb for some nade types.
Definition sv_nades.qc:79
bool nade_show_particles
Definition sv_nades.qh:53
#define SAME_TEAM(a, b)
Definition teams.qh:241
entity realowner
#define IS_MONSTER(v)
Definition utils.qh:23
#define vec2(...)
Definition vector.qh:90
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
int clip_load
Definition wepent.qh:14