X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fitem_key.qc;h=85159e49cf27699396c425a28b6e236bae332e43;hb=6dc9591eba337374f2b4348a6a6deaa1cb6887d0;hp=f181f376448761b3aa8ffd169369d62ba84105c2;hpb=e95cf471e2b4a66a099aff48cad52b3b37951518;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/item_key.qc b/qcsrc/server/item_key.qc index f181f3764..85159e49c 100644 --- a/qcsrc/server/item_key.qc +++ b/qcsrc/server/item_key.qc @@ -1,3 +1,17 @@ +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "../dpdefs/progsdefs.qh" + #include "../dpdefs/dpextensions.qh" + #include "../warpzonelib/util_server.qh" + #include "../common/util.qh" + #include "../common/monsters/monsters.qh" + #include "../common/triggers/subs.qh" + #include "defs.qh" + #include "../common/notifications.qh" + #include "item_key.qh" +#endif + /* TODO: - add an unlock sound (here to trigger_keylock and to func_door) @@ -7,20 +21,20 @@ TODO: - should keys have a trigger? */ -float item_keys_usekey(entity l, entity p) { +bool item_keys_usekey(entity l, entity p) { float valid = l.itemkeys & p.itemkeys; if (!valid) { // other has none of the needed keys - return FALSE; + return false; } else if (l.itemkeys == valid) { // ALL needed keys were given l.itemkeys = 0; - return TRUE; + return true; } else { // only some of the needed keys were given l.itemkeys &= ~valid; - return TRUE; + return true; } } @@ -105,7 +119,7 @@ void spawn_item_key() { { // first nudge it off the floor a little bit to avoid math errors setorigin(self, self.origin + '0 0 1'); - // note droptofloor returns FALSE if stuck/or would fall too far + // note droptofloor returns false if stuck/or would fall too far droptofloor(); } @@ -140,8 +154,8 @@ This is the only correct way to put keys on the map! itemkeys MUST always have exactly one bit set. */ void spawnfunc_item_key() { - local string _model, _netname; - local vector _colormod; + string _netname; + vector _colormod; // reject this entity if more than one key was set! if (self.itemkeys>0 && (self.itemkeys & (self.itemkeys-1)) != 0) { @@ -196,9 +210,7 @@ void spawnfunc_item_key() { } // find default model -#ifdef GMQCC - _model = string_null; -#endif + string _model = string_null; if (self.itemkeys <= ITEM_KEY_BIT(2)) { _model = "models/keys/key.md3"; } else if (self.itemkeys >= ITEM_KEY_BIT(3) && self.itemkeys <= ITEM_KEY_BIT(5)) { @@ -282,13 +294,11 @@ trigger_keylock * trigger givent targets */ void trigger_keylock_trigger(string s) { - local entity t, stemp, otemp, atemp; - - stemp = self; - otemp = other; - atemp = activator; - + entity stemp = self; + entity otemp = other; + entity atemp = activator; + entity t; for(t = world; (t = find(t, targetname, s)); ) if (t.use) { self = t; @@ -306,16 +316,14 @@ void trigger_keylock_trigger(string s) { * kill killtarget of trigger keylock. */ void trigger_keylock_kill(string s) { - local entity t; + entity t; for(t = world; (t = find(t, targetname, s)); ) remove(t); }; void trigger_keylock_touch(void) { - local float key_used, started_delay; - - key_used = FALSE; - started_delay = FALSE; + bool key_used = false; + bool started_delay = false; // only player may trigger the lock if (!IS_PLAYER(other)) @@ -333,20 +341,20 @@ void trigger_keylock_touch(void) { 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.delay <= time || started_delay == true) if (self.target2) { trigger_keylock_trigger(self.target2); - started_delay = TRUE; + started_delay = true; self.delay = time + self.wait; } } else { @@ -424,6 +432,4 @@ void spawnfunc_trigger_keylock(void) { EXACTTRIGGER_INIT; self.touch = trigger_keylock_touch; -}; - - +}