Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ammo.qc File Reference
Include dependency graph for ammo.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DROP_AMMO_RESOURCE(res_resource)
#define GIVE_AMMO_RESOURCE(res_resource, max_resource)

Functions

void nade_ammo_boom (entity this)
void nade_ammo_touch (entity this, entity toucher)

Macro Definition Documentation

◆ DROP_AMMO_RESOURCE

#define DROP_AMMO_RESOURCE ( res_resource)
Value:
amresource = GetResource(toucher, res_resource); \
if (amresource > 0) \
SetResource(toucher, res_resource, max(0, amresource + ammo_factor));
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
float max(float f,...)
entity entity toucher
Definition self.qh:72

Referenced by nade_ammo_touch().

◆ GIVE_AMMO_RESOURCE

#define GIVE_AMMO_RESOURCE ( res_resource,
max_resource )
Value:
if (GetResource(toucher, res_resource) < max_resource) \
{ \
GiveResourceWithLimit(toucher, res_resource, ammo_factor, max_resource); \
gave = true; \
}

Referenced by nade_ammo_touch().

Function Documentation

◆ nade_ammo_boom()

void nade_ammo_boom ( entity this)

Definition at line 67 of file ammo.qc.

68{
71}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void nade_ammo_touch(entity this, entity toucher)
Definition ammo.qc:4
float autocvar_g_nades_ammo_radius
Definition ammo.qh:12
float autocvar_g_nades_ammo_time
Definition ammo.qh:7
#define settouch(e, f)
Definition self.qh:73
entity nades_spawn_orb(entity this, float orb_lifetime, float orb_rad)
Spawns an orb for some nade types.
Definition sv_nades.qc:79

References autocvar_g_nades_ammo_radius, autocvar_g_nades_ammo_time, entity(), nade_ammo_touch(), nades_spawn_orb(), and settouch.

Referenced by nade_boom().

◆ nade_ammo_touch()

void nade_ammo_touch ( entity this,
entity toucher )

Definition at line 4 of file ammo.qc.

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}
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)
#define GIVE_AMMO_RESOURCE(res_resource, max_resource)
float autocvar_g_nades_ammo_rate
Definition ammo.qh:8
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 STAT(...)
Definition stats.qh:82
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

References autocvar_g_nades_ammo_clip_empty_rate, autocvar_g_nades_ammo_foe, autocvar_g_nades_ammo_friend, autocvar_g_nades_ammo_rate, autocvar_g_pickup_cells_max, autocvar_g_pickup_nails_max, autocvar_g_pickup_rockets_max, autocvar_g_pickup_shells_max, clip_load, DROP_AMMO_RESOURCE, entity(), frametime, GIVE_AMMO_RESOURCE, IS_DEAD, IS_MONSTER, IS_PLAYER, max(), MAX_WEAPONSLOTS, nade_show_particles, realowner, SAME_TEAM, Send_Effect(), STAT, toucher, vec2, and weaponentities.

Referenced by nade_ammo_boom().