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{
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}
66
68{
70
72 orb.colormod = NADE_TYPE_AMMO.m_color;
73}
74#endif // SVQC
75#ifdef MENUQC
77
78METHOD(AmmoNade, describe, string(AmmoNade this))
79{
80 TC(AmmoNade, this);
82 PAR(_("The %s detonates after a short delay, temporarily creating an orb around the point where it detonated for several seconds. "
83 "If your team members enter the orb they will recover ammo, and if enemies enter the sphere they will lose ammo."), COLORED_NAME(this));
84 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));
85 return PAGE_TEXT;
86}
87#endif // MENUQC
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
entity owner
Definition main.qh:87
#define COLORED_NAME(this)
Definition color.qh:195
void nade_ammo_touch(entity this, entity toucher)
Definition ammo.qc:4
void nade_ammo_boom(entity this)
Definition ammo.qc:67
#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_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:245
#define IS_PLAYER(s)
Definition player.qh:243
float frametime
vector origin
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:124
#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:643
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:649
#define PAGE_TEXT_INIT()
Definition string.qh:642
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
float 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:21
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
int clip_load
Definition wepent.qh:14