From: Mario Date: Sat, 18 Mar 2017 10:09:46 +0000 (+1000) Subject: Minor cleanup, also show a simple effect when a turret explodes but doesn't re-spawn X-Git-Tag: xonotic-v0.8.2~39 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7ce9999429714a463c09593b566f3b5428404d97;p=xonotic%2Fxonotic-data.pk3dir.git Minor cleanup, also show a simple effect when a turret explodes but doesn't re-spawn --- diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index 949f478fd..451afa95b 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -20,6 +20,7 @@ #include #endif +#ifdef SVQC float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax) { if (IS_PLAYER(player) && !IS_DEAD(player)) @@ -37,8 +38,6 @@ float check_tdeath(entity player, vector org, vector telefragmin, vector telefra return 0; } -#ifdef SVQC - void trigger_teleport_link(entity this); void tdeath(entity player, entity teleporter, entity telefragger, vector telefragmin, vector telefragmax) @@ -64,7 +63,6 @@ void spawn_tdeath(vector v0, entity e, vector v) { tdeath(e, e, e, '0 0 0', '0 0 0'); } - #endif void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags) @@ -174,8 +172,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle entity Simple_TeleportPlayer(entity teleporter, entity player) { vector locout; - entity e; - float p; + entity e = NULL; // Find the output teleporter if(teleporter.enemy) @@ -184,10 +181,12 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) } else { + // sorry CSQC, random stuff ain't gonna happen +#ifdef SVQC RandomSelection_Init(); FOREACH_ENTITY_STRING(targetname, teleporter.target, { - p = 1; + bool p = true; if(STAT(TELEPORT_TELEFRAG_AVOID, player)) { #ifdef SVQC @@ -196,11 +195,12 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) locout = it.origin + '0 0 1' * (1 - player.mins.z - 24); #endif if(check_tdeath(player, locout, '0 0 0', '0 0 0')) - p = 0; + p = false; } RandomSelection_AddEnt(it, (it.cnt ? it.cnt : 1), p); }); e = RandomSelection_chosen_ent; +#endif } #ifdef SVQC diff --git a/qcsrc/common/triggers/teleporters.qh b/qcsrc/common/triggers/teleporters.qh index 6f5f8cb76..d65882d55 100644 --- a/qcsrc/common/triggers/teleporters.qh +++ b/qcsrc/common/triggers/teleporters.qh @@ -71,26 +71,4 @@ void WarpZone_PostTeleportPlayer_Callback(entity pl); #ifdef CSQC .entity realowner; .float lastteleporttime; - -#define TDEATHLOOP(o) \ - entity head; \ - vector deathmin; \ - vector deathmax; \ - float deathradius; \ - deathmin = (o) + player.mins; \ - deathmax = (o) + player.maxs; \ - if(telefragmin != telefragmax) \ - { \ - if(deathmin.x > telefragmin.x) deathmin.x = telefragmin.x; \ - if(deathmin.y > telefragmin.y) deathmin.y = telefragmin.y; \ - if(deathmin.z > telefragmin.z) deathmin.z = telefragmin.z; \ - if(deathmax.x < telefragmax.x) deathmax.x = telefragmax.x; \ - if(deathmax.y < telefragmax.y) deathmax.y = telefragmax.y; \ - if(deathmax.z < telefragmax.z) deathmax.z = telefragmax.z; \ - } \ - deathradius = max(vlen(deathmin), vlen(deathmax)); \ - for(head = findradius(o, deathradius); head; head = head.chain) \ - if(head != player) \ - if(head.isplayermodel) \ - if(boxesoverlap(deathmin, deathmax, head.absmin, head.absmax)) #endif diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index 99f9f8032..d6442df8b 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -192,6 +192,10 @@ void turret_die(entity this) Turret tur = get_turretinfo(this.m_id); if(this.damage_flags & TFL_DMG_DEATH_NORESPAWN) { + // do a simple explosion effect here, since CSQC can't do it on a to-be-removed entity + sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); + Send_Effect(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1); + tur.tr_death(tur, this); delete(this.tur_head); diff --git a/qcsrc/lib/p2mathlib.qc b/qcsrc/lib/p2mathlib.qc index ac04034dd..0cee31121 100644 --- a/qcsrc/lib/p2mathlib.qc +++ b/qcsrc/lib/p2mathlib.qc @@ -20,84 +20,77 @@ vector vec_bias(vector v, float f) { vector c; - c_x = v_x + f; - c_y = v_y + f; - c_z = v_z + f; + c.x = v.x + f; + c.y = v.y + f; + c.z = v.z + f; return c; } vector vec_to_min(vector a, vector b) { vector c; - c_x = min(a_x, b_x); - c_y = min(a_y, b_y); - c_z = min(a_z, b_z); + c.x = min(a.x, b.x); + c.y = min(a.y, b.y); + c.z = min(a.z, b.z); return c; } vector vec_to_max(vector a, vector b) { vector c; - c_x = max(a_x, b_x); - c_y = max(a_y, b_y); - c_z = max(a_z, b_z); + c.x = max(a.x, b.x); + c.y = max(a.y, b.y); + c.z = max(a.z, b.z); return c; } // there may already be a function for bounding a vector in this manner, however my very quick search did not reveal one -- Player_2 vector vec_bounds_in(vector point, vector a, vector b) { - vector c, d, e; + vector d = vec_to_min(a, b); + vector e = vec_to_max(a, b); - d = vec_to_min(a, b); - e = vec_to_max(a, b); - - c = vec_to_max(point, d); - c = vec_to_min(c, e); + vector c = vec_to_min(vec_to_max(point, d), e); return c; } vector vec_bounds_out(vector point, vector a, vector b) { - vector c, d, e; - - d = vec_to_max(a, b); - e = vec_to_min(a, b); + vector d = vec_to_max(a, b); + vector e = vec_to_min(a, b); - c = vec_to_max(point, d); - c = vec_to_min(c, e); + vector c = vec_to_min(vec_to_max(point, d), e); return c; } float angle_snap_f(float f, float increment) { - float i; - for (i = 0; i <= 360; ) + for (int j = 0; j <= 360; ) { - if (f <= i - increment) return i - increment; - i = i + increment; + if (f <= j - increment) return j - increment; + j = j + increment; } return 0; } -vector angle_snap_vec(vector v, float increment) +vector angle_snap_vec(vector v, float increment) { vector c; - c_x = angle_snap_f(v_x, increment); - c_y = angle_snap_f(v_y, increment); - c_z = angle_snap_f(v_z, increment); + c.x = angle_snap_f(v.x, increment); + c.y = angle_snap_f(v.y, increment); + c.z = angle_snap_f(v.z, increment); return c; } -vector aim_vec(vector origin, vector target) +vector aim_vec(vector org, vector targ) { vector v; // we float around x and y, but rotate around z - v_x = target_x - origin_x; - v_y = target_y - origin_y; - v_z = origin_z - target_z; + v.x = targ.x - org.x; + v.y = targ.y - org.y; + v.z = org.z - targ.z; // get the angles actual return vectoangles(normalize(v)); } diff --git a/qcsrc/lib/p2mathlib.qh b/qcsrc/lib/p2mathlib.qh index 78743d6ed..dc2944aa9 100644 --- a/qcsrc/lib/p2mathlib.qh +++ b/qcsrc/lib/p2mathlib.qh @@ -32,4 +32,4 @@ vector vec_bounds_out(vector point, vector a, vector b); float angle_snap_f(float f, float increment); vector angle_snap_vec(vector v, float increment); -vector aim_vec(vector origin, vector target); +vector aim_vec(vector org, vector targ);