]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/item_key.qc
Merge branch 'master' into Mario/notifications
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / item_key.qc
index 530c2815c88349c55e3ccedb7a60070de23d88b2..79003853a6deef93d6ce20e93f5beecfb183518e 100644 (file)
@@ -9,8 +9,8 @@ TODO:
 
 float item_keys_usekey(entity l, entity p) {
        float valid = l.itemkeys & p.itemkeys;
-       
-       if not(valid) {
+
+       if (!valid) {
                // other has none of the needed keys
                return FALSE;
        } else if (l.itemkeys == valid) {
@@ -19,7 +19,7 @@ float item_keys_usekey(entity l, entity p) {
                return TRUE;
        } else {
                // only some of the needed keys were given
-               l.itemkeys &~= valid;
+               l.itemkeys &= ~valid;
                return TRUE;
        }
 }
@@ -27,15 +27,15 @@ float item_keys_usekey(entity l, entity p) {
 string item_keys_keylist(float keylist) {
        float base, l;
        string n;
-       
+
        // no keys
-       if not(keylist)
+       if (!keylist)
                return "";
-       
+
        // one key
        if ((keylist & (keylist-1)) != 0)
                return strcat("the ", item_keys_names[lowestbit(keylist)]);
-       
+
        n = "";
        base = 0;
        while (keylist) {
@@ -44,11 +44,11 @@ string item_keys_keylist(float keylist) {
                        n = strcat(n, ", the ", item_keys_names[base + l]);
                else
                        n = strcat("the ", item_keys_names[base + l]);
-               
+
                keylist = bitshift(keylist,  -(l + 1));
                base+= l + 1;
        }
-       
+
        return n;
 }
 
@@ -63,16 +63,16 @@ item_key
  * Key touch handler.
  */
 void item_key_touch(void) {
-       if not(IS_PLAYER(other))
+       if (!IS_PLAYER(other))
                return;
-               
+
        // player already picked up this key
        if (other.itemkeys & self.itemkeys)
                return;
-       
+
        other.itemkeys |= self.itemkeys;
        play2(other, self.noise);
-       
+
        centerprint(other, self.message);
 };
 
@@ -81,17 +81,17 @@ void item_key_touch(void) {
  */
 void spawn_item_key() {
        precache_model(self.model);
-       
+
        if (self.spawnflags & 1) // FLOATING
                self.noalign = 1;
-       
+
        if (self.noalign)
                self.movetype = MOVETYPE_NONE;
        else
                self.movetype = MOVETYPE_TOSS;
-               
+
        precache_sound(self.noise);
-               
+
        self.mdl = self.model;
        self.effects = EF_LOWPRECISION;
        setmodel(self, self.model);
@@ -100,7 +100,7 @@ void spawn_item_key() {
        setsize(self, '-16 -16 -56', '16 16 0');
        self.modelflags |= MF_ROTATE;
        self.solid = SOLID_TRIGGER;
-       
+
        if (!self.noalign)
        {
                // first nudge it off the floor a little bit to avoid math errors
@@ -116,7 +116,7 @@ void spawn_item_key() {
 /*QUAKED item_key (0 .5 .8) (-16 -16 -24) (16 16 32) FLOATING
 A key entity.
 The itemkeys should contain one of the following key IDs:
-1 - GOLD key - 
+1 - GOLD key -
 2 - SILVER key
 4 - BRONZE key
 8 - RED keycard
@@ -142,7 +142,7 @@ itemkeys MUST always have exactly one bit set.
 void spawnfunc_item_key() {
        local string _model, _netname;
        local 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!");
@@ -156,32 +156,32 @@ void spawnfunc_item_key() {
                _netname = "GOLD key";
                _colormod = '1 .9 0';
                break;
-               
+
        case 2:
                _netname = "SILVER key";
                _colormod = '.9 .9 .9';
                break;
-               
+
        case 4:
                _netname = "BRONZE key";
                _colormod = '.6 .25 0';
                break;
-               
+
        case 8:
                _netname = "RED keycard";
                _colormod = '.9 0 0';
                break;
-               
+
        case 16:
                _netname = "BLUE keycard";
                _colormod = '0 0 .9';
                break;
-               
+
        case 32:
                _netname = "GREEN keycard";
                _colormod = '0 .9 0';
                break;
-       
+
        default:
                _netname = "FLUFFY PINK keycard";
                _colormod = '1 1 1';
@@ -192,9 +192,9 @@ void spawnfunc_item_key() {
                        return;
                }
                break;
-               
+
        }
-       
+
        // find default model
 #ifdef GMQCC
        _model = string_null;
@@ -208,30 +208,30 @@ void spawnfunc_item_key() {
                remove(self);
                return;
        }
-       
+
        // set defailt netname
        if (self.netname == "")
                self.netname = _netname;
-       
+
        // set default colormod
        if (!self.colormod)
                self.colormod = _colormod;
-       
+
        // set default model
        if (self.model == "")
                self.model = _model;
-       
+
        // set default pickup message
        if (self.message == "")
                self.message = strzone(strcat("You've picked up the ", self.netname, "!"));
 
        if (self.noise == "")
                self.noise = "misc/itempickup.wav";
-       
+
        // save the name for later
        item_keys_names[lowestbit(self.itemkeys)] = self.netname;
 
-       // put the key on the map       
+       // put the key on the map
        spawn_item_key();
 }
 
@@ -283,12 +283,12 @@ trigger_keylock
  */
 void trigger_keylock_trigger(string s) {
        local entity t, stemp, otemp, atemp;
-       
+
        stemp = self;
        otemp = other;
        atemp = activator;
-       
-       
+
+
        for(t = world; (t = find(t, targetname, s)); )
                if (t.use) {
                        self = t;
@@ -296,7 +296,7 @@ void trigger_keylock_trigger(string s) {
                        activator = atemp;
                        self.use();
                }
-       
+
        self = stemp;
        other = otemp;
        activator = atemp;
@@ -313,35 +313,35 @@ void trigger_keylock_kill(string s) {
 
 void trigger_keylock_touch(void) {
        local float key_used, started_delay;
-       
+
        key_used = FALSE;
        started_delay = FALSE;
-       
+
        // only player may trigger the lock
-       if not(IS_PLAYER(other))
+       if (!IS_PLAYER(other))
                return;
-       
-       
+
+
        // check silver key
        if (self.itemkeys)
                key_used = item_keys_usekey(self, other);
-       
+
        activator = other;
-       
+
        if (self.itemkeys) {
                // at least one of the keys is missing
                if (key_used) {
                        // one or more keys were given, but others are still missing!
                        play2(other, self.noise1);
-                       centerprint(other, strcat("You also need ", item_keys_keylist(self.itemkeys), "!"));
+                       Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_LOCKED_ALSONEED, item_keys_keylist(self.itemkeys));
                        other.key_door_messagetime = time + 2;
                } else if (other.key_door_messagetime <= time) {
                        // no keys were given
                        play2(other, self.noise2);
-                       centerprint(other, strcat("You need ", item_keys_keylist(self.itemkeys), "!"));
+                       Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_LOCKED_NEED, item_keys_keylist(self.itemkeys));
                        other.key_door_messagetime = time + 2;
                }
-               
+
                // trigger target2
                if (self.delay <= time || started_delay == TRUE)
                if (self.target2) {
@@ -353,16 +353,16 @@ void trigger_keylock_touch(void) {
                // all keys were given!
                play2(other, self.noise);
                centerprint(other, self.message);
-               
+
                if (self.target)
                        trigger_keylock_trigger(self.target);
-                       
+
                if (self.killtarget)
                        trigger_keylock_kill(self.killtarget);
-               
+
                remove(self);
        }
-       
+
 };
 
 /*QUAKED trigger_keylock (.0 .5 .8) ?
@@ -390,10 +390,10 @@ void spawnfunc_trigger_keylock(void) {
                return;
        }
 
-       // set unlocked message 
+       // set unlocked message
        if (self.message == "")
                self.message = "Unlocked!";
-       
+
        // set default unlock noise
        if (self.noise == "") {
                if (self.sounds == 1)
@@ -403,26 +403,26 @@ void spawnfunc_trigger_keylock(void) {
                else //if (self.sounds == 3) {
                        self.noise = "misc/trigger1.wav";
        }
-       
+
        // set default use key sound
        if (self.noise1 == "")
                self.noise1 = "misc/decreasevalue.wav";
-       
+
        // set closed sourd
        if (self.noise2 == "")
                self.noise2 = "misc/talk.wav";
-       
+
        // delay between triggering message2 and trigger2
        if (!self.wait)
                self.wait = 5;
-       
+
        // precache sounds
        precache_sound(self.noise);
        precache_sound(self.noise1);
        precache_sound(self.noise2);
-       
+
        EXACTTRIGGER_INIT;
-       
+
        self.touch = trigger_keylock_touch;
 };