2 * Update self.tur_shotorg by getting up2date bone info
3 * NOTICE this func overwrites the global v_forward, v_right and v_up vectors.
5 float turret_tag_fire_update()
9 error("Call to turret_tag_fire_update with self.tur_head missing!\n");
10 self.tur_shotorg = '0 0 0';
14 self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
15 v_forward = normalize(v_forward);
21 * Railgun-like beam, but has thickness and suppots slowing of target
23 void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax,
24 float bforce, float f_dmg, float f_velfactor, int deathtype)
27 vector hitloc, force, endpoint, dir;
30 dir = normalize(end - start);
33 // go a little bit into the wall because we need to hit this wall later
36 // trace multiple times until we hit a wall, each obstacle will be made unsolid.
37 // note down which entities were hit so we can damage them later
40 tracebox(start, smin, smax, end, false, this);
42 // if it is world we can't hurt it so stop now
43 if (trace_ent == world || trace_fraction == 1)
46 if (trace_ent.solid == SOLID_BSP)
49 // make the entity non-solid so we can hit the next one
50 trace_ent.railgunhit = true;
51 trace_ent.railgunhitloc = end;
52 trace_ent.railgunhitsolidbackup = trace_ent.solid;
54 // stop if this is a wall
56 // make the entity non-solid
57 trace_ent.solid = SOLID_NOT;
60 endpoint = trace_endpos;
62 // find all the entities the railgun hit and restore their solid state
63 ent = findfloat(world, railgunhit, true);
66 // restore their solid type
67 ent.solid = ent.railgunhitsolidbackup;
68 ent = findfloat(ent, railgunhit, true);
71 // find all the entities the railgun hit and hurt them
72 ent = findfloat(world, railgunhit, true);
75 // get the details we need to call the damage function
76 hitloc = ent.railgunhitloc;
77 ent.railgunhitloc = '0 0 0';
78 ent.railgunhitsolidbackup = SOLID_NOT;
79 ent.railgunhit = false;
84 Damage (ent, this, this, f_dmg, deathtype, hitloc, force);
85 ent.velocity = ent.velocity * f_velfactor;
86 //ent.alpha = 0.25 + random() * 0.75;
89 // advance to the next entity
90 ent = findfloat(ent, railgunhit, true);
92 trace_endpos = endpoint;
101 self.think = SUB_Remove;
102 self.nextthink = time;
110 self.nextthink = time;
113 void mark_error(vector where,float lifetime)
115 entity err = new(error_marker);
116 setmodel(err, MDL_MARKER);
117 setorigin(err,where);
118 err.movetype = MOVETYPE_NONE;
119 err.think = marker_think;
120 err.nextthink = time;
123 err.cnt = lifetime + time;
126 void mark_info(vector where,float lifetime)
128 entity err = spawn(info_marker);
129 setmodel(err, MDL_MARKER);
130 setorigin(err,where);
131 err.movetype = MOVETYPE_NONE;
132 err.think = marker_think;
133 err.nextthink = time;
136 err.cnt = lifetime + time;
139 entity mark_misc(vector where,float lifetime)
141 entity err = spawn(mark_misc);
142 setmodel(err, MDL_MARKER);
143 setorigin(err,where);
144 err.movetype = MOVETYPE_NONE;
145 err.think = marker_think;
146 err.nextthink = time;
149 err.cnt = lifetime + time;
153 MODEL(TUR_C512, "models/turrets/c512.md3");
156 * Paint a v_color colord circle on target onwho
157 * that fades away over f_time
159 void paint_target(entity onwho, float f_size, vector v_color, float f_time)
164 setmodel(e, MDL_TUR_C512); // precision set above
165 e.scale = (f_size/512);
166 //setsize(e, '0 0 0', '0 0 0');
167 //setattachment(e,onwho,"");
168 setorigin(e,onwho.origin + '0 0 1');
170 e.movetype = MOVETYPE_FLY;
172 e.velocity = (v_color * 32); // + '0 0 1' * 64;
174 e.colormod = v_color;
175 SUB_SetFade(e,time,f_time);
178 void paint_target2(entity onwho, float f_size, vector v_color, float f_time)
183 setmodel(e, MDL_TUR_C512); // precision set above
184 e.scale = (f_size/512);
185 setsize(e, '0 0 0', '0 0 0');
187 setorigin(e,onwho.origin + '0 0 1');
189 e.movetype = MOVETYPE_FLY;
191 e.velocity = (v_color * 32); // + '0 0 1' * 64;
192 e.avelocity_x = -128;
194 e.colormod = v_color;
195 SUB_SetFade(e,time,f_time);
198 void paint_target3(vector where, float f_size, vector v_color, float f_time)
202 setmodel(e, MDL_TUR_C512); // precision set above
203 e.scale = (f_size/512);
204 setsize(e, '0 0 0', '0 0 0');
205 setorigin(e,where+ '0 0 1');
206 e.movetype = MOVETYPE_NONE;
207 e.velocity = '0 0 0';
208 e.colormod = v_color;
209 SUB_SetFade(e,time,f_time);