X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Fteleporters.qc;h=e1cd95058dbb7b597f174614c8b203be1674e05d;hp=ba472ac55732e7f479c57fc6c97ccf028a06f20e;hb=d865de7a9a17c5a1d9286aec40f68c3530697660;hpb=8ba1f6c672361186033b8bebc3be677ac94bd4da diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index ba472ac557..e1cd95058d 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) @@ -92,7 +90,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle RandomSelection_Init(); FOREACH_WORD(teleporter.noise, true, { - RandomSelection_Add(NULL, 0, it, 1, 1); + RandomSelection_AddString(it, 1, 1); }); thesound = RandomSelection_chosen_string; } @@ -124,22 +122,20 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle UpdateCSQCProjectileAfterTeleport(player); UpdateItemAfterTeleport(player); #elif defined(CSQC) - from = player.move_origin; - player.move_origin = to; - player.move_angles = to_angles; - player.move_velocity = to_velocity; - player.move_flags &= ~FL_ONGROUND; + from = player.origin; + setorigin(player, to); + player.angles = to_angles; + player.velocity = to_velocity; + UNSET_ONGROUND(player); player.iflags |= IFLAG_TELEPORTED | IFLAG_V_ANGLE | IFLAG_ANGLES; player.csqcmodel_teleported = 1; player.v_angle = to_angles; - if(player.isplayermodel) // not for anything but the main player + if(player == csqcplayer) // not for anything but the main player { - setproperty(VF_ANGLES, player.move_angles); - setproperty(VF_CL_VIEWANGLES, player.move_angles); + setproperty(VF_ANGLES, player.angles); + setproperty(VF_CL_VIEWANGLES, player.angles); } - - makevectors(player.move_angles); #endif #ifdef SVQC @@ -176,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) @@ -186,78 +181,64 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) } else { + // sorry CSQC, random stuff ain't gonna happen +#ifdef SVQC RandomSelection_Init(); - for(e = NULL; (e = find(e, targetname, teleporter.target)); ) + FOREACH_ENTITY_STRING(targetname, teleporter.target, { - p = 1; + bool p = true; if(STAT(TELEPORT_TELEFRAG_AVOID, player)) { #ifdef SVQC - locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + locout = it.origin + '0 0 1' * (1 - player.mins.z - 24); #elif defined(CSQC) - locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + 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_Add(e, 0, string_null, (e.cnt ? e.cnt : 1), p); - } + RandomSelection_AddEnt(it, (it.cnt ? it.cnt : 1), p); + }); e = RandomSelection_chosen_ent; +#endif } #ifdef SVQC if(!e) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); } #elif defined(CSQC) - if(!e) { LOG_INFO("Teleport destination could not be found from CSQC.\n"); } + if(!e) { LOG_INFO("Teleport destination could not be found from CSQC."); } #endif makevectors(e.mangle); -#ifdef SVQC if(e.speed) if(vdist(player.velocity, >, e.speed)) player.velocity = normalize(player.velocity) * max(0, e.speed); -#elif defined(CSQC) - if(e.speed) - if(vdist(player.move_velocity, >, e.speed)) - player.move_velocity = normalize(player.move_velocity) * max(0, e.speed); -#endif -#ifdef SVQC if(STAT(TELEPORT_MAXSPEED, player)) if(vdist(player.velocity, >, STAT(TELEPORT_MAXSPEED, player))) player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player)); -#elif defined(CSQC) - if(STAT(TELEPORT_MAXSPEED, player)) - if(vdist(player.move_velocity, >, STAT(TELEPORT_MAXSPEED, player))) - player.move_velocity = normalize(player.move_velocity) * max(0, STAT(TELEPORT_MAXSPEED, player)); -#endif -#ifdef SVQC locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER); -#elif defined(CSQC) - locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); - - TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.move_velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER); -#endif return e; } void teleport_findtarget(entity this) { + bool istrigger = (this.solid == SOLID_TRIGGER); + int n = 0; - entity e; - for(e = NULL; (e = find(e, targetname, this.target)); ) + for(entity e = NULL; (e = find(e, targetname, this.target)); ) { ++n; #ifdef SVQC - if(e.movetype == MOVETYPE_NONE) + if(e.move_movetype == MOVETYPE_NONE) waypoint_spawnforteleporter(this, e.origin, 0); if(e.classname != "info_teleport_destination") - LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n"); + LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work."); #endif } @@ -270,7 +251,7 @@ void teleport_findtarget(entity this) else if(n == 1) { // exactly one dest - bots love that - this.enemy = find(e, targetname, this.target); + this.enemy = find(NULL, targetname, this.target); } else { @@ -279,18 +260,20 @@ void teleport_findtarget(entity this) } // now enable touch - settouch(this, Teleport_Touch); + if(istrigger) + settouch(this, Teleport_Touch); #ifdef SVQC - trigger_teleport_link(this); + if(istrigger) + trigger_teleport_link(this); #endif } entity Teleport_Find(vector mi, vector ma) { - entity e; - for(e = NULL; (e = find(e, classname, "trigger_teleport")); ) - if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, NULL)) - return e; + IL_EACH(g_teleporters, WarpZoneLib_BoxTouchesBrush(mi, ma, it, NULL), + { + return it; + }); return NULL; } @@ -310,9 +293,9 @@ void WarpZone_PostTeleportPlayer_Callback(entity pl) #ifdef SVQC if(!(pl.flags & FL_PROJECTILE)) #elif defined(CSQC) - if(!(pl.move_flags & BIT(15))) // FL_PROJECTILE + if(!(pl.flags & BIT(15))) // FL_PROJECTILE #endif - LOG_INFO("A non-projectile got through a warpzone and its owner cleared. It's a ", pl.classname, ".\n"); + LOG_INFO("A non-projectile got through a warpzone and its owner cleared. It's a ", pl.classname, "."); pl.owner = NULL; } if(IS_PLAYER(pl))