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 CHECK_AMMO_RESOURCE_LIMIT(amresource, res_resource)
#define DROP_AMMO_RESOURCE(amresource, res_resource)

Functions

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

Macro Definition Documentation

◆ CHECK_AMMO_RESOURCE_LIMIT

#define CHECK_AMMO_RESOURCE_LIMIT ( amresource,
res_resource )
Value:
if (amresource < maxammo) \
GiveResourceWithLimit(toucher, res_resource, ammo_factor, maxammo);
entity entity toucher
Definition self.qh:72

Referenced by nade_ammo_touch().

◆ DROP_AMMO_RESOURCE

#define DROP_AMMO_RESOURCE ( amresource,
res_resource )
Value:
if (amresource > 0) \
SetResource(toucher, res_resource, amresource + ammo_factor);

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{
70
72 orb.colormod = NADE_TYPE_AMMO.m_color;
73}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity owner
Definition main.qh:87
void nade_ammo_touch(entity this, entity toucher)
Definition ammo.qc:4
float autocvar_g_nades_ammo_time
Definition ammo.qh:7
vector origin
#define settouch(e, f)
Definition self.qh:73
entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
Definition sv_nades.qc:75
float autocvar_g_nades_nade_radius
Definition sv_nades.qh:21
entity realowner

References autocvar_g_nades_ammo_time, autocvar_g_nades_nade_radius, entity(), nade_ammo_touch(), nades_spawn_orb(), origin, owner, realowner, 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{
6 float maxammo = 999;
7 float ammo_factor;
8 float amshells = GetResource(toucher, RES_SHELLS);
9 float ambullets = GetResource(toucher, RES_BULLETS);
10 float amrockets = GetResource(toucher, RES_ROCKETS);
11 float amcells = GetResource(toucher, RES_CELLS);
13 if(!IS_DEAD(toucher))
14 if(!STAT(FROZEN, toucher))
15 {
16 float new_load;
17 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
18 {
19 .entity weaponentity = weaponentities[slot];
20 if (toucher.(weaponentity).clip_size)
21 {
22 new_load = (SAME_TEAM(toucher, this.realowner))
23 ? toucher.(weaponentity).clip_size
24 : max(0, toucher.(weaponentity).clip_load - toucher.(weaponentity).clip_size * (autocvar_g_nades_ammo_clip_empty_rate * frametime/2));
25
26 toucher.(weaponentity).clip_load = toucher.(weaponentity).(weapon_load[toucher.(weaponentity).m_switchweapon.m_id]) = new_load;
27 }
28 }
29
31 if ( toucher != this.realowner )
33
34#define CHECK_AMMO_RESOURCE_LIMIT(amresource, res_resource) \
35 if (amresource < maxammo) \
36 GiveResourceWithLimit(toucher, res_resource, ammo_factor, maxammo);
37
38#define DROP_AMMO_RESOURCE(amresource, res_resource) \
39 if (amresource > 0) \
40 SetResource(toucher, res_resource, amresource + ammo_factor);
41
42 if ( ammo_factor > 0 )
43 {
44 CHECK_AMMO_RESOURCE_LIMIT(amshells, RES_SHELLS);
45 CHECK_AMMO_RESOURCE_LIMIT(ambullets, RES_BULLETS);
46 CHECK_AMMO_RESOURCE_LIMIT(amrockets, RES_ROCKETS);
47 CHECK_AMMO_RESOURCE_LIMIT(amcells, RES_CELLS);
48
49 if (this.nade_show_particles)
50 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
51 }
52 else if ( ammo_factor < 0 )
53 {
54 //Foe drops ammo points
55 DROP_AMMO_RESOURCE(amshells, RES_SHELLS);
56 DROP_AMMO_RESOURCE(ambullets, RES_BULLETS);
57 DROP_AMMO_RESOURCE(amrockets, RES_ROCKETS);
58 DROP_AMMO_RESOURCE(amcells, RES_CELLS);
59
60 return;
61 }
62#undef CHECK_AMMO_RESOURCE_LIMIT
63#undef DROP_AMMO_RESOURCE
64 }
65}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define DROP_AMMO_RESOURCE(amresource, res_resource)
#define CHECK_AMMO_RESOURCE_LIMIT(amresource, res_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:245
#define IS_PLAYER(s)
Definition player.qh:243
float frametime
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:124
#define STAT(...)
Definition stats.qh:82
float max(float f,...)
float nade_show_particles
Definition sv_nades.qh:53
#define SAME_TEAM(a, b)
Definition teams.qh:241
#define IS_MONSTER(v)
Definition utils.qh:21
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, CHECK_AMMO_RESOURCE_LIMIT, clip_load, DROP_AMMO_RESOURCE, entity(), frametime, GetResource(), IS_DEAD, IS_MONSTER, IS_PLAYER, max(), MAX_WEAPONSLOTS, nade_show_particles, realowner, SAME_TEAM, Send_Effect(), STAT, toucher, and weaponentities.

Referenced by nade_ammo_boom().