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
5{
6 entity targ = this.enemy;
7
8 switch(MUTATOR_CALLHOOK(FusionReactor_ValidTarget, this, targ))
9 {
10 case MUT_FUSREAC_TARG_VALID: { return true; }
11 case MUT_FUSREAC_TARG_INVALID: { return false; }
12 }
13
14 if((this.attack_finished_single[0] > time)
15 || (!targ)
16 || (IS_DEAD(targ))
17 || (this.ammo < this.shot_dmg)
18 || (targ.ammo >= targ.ammo_max)
19 || (vdist(targ.origin - this.origin, >, this.target_range))
20 || (this.team != targ.team)
21 || (!(targ.ammo_flags & TFL_AMMO_ENERGY))
22 ) { return false; }
23
24 return true;
25}
26
27spawnfunc(turret_fusionreactor) { if (!turret_initialize(this, TUR_FUSIONREACTOR)) delete(this); }
28
29METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it))
30{
31 it.enemy.ammo = min(it.enemy.ammo + it.shot_dmg,it.enemy.ammo_max);
32 vector fl_org = 0.5 * (it.enemy.absmin + it.enemy.absmax);
33 te_smallflash(fl_org);
34}
35METHOD(FusionReactor, tr_think, void(FusionReactor thistur, entity it))
36{
37 it.tur_head.avelocity = '0 250 0' * (it.ammo / it.ammo_max);
38}
39METHOD(FusionReactor, tr_setup, void(FusionReactor this, entity it))
40{
41 it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE;
44 it.shoot_flags = TFL_SHOOT_HITALLVALID;
45 it.aim_flags = TFL_AIM_NO;
46 it.track_flags = TFL_TRACK_NO;
47
48 it.tur_head.scale = 0.75;
49 it.tur_head.avelocity = '0 50 0';
50
51 it.turret_firecheckfunc = turret_fusionreactor_firecheck;
52}
53
54#endif // SVQC
55#ifdef MENUQC
56
57METHOD(FusionReactor, describe, string(FusionReactor this))
58{
59 TC(FusionReactor, this);
61 PAR(_("The %s is a bit of a unique turret, instead helping out other turrets rather than directly attacking its targets. "
62 "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));
63 PAR(_("This is the only turret that doesn't directly attack its targets."));
64 return PAGE_TEXT;
65}
66
67#endif // MENUQC
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define COLORED_NAME(this)
Definition color.qh:195
#define IS_DEAD(s)
Definition player.qh:245
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: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 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
Definition turret.qh:106
const int TFL_FIRECHECK_DISTANCES
Definition turret.qh:113
const int TFL_TARGETSELECT_TEAMCHECK
Definition turret.qh:87
const int TFL_FIRECHECK_AMMO_OWN
Definition turret.qh:120
const int TFL_FIRECHECK_DEAD
Definition turret.qh:112
const int TFL_TARGETSELECT_RANGELIMITS
Definition turret.qh:86
const int TFL_FIRECHECK_AMMO_OTHER
Definition turret.qh:121
const int TFL_AMMO_ENERGY
Definition turret.qh:157
const int TFL_AIM_NO
Definition turret.qh:97
const int TFL_AMMO_RECHARGE
Definition turret.qh:160
const int TFL_TARGETSELECT_OWNTEAM
Definition turret.qh:89
const int TFL_SHOOT_HITALLVALID
Definition turret.qh:130
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
float attack_finished_single[MAX_WEAPONSLOTS]