X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fteleport.qc;h=69e2c49c1d9c83b3ceb2b13fb3a14bc9f96e8f65;hb=7666560c6a475aefe6b55ff74a20444f328e0093;hp=129f4e387cbab7ca43b3e9ec93e3fca1b0ff4973;hpb=5607e279fe7b0dc9f92e15556ed6dc33f17f549c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index 129f4e387..69e2c49c1 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -1,72 +1,127 @@ +REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT) + #ifdef SVQC -void trigger_teleport_use() -{SELFPARAM(); +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) -{SELFPARAM(); - string s; - - if (self.active != ACTIVE_ACTIVE) +void Teleport_Touch(entity this, entity toucher) +{ + if (this.active != ACTIVE_ACTIVE) return; - if (!other.teleportable) +#ifdef SVQC + if (!toucher.teleportable) return; - if(other.vehicle) - if(!other.vehicle.teleportable) + if(toucher.vehicle) + if(!toucher.vehicle.teleportable) return; - if(IS_TURRET(other)) + if(IS_TURRET(toucher)) + return; +#elif defined(CSQC) + if(!IS_PLAYER(toucher)) return; +#endif - if(other.deadflag != DEAD_NO) + if(IS_DEAD(toucher)) return; - if(self.team) - if(((self.spawnflags & 4) == 0) == (self.team != other.team)) + if(this.team) + if(((this.spawnflags & 4) == 0) == (DIFF_TEAM(this, toucher))) return; - EXACTTRIGGER_TOUCH; + EXACTTRIGGER_TOUCH(this, toucher); - if(IS_PLAYER(other)) - RemoveGrapplingHook(other); +#ifdef SVQC + if(IS_PLAYER(toucher)) + RemoveGrapplingHook(toucher); +#endif - entity e = Simple_TeleportPlayer(self, other); + entity e; + e = Simple_TeleportPlayer(this, toucher); - 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, toucher, toucher); // TODO: should we be using toucher for trigger too? + if (!this.target) this.target = s; - WITH(entity, self, e, SUB_UseTargets()); + SUB_UseTargets(e, toucher, toucher); +#endif } -void spawnfunc_trigger_teleport() -{SELFPARAM(); - self.angles = '0 0 0'; +#ifdef SVQC +float trigger_teleport_send(entity this, entity to, float sf) +{ + 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); +} + +spawnfunc(trigger_teleport) +{ + this.angles = '0 0 0'; - self.active = ACTIVE_ACTIVE; + 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; + //settouch(this, trigger_push_touch); + this.move_time = time; + defer(this, 0.25, teleport_findtarget); + + this.teleport_next = teleport_first; + teleport_first = this; + + return true; +} + #endif