]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/fusionreactor.qc
Merge branch 'master' into Mario/target_teleporter_v2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / fusionreactor.qc
1 #include "fusionreactor.qh"
2
3 #ifdef SVQC
4 bool turret_fusionreactor_firecheck(entity this)
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
27 spawnfunc(turret_fusionreactor) { if (!turret_initialize(this, TUR_FUSIONREACTOR)) delete(this); }
28
29 METHOD(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 }
35 METHOD(FusionReactor, tr_think, void(FusionReactor thistur, entity it))
36 {
37     it.tur_head.avelocity = '0 250 0' * (it.ammo / it.ammo_max);
38 }
39 METHOD(FusionReactor, tr_setup, void(FusionReactor this, entity it))
40 {
41     it.ammo_flags                               = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE;
42     it.target_select_flags      = TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_OWNTEAM | TFL_TARGETSELECT_RANGELIMITS;
43     it.firecheck_flags          = TFL_FIRECHECK_AMMO_OWN | TFL_FIRECHECK_AMMO_OTHER | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_DEAD;
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