X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fitem_key.qc;h=cf2b25acff05fb776137775c59ac07f67ce19d63;hp=6a1527745e3f368eab3c35715790dffbf216bff7;hb=c6ebaefab2aca7df4648dac3ccdd4b52de45d0ed;hpb=c89dfaa4d0342b98c320621557973a65114fbdf4 diff --git a/qcsrc/server/item_key.qc b/qcsrc/server/item_key.qc index 6a1527745..cf2b25acf 100644 --- a/qcsrc/server/item_key.qc +++ b/qcsrc/server/item_key.qc @@ -1,11 +1,10 @@ #include "item_key.qh" -#include "_all.qh" #include "../common/triggers/subs.qh" #include "../common/monsters/all.qh" -#include "../common/notifications.qh" +#include "../common/notifications/all.qh" #include "../common/util.qh" -#include "../warpzonelib/util_server.qh" +#include "../lib/warpzone/util_server.qh" /* TODO: @@ -40,7 +39,7 @@ string item_keys_keylist(float keylist) { return ""; // one key - if ((keylist & (keylist-1)) != 0) + if ((keylist & (keylist-1)) == 0) return strcat("the ", item_keys_names[lowestbit(keylist)]); string n = ""; @@ -69,56 +68,61 @@ item_key /** * Key touch handler. */ -void item_key_touch() -{SELFPARAM(); - if (!IS_PLAYER(other)) +void item_key_touch(entity this, entity toucher) +{ + if (!IS_PLAYER(toucher)) return; // player already picked up this key - if (other.itemkeys & self.itemkeys) + if (toucher.itemkeys & this.itemkeys) return; - other.itemkeys |= self.itemkeys; - play2(other, self.noise); + toucher.itemkeys |= this.itemkeys; + play2(toucher, this.noise); + + centerprint(toucher, this.message); - centerprint(other, self.message); + string oldmsg = this.message; + this.message = ""; + SUB_UseTargets(this, toucher, toucher); // TODO: should we be using toucher for the trigger here? + this.message = oldmsg; }; /** * Spawn a key with given model, key code and color. */ -void spawn_item_key() -{SELFPARAM(); - precache_model(self.model); +void spawn_item_key(entity this) +{ + precache_model(this.model); - if (self.spawnflags & 1) // FLOATING - self.noalign = 1; + if (this.spawnflags & 1) // FLOATING + this.noalign = 1; - if (self.noalign) - self.movetype = MOVETYPE_NONE; + if (this.noalign) + this.movetype = MOVETYPE_NONE; else - self.movetype = MOVETYPE_TOSS; + this.movetype = MOVETYPE_TOSS; - precache_sound(self.noise); + precache_sound(this.noise); - self.mdl = self.model; - self.effects = EF_LOWPRECISION; - _setmodel(self, self.model); - //setsize(self, '-16 -16 -24', '16 16 32'); - setorigin(self, self.origin + '0 0 32'); - setsize(self, '-16 -16 -56', '16 16 0'); - self.modelflags |= MF_ROTATE; - self.solid = SOLID_TRIGGER; + this.mdl = this.model; + this.effects = EF_LOWPRECISION; + _setmodel(this, this.model); + //setsize(this, '-16 -16 -24', '16 16 32'); + setorigin(this, this.origin + '0 0 32'); + setsize(this, '-16 -16 -56', '16 16 0'); + this.modelflags |= MF_ROTATE; + this.solid = SOLID_TRIGGER; - if (!self.noalign) + if (!this.noalign) { // first nudge it off the floor a little bit to avoid math errors - setorigin(self, self.origin + '0 0 1'); + setorigin(this, this.origin + '0 0 1'); // note droptofloor returns false if stuck/or would fall too far - droptofloor(); + droptofloor(this); } - self.touch = item_key_touch; + settouch(this, item_key_touch); }; @@ -148,46 +152,46 @@ This is the only correct way to put keys on the map! itemkeys MUST always have exactly one bit set. */ -void spawnfunc_item_key() -{SELFPARAM(); +spawnfunc(item_key) +{ string _netname; vector _colormod; // reject this entity if more than one key was set! - if (self.itemkeys>0 && (self.itemkeys & (self.itemkeys-1)) != 0) { - objerror("item_key.itemkeys must contain only 1 bit set specifying the key it represents!"); - remove(self); + if (this.itemkeys>0 && (this.itemkeys & (this.itemkeys-1)) != 0) { + objerror(this, "item_key.itemkeys must contain only 1 bit set specifying the key it represents!"); + remove(this); return; } // find default netname and colormod - switch(self.itemkeys) { - case 1: + switch(this.itemkeys) { + case BIT(0): _netname = "GOLD key"; _colormod = '1 .9 0'; break; - case 2: + case BIT(1): _netname = "SILVER key"; _colormod = '.9 .9 .9'; break; - case 4: + case BIT(2): _netname = "BRONZE key"; _colormod = '.6 .25 0'; break; - case 8: + case BIT(3): _netname = "RED keycard"; _colormod = '.9 0 0'; break; - case 16: + case BIT(4): _netname = "BLUE keycard"; _colormod = '0 0 .9'; break; - case 32: + case BIT(5): _netname = "GREEN keycard"; _colormod = '0 .9 0'; break; @@ -196,9 +200,9 @@ void spawnfunc_item_key() _netname = "FLUFFY PINK keycard"; _colormod = '1 1 1'; - if (self.netname == "") { - objerror("item_key doesn't have a default name for this key and a custom one was not specified!"); - remove(self); + if (this.netname == "") { + objerror(this, "item_key doesn't have a default name for this key and a custom one was not specified!"); + remove(this); return; } break; @@ -207,40 +211,40 @@ void spawnfunc_item_key() // find default model string _model = string_null; - if (self.itemkeys <= ITEM_KEY_BIT(2)) { + if (this.itemkeys <= ITEM_KEY_BIT(2)) { _model = "models/keys/key.md3"; - } else if (self.itemkeys >= ITEM_KEY_BIT(3) && self.itemkeys <= ITEM_KEY_BIT(5)) { + } else if (this.itemkeys >= ITEM_KEY_BIT(3) && this.itemkeys <= ITEM_KEY_BIT(5)) { _model = "models/keys/key.md3"; // FIXME: replace it by a keycard model! - } else if (self.model == "") { - objerror("item_key doesn't have a default model for this key and a custom one was not specified!"); - remove(self); + } else if (this.model == "") { + objerror(this, "item_key doesn't have a default model for this key and a custom one was not specified!"); + remove(this); return; } // set defailt netname - if (self.netname == "") - self.netname = _netname; + if (this.netname == "") + this.netname = _netname; // set default colormod - if (!self.colormod) - self.colormod = _colormod; + if (!this.colormod) + this.colormod = _colormod; // set default model - if (self.model == "") - self.model = _model; + if (this.model == "") + this.model = _model; // set default pickup message - if (self.message == "") - self.message = strzone(strcat("You've picked up the ", self.netname, "!")); + if (this.message == "") + this.message = strzone(strcat("You've picked up the ", this.netname, "!")); - if (self.noise == "") - self.noise = "misc/itempickup.wav"; + if (this.noise == "") + this.noise = strzone(SND(ITEMPICKUP)); // save the name for later - item_keys_names[lowestbit(self.itemkeys)] = self.netname; + item_keys_names[lowestbit(this.itemkeys)] = this.netname; // put the key on the map - spawn_item_key(); + spawn_item_key(this); } /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32) FLOATING @@ -255,11 +259,11 @@ FLOATING: the item will float in air, instead of aligning to the floor by fallin ---------NOTES---------- Don't use this entity on new maps! Use item_key instead. */ -void spawnfunc_item_key1(void) -{SELFPARAM(); - self.classname = "item_key"; - self.itemkeys = ITEM_KEY_BIT(1); - spawnfunc_item_key(); +spawnfunc(item_key1) +{ + this.classname = "item_key"; + this.itemkeys = ITEM_KEY_BIT(1); + spawnfunc_item_key(this); }; /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32) FLOATING @@ -274,9 +278,9 @@ FLOATING: the item will float in air, instead of aligning to the floor by fallin ---------NOTES---------- Don't use this entity on new maps! Use item_key instead. */ -void spawnfunc_item_key2(void) -{SELFPARAM(); - self.classname = "item_key"; - self.itemkeys = ITEM_KEY_BIT(0); - spawnfunc_item_key(); +spawnfunc(item_key2) +{ + this.classname = "item_key"; + this.itemkeys = ITEM_KEY_BIT(0); + spawnfunc_item_key(this); };