X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fteleport.qc;h=8ee6b7a69727e091f5a83459b4309b6e9172686f;hb=fc15d72b041c9a748b605ba28735380fbe5b5b01;hp=d983cf3aec1d23842ef0f5367e268f4b86fa3fb9;hpb=a97f97fea293089f2e7b6c26304d4355a649cde3;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index d983cf3ae..8ee6b7a69 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -1,21 +1,22 @@ +REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT) + #ifdef SVQC -void trigger_teleport_use() +void trigger_teleport_use(entity this, entity actor, entity trigger) { if(teamplay) - self.team = activator.team; + this.team = actor.team; #ifdef SVQC - self.SendFlags |= SF_TRIGGER_UPDATE; + this.SendFlags |= SF_TRIGGER_UPDATE; #endif } +#endif -void Teleport_Touch (void) +void Teleport_Touch (entity this) { - entity oldself; - string s; - - if (self.active != ACTIVE_ACTIVE) + if (this.active != ACTIVE_ACTIVE) return; +#ifdef SVQC if (!other.teleportable) return; @@ -25,53 +26,102 @@ void Teleport_Touch (void) if(IS_TURRET(other)) return; +#elif defined(CSQC) + if(!IS_PLAYER(other)) + return; +#endif - if(other.deadflag != DEAD_NO) + if(IS_DEAD(other)) return; - if(self.team) - if(((self.spawnflags & 4) == 0) == (self.team != other.team)) + if(this.team) + if(((this.spawnflags & 4) == 0) == (DIFF_TEAM(this, other))) return; EXACTTRIGGER_TOUCH; +#ifdef SVQC if(IS_PLAYER(other)) RemoveGrapplingHook(other); +#endif entity e; - e = Simple_TeleportPlayer(self, other); + e = Simple_TeleportPlayer(this, other); - activator = other; - s = self.target; self.target = string_null; - SUB_UseTargets(); - if (!self.target) self.target = s; +#ifdef SVQC + string s = this.target; this.target = string_null; + SUB_UseTargets(this, other, other); // TODO: should we be using other for trigger too? + if (!this.target) this.target = s; - oldself = self; - self = e; - SUB_UseTargets(); - self = oldself; + SUB_UseTargets(e, other, other); +#endif } -void spawnfunc_trigger_teleport() +#ifdef SVQC +float trigger_teleport_send(entity this, entity to, float sf) { - self.angles = '0 0 0'; + WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT); - EXACTTRIGGER_INIT; + WriteByte(MSG_ENTITY, this.team); + WriteInt24_t(MSG_ENTITY, this.spawnflags); + WriteByte(MSG_ENTITY, this.active); + WriteCoord(MSG_ENTITY, this.speed); + + trigger_common_write(this, true); + + return true; +} + +void trigger_teleport_link(entity this) +{ + //trigger_link(this, trigger_teleport_send); +} - self.active = ACTIVE_ACTIVE; +spawnfunc(trigger_teleport) +{ + this.angles = '0 0 0'; + + this.active = ACTIVE_ACTIVE; + //trigger_init(this); // only for predicted triggers? + EXACTTRIGGER_INIT; + this.use = trigger_teleport_use; - self.use = trigger_teleport_use; + if(this.noise != "") + FOREACH_WORD(this.noise, true, precache_sound(it)); // this must be called to spawn the teleport waypoints for bots - InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET); + InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET); - if (self.target == "") + if (this.target == "") { - objerror ("Teleporter with no target"); + objerror (this, "Teleporter with no target"); return; } - self.teleport_next = teleport_first; - teleport_first = self; + this.teleport_next = teleport_first; + teleport_first = this; } +#elif defined(CSQC) +NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew) +{ + this.classname = "trigger_teleport"; + int mytm = ReadByte(); if(mytm) { this.team = mytm - 1; } + this.spawnflags = ReadInt24_t(); + this.active = ReadByte(); + this.speed = ReadCoord(); + + trigger_common_read(this, true); + + this.entremove = trigger_remove_generic; + this.solid = SOLID_TRIGGER; + //this.move_touch = trigger_push_touch; + this.move_time = time; + defer(this, 0.25, teleport_findtarget); + + this.teleport_next = teleport_first; + teleport_first = this; + + return true; +} + #endif