=============================================================================
*/
-float door_check_keys(void)
-{SELFPARAM();
- local entity door;
-
- if (self.owner)
- door = self.owner;
- else
- door = self;
+bool door_check_keys(entity door, entity player)
+{
+ if(door.owner)
+ door = door.owner;
// no key needed
- if (!door.itemkeys)
+ if(!door.itemkeys)
return true;
// this door require a key
// only a player can have a key
- if (!IS_PLAYER(other))
+ if(!IS_PLAYER(player))
return false;
-#ifdef SVQC
- if (item_keys_usekey(door, other))
+ int valid = (door.itemkeys & player.itemkeys);
+ door.itemkeys &= ~valid; // only some of the needed keys were given
+
+ if(!door.itemkeys)
{
- // some keys were used
- if (other.key_door_messagetime <= time)
- {
- play2(other, SND(TALK));
- Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_LOCKED_ALSONEED, item_keys_keylist(door.itemkeys));
- other.key_door_messagetime = time + 2;
- }
+#ifdef SVQC
+ play2(player, SND(TALK));
+ Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_UNLOCKED);
+#endif
+ return true;
}
- else
+
+ if(!valid)
{
- // no keys were used
- if (other.key_door_messagetime <= time)
+#ifdef SVQC
+ if(player.key_door_messagetime <= time)
{
- play2(other, SND(TALK));
- Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_LOCKED_NEED, item_keys_keylist(door.itemkeys));
-
- other.key_door_messagetime = time + 2;
+ play2(player, SND(TALK));
+ Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_LOCKED_NEED, item_keys_keylist(door.itemkeys));
+ player.key_door_messagetime = time + 2;
}
- }
#endif
+ return false;
+ }
- if (door.itemkeys)
- {
+ // door needs keys the player doesn't have
#ifdef SVQC
- // door is now unlocked
- play2(other, SND(TALK));
- Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_DOOR_UNLOCKED);
-#endif
- return true;
+ if(player.key_door_messagetime <= time)
+ {
+ play2(player, SND(TALK));
+ Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_LOCKED_ALSONEED, item_keys_keylist(door.itemkeys));
+ player.key_door_messagetime = time + 2;
}
- else
- return false;
+#endif
+
+ return false;
}
void door_fire()
return;
// check if door is locked
- if (!door_check_keys())
+ if (!door_check_keys(self, other))
return;
self.attack_finished_single = time + 1;
door_use ();
}
-void spawn_field(vector fmins, vector fmaxs)
+void door_spawnfield(vector fmins, vector fmaxs)
{SELFPARAM();
entity trigger;
vector t1 = fmins, t2 = fmaxs;
if (self.items)
return;
- spawn_field(self.absmin, self.absmax);
+ door_spawnfield(self.absmin, self.absmax);
return; // don't want to link this door
}
if (self.items)
return;
- spawn_field(cmins, cmaxs);
+ door_spawnfield(cmins, cmaxs);
}
#ifdef SVQC