X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Fplatforms.qc;h=4747877314a3ac52f78c30c06233ec3f63dcf170;hb=bc50c2d7ca3e0a44ed1712400ef8e170e6df8210;hp=c089039a60bccf1549b1602fb643380c7b64129c;hpb=8ae20128ca1e3cbd97b90be3ff11c31ef62a4ef5;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/platforms.qc b/qcsrc/common/triggers/platforms.qc index c089039a6..474787731 100644 --- a/qcsrc/common/triggers/platforms.qc +++ b/qcsrc/common/triggers/platforms.qc @@ -1,17 +1,18 @@ -void generic_plat_blocked(entity this) +#include "platforms.qh" +void generic_plat_blocked(entity this, entity blocker) { #ifdef SVQC - if(this.dmg && other.takedamage != DAMAGE_NO) + if(this.dmg && blocker.takedamage != DAMAGE_NO) { if(this.dmgtime2 < time) { - Damage (other, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0'); this.dmgtime2 = time + this.dmgtime; } // Gib dead/dying stuff - if(IS_DEAD(other)) - Damage (other, this, this, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + if(IS_DEAD(blocker)) + Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0'); } #endif } @@ -23,7 +24,7 @@ void plat_spawn_inside_trigger(entity this) trigger = spawn(); settouch(trigger, plat_center_touch); - trigger.movetype = MOVETYPE_NONE; + set_movetype(trigger, MOVETYPE_NONE); trigger.solid = SOLID_TRIGGER; trigger.enemy = this; @@ -53,74 +54,74 @@ void plat_spawn_inside_trigger(entity this) } // otherwise, something is fishy... - remove(trigger); + delete(trigger); objerror(this, "plat_spawn_inside_trigger: platform has odd size or lip, can't spawn"); } void plat_hit_top(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); - this.state = 1; + this.state = STATE_TOP; - SUB_THINK(this, plat_go_down); - this.SUB_NEXTTHINK = this.SUB_LTIME + 3; + setthink(this, plat_go_down); + this.nextthink = this.ltime + 3; } void plat_hit_bottom(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); - this.state = 2; + this.state = STATE_BOTTOM; } void plat_go_down(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_NORM); - this.state = 3; + this.state = STATE_DOWN; SUB_CalcMove (this, this.pos2, TSPEED_LINEAR, this.speed, plat_hit_bottom); } void plat_go_up(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_NORM); - this.state = 4; + this.state = STATE_UP; SUB_CalcMove (this, this.pos1, TSPEED_LINEAR, this.speed, plat_hit_top); } -void plat_center_touch(entity this) +void plat_center_touch(entity this, entity toucher) { #ifdef SVQC - if (!other.iscreature) + if (!toucher.iscreature) return; - if (other.health <= 0) + if (toucher.health <= 0) return; #elif defined(CSQC) - if (!IS_PLAYER(other)) + if (!IS_PLAYER(toucher)) return; - if(IS_DEAD(other)) + if(IS_DEAD(toucher)) return; #endif - if (this.enemy.state == 2) { + if (this.enemy.state == STATE_BOTTOM) { plat_go_up(this.enemy); - } else if (this.enemy.state == 1) - this.enemy.SUB_NEXTTHINK = this.enemy.SUB_LTIME + 1; + } else if (this.enemy.state == STATE_TOP) + this.enemy.nextthink = this.enemy.ltime + 1; } -void plat_outside_touch(entity this) +void plat_outside_touch(entity this, entity toucher) { #ifdef SVQC - if (!other.iscreature) + if (!toucher.iscreature) return; - if (other.health <= 0) + if (toucher.health <= 0) return; #elif defined(CSQC) - if (!IS_PLAYER(other)) + if (!IS_PLAYER(toucher)) return; #endif - if (this.enemy.state == 1) { + if (this.enemy.state == STATE_TOP) { entity e = this.enemy; plat_go_down(e); } @@ -128,40 +129,35 @@ void plat_outside_touch(entity this) void plat_trigger_use(entity this, entity actor, entity trigger) { -#ifdef SVQC if (getthink(this)) return; // already activated -#elif defined(CSQC) - if(this.move_think) - return; -#endif plat_go_down(this); } -void plat_crush(entity this) +void plat_crush(entity this, entity blocker) { - if((this.spawnflags & 4) && (other.takedamage != DAMAGE_NO)) + if((this.spawnflags & CRUSH) && (blocker.takedamage != DAMAGE_NO)) { // KIll Kill Kill!! #ifdef SVQC - Damage (other, this, this, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0'); #endif } else { #ifdef SVQC - if((this.dmg) && (other.takedamage != DAMAGE_NO)) + if((this.dmg) && (blocker.takedamage != DAMAGE_NO)) { // Shall we bite? - Damage (other, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0'); // Gib dead/dying stuff - if(IS_DEAD(other)) - Damage (other, this, this, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + if(IS_DEAD(blocker)) + Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0'); } #endif - if (this.state == 4) + if (this.state == STATE_UP) plat_go_down (this); - else if (this.state == 3) + else if (this.state == STATE_DOWN) plat_go_up (this); // when in other states, then the plat_crush event came delayed after // plat state already had changed @@ -172,11 +168,13 @@ void plat_crush(entity this) void plat_use(entity this, entity actor, entity trigger) { this.use = func_null; - if (this.state != 4) + if (this.state != STATE_UP) objerror (this, "plat_use: not in up state"); plat_go_down(this); } +// WARNING: backwards compatibility because people don't use already existing fields :( +// TODO: Check if any maps use these fields and remove these fields if it doesn't break maps .string sound1, sound2; void plat_reset(entity this) @@ -184,13 +182,13 @@ void plat_reset(entity this) IFTARGETED { setorigin(this, this.pos1); - this.state = 4; + this.state = STATE_UP; this.use = plat_use; } else { setorigin(this, this.pos2); - this.state = 2; + this.state = STATE_BOTTOM; this.use = plat_trigger_use; }