From: Mario Date: Sat, 15 Jul 2017 03:30:24 +0000 (+1000) Subject: Merge branch 'master' into Mario/target_teleporter_v2 X-Git-Tag: xonotic-v0.8.5~2421^2~1 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=183c84009b2439305a2800111912a5d957056d88;hp=b0c92481c72ae52b468998c31fb78f809a99bb53;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into Mario/target_teleporter_v2 --- diff --git a/qcsrc/common/triggers/misc/teleport_dest.qc b/qcsrc/common/triggers/misc/teleport_dest.qc index fc3cec863..3f5203806 100644 --- a/qcsrc/common/triggers/misc/teleport_dest.qc +++ b/qcsrc/common/triggers/misc/teleport_dest.qc @@ -55,11 +55,6 @@ spawnfunc(misc_teleporter_dest) spawnfunc_info_teleport_destination(this); } -spawnfunc(target_teleporter) -{ - spawnfunc_info_teleport_destination(this); -} - #elif defined(CSQC) void teleport_dest_remove(entity this) diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index 451afa95b..169cdf061 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -228,9 +228,10 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) 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 @@ -250,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 { @@ -259,9 +260,11 @@ 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 } diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index 5f545f014..0330ce8d8 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -12,52 +12,83 @@ void trigger_teleport_use(entity this, entity actor, entity trigger) } #endif -void Teleport_Touch(entity this, entity toucher) +bool Teleport_Active(entity this, entity player) { if (this.active != ACTIVE_ACTIVE) - return; + return false; #ifdef SVQC - if (!toucher.teleportable) - return; + if (!player.teleportable) + return false; - if(toucher.vehicle) - if(!toucher.vehicle.teleportable) - return; + if(player.vehicle) + if(!player.vehicle.teleportable) + return false; - if(IS_TURRET(toucher)) - return; + if(IS_TURRET(player)) + return false; #elif defined(CSQC) - if(!IS_PLAYER(toucher)) - return; + if(!IS_PLAYER(player)) + return false; #endif - if(IS_DEAD(toucher)) - return; + if(IS_DEAD(player)) + return false; if(this.team) - if(((this.spawnflags & 4) == 0) == (DIFF_TEAM(this, toucher))) - return; + if(((this.spawnflags & 4) == 0) == (DIFF_TEAM(this, player))) + return false; - EXACTTRIGGER_TOUCH(this, toucher); + return true; +} + +void Teleport_Touch(entity this, entity toucher) +{ + entity player = toucher; + + if(!Teleport_Active(this, player)) + return; + + EXACTTRIGGER_TOUCH(this, player); #ifdef SVQC - if(IS_PLAYER(toucher)) - RemoveGrapplingHooks(toucher); + if(IS_PLAYER(player)) + RemoveGrapplingHooks(player); #endif entity e; - e = Simple_TeleportPlayer(this, toucher); + e = Simple_TeleportPlayer(this, player); #ifdef SVQC string s = this.target; this.target = string_null; - SUB_UseTargets(this, toucher, toucher); // TODO: should we be using toucher for trigger too? + SUB_UseTargets(this, player, player); // TODO: should we be using toucher for trigger too? if (!this.target) this.target = s; - SUB_UseTargets(e, toucher, toucher); + SUB_UseTargets(e, player, player); #endif } +#ifdef SVQC +void target_teleport_use(entity this, entity actor, entity trigger) +{ + entity player = actor; + + if(!Teleport_Active(this, player)) + return; + + if(IS_PLAYER(player)) + RemoveGrapplingHooks(player); + + entity e = Simple_TeleportPlayer(this, player); + + string s = this.target; this.target = string_null; + SUB_UseTargets(this, player, player); // TODO: should we be using toucher for trigger too? + if (!this.target) this.target = s; + + SUB_UseTargets(e, player, player); +} +#endif + #ifdef SVQC float trigger_teleport_send(entity this, entity to, float sf) { @@ -101,6 +132,25 @@ spawnfunc(trigger_teleport) IL_PUSH(g_teleporters, this); } + +spawnfunc(target_teleporter) +{ + if(this.target == "") + { + // actually a destination! + spawnfunc_info_teleport_destination(this); + return; + } + + this.active = ACTIVE_ACTIVE; + + this.use = target_teleport_use; + + if(this.noise != "") + FOREACH_WORD(this.noise, true, precache_sound(it)); + + InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET); +} #elif defined(CSQC) NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew) {