Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
fusionreactor.qc
Go to the documentation of this file.
1#include "fusionreactor.qh"
2
3#ifdef SVQC
4
6{
7 entity targ = this.enemy;
8
9 switch (MUTATOR_CALLHOOK(FusionReactor_ValidTarget, this, targ))
10 {
11 case MUT_FUSREAC_TARG_VALID: return true;
12 case MUT_FUSREAC_TARG_INVALID: return false;
13 }
14
15 if (this.attack_finished_single[0] > time
16 || !targ || this.team != targ.team
17 || IS_DEAD(targ)
18 || this.ammo < this.shot_dmg || targ.ammo >= targ.ammo_max
19 || vdist(targ.origin - this.origin, >, this.target_range)
20 || !(targ.ammo_flags & TFL_AMMO_ENERGY))
21 return false;
22
23 return true;
24}
25
26spawnfunc(turret_fusionreactor)
27{
28 if (!turret_initialize(this, TUR_FUSIONREACTOR))
29 delete(this);
30}
31
32METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it))
33{
34 it.enemy.ammo = min(it.enemy.ammo + it.shot_dmg, it.enemy.ammo_max);
35 vector fl_org = 0.5 * (it.enemy.absmin + it.enemy.absmax);
36 te_smallflash(fl_org);
37}
38METHOD(FusionReactor, tr_think, void(FusionReactor thistur, entity it))
39{
40 it.tur_head.avelocity = '0 250 0' * (it.ammo / it.ammo_max);
41}
42METHOD(FusionReactor, tr_setup, void(FusionReactor this, entity it))
43{
44 it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE;
47 it.shoot_flags = TFL_SHOOT_HITALLVALID;
48 it.aim_flags = TFL_AIM_NO;
49 it.track_flags = TFL_TRACK_NO;
50
51 it.tur_head.scale = 0.75;
52 it.tur_head.avelocity = '0 50 0';
53
54 it.turret_firecheckfunc = turret_fusionreactor_firecheck;
55}
56
57#endif // SVQC
58#ifdef MENUQC
59
60METHOD(FusionReactor, describe, string(FusionReactor this))
61{
62 TC(FusionReactor, this);
64 PAR(_("The %s is a bit of a unique turret, instead helping out other turrets rather than directly attacking its targets. "
65 "It has no weapon of its own, and instead works by generating power for nearby turrets, so that they can attack their shared targets more often."), COLORED_NAME(this));
66 PAR(_("This is the only turret that doesn't directly attack its targets."));
67 return PAGE_TEXT;
68}
69
70#endif // MENUQC
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
int team
Definition main.qh:188
#define COLORED_NAME(this)
Definition color.qh:195
#define IS_DEAD(s)
Definition player.qh:244
float time
bool turret_fusionreactor_firecheck(entity this)
#define TC(T, sym)
Definition _all.inc:82
float min(float f,...)
#define METHOD(cname, name, prototype)
Definition oo.qh:269
vector
Definition self.qh:92
@ MUT_FUSREAC_TARG_VALID
Definition events.qh:1201
@ MUT_FUSREAC_TARG_INVALID
Definition events.qh:1202
#define spawnfunc(id)
Definition spawnfunc.qh:96
#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 enemy
Definition sv_ctf.qh:153
bool turret_initialize(entity this, Turret tur)
float ammo
Definition sv_turrets.qh:43
const int TFL_TRACK_NO
don't move head
Definition turret.qh:107
const int TFL_FIRECHECK_DISTANCES
another range check
Definition turret.qh:114
const int TFL_TARGETSELECT_TEAMCHECK
don't attack teammates
Definition turret.qh:88
const int TFL_FIRECHECK_AMMO_OWN
own ammo needs to be larger than damage dealt
Definition turret.qh:121
const int TFL_FIRECHECK_DEAD
don't attack dead targets (zombies?)
Definition turret.qh:113
const int TFL_TARGETSELECT_RANGELIMITS
limit target selection range
Definition turret.qh:87
const int TFL_FIRECHECK_AMMO_OTHER
target's ammo needs to be less than max
Definition turret.qh:122
const int TFL_AMMO_ENERGY
uses power
Definition turret.qh:158
const int TFL_AIM_NO
no aiming
Definition turret.qh:98
const int TFL_AMMO_RECHARGE
regenerates ammo
Definition turret.qh:161
const int TFL_TARGETSELECT_OWNTEAM
only attack teammates
Definition turret.qh:90
const int TFL_SHOOT_HITALLVALID
loop through all valid targets
Definition turret.qh:131
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
float attack_finished_single[MAX_WEAPONSLOTS]