X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fdoor.qc;h=a27787634bf24a4f719d96d627ad89ea7539af8e;hp=24fc6d64c77bc3d49b62275283c12c5934ed1136;hb=7666560c6a475aefe6b55ff74a20444f328e0093;hpb=18e2cd311a581f77ba8eb9c5421dd219ff5d760d diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 24fc6d64c7..a27787634b 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -20,56 +20,56 @@ THINK FUNCTIONS ============================================================================= */ -void() door_go_down; -void() door_go_up; -void() door_rotating_go_down; -void() door_rotating_go_up; - -void door_blocked() -{SELFPARAM(); - if((self.spawnflags & 8) +void door_go_down(entity this); +void door_go_up(entity this); +void door_rotating_go_down(entity this); +void door_rotating_go_up(entity this, entity oth); + +void door_blocked(entity this, entity blocker) +{ + if((this.spawnflags & 8) #ifdef SVQC - && (other.takedamage != DAMAGE_NO) + && (blocker.takedamage != DAMAGE_NO) #elif defined(CSQC) - && !PHYS_DEAD(other) + && !IS_DEAD(blocker) #endif ) { // KIll Kill Kill!! #ifdef SVQC - Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, blocker.origin, '0 0 0'); #endif } else { #ifdef SVQC - if((self.dmg) && (other.takedamage == DAMAGE_YES)) // Shall we bite? - Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + if((this.dmg) && (blocker.takedamage == DAMAGE_YES)) // Shall we bite? + Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, blocker.origin, '0 0 0'); #endif // don't change direction for dead or dying stuff - if(PHYS_DEAD(other) + if(IS_DEAD(blocker) #ifdef SVQC - && (other.takedamage == DAMAGE_NO) + && (blocker.takedamage == DAMAGE_NO) #endif ) { - if (self.wait >= 0) + if (this.wait >= 0) { - if (self.state == STATE_DOWN) - if (self.classname == "door") + if (this.state == STATE_DOWN) + if (this.classname == "door") { - door_go_up (); + door_go_up (this); } else { - door_rotating_go_up (); + door_rotating_go_up(this, blocker); } else - if (self.classname == "door") + if (this.classname == "door") { - door_go_down (); + door_go_down (this); } else { - door_rotating_go_down (); + door_rotating_go_down (this); } } } @@ -77,72 +77,72 @@ void door_blocked() else { //gib dying stuff just to make sure - if((self.dmg) && (other.takedamage != DAMAGE_NO)) // Shall we bite? - Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + if((this.dmg) && (blocker.takedamage != DAMAGE_NO)) // Shall we bite? + Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, blocker.origin, '0 0 0'); } #endif } } -void door_hit_top() -{SELFPARAM(); - if (self.noise1 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); - self.state = STATE_TOP; - if (self.spawnflags & DOOR_TOGGLE) +void door_hit_top(entity this) +{ + if (this.noise1 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); + this.state = STATE_TOP; + if (this.spawnflags & DOOR_TOGGLE) return; // don't come down automatically - if (self.classname == "door") + if (this.classname == "door") { - self.SUB_THINK = door_go_down; + SUB_THINK(this, door_go_down); } else { - self.SUB_THINK = door_rotating_go_down; + SUB_THINK(this, door_rotating_go_down); } - self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait; + this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait; } -void door_hit_bottom() -{SELFPARAM(); - if (self.noise1 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); - self.state = STATE_BOTTOM; +void door_hit_bottom(entity this) +{ + if (this.noise1 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); + this.state = STATE_BOTTOM; } -void door_go_down() -{SELFPARAM(); - if (self.noise2 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); - if (self.max_health) +void door_go_down(entity this) +{ + if (this.noise2 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); + if (this.max_health) { - self.takedamage = DAMAGE_YES; - self.health = self.max_health; + this.takedamage = DAMAGE_YES; + this.health = this.max_health; } - self.state = STATE_DOWN; - SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, door_hit_bottom); + this.state = STATE_DOWN; + SUB_CalcMove (this, this.pos1, TSPEED_LINEAR, this.speed, door_hit_bottom); } -void door_go_up() -{SELFPARAM(); - if (self.state == STATE_UP) +void door_go_up(entity this) +{ + if (this.state == STATE_UP) return; // already going up - if (self.state == STATE_TOP) + if (this.state == STATE_TOP) { // reset top wait time - self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait; + this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait; return; } - if (self.noise2 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); - self.state = STATE_UP; - SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, door_hit_top); + if (this.noise2 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); + this.state = STATE_UP; + SUB_CalcMove (this, this.pos2, TSPEED_LINEAR, this.speed, door_hit_top); string oldmessage; - oldmessage = self.message; - self.message = ""; - SUB_UseTargets(); - self.message = oldmessage; + oldmessage = this.message; + this.message = ""; + SUB_UseTargets(this, NULL, NULL); + this.message = oldmessage; } @@ -185,7 +185,7 @@ bool door_check_keys(entity door, entity player) #ifdef SVQC if(player.key_door_messagetime <= time) { - play2(player, SND(TALK)); + play2(player, door.noise3); Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_LOCKED_NEED, item_keys_keylist(door.itemkeys)); player.key_door_messagetime = time + 2; } @@ -197,7 +197,7 @@ bool door_check_keys(entity door, entity player) #ifdef SVQC if(player.key_door_messagetime <= time) { - play2(player, SND(TALK)); + play2(player, door.noise3); Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_LOCKED_ALSONEED, item_keys_keylist(door.itemkeys)); player.key_door_messagetime = time + 2; } @@ -206,93 +206,80 @@ bool door_check_keys(entity door, entity player) return false; } -void door_fire() -{SELFPARAM(); - entity starte; - - if (self.owner != self) - objerror ("door_fire: self.owner != self"); +void door_fire(entity this, entity actor, entity trigger) +{ + if (this.owner != this) + objerror (this, "door_fire: this.owner != this"); - if (self.spawnflags & DOOR_TOGGLE) + if (this.spawnflags & DOOR_TOGGLE) { - if (self.state == STATE_UP || self.state == STATE_TOP) + if (this.state == STATE_UP || this.state == STATE_TOP) { - starte = self; - do - { - if (self.classname == "door") - { - door_go_down (); + entity e = this; + do { + if (e.classname == "door") { + door_go_down(e); + } else { + door_rotating_go_down(e); } - else - { - door_rotating_go_down (); - } - setself(self.enemy); - } while ( (self != starte) && (self != world) ); - setself(this); + e = e.enemy; + } while ((e != this) && (e != NULL)); return; } } // trigger all paired doors - starte = self; - do - { - if (self.classname == "door") - { - door_go_up (); - } else - { + entity e = this; + do { + if (e.classname == "door") { + door_go_up(e); + } else { // if the BIDIR spawnflag (==2) is set and the trigger has set trigger_reverse, reverse the opening direction - if ((self.spawnflags & 2) && other.trigger_reverse!=0 && self.lip!=666 && self.state == STATE_BOTTOM) - { - self.lip = 666; // self.lip is used to remember reverse opening direction for door_rotating - self.pos2 = '0 0 0' - self.pos2; + if ((e.spawnflags & 2) && trigger.trigger_reverse!=0 && e.lip != 666 && e.state == STATE_BOTTOM) { + e.lip = 666; // e.lip is used to remember reverse opening direction for door_rotating + e.pos2 = '0 0 0' - e.pos2; } // if BIDIR_IN_DOWN (==8) is set, prevent the door from reoping during closing if it is triggered from the wrong side - if (!((self.spawnflags & 2) && (self.spawnflags & 8) && self.state == STATE_DOWN - && (((self.lip==666) && (other.trigger_reverse==0)) || ((self.lip!=666) && (other.trigger_reverse!=0))))) + if (!((e.spawnflags & 2) && (e.spawnflags & 8) && e.state == STATE_DOWN + && (((e.lip == 666) && (trigger.trigger_reverse == 0)) || ((e.lip != 666) && (trigger.trigger_reverse != 0))))) { - door_rotating_go_up (); + door_rotating_go_up(e, trigger); } } - setself(self.enemy); - } while ( (self != starte) && (self != world) ); - setself(this); + e = e.enemy; + } while ((e != this) && (e != NULL)); } -void door_use() -{SELFPARAM(); - //dprint("door_use (model: ");dprint(self.model);dprint(")\n"); +void door_use(entity this, entity actor, entity trigger) +{ + //dprint("door_use (model: ");dprint(this.model);dprint(")\n"); - if (self.owner) - { - WITH(entity, self, self.owner, door_fire()); - } + if (this.owner) + door_fire(this.owner, actor, trigger); } -void door_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) -{SELFPARAM(); - if(self.spawnflags & DOOR_NOSPLASH) +void door_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +{ + if(this.spawnflags & DOOR_NOSPLASH) if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH)) return; - self.health = self.health - damage; + this.health = this.health - damage; - if (self.itemkeys) + if (this.itemkeys) { // don't allow opening doors through damage if keys are required return; } - if (self.health <= 0) + if (this.health <= 0) { - self.owner.health = self.owner.max_health; - self.owner.takedamage = DAMAGE_NO; // wil be reset upon return - WITH(entity, self, self.owner, door_use()); + this.owner.health = this.owner.max_health; + this.owner.takedamage = DAMAGE_NO; // wil be reset upon return + door_use(this.owner, NULL, NULL); } } +.float door_finished; /* ================ @@ -302,120 +289,119 @@ Prints messages ================ */ -void door_touch() -{SELFPARAM(); - if (!IS_PLAYER(other)) +void door_touch(entity this, entity toucher) +{ + if (!IS_PLAYER(toucher)) return; - if (self.owner.attack_finished_single > time) + if (this.owner.door_finished > time) return; - self.owner.attack_finished_single = time + 2; + this.owner.door_finished = time + 2; #ifdef SVQC - if (!(self.owner.dmg) && (self.owner.message != "")) + if (!(this.owner.dmg) && (this.owner.message != "")) { - if (IS_CLIENT(other)) - centerprint(other, self.owner.message); - play2(other, SND(TALK)); + if (IS_CLIENT(toucher)) + centerprint(toucher, this.owner.message); + play2(toucher, this.owner.noise); } #endif } -void door_generic_plat_blocked() -{SELFPARAM(); - - if((self.spawnflags & 8) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!! +void door_generic_plat_blocked(entity this, entity blocker) +{ + if((this.spawnflags & 8) && (blocker.takedamage != DAMAGE_NO)) { // Kill Kill Kill!! #ifdef SVQC - Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, blocker.origin, '0 0 0'); #endif } else { #ifdef SVQC - if((self.dmg) && (other.takedamage == DAMAGE_YES)) // Shall we bite? - Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + if((this.dmg) && (blocker.takedamage == DAMAGE_YES)) // Shall we bite? + Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, blocker.origin, '0 0 0'); #endif //Dont chamge direction for dead or dying stuff - if(PHYS_DEAD(other) && (other.takedamage == DAMAGE_NO)) + if(IS_DEAD(blocker) && (blocker.takedamage == DAMAGE_NO)) { - if (self.wait >= 0) + if (this.wait >= 0) { - if (self.state == STATE_DOWN) - door_rotating_go_up (); + if (this.state == STATE_DOWN) + door_rotating_go_up (this, blocker); else - door_rotating_go_down (); + door_rotating_go_down (this); } } #ifdef SVQC else { //gib dying stuff just to make sure - if((self.dmg) && (other.takedamage != DAMAGE_NO)) // Shall we bite? - Damage (other, self, self, 10000, DEATH_HURTTRIGGER.m_id, other.origin, '0 0 0'); + if((this.dmg) && (blocker.takedamage != DAMAGE_NO)) // Shall we bite? + Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, blocker.origin, '0 0 0'); } #endif } } -void door_rotating_hit_top() -{SELFPARAM(); - if (self.noise1 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); - self.state = STATE_TOP; - if (self.spawnflags & DOOR_TOGGLE) +void door_rotating_hit_top(entity this) +{ + if (this.noise1 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); + this.state = STATE_TOP; + if (this.spawnflags & DOOR_TOGGLE) return; // don't come down automatically - self.SUB_THINK = door_rotating_go_down; - self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait; + SUB_THINK(this, door_rotating_go_down); + this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait; } -void door_rotating_hit_bottom() -{SELFPARAM(); - if (self.noise1 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM); - if (self.lip==666) // self.lip is used to remember reverse opening direction for door_rotating +void door_rotating_hit_bottom(entity this) +{ + if (this.noise1 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); + if (this.lip==666) // this.lip is used to remember reverse opening direction for door_rotating { - self.pos2 = '0 0 0' - self.pos2; - self.lip = 0; + this.pos2 = '0 0 0' - this.pos2; + this.lip = 0; } - self.state = STATE_BOTTOM; + this.state = STATE_BOTTOM; } -void door_rotating_go_down() -{SELFPARAM(); - if (self.noise2 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); - if (self.max_health) +void door_rotating_go_down(entity this) +{ + if (this.noise2 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); + if (this.max_health) { - self.takedamage = DAMAGE_YES; - self.health = self.max_health; + this.takedamage = DAMAGE_YES; + this.health = this.max_health; } - self.state = STATE_DOWN; - SUB_CalcAngleMove (self.pos1, TSPEED_LINEAR, self.speed, door_rotating_hit_bottom); + this.state = STATE_DOWN; + SUB_CalcAngleMove (this, this.pos1, TSPEED_LINEAR, this.speed, door_rotating_hit_bottom); } -void door_rotating_go_up() -{SELFPARAM(); - if (self.state == STATE_UP) +void door_rotating_go_up(entity this, entity oth) +{ + if (this.state == STATE_UP) return; // already going up - if (self.state == STATE_TOP) + if (this.state == STATE_TOP) { // reset top wait time - self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait; + this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait; return; } - if (self.noise2 != "") - _sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM); - self.state = STATE_UP; - SUB_CalcAngleMove (self.pos2, TSPEED_LINEAR, self.speed, door_rotating_hit_top); + if (this.noise2 != "") + _sound (this, CH_TRIGGER_SINGLE, this.noise2, VOL_BASE, ATTEN_NORM); + this.state = STATE_UP; + SUB_CalcAngleMove (this, this.pos2, TSPEED_LINEAR, this.speed, door_rotating_hit_top); string oldmessage; - oldmessage = self.message; - self.message = ""; - SUB_UseTargets(); - self.message = oldmessage; + oldmessage = this.message; + this.message = ""; + SUB_UseTargets(this, NULL, oth); // TODO: is oth needed here? + this.message = oldmessage; } @@ -427,47 +413,39 @@ Spawned if a door lacks a real activator ========================================= */ -void door_trigger_touch() -{SELFPARAM(); - if (other.health < 1) +void door_trigger_touch(entity this, entity toucher) +{ + if (toucher.health < 1) #ifdef SVQC - if (!((other.iscreature || (other.flags & FL_PROJECTILE)) && !PHYS_DEAD(other))) + if (!((toucher.iscreature || (toucher.flags & FL_PROJECTILE)) && !IS_DEAD(toucher))) #elif defined(CSQC) - if(!((IS_CLIENT(other) || other.classname == "csqcprojectile") && !PHYS_DEAD(other))) + if(!((IS_CLIENT(toucher) || toucher.classname == "csqcprojectile") && !IS_DEAD(toucher))) #endif return; - if (time < self.attack_finished_single) + if (time < this.door_finished) return; // check if door is locked - if (!door_check_keys(self, other)) + if (!door_check_keys(this, toucher)) return; - self.attack_finished_single = time + 1; - - activator = other; + this.door_finished = time + 1; - setself(self.owner); - door_use (); + door_use(this.owner, toucher, NULL); } -void door_spawnfield(vector fmins, vector fmaxs) -{SELFPARAM(); +void door_spawnfield(entity this, vector fmins, vector fmaxs) +{ entity trigger; vector t1 = fmins, t2 = fmaxs; - trigger = spawn(); - trigger.classname = "doortriggerfield"; + trigger = new(doortriggerfield); trigger.movetype = MOVETYPE_NONE; trigger.solid = SOLID_TRIGGER; - trigger.owner = self; + trigger.owner = this; #ifdef SVQC - trigger.touch = door_trigger_touch; -#elif defined(CSQC) - trigger.trigger_touch = door_trigger_touch; - trigger.draw = trigger_draw_generic; - trigger.drawmask = MASK_NORMAL; + settouch(trigger, door_trigger_touch); #endif setsize (trigger, t1 - '60 60 8', t2 + '60 60 8'); @@ -483,8 +461,8 @@ LinkDoors */ entity LinkDoors_nextent(entity cur, entity near, entity pass) -{SELFPARAM(); - while((cur = find(cur, classname, self.classname)) && ((cur.spawnflags & 4) || cur.enemy)) +{ + while((cur = find(cur, classname, pass.classname)) && ((cur.spawnflags & 4) || cur.enemy)) { } return cur; @@ -506,8 +484,8 @@ bool LinkDoors_isconnected(entity e1, entity e2, entity pass) #ifdef SVQC void door_link(); #endif -void LinkDoors() -{SELFPARAM(); +void LinkDoors(entity this) +{ entity t; vector cmins, cmaxs; @@ -515,51 +493,51 @@ void LinkDoors() door_link(); #endif - if (self.enemy) + if (this.enemy) return; // already linked by another door - if (self.spawnflags & 4) + if (this.spawnflags & 4) { - self.owner = self.enemy = self; + this.owner = this.enemy = this; - if (self.health) + if (this.health) return; IFTARGETED return; - if (self.items) + if (this.items) return; - door_spawnfield(self.absmin, self.absmax); + door_spawnfield(this, this.absmin, this.absmax); return; // don't want to link this door } - FindConnectedComponent(self, enemy, LinkDoors_nextent, LinkDoors_isconnected, world); + FindConnectedComponent(this, enemy, LinkDoors_nextent, LinkDoors_isconnected, this); // set owner, and make a loop of the chain LOG_TRACE("LinkDoors: linking doors:"); - for(t = self; ; t = t.enemy) + for(t = this; ; t = t.enemy) { LOG_TRACE(" ", etos(t)); - t.owner = self; - if(t.enemy == world) + t.owner = this; + if(t.enemy == NULL) { - t.enemy = self; + t.enemy = this; break; } } LOG_TRACE("\n"); // collect health, targetname, message, size - cmins = self.absmin; - cmaxs = self.absmax; - for(t = self; ; t = t.enemy) + cmins = this.absmin; + cmaxs = this.absmax; + for(t = this; ; t = t.enemy) { - if(t.health && !self.health) - self.health = t.health; - if((t.targetname != "") && (self.targetname == "")) - self.targetname = t.targetname; - if((t.message != "") && (self.message == "")) - self.message = t.message; + if(t.health && !this.health) + this.health = t.health; + if((t.targetname != "") && (this.targetname == "")) + this.targetname = t.targetname; + if((t.message != "") && (this.message == "")) + this.message = t.message; if (t.absmin_x < cmins_x) cmins_x = t.absmin_x; if (t.absmin_y < cmins_y) @@ -572,33 +550,35 @@ void LinkDoors() cmaxs_y = t.absmax_y; if (t.absmax_z > cmaxs_z) cmaxs_z = t.absmax_z; - if(t.enemy == self) + if(t.enemy == this) break; } // distribute health, targetname, message - for(t = self; t; t = t.enemy) + for(t = this; t; t = t.enemy) { - t.health = self.health; - t.targetname = self.targetname; - t.message = self.message; - if(t.enemy == self) + t.health = this.health; + t.targetname = this.targetname; + t.message = this.message; + if(t.enemy == this) break; } // shootable, or triggered doors just needed the owner/enemy links, // they don't spawn a field - if (self.health) + if (this.health) return; IFTARGETED return; - if (self.items) + if (this.items) return; - door_spawnfield(cmins, cmaxs); + door_spawnfield(this, cmins, cmaxs); } +REGISTER_NET_LINKED(ENT_CLIENT_DOOR) + #ifdef SVQC /*QUAKED spawnfunc_func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE if two doors touch, they are assumed to be connected and operate as a unit. @@ -629,36 +609,36 @@ FIXME: only one sound set available at the time being */ -float door_send(entity to, float sf) -{SELFPARAM(); - WriteByte(MSG_ENTITY, ENT_CLIENT_DOOR); +float door_send(entity this, entity to, float sf) +{ + WriteHeader(MSG_ENTITY, ENT_CLIENT_DOOR); WriteByte(MSG_ENTITY, sf); if(sf & SF_TRIGGER_INIT) { - WriteString(MSG_ENTITY, self.classname); - WriteByte(MSG_ENTITY, self.spawnflags); + WriteString(MSG_ENTITY, this.classname); + WriteByte(MSG_ENTITY, this.spawnflags); - WriteString(MSG_ENTITY, self.model); + WriteString(MSG_ENTITY, this.model); - trigger_common_write(true); + trigger_common_write(this, true); - WriteCoord(MSG_ENTITY, self.pos1_x); - WriteCoord(MSG_ENTITY, self.pos1_y); - WriteCoord(MSG_ENTITY, self.pos1_z); - WriteCoord(MSG_ENTITY, self.pos2_x); - WriteCoord(MSG_ENTITY, self.pos2_y); - WriteCoord(MSG_ENTITY, self.pos2_z); + WriteCoord(MSG_ENTITY, this.pos1_x); + WriteCoord(MSG_ENTITY, this.pos1_y); + WriteCoord(MSG_ENTITY, this.pos1_z); + WriteCoord(MSG_ENTITY, this.pos2_x); + WriteCoord(MSG_ENTITY, this.pos2_y); + WriteCoord(MSG_ENTITY, this.pos2_z); - WriteCoord(MSG_ENTITY, self.size_x); - WriteCoord(MSG_ENTITY, self.size_y); - WriteCoord(MSG_ENTITY, self.size_z); + WriteCoord(MSG_ENTITY, this.size_x); + WriteCoord(MSG_ENTITY, this.size_y); + WriteCoord(MSG_ENTITY, this.size_z); - WriteShort(MSG_ENTITY, self.wait); - WriteShort(MSG_ENTITY, self.speed); - WriteByte(MSG_ENTITY, self.lip); - WriteByte(MSG_ENTITY, self.state); - WriteCoord(MSG_ENTITY, self.SUB_LTIME); + WriteShort(MSG_ENTITY, this.wait); + WriteShort(MSG_ENTITY, this.speed); + WriteByte(MSG_ENTITY, this.lip); + WriteByte(MSG_ENTITY, this.state); + WriteCoord(MSG_ENTITY, this.SUB_LTIME); } if(sf & SF_TRIGGER_RESET) @@ -668,16 +648,16 @@ float door_send(entity to, float sf) if(sf & SF_TRIGGER_UPDATE) { - WriteCoord(MSG_ENTITY, self.origin_x); - WriteCoord(MSG_ENTITY, self.origin_y); - WriteCoord(MSG_ENTITY, self.origin_z); - - WriteCoord(MSG_ENTITY, self.pos1_x); - WriteCoord(MSG_ENTITY, self.pos1_y); - WriteCoord(MSG_ENTITY, self.pos1_z); - WriteCoord(MSG_ENTITY, self.pos2_x); - WriteCoord(MSG_ENTITY, self.pos2_y); - WriteCoord(MSG_ENTITY, self.pos2_z); + WriteCoord(MSG_ENTITY, this.origin_x); + WriteCoord(MSG_ENTITY, this.origin_y); + WriteCoord(MSG_ENTITY, this.origin_z); + + WriteCoord(MSG_ENTITY, this.pos1_x); + WriteCoord(MSG_ENTITY, this.pos1_y); + WriteCoord(MSG_ENTITY, this.pos1_z); + WriteCoord(MSG_ENTITY, this.pos2_x); + WriteCoord(MSG_ENTITY, this.pos2_y); + WriteCoord(MSG_ENTITY, this.pos2_z); } return true; @@ -686,32 +666,32 @@ float door_send(entity to, float sf) void door_link() { // set size now, as everything is loaded - //FixSize(self); - //Net_LinkEntity(self, false, 0, door_send); + //FixSize(this); + //Net_LinkEntity(this, false, 0, door_send); } #endif -void door_init_startopen() -{SELFPARAM(); - SUB_SETORIGIN(self, self.pos2); - self.pos2 = self.pos1; - self.pos1 = self.origin; +void door_init_startopen(entity this) +{ + SUB_SETORIGIN(this, this.pos2); + this.pos2 = this.pos1; + this.pos1 = this.origin; #ifdef SVQC - self.SendFlags |= SF_TRIGGER_UPDATE; + this.SendFlags |= SF_TRIGGER_UPDATE; #endif } -void door_reset() -{SELFPARAM(); - SUB_SETORIGIN(self, self.pos1); - self.SUB_VELOCITY = '0 0 0'; - self.state = STATE_BOTTOM; - self.SUB_THINK = func_null; - self.SUB_NEXTTHINK = 0; +void door_reset(entity this) +{ + SUB_SETORIGIN(this, this.pos1); + this.SUB_VELOCITY = '0 0 0'; + this.state = STATE_BOTTOM; + SUB_THINK(this, func_null); + this.SUB_NEXTTHINK = 0; #ifdef SVQC - self.SendFlags |= SF_TRIGGER_RESET; + this.SendFlags |= SF_TRIGGER_RESET; #endif } @@ -721,152 +701,152 @@ void door_reset() spawnfunc(func_door) { // Quake 1 keys compatibility - if (self.spawnflags & SPAWNFLAGS_GOLD_KEY) - self.itemkeys |= ITEM_KEY_BIT(0); - if (self.spawnflags & SPAWNFLAGS_SILVER_KEY) - self.itemkeys |= ITEM_KEY_BIT(1); + if (this.spawnflags & SPAWNFLAGS_GOLD_KEY) + this.itemkeys |= ITEM_KEY_BIT(0); + if (this.spawnflags & SPAWNFLAGS_SILVER_KEY) + this.itemkeys |= ITEM_KEY_BIT(1); - SetMovedir(self); + SetMovedir(this); - self.max_health = self.health; - if (!InitMovingBrushTrigger()) + this.max_health = this.health; + if (!InitMovingBrushTrigger(this)) return; - self.effects |= EF_LOWPRECISION; - self.classname = "door"; + this.effects |= EF_LOWPRECISION; + this.classname = "door"; - self.blocked = door_blocked; - self.use = door_use; + if(this.noise == "") + this.noise = "misc/talk.wav"; + if(this.noise3 == "") + this.noise3 = "misc/talk.wav"; + precache_sound(this.noise); + precache_sound(this.noise3); - if(self.dmg && (self.message == "")) - self.message = "was squished"; - if(self.dmg && (self.message2 == "")) - self.message2 = "was squished by"; + setblocked(this, door_blocked); + this.use = door_use; - if (self.sounds > 0) + if(this.dmg && (this.message == "")) + this.message = "was squished"; + if(this.dmg && (this.message2 == "")) + this.message2 = "was squished by"; + + if (this.sounds > 0) { precache_sound ("plats/medplat1.wav"); precache_sound ("plats/medplat2.wav"); - self.noise2 = "plats/medplat1.wav"; - self.noise1 = "plats/medplat2.wav"; + this.noise2 = "plats/medplat1.wav"; + this.noise1 = "plats/medplat2.wav"; } - if (!self.speed) - self.speed = 100; - if (!self.wait) - self.wait = 3; - if (!self.lip) - self.lip = 8; + if (!this.speed) + this.speed = 100; + if (!this.wait) + this.wait = 3; + if (!this.lip) + this.lip = 8; - self.pos1 = self.SUB_ORIGIN; - self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); + this.pos1 = this.SUB_ORIGIN; + this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip); - if(self.spawnflags & DOOR_NONSOLID) - self.solid = SOLID_NOT; + if(this.spawnflags & DOOR_NONSOLID) + this.solid = SOLID_NOT; // DOOR_START_OPEN is to allow an entity to be lighted in the closed position // but spawn in the open position - if (self.spawnflags & DOOR_START_OPEN) - InitializeEntity(self, door_init_startopen, INITPRIO_SETLOCATION); + if (this.spawnflags & DOOR_START_OPEN) + InitializeEntity(this, door_init_startopen, INITPRIO_SETLOCATION); - self.state = STATE_BOTTOM; + this.state = STATE_BOTTOM; - if (self.health) + if (this.health) { - self.takedamage = DAMAGE_YES; - self.event_damage = door_damage; + this.takedamage = DAMAGE_YES; + this.event_damage = door_damage; } - if (self.items) - self.wait = -1; + if (this.items) + this.wait = -1; - self.touch = door_touch; + settouch(this, door_touch); // LinkDoors can't be done until all of the doors have been spawned, so // the sizes can be detected properly. - InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS); + InitializeEntity(this, LinkDoors, INITPRIO_LINKDOORS); - self.reset = door_reset; + this.reset = door_reset; } #elif defined(CSQC) -void door_draw(entity this) +NET_HANDLE(ENT_CLIENT_DOOR, bool isnew) { - Movetype_Physics_NoMatchServer(); - - trigger_draw_generic(this); -} - -void ent_door() -{SELFPARAM(); - float sf = ReadByte(); + int sf = ReadByte(); if(sf & SF_TRIGGER_INIT) { - self.classname = strzone(ReadString()); - self.spawnflags = ReadByte(); - - self.mdl = strzone(ReadString()); - _setmodel(self, self.mdl); - - trigger_common_read(true); - - 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.wait = ReadShort(); - self.speed = ReadShort(); - self.lip = ReadByte(); - self.state = ReadByte(); - self.SUB_LTIME = ReadCoord(); - - self.solid = SOLID_BSP; - self.movetype = MOVETYPE_PUSH; - self.trigger_touch = door_touch; - self.draw = door_draw; - self.drawmask = MASK_NORMAL; - self.use = door_use; - - LinkDoors(); - - if(self.spawnflags & DOOR_START_OPEN) - door_init_startopen(); - - self.move_time = time; - self.move_origin = self.origin; - self.move_movetype = MOVETYPE_PUSH; - self.move_angles = self.angles; - self.move_blocked = door_blocked; + this.classname = strzone(ReadString()); + this.spawnflags = ReadByte(); + + this.mdl = strzone(ReadString()); + _setmodel(this, this.mdl); + + trigger_common_read(this, true); + + vector v; + + v.x = ReadCoord(); + v.y = ReadCoord(); + v.z = ReadCoord(); + this.pos1 = v; + + v.x = ReadCoord(); + v.y = ReadCoord(); + v.z = ReadCoord(); + this.pos2 = v; + + v.x = ReadCoord(); + v.y = ReadCoord(); + v.z = ReadCoord(); + this.size = v; + + this.wait = ReadShort(); + this.speed = ReadShort(); + this.lip = ReadByte(); + this.state = ReadByte(); + this.SUB_LTIME = ReadCoord(); + + this.solid = SOLID_BSP; + this.movetype = MOVETYPE_PUSH; + this.use = door_use; + + LinkDoors(this); + + if(this.spawnflags & DOOR_START_OPEN) + door_init_startopen(this); + + this.move_time = time; + this.move_movetype = MOVETYPE_PUSH; } if(sf & SF_TRIGGER_RESET) { - door_reset(); + door_reset(this); } if(sf & SF_TRIGGER_UPDATE) { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); - self.move_origin = self.origin; - - self.pos1_x = ReadCoord(); - self.pos1_y = ReadCoord(); - self.pos1_z = ReadCoord(); - self.pos2_x = ReadCoord(); - self.pos2_y = ReadCoord(); - self.pos2_z = ReadCoord(); + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); + setorigin(this, this.origin); + + this.pos1_x = ReadCoord(); + this.pos1_y = ReadCoord(); + this.pos1_z = ReadCoord(); + this.pos2_x = ReadCoord(); + this.pos2_y = ReadCoord(); + this.pos2_z = ReadCoord(); } + return true; } #endif