]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/fusionreactor.qc
Merge branch 'master' into Mario/race_target_waypoint
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / fusionreactor.qc
1 #include "fusionreactor.qh"
2
3 #ifdef IMPLEMENTATION
4 #ifdef SVQC
5 bool turret_fusionreactor_firecheck(entity this)
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)
17     || (IS_DEAD(targ))
18     || (this.ammo < this.shot_dmg)
19     || (targ.ammo >= targ.ammo_max)
20     || (vdist(targ.origin - this.origin, >, this.target_range))
21     || (this.team != targ.team)
22     || (!(targ.ammo_flags & TFL_AMMO_ENERGY))
23     ) { return false; }
24
25     return true;
26 }
27
28 spawnfunc(turret_fusionreactor) { if (!turret_initialize(this, TUR_FUSIONREACTOR)) delete(this); }
29
30 METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it))
31 {
32     it.enemy.ammo = min(it.enemy.ammo + it.shot_dmg,it.enemy.ammo_max);
33     vector fl_org = 0.5 * (it.enemy.absmin + it.enemy.absmax);
34     te_smallflash(fl_org);
35 }
36 METHOD(FusionReactor, tr_think, void(FusionReactor thistur, entity it))
37 {
38     it.tur_head.avelocity = '0 250 0' * (it.ammo / it.ammo_max);
39 }
40 METHOD(FusionReactor, tr_setup, void(FusionReactor this, entity it))
41 {
42     it.ammo_flags                               = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE;
43     it.target_select_flags      = TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_OWNTEAM | TFL_TARGETSELECT_RANGELIMITS;
44     it.firecheck_flags          = TFL_FIRECHECK_AMMO_OWN | TFL_FIRECHECK_AMMO_OTHER | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_DEAD;
45     it.shoot_flags                      = TFL_SHOOT_HITALLVALID;
46     it.aim_flags                                = TFL_AIM_NO;
47     it.track_flags                      = TFL_TRACK_NO;
48
49     it.tur_head.scale = 0.75;
50     it.tur_head.avelocity = '0 50 0';
51
52     it.turret_firecheckfunc = turret_fusionreactor_firecheck;
53 }
54
55 #endif
56 #endif