X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Futil.qc;h=4928262f2f4ef85c355e875c7a1c2097a1bdd58d;hb=7666560c6a475aefe6b55ff74a20444f328e0093;hp=6de59027e38bdc668a9071f398a9bb1955cc73d9;hpb=04bbc270623d9f75f19d00c93b6f5b2c51734bf4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/util.qc b/qcsrc/common/turrets/util.qc index 6de59027e..4928262f2 100644 --- a/qcsrc/common/turrets/util.qc +++ b/qcsrc/common/turrets/util.qc @@ -1,139 +1,27 @@ /* -* Return a angle within +/- 360. -*/ -float anglemods(float v) -{ - v = v - 360 * floor(v / 360); - - if(v >= 180) - return v - 360; - else if(v <= -180) - return v + 360; - else - return v; -} - -/* -* Return the short angle -*/ -float shortangle_f(float ang1, float ang2) -{ - if(ang1 > ang2) - { - if(ang1 > 180) - return ang1 - 360; - } - else - { - if(ang1 < -180) - return ang1 + 360; - } - - return ang1; -} - -vector shortangle_v(vector ang1, vector ang2) -{ - vector vtmp; - - vtmp_x = shortangle_f(ang1_x,ang2_x); - vtmp_y = shortangle_f(ang1_y,ang2_y); - vtmp_z = shortangle_f(ang1_z,ang2_z); - - return vtmp; -} - -vector shortangle_vxy(vector ang1, vector ang2) -{ - vector vtmp = '0 0 0'; - - vtmp_x = shortangle_f(ang1_x,ang2_x); - vtmp_y = shortangle_f(ang1_y,ang2_y); - - return vtmp; -} - - -/* -* Get "real" origin, in worldspace, even if ent is attached to something else. -*/ -vector real_origin(entity ent) -{ - entity e; - vector v = ((ent.absmin + ent.absmax) * 0.5); - - e = ent.tag_entity; - while(e) - { - v = v + ((e.absmin + e.absmax) * 0.5); - e = e.tag_entity; - } - - return v; -} - -/* -* Return the angle between two enteties -*/ -vector angleofs(entity from, entity to) -{ - vector v_res; - - v_res = normalize(to.origin - from.origin); - v_res = vectoangles(v_res); - v_res = v_res - from.angles; - - if (v_res_x < 0) v_res_x += 360; - if (v_res_x > 180) v_res_x -= 360; - - if (v_res_y < 0) v_res_y += 360; - if (v_res_y > 180) v_res_y -= 360; - - return v_res; -} - -vector angleofs3(vector from, vector from_a, entity to) -{ - vector v_res; - - v_res = normalize(to.origin - from); - v_res = vectoangles(v_res); - v_res = v_res - from_a; - - if (v_res_x < 0) v_res_x += 360; - if (v_res_x > 180) v_res_x -= 360; - - if (v_res_y < 0) v_res_y += 360; - if (v_res_y > 180) v_res_y -= 360; - - return v_res; -} - -/* -* Update self.tur_shotorg by getting up2date bone info +* Update this.tur_shotorg by getting up2date bone info * NOTICE this func overwrites the global v_forward, v_right and v_up vectors. */ -#define turret_tag_fire_update() self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));v_forward = normalize(v_forward) -float turret_tag_fire_update_s() +float turret_tag_fire_update(entity this) { - if(!self.tur_head) + if(!this.tur_head) { - error("Call to turret_tag_fire_update with self.tur_head missing!\n"); - self.tur_shotorg = '0 0 0'; - return FALSE; + LOG_DEBUG("Call to turret_tag_fire_update with this.tur_head missing!\n"); + this.tur_shotorg = '0 0 0'; + return false; } - self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire")); + this.tur_shotorg = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_fire")); v_forward = normalize(v_forward); - return TRUE; + return true; } /* * Railgun-like beam, but has thickness and suppots slowing of target */ -void FireImoBeam (vector start, vector end, vector smin, vector smax, - float bforce, float f_dmg, float f_velfactor, float deathtype) +void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax, + float bforce, float f_dmg, float f_velfactor, int deathtype) { vector hitloc, force, endpoint, dir; @@ -149,17 +37,17 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax, // note down which entities were hit so we can damage them later while (1) { - tracebox(start, smin, smax, end, FALSE, self); + tracebox(start, smin, smax, end, false, this); - // if it is world we can't hurt it so stop now - if (trace_ent == world || trace_fraction == 1) + // if it is NULL we can't hurt it so stop now + if (trace_ent == NULL || trace_fraction == 1) break; if (trace_ent.solid == SOLID_BSP) break; // make the entity non-solid so we can hit the next one - trace_ent.railgunhit = TRUE; + trace_ent.railgunhit = true; trace_ent.railgunhitloc = end; trace_ent.railgunhitsolidbackup = trace_ent.solid; @@ -172,67 +60,63 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax, endpoint = trace_endpos; // find all the entities the railgun hit and restore their solid state - ent = findfloat(world, railgunhit, TRUE); + ent = findfloat(NULL, railgunhit, true); while (ent) { // restore their solid type ent.solid = ent.railgunhitsolidbackup; - ent = findfloat(ent, railgunhit, TRUE); + ent = findfloat(ent, railgunhit, true); } // find all the entities the railgun hit and hurt them - ent = findfloat(world, railgunhit, TRUE); + ent = findfloat(NULL, railgunhit, true); while (ent) { // get the details we need to call the damage function hitloc = ent.railgunhitloc; ent.railgunhitloc = '0 0 0'; ent.railgunhitsolidbackup = SOLID_NOT; - ent.railgunhit = FALSE; + ent.railgunhit = false; // apply the damage if (ent.takedamage) { - Damage (ent, self, self, f_dmg, deathtype, hitloc, force); + Damage (ent, this, this, f_dmg, deathtype, hitloc, force); ent.velocity = ent.velocity * f_velfactor; //ent.alpha = 0.25 + random() * 0.75; } // advance to the next entity - ent = findfloat(ent, railgunhit, TRUE); + ent = findfloat(ent, railgunhit, true); } trace_endpos = endpoint; } #ifdef TURRET_DEBUG -void SUB_Remove(); -void marker_think() +void marker_think(entity this, ) { - if(self.cnt) - if(self.cnt < time) + if(this.cnt) + if(this.cnt < time) { - self.think = SUB_Remove; - self.nextthink = time; + setthink(this, SUB_Remove); + this.nextthink = time; return; } - self.frame += 1; - if(self.frame > 29) - self.frame = 0; + this.frame += 1; + if(this.frame > 29) + this.frame = 0; - self.nextthink = time; + this.nextthink = time; } void mark_error(vector where,float lifetime) { - entity err; - - err = spawn(); - err.classname = "error_marker"; - setmodel(err,"models/marker.md3"); - setorigin(err,where); + entity err = new(error_marker); + setmodel(err, MDL_MARKER); + setorigin(err, where); err.movetype = MOVETYPE_NONE; - err.think = marker_think; + setthink(err, marker_think); err.nextthink = time; err.skin = 0; if(lifetime) @@ -241,14 +125,11 @@ void mark_error(vector where,float lifetime) void mark_info(vector where,float lifetime) { - entity err; - - err = spawn(); - err.classname = "info_marker"; - setmodel(err,"models/marker.md3"); - setorigin(err,where); + entity err = spawn(info_marker); + setmodel(err, MDL_MARKER); + setorigin(err, where); err.movetype = MOVETYPE_NONE; - err.think = marker_think; + setthink(err, marker_think); err.nextthink = time; err.skin = 1; if(lifetime) @@ -257,14 +138,11 @@ void mark_info(vector where,float lifetime) entity mark_misc(vector where,float lifetime) { - entity err; - - err = spawn(); - err.classname = "mark_misc"; - setmodel(err,"models/marker.md3"); - setorigin(err,where); + entity err = spawn(mark_misc); + setmodel(err, MDL_MARKER); + setorigin(err, where); err.movetype = MOVETYPE_NONE; - err.think = marker_think; + setthink(err, marker_think); err.nextthink = time; err.skin = 3; if(lifetime) @@ -272,6 +150,8 @@ entity mark_misc(vector where,float lifetime) return err; } +MODEL(TUR_C512, "models/turrets/c512.md3"); + /* * Paint a v_color colord circle on target onwho * that fades away over f_time @@ -281,11 +161,11 @@ void paint_target(entity onwho, float f_size, vector v_color, float f_time) entity e; e = spawn(); - setmodel(e, "models/turrets/c512.md3"); // precision set above + setmodel(e, MDL_TUR_C512); // precision set above e.scale = (f_size/512); //setsize(e, '0 0 0', '0 0 0'); //setattachment(e,onwho,""); - setorigin(e,onwho.origin + '0 0 1'); + setorigin(e, onwho.origin + '0 0 1'); e.alpha = 0.15; e.movetype = MOVETYPE_FLY; @@ -300,11 +180,11 @@ void paint_target2(entity onwho, float f_size, vector v_color, float f_time) entity e; e = spawn(); - setmodel(e, "models/turrets/c512.md3"); // precision set above + setmodel(e, MDL_TUR_C512); // precision set above e.scale = (f_size/512); setsize(e, '0 0 0', '0 0 0'); - setorigin(e,onwho.origin + '0 0 1'); + setorigin(e, onwho.origin + '0 0 1'); e.alpha = 0.15; e.movetype = MOVETYPE_FLY; @@ -319,10 +199,10 @@ void paint_target3(vector where, float f_size, vector v_color, float f_time) { entity e; e = spawn(); - setmodel(e, "models/turrets/c512.md3"); // precision set above + setmodel(e, MDL_TUR_C512); // precision set above e.scale = (f_size/512); setsize(e, '0 0 0', '0 0 0'); - setorigin(e,where+ '0 0 1'); + setorigin(e, where + '0 0 1'); e.movetype = MOVETYPE_NONE; e.velocity = '0 0 0'; e.colormod = v_color;