X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fplat.qc;h=7e2ae74aabfd5080e936a2f20fc615c8989d624d;hb=c0da80fe6125a43ee99a90808ac6f9d0ddcf88c8;hp=5ac8b2a8d273d1dcb60144c380603f2156bd2637;hpb=22a37c4431f80ece25aeff28c18bc67dd183a352;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/func/plat.qc b/qcsrc/common/triggers/func/plat.qc index 5ac8b2a8d..7e2ae74aa 100644 --- a/qcsrc/common/triggers/func/plat.qc +++ b/qcsrc/common/triggers/func/plat.qc @@ -1,39 +1,29 @@ +REGISTER_NET_LINKED(ENT_CLIENT_PLAT) + #ifdef SVQC -void plat_delayedinit() +void plat_link(); + +void plat_delayedinit(entity this) { - plat_spawn_inside_trigger (); // the "start moving" trigger + plat_link(); + plat_spawn_inside_trigger(); // the "start moving" trigger } float plat_send(entity to, float sf) -{ - WriteByte(MSG_ENTITY, ENT_CLIENT_PLAT); +{SELFPARAM(); + WriteHeader(MSG_ENTITY, ENT_CLIENT_PLAT); WriteByte(MSG_ENTITY, sf); if(sf & SF_TRIGGER_INIT) { - WriteShort(MSG_ENTITY, num_for_edict(self)); - WriteString(MSG_ENTITY, self.target); - WriteString(MSG_ENTITY, self.target2); - WriteString(MSG_ENTITY, self.target3); - WriteString(MSG_ENTITY, self.target4); - WriteString(MSG_ENTITY, self.targetname); - WriteByte(MSG_ENTITY, self.platmovetype_start); WriteByte(MSG_ENTITY, self.platmovetype_turn); WriteByte(MSG_ENTITY, self.platmovetype_end); - - WriteCoord(MSG_ENTITY, self.origin_x); - WriteCoord(MSG_ENTITY, self.origin_y); - WriteCoord(MSG_ENTITY, self.origin_z); + WriteByte(MSG_ENTITY, self.spawnflags); WriteString(MSG_ENTITY, self.model); - WriteCoord(MSG_ENTITY, self.mins_x); - WriteCoord(MSG_ENTITY, self.mins_y); - WriteCoord(MSG_ENTITY, self.mins_z); - WriteCoord(MSG_ENTITY, self.maxs_x); - WriteCoord(MSG_ENTITY, self.maxs_y); - WriteCoord(MSG_ENTITY, self.maxs_z); + trigger_common_write(self, true); WriteCoord(MSG_ENTITY, self.pos1_x); WriteCoord(MSG_ENTITY, self.pos1_y); @@ -46,10 +36,6 @@ float plat_send(entity to, float sf) WriteCoord(MSG_ENTITY, self.size_y); WriteCoord(MSG_ENTITY, self.size_z); - WriteAngle(MSG_ENTITY, self.angles_x); - WriteAngle(MSG_ENTITY, self.angles_y); - WriteAngle(MSG_ENTITY, self.angles_z); - WriteAngle(MSG_ENTITY, self.mangle_x); WriteAngle(MSG_ENTITY, self.mangle_y); WriteAngle(MSG_ENTITY, self.mangle_z); @@ -72,155 +58,140 @@ float plat_send(entity to, float sf) void plat_link() { - Net_LinkEntity(self, 0, false, plat_send); + //Net_LinkEntity(self, 0, false, plat_send); } -void spawnfunc_func_plat() +spawnfunc(func_plat) { - if (self.sounds == 0) - self.sounds = 2; + if (this.sounds == 0) this.sounds = 2; - if(self.spawnflags & 4) - self.dmg = 10000; + if (this.spawnflags & 4) this.dmg = 10000; - if(self.dmg && (self.message == "")) - self.message = "was squished"; - if(self.dmg && (self.message2 == "")) - self.message2 = "was squished by"; + if (this.dmg && (this.message == "")) this.message = "was squished"; + if (this.dmg && (this.message2 == "")) this.message2 = "was squished by"; - if (self.sounds == 1) + if (this.sounds == 1) { precache_sound ("plats/plat1.wav"); precache_sound ("plats/plat2.wav"); - self.noise = "plats/plat1.wav"; - self.noise1 = "plats/plat2.wav"; + this.noise = "plats/plat1.wav"; + this.noise1 = "plats/plat2.wav"; } - if (self.sounds == 2) + if (this.sounds == 2) { precache_sound ("plats/medplat1.wav"); precache_sound ("plats/medplat2.wav"); - self.noise = "plats/medplat1.wav"; - self.noise1 = "plats/medplat2.wav"; + this.noise = "plats/medplat1.wav"; + this.noise1 = "plats/medplat2.wav"; } - if (self.sound1) + if (this.sound1) { - precache_sound (self.sound1); - self.noise = self.sound1; + precache_sound (this.sound1); + this.noise = this.sound1; } - if (self.sound2) + if (this.sound2) { - precache_sound (self.sound2); - self.noise1 = self.sound2; + precache_sound (this.sound2); + this.noise1 = this.sound2; } - self.mangle = self.angles; - self.angles = '0 0 0'; + this.mangle = this.angles; + this.angles = '0 0 0'; - self.classname = "plat"; - if (!InitMovingBrushTrigger()) + this.classname = "plat"; + if (!InitMovingBrushTrigger(this)) return; - self.effects |= EF_LOWPRECISION; - setsize (self, self.mins , self.maxs); - - self.blocked = plat_crush; + this.effects |= EF_LOWPRECISION; + setsize (this, this.mins , this.maxs); - if (!self.speed) - self.speed = 150; - if (!self.lip) - self.lip = 16; - if (!self.height) - self.height = self.size_z - self.lip; + this.blocked = plat_crush; - self.pos1 = self.origin; - self.pos2 = self.origin; - self.pos2_z = self.origin_z - self.height; + if (!this.speed) this.speed = 150; + if (!this.lip) this.lip = 16; + if (!this.height) this.height = this.size.z - this.lip; - self.reset = plat_reset; - plat_reset(); + this.pos1 = this.origin; + this.pos2 = this.origin; + this.pos2_z = this.origin.z - this.height; - plat_link(); + this.reset = plat_reset; + this.reset(this); - InitializeEntity(self, plat_delayedinit, INITPRIO_FINDTARGET); + InitializeEntity(this, plat_delayedinit, INITPRIO_FINDTARGET); } #elif defined(CSQC) -void plat_draw() +void plat_draw(entity this) { - + Movetype_Physics_NoMatchServer(this); + //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy); } -void ent_plat() +NET_HANDLE(ENT_CLIENT_PLAT, bool isnew) { float sf = ReadByte(); if(sf & SF_TRIGGER_INIT) { - self.sv_entnum = ReadShort(); - self.target = strzone(ReadString()); - self.target2 = strzone(ReadString()); - self.target3 = strzone(ReadString()); - self.target4 = strzone(ReadString()); - self.targetname = strzone(ReadString()); - - self.platmovetype_start = ReadByte(); - self.platmovetype_turn = ReadByte(); - self.platmovetype_end = ReadByte(); - - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); - - self.model = strzone(ReadString()); - setmodel(self, self.model); - - self.mins_x = ReadCoord(); - self.mins_y = ReadCoord(); - self.mins_z = ReadCoord(); - self.maxs_x = ReadCoord(); - self.maxs_y = ReadCoord(); - self.maxs_z = ReadCoord(); - setsize(self, self.mins, self.maxs); - - self.pos1_x = ReadCoord(); - self.pos1_y = ReadCoord(); - self.pos1_z = ReadCoord(); - self.pos2_x = ReadCoord(); - self.pos2_y = ReadCoord(); - self.pos2_z = ReadCoord(); - - self.size_x = ReadCoord(); - self.size_y = ReadCoord(); - self.size_z = ReadCoord(); - - self.angles_x = ReadAngle(); - self.angles_y = ReadAngle(); - self.angles_z = ReadAngle(); - - self.mangle_x = ReadAngle(); - self.mangle_y = ReadAngle(); - self.mangle_z = ReadAngle(); - - self.speed = ReadShort(); - self.height = ReadShort(); - self.lip = ReadByte(); - self.state = ReadByte(); - - self.dmg = ReadShort(); - - self.solid = SOLID_BSP; - self.movetype = MOVETYPE_PUSH; - self.drawmask = MASK_NORMAL; - self.draw = plat_draw; - self.use = plat_use; - - plat_reset(); // also called here + this.platmovetype_start = ReadByte(); + this.platmovetype_turn = ReadByte(); + this.platmovetype_end = ReadByte(); + this.spawnflags = ReadByte(); + + this.model = strzone(ReadString()); + _setmodel(this, this.model); + + trigger_common_read(this, true); + + this.pos1_x = ReadCoord(); + this.pos1_y = ReadCoord(); + this.pos1_z = ReadCoord(); + this.pos2_x = ReadCoord(); + this.pos2_y = ReadCoord(); + this.pos2_z = ReadCoord(); + + this.size_x = ReadCoord(); + this.size_y = ReadCoord(); + this.size_z = ReadCoord(); + + this.mangle_x = ReadAngle(); + this.mangle_y = ReadAngle(); + this.mangle_z = ReadAngle(); + + this.speed = ReadShort(); + this.height = ReadShort(); + this.lip = ReadByte(); + this.state = ReadByte(); + + this.dmg = ReadShort(); + + this.classname = "plat"; + this.solid = SOLID_BSP; + this.movetype = MOVETYPE_PUSH; + this.drawmask = MASK_NORMAL; + this.draw = plat_draw; + this.use = plat_use; + this.entremove = trigger_remove_generic; + + plat_reset(this); // also called here + + this.move_movetype = MOVETYPE_PUSH; + this.move_origin = this.origin; + this.move_angles = this.angles; + this.move_time = time; + + plat_spawn_inside_trigger(); } if(sf & SF_TRIGGER_RESET) { - plat_reset(); + plat_reset(this); + + this.move_origin = this.origin; + this.move_angles = this.angles; + this.move_time = time; } + return true; } #endif