]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/turret/fusionreactor.qc
Hunter-Killer: Only loop through entities that can be damaged by contents (not perfec...
[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     if (this.attack_finished_single[0] > time)
8         return false;
9
10     if (IS_DEAD(this.enemy))
11         return false;
12
13     if (this.enemy == NULL)
14         return false;
15
16     if (this.ammo < this.shot_dmg)
17         return false;
18
19     if (this.enemy.ammo >= this.enemy.ammo_max)
20         return false;
21
22     if(vdist(this.enemy.origin - this.origin, >, this.target_range))
23         return false;
24
25     if(this.team != this.enemy.team)
26         return false;
27
28     if(!(this.enemy.ammo_flags & TFL_AMMO_ENERGY))
29         return false;
30
31     return true;
32 }
33
34 spawnfunc(turret_fusionreactor) { if (!turret_initialize(this, TUR_FUSIONREACTOR)) delete(this); }
35
36 METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it))
37 {
38     it.enemy.ammo = min(it.enemy.ammo + it.shot_dmg,it.enemy.ammo_max);
39     vector fl_org = 0.5 * (it.enemy.absmin + it.enemy.absmax);
40     te_smallflash(fl_org);
41 }
42 METHOD(FusionReactor, tr_think, void(FusionReactor thistur, entity it))
43 {
44     it.tur_head.avelocity = '0 250 0' * (it.ammo / it.ammo_max);
45 }
46 METHOD(FusionReactor, tr_setup, void(FusionReactor this, entity it))
47 {
48     it.ammo_flags                               = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE;
49     it.target_select_flags      = TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_OWNTEAM | TFL_TARGETSELECT_RANGELIMITS;
50     it.firecheck_flags          = TFL_FIRECHECK_AMMO_OWN | TFL_FIRECHECK_AMMO_OTHER | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_DEAD;
51     it.shoot_flags                      = TFL_SHOOT_HITALLVALID;
52     it.aim_flags                                = TFL_AIM_NO;
53     it.track_flags                      = TFL_TRACK_NO;
54
55     it.tur_head.scale = 0.75;
56     it.tur_head.avelocity = '0 50 0';
57
58     it.turret_firecheckfunc = turret_fusionreactor_firecheck;
59 }
60
61 #endif
62 #endif