X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fteleport.qc;h=be8040079b91f36670492816498228debff65bfa;hb=6f4c7132e635c0150e3894f2f9958b361ce0c238;hp=95bd7fbbd4ff0ab788035aff177c7e0d52d47e95;hpb=03f978544a8b13a18cef1c7cc3dbcaba1c3aee4c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index 95bd7fbbd..be8040079 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -1,3 +1,5 @@ +REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT) + #ifdef SVQC void trigger_teleport_use() {SELFPARAM(); @@ -7,14 +9,14 @@ void trigger_teleport_use() self.SendFlags |= SF_TRIGGER_UPDATE; #endif } +#endif -void Teleport_Touch (void) +void Teleport_Touch () {SELFPARAM(); - string s; - if (self.active != ACTIVE_ACTIVE) return; +#ifdef SVQC if (!other.teleportable) return; @@ -24,39 +26,70 @@ 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(((self.spawnflags & 4) == 0) == (DIFF_TEAM(this, other))) return; EXACTTRIGGER_TOUCH; +#ifdef SVQC if(IS_PLAYER(other)) RemoveGrapplingHook(other); +#endif - entity e = Simple_TeleportPlayer(self, other); + entity e; + e = Simple_TeleportPlayer(self, other); +#ifdef SVQC activator = other; - s = self.target; self.target = string_null; + string s = self.target; self.target = string_null; SUB_UseTargets(); if (!self.target) self.target = s; WITH(entity, self, e, SUB_UseTargets()); +#endif +} + +#ifdef SVQC +float trigger_teleport_send(entity this, entity to, float sf) +{ + WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT); + + 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); } spawnfunc(trigger_teleport) { self.angles = '0 0 0'; - EXACTTRIGGER_INIT; - self.active = ACTIVE_ACTIVE; - + //trigger_init(self); // only for predicted triggers? + EXACTTRIGGER_INIT; self.use = trigger_teleport_use; + if(self.noise != "") + FOREACH_WORD(self.noise, true, precache_sound(it)); + // this must be called to spawn the teleport waypoints for bots InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET); @@ -69,4 +102,29 @@ spawnfunc(trigger_teleport) self.teleport_next = teleport_first; teleport_first = self; } +#elif defined(CSQC) +NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew) +{ + self.classname = "trigger_teleport"; + int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; } + self.spawnflags = ReadInt24_t(); + self.active = ReadByte(); + self.speed = ReadCoord(); + + trigger_common_read(true); + + self.entremove = trigger_remove_generic; + self.solid = SOLID_TRIGGER; + //self.draw = trigger_draw_generic; + //self.move_touch = trigger_push_touch; + self.drawmask = MASK_NORMAL; + self.move_time = time; + defer(self, 0.25, teleport_findtarget); + + self.teleport_next = teleport_first; + teleport_first = self; + + return true; +} + #endif