X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fdoor_secret.qc;h=6f2d101ef9a914b61bae21278a6c5fa1c386b6a5;hp=8686c671f7c097c3a5307ecca54e478ef2b3734b;hb=d865de7a9a17c5a1d9286aec40f68c3530697660;hpb=32ca966802c45c4c231210c2d8776bc3f4135dc2 diff --git a/qcsrc/common/triggers/func/door_secret.qc b/qcsrc/common/triggers/func/door_secret.qc index 8686c671f..6f2d101ef 100644 --- a/qcsrc/common/triggers/func/door_secret.qc +++ b/qcsrc/common/triggers/func/door_secret.qc @@ -1,11 +1,12 @@ +#include "door_secret.qh" #ifdef SVQC -void() fd_secret_move1; -void() fd_secret_move2; -void() fd_secret_move3; -void() fd_secret_move4; -void() fd_secret_move5; -void() fd_secret_move6; -void() fd_secret_done; +void fd_secret_move1(entity this); +void fd_secret_move2(entity this); +void fd_secret_move3(entity this); +void fd_secret_move4(entity this); +void fd_secret_move5(entity this); +void fd_secret_move6(entity this); +void fd_secret_done(entity this); const float SECRET_OPEN_ONCE = 1; // stays open const float SECRET_1ST_LEFT = 2; // 1st move is left of arrow @@ -13,132 +14,136 @@ const float SECRET_1ST_DOWN = 4; // 1st move is down from arrow const float SECRET_NO_SHOOT = 8; // only opened by trigger const float SECRET_YES_SHOOT = 16; // shootable even if targeted -void fd_secret_use() -{SELFPARAM(); +void fd_secret_use(entity this, entity actor, entity trigger) +{ float temp; string message_save; - self.health = 10000; - self.bot_attack = true; + this.health = 10000; + if(!this.bot_attack) + IL_PUSH(g_bot_targets, this); + this.bot_attack = true; // exit if still moving around... - if (self.origin != self.oldorigin) + if (this.origin != this.oldorigin) return; - message_save = self.message; - self.message = ""; // no more message - SUB_UseTargets(); // fire all targets / killtargets - self.message = message_save; + message_save = this.message; + this.message = ""; // no more message + SUB_UseTargets(this, actor, trigger); // fire all targets / killtargets + this.message = message_save; - self.velocity = '0 0 0'; + this.velocity = '0 0 0'; // Make a sound, wait a little... - if (self.noise1 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); - self.SUB_NEXTTHINK = self.SUB_LTIME + 0.1; + if (this.noise1 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); + this.nextthink = this.ltime + 0.1; - temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1 - makevectors(self.mangle); + temp = 1 - (this.spawnflags & SECRET_1ST_LEFT); // 1 or -1 + makevectors(this.mangle); - if (!self.t_width) + if (!this.t_width) { - if (self.spawnflags & SECRET_1ST_DOWN) - self.t_width = fabs(v_up * self.size); + if (this.spawnflags & SECRET_1ST_DOWN) + this.t_width = fabs(v_up * this.size); else - self.t_width = fabs(v_right * self.size); + this.t_width = fabs(v_right * this.size); } - if (!self.t_length) - self.t_length = fabs(v_forward * self.size); + if (!this.t_length) + this.t_length = fabs(v_forward * this.size); - if (self.spawnflags & SECRET_1ST_DOWN) - self.dest1 = self.origin - v_up * self.t_width; + if (this.spawnflags & SECRET_1ST_DOWN) + this.dest1 = this.origin - v_up * this.t_width; else - self.dest1 = self.origin + v_right * (self.t_width * temp); + this.dest1 = this.origin + v_right * (this.t_width * temp); - self.dest2 = self.dest1 + v_forward * self.t_length; - SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move1); - if (self.noise2 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); + this.dest2 = this.dest1 + v_forward * this.t_length; + SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move1); + if (this.noise2 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); } -void fd_secret_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) { - fd_secret_use(); + fd_secret_use(this, NULL, NULL); } // Wait after first movement... -void fd_secret_move1() -{SELFPARAM(); - self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0; - self.think = fd_secret_move2; - if (self.noise3 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM); +void fd_secret_move1(entity this) +{ + this.nextthink = this.ltime + 1.0; + setthink(this, fd_secret_move2); + if (this.noise3 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM); } // Start moving sideways w/sound... -void fd_secret_move2() -{SELFPARAM(); - if (self.noise2 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); - SUB_CalcMove(self.dest2, TSPEED_LINEAR, self.speed, fd_secret_move3); +void fd_secret_move2(entity this) +{ + if (this.noise2 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); + SUB_CalcMove(this, this.dest2, TSPEED_LINEAR, this.speed, fd_secret_move3); } // Wait here until time to go back... -void fd_secret_move3() -{SELFPARAM(); - if (self.noise3 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM); - if (!(self.spawnflags & SECRET_OPEN_ONCE)) +void fd_secret_move3(entity this) +{ + if (this.noise3 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM); + if (!(this.spawnflags & SECRET_OPEN_ONCE)) { - self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait; - self.think = fd_secret_move4; + this.nextthink = this.ltime + this.wait; + setthink(this, fd_secret_move4); } } // Move backward... -void fd_secret_move4() -{SELFPARAM(); - if (self.noise2 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); - SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move5); +void fd_secret_move4(entity this) +{ + if (this.noise2 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); + SUB_CalcMove(this, this.dest1, TSPEED_LINEAR, this.speed, fd_secret_move5); } // Wait 1 second... -void fd_secret_move5() -{SELFPARAM(); - self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0; - self.think = fd_secret_move6; - if (self.noise3 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM); +void fd_secret_move5(entity this) +{ + this.nextthink = this.ltime + 1.0; + setthink(this, fd_secret_move6); + if (this.noise3 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM); } -void fd_secret_move6() -{SELFPARAM(); - if (self.noise2 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); - SUB_CalcMove(self.oldorigin, TSPEED_LINEAR, self.speed, fd_secret_done); +void fd_secret_move6(entity this) +{ + if (this.noise2 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); + SUB_CalcMove(this, this.oldorigin, TSPEED_LINEAR, this.speed, fd_secret_done); } -void fd_secret_done() -{SELFPARAM(); - if (self.spawnflags&SECRET_YES_SHOOT) +void fd_secret_done(entity this) +{ + if (this.spawnflags&SECRET_YES_SHOOT) { - self.health = 10000; - self.takedamage = DAMAGE_YES; - //self.th_pain = fd_secret_use; + this.health = 10000; + this.takedamage = DAMAGE_YES; + //this.th_pain = fd_secret_use; } - if (self.noise3 != "") - _sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM); + if (this.noise3 != "") + _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM); } -void secret_blocked() -{SELFPARAM(); - if (time < self.attack_finished_single) +.float door_finished; + +void secret_blocked(entity this, entity blocker) +{ + if (time < this.door_finished) return; - self.attack_finished_single = time + 0.5; - //T_Damage (other, self, self, self.dmg, self.dmg, self.deathtype, DT_IMPACT, (self.absmin + self.absmax) * 0.5, '0 0 0', Obituary_Generic); + this.door_finished = time + 0.5; + //T_Damage (other, this, this, this.dmg, this.dmg, this.deathtype, DT_IMPACT, (this.absmin + this.absmax) * 0.5, '0 0 0', Obituary_Generic); } /* @@ -148,33 +153,33 @@ secret_touch Prints messages ================ */ -void secret_touch() -{SELFPARAM(); - if (!other.iscreature) +void secret_touch(entity this, entity toucher) +{ + if (!toucher.iscreature) return; - if (self.attack_finished_single > time) + if (this.door_finished > time) return; - self.attack_finished_single = time + 2; + this.door_finished = time + 2; - if (self.message) + if (this.message) { - if (IS_CLIENT(other)) - centerprint(other, self.message); - play2(other, SND(TALK)); + if (IS_CLIENT(toucher)) + centerprint(toucher, this.message); + play2(toucher, this.noise); } } -void secret_reset() -{SELFPARAM(); - if (self.spawnflags&SECRET_YES_SHOOT) +void secret_reset(entity this) +{ + if (this.spawnflags & SECRET_YES_SHOOT) { - self.health = 10000; - self.takedamage = DAMAGE_YES; + this.health = 10000; + this.takedamage = DAMAGE_YES; } - setorigin(self, self.oldorigin); - self.think = func_null; - self.SUB_NEXTTHINK = 0; + setorigin(this, this.oldorigin); + setthink(this, func_null); + this.nextthink = 0; } /*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot @@ -196,41 +201,42 @@ If a secret door has a targetname, it will only be opened by it's botton or trig spawnfunc(func_door_secret) { - /*if (!self.deathtype) // map makers can override this - self.deathtype = " got in the way";*/ + /*if (!this.deathtype) // map makers can override this + this.deathtype = " got in the way";*/ - if (!self.dmg) - self.dmg = 2; + if (!this.dmg) this.dmg = 2; // Magic formula... - self.mangle = self.angles; - self.angles = '0 0 0'; - self.classname = "door"; - if (!InitMovingBrushTrigger()) - return; - self.effects |= EF_LOWPRECISION; - - self.touch = secret_touch; - self.blocked = secret_blocked; - self.speed = 50; - self.use = fd_secret_use; + this.mangle = this.angles; + this.angles = '0 0 0'; + this.classname = "door"; + if (!InitMovingBrushTrigger(this)) return; + this.effects |= EF_LOWPRECISION; + + if (this.noise == "") this.noise = "misc/talk.wav"; + precache_sound(this.noise); + + settouch(this, secret_touch); + setblocked(this, secret_blocked); + this.speed = 50; + this.use = fd_secret_use; IFTARGETED { } else - self.spawnflags |= SECRET_YES_SHOOT; + this.spawnflags |= SECRET_YES_SHOOT; - if(self.spawnflags&SECRET_YES_SHOOT) + if (this.spawnflags & SECRET_YES_SHOOT) { - self.health = 10000; - self.takedamage = DAMAGE_YES; - self.event_damage = fd_secret_damage; + //this.canteamdamage = true; // TODO + this.health = 10000; + this.takedamage = DAMAGE_YES; + this.event_damage = fd_secret_damage; } - self.oldorigin = self.origin; - if (!self.wait) - self.wait = 5; // 5 seconds before closing + this.oldorigin = this.origin; + if (!this.wait) this.wait = 5; // seconds before closing - self.reset = secret_reset; - secret_reset(); + this.reset = secret_reset; + this.reset(this); } #endif