]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/tturrets/units/unit_mlrs.qc
change ALL sound calls AGAIN (damn Spike)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tturrets / units / unit_mlrs.qc
1 void spawnfunc_turret_mlrs();
2 void turret_mlrs_dinit();
3 void turret_mlrs_attack();
4 void turret_mlrs_rocket_explode();
5 void turret_mlrs_rocket_touch();
6
7 void turret_mlrs_postthink()
8 {
9     // 0 = full, 6 = empty
10     self.tur_head.frame = bound(0, 6 - floor(0.1 + self.ammo / self.shot_dmg), 6);
11     if(self.tur_head.frame < 0)
12     {
13         dprint("ammo:",ftos(self.ammo),"\n");
14         dprint("shot_dmg:",ftos(self.shot_dmg),"\n");
15     }
16     
17 }
18
19 void turret_mlrs_attack()
20 {
21     entity missile;
22
23     turret_tag_fire_update();
24
25     asound (self, CH_WEAPON_A, "weapons/rocket_fire.wav", VOL_BASE, ATTN_NORM);
26
27     missile                    = spawn ();
28     setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
29     setorigin(missile, self.tur_shotorg);
30     missile.classname          = "mlrs_missile";
31     missile.owner              = self;
32     missile.bot_dodge          = TRUE;
33     missile.bot_dodgerating    = self.shot_dmg;
34     missile.takedamage         = DAMAGE_NO;
35     missile.damageforcescale   = 4;
36     missile.think              = turret_mlrs_rocket_explode;
37     missile.nextthink          = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
38     missile.solid              = SOLID_BBOX;
39     missile.movetype           = MOVETYPE_FLYMISSILE;
40     missile.velocity           = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
41     missile.angles             = vectoangles(missile.velocity);
42     missile.touch              = turret_mlrs_rocket_touch;
43     missile.flags              = FL_PROJECTILE;
44     missile.solid              = SOLID_BBOX;
45     missile.enemy              = self.enemy;
46
47         CSQCProjectile(missile, TRUE, PROJECTILE_ROCKET, FALSE); // no cull, fly sound
48
49     te_explosion (missile.origin);
50 }
51
52 void turret_mlrs_rocket_touch()
53 {
54     if( (other == self.owner) || (other == self.owner.tur_head) )
55         return;
56
57     PROJECTILE_TOUCH;
58
59     turret_mlrs_rocket_explode();
60 }
61
62 void turret_mlrs_rocket_explode()
63 {
64
65     if(self.event_damage != SUB_Null)
66     {
67         self.event_damage = SUB_Null;
68         self.think = turret_mlrs_rocket_explode;
69         self.nextthink = time;
70         return;
71     }
72
73 #ifdef TURRET_DEBUG
74     float d;
75
76     d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_MLRS, world);
77     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
78     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
79 #else
80     RadiusDamage (self, self.owner, self.owner.shot_dmg, self.owner.shot_dmg * 0.5, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_MLRS, world);
81 #endif
82
83     // Target dead, Tell turret.
84     if ((self.enemy.deadflag != DEAD_NO) && (self.enemy == self.owner.enemy))
85         self.owner.enemy = world;
86
87     remove (self);
88 }
89
90 void turret_mlrs_dinit()
91 {
92     if (self.netname == "")      self.netname  = "MLRS turret";
93
94     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
95     self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
96     self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE;// | TFL_AIM_GROUND2;
97
98     if (turret_stdproc_init("mlrs_std", "models/turrets/base.md3", "models/turrets/mlrs.md3", TID_MLRS) == 0)
99     {
100         remove(self);
101         return;
102     }
103
104     self.damage_flags |= TFL_DMG_HEADSHAKE;
105     self.shoot_flags  |= TFL_SHOOT_VOLLYALWAYS;
106     self.volly_counter = self.shot_volly;
107
108     // Our fire routine
109     self.turret_firefunc  = turret_mlrs_attack;
110     self.turret_postthink = turret_mlrs_postthink;
111
112 }
113
114 /*QUAKED turret_mlrs (0 .5 .8) ?
115 */
116
117 void spawnfunc_turret_mlrs()
118 {
119     precache_model ("models/turrets/mlrs.md3");
120     precache_model ("models/turrets/base.md3");
121
122     self.think = turret_mlrs_dinit;
123     self.nextthink = time + 0.5;
124 }
125
126