X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Fplatforms.qc;h=a2efc1142e316aeee6e4cd5b4ab740cc72a924ea;hb=8e12088e8a6a698f155e4f79a1b07a5656355ce6;hp=0176fe9b02e3cdae931e510850b89729592f0738;hpb=cf55d14195d9f1737f4fa5cb3b18628808d1b46f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/platforms.qc b/qcsrc/common/triggers/platforms.qc index 0176fe9b0..a2efc1142 100644 --- a/qcsrc/common/triggers/platforms.qc +++ b/qcsrc/common/triggers/platforms.qc @@ -1,42 +1,24 @@ void generic_plat_blocked() { #ifdef SVQC + SELFPARAM(); if(self.dmg && other.takedamage != DAMAGE_NO) { if(self.dmgtime2 < time) { - Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0'); + Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); self.dmgtime2 = time + self.dmgtime; } // Gib dead/dying stuff - if(other.deadflag != DEAD_NO) - Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0'); + if(IS_DEAD(other)) + Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); } #endif } -#ifdef SVQC -float plat_trigger_send(entity to, float sf) -{ - WriteByte(MSG_ENTITY, ENT_CLIENT_PLAT_TRIGGER); - WriteShort(MSG_ENTITY, num_for_edict(self.enemy)); - - WriteCoord(MSG_ENTITY, self.origin_x); - WriteCoord(MSG_ENTITY, self.origin_y); - WriteCoord(MSG_ENTITY, self.origin_z); - - 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); - return true; -} - void plat_spawn_inside_trigger() -{ +{SELFPARAM(); entity trigger; vector tmin, tmax; @@ -46,6 +28,12 @@ void plat_spawn_inside_trigger() trigger.solid = SOLID_TRIGGER; trigger.enemy = self; +#ifdef CSQC + trigger.drawmask = MASK_NORMAL; + trigger.trigger_touch = plat_center_touch; + trigger.draw = trigger_draw_generic; +#endif + tmin = self.absmin + '25 25 0'; tmax = self.absmax - '25 25 -8'; tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8); @@ -68,7 +56,6 @@ void plat_spawn_inside_trigger() if(tmin_z < tmax_z) { setsize (trigger, tmin, tmax); - Net_LinkEntity(trigger, false, 0, plat_trigger_send); return; } @@ -76,62 +63,38 @@ void plat_spawn_inside_trigger() remove(trigger); objerror("plat_spawn_inside_trigger: platform has odd size or lip, can't spawn"); } -#elif defined(CSQC) -void ent_plat_trigger() -{ - float myenemy = ReadShort(); - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); - - 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.enemy = findfloat(world, sv_entnum, myenemy); - if(!self.enemy) { print("^1BAD BAD BAD!!!\n"); } - self.drawmask = MASK_NORMAL; - self.draw = trigger_draw_generic; - self.trigger_touch = plat_center_touch; - self.solid = SOLID_TRIGGER; -} -#endif void plat_hit_top() -{ - sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); +{SELFPARAM(); + _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); self.state = 1; - self.think = plat_go_down; - trigger_setnextthink(self, self.ltime + 3); + + self.SUB_THINK = plat_go_down; + self.SUB_NEXTTHINK = self.SUB_LTIME + 3; } void plat_hit_bottom() -{ - sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); +{SELFPARAM(); + _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); self.state = 2; } void plat_go_down() -{ - sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM); +{SELFPARAM(); + _sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM); self.state = 3; SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, plat_hit_bottom); } void plat_go_up() -{ - sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM); +{SELFPARAM(); + _sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM); self.state = 4; SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top); } void plat_center_touch() -{ +{SELFPARAM(); #ifdef SVQC if (!other.iscreature) return; @@ -141,17 +104,19 @@ void plat_center_touch() #elif defined(CSQC) if (!IS_PLAYER(other)) return; + if(IS_DEAD(other)) + return; #endif - self = self.enemy; + setself(self.enemy); if (self.state == 2) plat_go_up (); else if (self.state == 1) - trigger_setnextthink(self, self.ltime + 1); + self.SUB_NEXTTHINK = self.SUB_LTIME + 1; } void plat_outside_touch() -{ +{SELFPARAM(); #ifdef SVQC if (!other.iscreature) return; @@ -163,25 +128,30 @@ void plat_outside_touch() return; #endif - self = self.enemy; + setself(self.enemy); if (self.state == 1) plat_go_down (); } void plat_trigger_use() -{ +{SELFPARAM(); +#ifdef SVQC if (self.think) return; // already activated +#elif defined(CSQC) + if(self.move_think) + return; +#endif plat_go_down(); } void plat_crush() -{ +{SELFPARAM(); if((self.spawnflags & 4) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!! #ifdef SVQC - Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0'); + Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); #endif } else @@ -189,10 +159,10 @@ void plat_crush() #ifdef SVQC if((self.dmg) && (other.takedamage != DAMAGE_NO)) { // Shall we bite? - Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0'); + Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); // Gib dead/dying stuff - if(other.deadflag != DEAD_NO) - Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0'); + if(IS_DEAD(other)) + Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); } #endif @@ -207,7 +177,7 @@ void plat_crush() } void plat_use() -{ +{SELFPARAM(); self.use = func_null; if (self.state != 4) objerror ("plat_use: not in up state"); @@ -216,34 +186,32 @@ void plat_use() .string sound1, sound2; -void plat_reset() +void plat_reset(entity this) { IFTARGETED { - setorigin (self, self.pos1); - self.state = 4; - self.use = plat_use; + setorigin (this, this.pos1); + this.state = 4; + this.use = plat_use; } else { - setorigin (self, self.pos2); - self.state = 2; - self.use = plat_trigger_use; + setorigin (this, this.pos2); + this.state = 2; + this.use = plat_trigger_use; } #ifdef SVQC - self.SendFlags |= SF_TRIGGER_RESET; + this.SendFlags |= SF_TRIGGER_RESET; #endif } -#ifdef SVQC .float platmovetype_start_default, platmovetype_end_default; -float set_platmovetype(entity e, string s) +bool set_platmovetype(entity e, string s) { // sets platmovetype_start and platmovetype_end based on a string consisting of two values - float n; - n = tokenize_console(s); + int n = tokenize_console(s); if(n > 0) e.platmovetype_start = stof(argv(0)); else @@ -266,4 +234,3 @@ float set_platmovetype(entity e, string s) return true; } -#endif