X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fgamemode_keyhunt.qc;h=5fa2f6db2b7a9ea384a442664612681cca80f108;hb=34095b88e7a8d82f83aca8ce1009f9622026d159;hp=2a67316101f846261dc819f6476bf7ef23f539e7;hpb=77f03e6ce033bef39ac19e0e7cb6e606ffcb26db;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qc b/qcsrc/server/mutators/gamemode_keyhunt.qc index 2a6731610..5fa2f6db2 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/gamemode_keyhunt.qc @@ -1,4 +1,8 @@ -#define FOR_EACH_KH_KEY(v) for(v = kh_worldkeylist; v; v = v.kh_worldkeynext ) +#include "gamemode_keyhunt.qh" +#include "../_all.qh" + +#include "gamemode.qh" + // #define KH_PLAYER_USE_ATTACHMENT // #define KH_PLAYER_USE_CARRIEDMODEL @@ -271,7 +275,7 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs } // in any case: setattachment(key, world, ""); - setorigin(key, key.owner.origin + '0 0 1' * (PL_MIN_z - KH_KEY_MIN_z)); + setorigin(key, key.owner.origin + '0 0 1' * (PL_MIN.z - KH_KEY_MIN_z)); key.angles = key.owner.angles; #else setorigin(key, key.owner.origin + key.origin.z * '0 0 1'); @@ -397,7 +401,7 @@ void kh_Key_AssignTo(entity key, entity player) // runs every time a key is pic } } -void kh_Key_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) +void kh_Key_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) { if(self.owner) return; @@ -867,6 +871,8 @@ float kh_CheckPlayers(float num) return 0; } +#define KH_READY_TEAMS() (!p1 + !p2 + ((kh_teams >= 3) ? !p3 : p3) + ((kh_teams >= 4) ? !p4 : p4)) +#define KH_READY_TEAMS_OK() (KH_READY_TEAMS() == kh_teams) void kh_WaitForPlayers() // delay start of the round until enough players are present { if(time < game_starttime) @@ -875,15 +881,35 @@ void kh_WaitForPlayers() // delay start of the round until enough players are p return; } + static float prev_missing_teams_mask; float p1 = kh_CheckPlayers(0), p2 = kh_CheckPlayers(1), p3 = kh_CheckPlayers(2), p4 = kh_CheckPlayers(3); - if (!(p1 || p2 || p3 || p4)) + if(KH_READY_TEAMS_OK()) { + if(prev_missing_teams_mask > 0) + Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS); + prev_missing_teams_mask = -1; Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_ROUNDSTART, autocvar_g_balance_keyhunt_delay_round); kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, kh_StartRound); } else { - Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_WAIT, p1, p2, p3, p4); + if(player_count == 0) + { + if(prev_missing_teams_mask > 0) + Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS); + prev_missing_teams_mask = -1; + } + else + { + float missing_teams_mask = (!!p1) + (!!p2) * 2; + if(kh_teams >= 3) missing_teams_mask += (!!p3) * 4; + if(kh_teams >= 4) missing_teams_mask += (!!p4) * 8; + if(prev_missing_teams_mask != missing_teams_mask) + { + Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask); + prev_missing_teams_mask = missing_teams_mask; + } + } kh_Controller_SetThink(1, kh_WaitForPlayers); } } @@ -908,10 +934,9 @@ void kh_StartRound() // runs at the start of each round } float p1 = kh_CheckPlayers(0), p2 = kh_CheckPlayers(1), p3 = kh_CheckPlayers(2), p4 = kh_CheckPlayers(3); - if(p1 || p2 || p3 || p4) + if(!KH_READY_TEAMS_OK()) { kh_Controller_SetThink(1, kh_WaitForPlayers); - Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_WAIT, p1, p2, p3, p4); return; }