]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/tturrets/units/unit_mlrs.qc
Fix accuracy stats (#400)
[divverent/nexuiz.git] / data / 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
10     // 0 = full, 6 = empty
11     self.tur_head.frame = rint(6 - (self.ammo / self.shot_dmg));
12 }
13
14 void turret_mlrs_attack()
15 {
16     entity missile;
17
18     turret_tag_fire_update();
19
20     sound (self, CHAN_WEAPON, "weapons/rocket_fire.wav", VOL_BASE, ATTN_NORM);
21
22     missile                    = spawn ();
23     //setsize (missile, '0 0 0', '0 0 0'); // give it some size so it can be shot
24     setsize (missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
25     setorigin(missile, self.tur_shotorg);
26     missile.classname          = "mlrs_missile";
27     missile.owner              = self;
28     missile.bot_dodge          = TRUE;
29     missile.bot_dodgerating    = self.shot_dmg;
30     missile.takedamage         = DAMAGE_NO;
31     missile.damageforcescale   = 4;
32     //missile.health             = 25;
33     missile.think              = turret_mlrs_rocket_explode;
34
35     missile.nextthink          = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed);
36     //missile.nextthink          = missile.nextthink + random() * self.shot_spread;
37
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     //self.tur_head.frame = 7 - self.volly_counter;
52 }
53
54 void turret_mlrs_rocket_touch()
55 {
56     if( (other == self.owner) || (other == self.owner.tur_head) )
57         return;
58
59     PROJECTILE_TOUCH;
60
61     turret_mlrs_rocket_explode();
62 }
63
64 void turret_mlrs_rocket_explode()
65 {
66     vector org2;
67
68     if(self.event_damage != SUB_Null)
69     {
70         self.event_damage = SUB_Null;
71         self.think = turret_mlrs_rocket_explode;
72         self.nextthink = time;
73         return;
74     }
75
76
77     sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
78     org2 = findbetterlocation (self.origin, 16);
79     pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
80     //w_deathtypestring = "dident escape the rocket barrage";
81 #ifdef TURRET_DEBUG
82     float d;
83
84     d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET, world, 0);
85     self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d; //self.owner.shot_dmg;
86     self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
87 #else
88     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, world, 0);
89 #endif
90
91     // Target dead, Tell turret.
92     if ((self.enemy.deadflag != DEAD_NO) && (self.enemy == self.owner.enemy))
93         self.owner.enemy = world;
94
95     remove (self);
96 }
97
98 void turret_mlrs_dinit()
99 {
100     if (self.netname == "")      self.netname  = "MLRS turret";
101
102     self.turrcaps_flags = TFL_TURRCAPS_RADIUSDMG | TFL_TURRCAPS_MEDPROJ | TFL_TURRCAPS_PLAYERKILL;
103     self.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE;
104     self.aim_flags = TFL_AIM_LEAD | TFL_AIM_ZEASE | TFL_AIM_SHOTTIMECOMPENSATE | TFL_AIM_INFRONT;
105
106     if (turret_stdproc_init("mlrs_std",0) == 0)
107     {
108         remove(self);
109         return;
110     }
111
112     self.damage_flags |= TFL_DMG_HEADSHAKE;
113
114     self.shoot_flags |= TFL_SHOOT_VOLLYALWAYS;
115     self.volly_counter = self.shot_volly;
116
117     setmodel(self,"models/turrets/base.md3");
118     setmodel(self.tur_head,"models/turrets/mlrs.md3");
119
120     if (!turret_tag_setup())
121         dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n");
122
123     // Our fire routine
124     self.turret_firefunc  = turret_mlrs_attack;
125     self.turret_postthink = turret_mlrs_postthink;
126
127 }
128
129 /*QUAKED turret_mlrs (0 .5 .8) ?
130 */
131
132 void spawnfunc_turret_mlrs()
133 {
134     //precache_model ( "models/turrets/rocket.md3");
135     precache_model ("models/turrets/mlrs.md3");
136     precache_model ("models/turrets/base.md3");
137
138     self.think = turret_mlrs_dinit;
139     self.nextthink = time + 0.5;
140 }
141
142