]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Keyhunt patch by Mario
authorSamual Lenks <samual@xonotic.org>
Fri, 1 Mar 2013 18:11:28 +0000 (13:11 -0500)
committerSamual Lenks <samual@xonotic.org>
Fri, 1 Mar 2013 18:11:28 +0000 (13:11 -0500)
qcsrc/common/notifications.qh
qcsrc/server/arena.qc
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/mutators/gamemode_keyhunt.qh

index 1d0626cc18d696111ad9e6249a72ae3b6f3ffcca..1b205cee8fccafef1e57eaf519adca6d7cfac13f 100644 (file)
@@ -98,7 +98,6 @@ void Send_Notification_WOVA(
 // legacy stuff
 void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num);
 #define Send_CSQC_Centerprint_Generic_Expire(e,id) Send_CSQC_Centerprint_Generic(e, id, "", 1, 0)
-float CPID_KH_MSG = 10;
 #endif
 
 
@@ -277,6 +276,10 @@ float CPID_KH_MSG = 10;
        MSG_INFO_NOTIF(2, INFO_JOIN_PLAY,                                               1, 0, "s1", "",                                                 "",                                             _("^BG%s^F3 is now playing\n"), "") \
        MSG_INFO_NOTIF(1, INFO_KEEPAWAY_DROPPED,                                1, 0, "s1", "s1",                                               "notify_balldropped",   _("^BG%s^BG has dropped the ball!\n"), "") \
        MSG_INFO_NOTIF(1, INFO_KEEPAWAY_PICKUP,                                 1, 0, "s1", "s1",                                               "notify_ballpickedup",  _("^BG%s^BG has picked up the ball!\n"), "") \
+       MSG_INFO_NOTIF(1, INFO_KEYHUNT_CAPTURE,                                 2, 0, "s1 s2", "",                                              "",                                             _("^BG%s captured the keys for the %s\n"), "") \
+       MSG_INFO_NOTIF(1, INFO_KEYHUNT_DROP,                                    2, 0, "s1 s2", "",                                              "",                                             _("^BG%s^BG dropped the %s\n"), "") \
+       MSG_INFO_NOTIF(1, INFO_KEYHUNT_LOST,                                    2, 0, "s1 s2", "",                                              "",                                             _("^BGThe %s^BG could not take care of the %s\n"), "") \
+       MSG_INFO_NOTIF(1, INFO_KEYHUNT_PICKUP,                                  2, 0, "s1 s2", "",                                              "",                                             _("^BG%s^BG picked up the %s\n"), "") \
        MSG_INFO_NOTIF(1, INFO_LMS_NOLIVES,                                             1, 0, "s1", "",                                                 "",                                             _("^BG%s^F3 has no more lives left\n"), "") \
        MSG_INFO_NOTIF(1, INFO_LMS_FORFEIT,                                             1, 0, "s1", "",                                                 "",                                             _("^BG%s^F3 forfeited\n"), "") \
        MSG_INFO_NOTIF(1, INFO_POWERUP_INVISIBILITY,                    1, 0, "s1", "s1",                                               "strength",                             _("^BG%s^K1 picked up Invisibility\n"), "") \
@@ -441,10 +444,16 @@ float CPID_KH_MSG = 10;
        MSG_CENTER_NOTIF(1, CENTER_KEEPAWAY_DROPPED,                            1, 0, "s1",                     CPID_KEEPAWAY,                  "0 0", _("^BG%s^BG has dropped the ball!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_KEEPAWAY_PICKUP,                                     1, 0, "s1",                     CPID_KEEPAWAY,                  "0 0", _("^BG%s^BG has picked up the ball!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_KEEPAWAY_WARN,                                       0, 0, "",                               CPID_KA_WARN,                   "0 0", _("^BGKilling people while you don't have the ball gives no points!"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_HELP,                                        0, 0, "",                               CPID_KEYHUNT,                   "0 0", _("^BGAll keys are in your team's hands!"), _("Help the key carriers to meet!")) \
+       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_INTERFERE,                           1, 0, "s1",                             CPID_KEYHUNT,                   "0 0", _("^BGAll keys are in %s's hands!"), _("Interfere ^F4NOW^BG!")) \
+       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_MEET,                                        0, 0, "",                               CPID_KEYHUNT,                   "0 0", _("^BGAll keys are in your team's hands!"), _("Meet the other key carriers ^F4NOW^BG!")) \
+       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_SCAN,                                        0, 0, "",                               CPID_KEYHUNT,                   "-1 0", _("^BGScanning frequency range..."), "") \
+       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_START,                                       1, 0, "s1",                             CPID_KEYHUNT,                   "0 0", _("^BGYou are starting with the %s"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_WAIT,                                        1, 0, "s1",                             CPID_KEYHUNT,                   "-1 0", _("^BGWaiting for players to join..."), _("Need active players for: %s")) \
        MSG_CENTER_NOTIF(1, CENTER_LMS_CAMPCHECK,                                       0, 0, "",                               CPID_LMS_CAMP,                  "0 0", _("^F2Don't camp!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MOTD,                                                        1, 0, "s1",                             CPID_MOTD,                              "-1 0", _("^BG%s"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO,                                     0, 0, "",                               CPID_MINSTA_FINDAMMO,   "1 9", _("^F4^COUNT^BG left to find some ammo!"), "") \
-       MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO_FIRST,                       0, 0, "",                               CPID_MINSTA_FINDAMMO,   "1 10", _("^BGGet some ammo or you'll be dead in ^F4^COUNT^BG!"), _("Get some ammo! ^F4^COUNT^BG left!")) \
+       MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO_FIRST,                       0, 0, "",                               CPID_MINSTA_FINDAMMO,   "1 10", _("^BGGet some ammo or you'll be dead in ^F4^COUNT^BG!"), _("^BGGet some ammo! ^F4^COUNT^BG left!")) \
        MSG_CENTER_NOTIF(1, CENTER_NIX_COUNTDOWN,                                       0, 2, "item_wepname",   CPID_NIX,                               "1 f2", _("^F2^COUNT^BG until weapon change...\nNext weapon: ^F1%s"), "") \
        MSG_CENTER_NOTIF(1, CENTER_NIX_NEWWEAPON,                                       0, 1, "item_wepname",   CPID_NIX,                               "0 0", _("^F2Active weapon: ^F1%s"), "") \
        MSG_CENTER_NOTIF(1, CENTER_JOIN_NOSPAWNS,                                       0, 0, "",                               CPID_PREVENT_JOIN,              "0 0", _("^K1No spawnpoints available!\nHope your team can fix it..."), "") \
@@ -704,6 +713,7 @@ string arg_slot[NOTIF_MAX_ARGS];
        ARG_CASE(ARG_DC,                        "item_centime",         ftos(autocvar_notification_item_centerprinttime)) \
        ARG_CASE(ARG_SV,                        "death_team",           Team_ColoredFullName(f1)) \
        ARG_CASE(ARG_CS,                        "death_team",           Team_ColoredFullName(f1 - 1)) \
+       ARG_CASE(ARG_CS,                        "kh_teams",             notif_arg_kh_teams(f1, f2, f3, f4)) \
        ARG_CASE(ARG_CS_SV,                     "race_time",            mmssss(f2)) \
        ARG_CASE(ARG_CS_SV,             "race_diff",            ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2))))
 
@@ -720,6 +730,32 @@ string arg_slot[NOTIF_MAX_ARGS];
        SPREE_ITEM(30, 30, _("ARMAGEDDON! "), _("%s^K1 unleashes ARMAGEDDON! %s^BG"), _("%s^K1 made THIRTY SCORES IN A ROW! %s^BG"))
 
 #ifdef CSQC
+string notif_arg_kh_teams(float f1, float f2, float f3, float f4)
+{
+       return sprintf("%s%s%s%s",
+               (f1 ?
+                       sprintf("%s%s", Team_ColoredFullName(f1), ((f2 + f3 + f4) ? ", " : ""))
+                       :
+                       ""
+               ),
+               (f2 ?
+                       sprintf("%s%s", Team_ColoredFullName(f2), ((f3 + f4) ? ", " : ""))
+                       :
+                       ""
+               ),
+               (f3 ?
+                       sprintf("%s%s", Team_ColoredFullName(f3), (f4 ? ", " : ""))
+                       :
+                       ""
+               ),
+               (f4 ?
+                       Team_ColoredFullName(f4)
+                       :
+                       ""
+               )
+       );
+}
+
 string notif_arg_spree_cen(float spree)
 {
        // 0 = off, 1 = target (but only for first victim) and attacker
index fc5756e4db704d4379d8fb5f5198a51568006eba..dab9998231770fe05dd2beb4cec0ec9bafa79be2 100644 (file)
@@ -123,7 +123,7 @@ void reset_map(float dorespawn)
        }
 
        if(g_keyhunt)
-               kh_Controller_SetThink_NoMsg(autocvar_g_balance_keyhunt_delay_round+(game_starttime - time), kh_StartRound);
+               kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round+(game_starttime - time), kh_StartRound);
 
        if(g_arena)
        if(champion && champion.classname == "player" && player_count > 1)
index 7755b0f45514e0b72c4eb3bfd1015bb1fe400b12..3bdfcf778efb548cc12c103735b306a782ca1cb6 100644 (file)
@@ -20,7 +20,6 @@ vector KH_KEY_MIN = '-10 -10 -46';
 vector KH_KEY_MAX = '10 10 3';
 float KH_KEY_BRIGHTNESS = 2;
 
-string kh_Controller_Waitmsg;
 float kh_no_radar_circles;
 
 // kh_state
@@ -122,55 +121,18 @@ void kh_update_state()
 
 
 var kh_Think_t kh_Controller_Thinkfunc;
-void kh_Controller_SetThink(float t, string msg, float centerprint_duration, kh_Think_t func)  // runs occasionaly
+void kh_Controller_SetThink(float t, kh_Think_t func)  // runs occasionaly
 {
        kh_Controller_Thinkfunc = func;
        kh_controller.cnt = ceil(t);
-       if(kh_Controller_Waitmsg != "")
-               strunzone(kh_Controller_Waitmsg);
-       if(msg == "")
-               kh_Controller_Waitmsg = "";
-       else
-       {
-               kh_controller.kh_cp_duration = centerprint_duration;
-               kh_Controller_Waitmsg = strzone(msg);
-       }
        if(t == 0)
                kh_controller.nextthink = time; // force
 }
-void kh_Controller_SetThink_NoMsg(float t, kh_Think_t func)  // runs occasionaly
-{
-       kh_Controller_SetThink(t, "", 0, func);
-}
 
 void kh_Controller_Think()  // called a lot
 {
-       entity e;
        if(intermission_running)
                return;
-       if(self.cnt > 0)
-       {
-               if(kh_Controller_Waitmsg != "")
-               {
-                       string s;
-                       if(substring(kh_Controller_Waitmsg, strlen(kh_Controller_Waitmsg)-1, 1) == " ")
-                               s = strcat(kh_Controller_Waitmsg, ftos(self.cnt));
-                       else
-                               s = kh_Controller_Waitmsg;
-
-                       //dprint(s, "\n");
-
-                       FOR_EACH_PLAYER(e)
-                               if(clienttype(e) == CLIENTTYPE_REAL)
-                                       Send_CSQC_Centerprint_Generic(e, CPID_KH_MSG, s, self.kh_cp_duration, 0);
-               }
-               self.cnt -= 1;
-       }
-       else if(self.cnt == 0)
-       {
-               self.cnt -= 1;
-               kh_Controller_Thinkfunc();
-       }
        self.nextthink = time + 1;
 }
 
@@ -436,7 +398,7 @@ void kh_Key_Collect(entity key, entity player)  //a player picks up a dropped ke
                PlayerScore_Add(player, SP_KH_PICKUPS, 1);
        }
        key.kh_dropperteam = 0;
-       bprint(player.netname, "^7 picked up the ", key.netname, "\n");
+       Send_Notification(NOTIF_ANY, world, MSG_INFO, INFO_KEYHUNT_PICKUP, player.netname, key.netname);
 
        kh_Key_AssignTo(key, player); // this also updates .kh_state
 }
@@ -510,7 +472,8 @@ void kh_FinishRound()  // runs when a team captures the keys
                kh_Key_Remove(key);
        kh_no_radar_circles = FALSE;
 
-       kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, "Round starts in ", 1, kh_StartRound);
+       Send_Notification(NOTIF_ANY, world, MSG_CENTER, CENTER_ARENA_ROUNDSTART, autocvar_g_balance_keyhunt_delay_round);
+       kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, kh_StartRound);
 }
 
 void kh_WinnerTeam(float teem)  // runs when a team wins
@@ -533,15 +496,17 @@ void kh_WinnerTeam(float teem)  // runs when a team wins
        }
 
        first = TRUE;
+       string keyowner = "";
        FOR_EACH_KH_KEY(key)
                if(key.owner.kh_next == key)
                {
                        if(!first)
-                               bprint("^7, ");
-                       bprint(key.owner.netname);
+                               keyowner = strcat(keyowner, ", ");
+                       keyowner = key.owner.netname;
                        first = FALSE;
                }
-       bprint("^7 captured the keys for the ", Team_ColoredFullName(teem), "\n");
+
+       Send_Notification(NOTIF_ANY, world, MSG_INFO, INFO_KEYHUNT_CAPTURE, keyowner, Team_ColoredFullName(teem));
 
        first = TRUE;
        midpoint = '0 0 0';
@@ -595,8 +560,7 @@ void kh_LoserTeam(float teem, entity lostkey)  // runs when a player pushes a fl
                        // don't actually GIVE him the -nn points, just log
                kh_Scores_Event(attacker, world, "push", autocvar_g_balance_keyhunt_score_push, 0);
                PlayerScore_Add(attacker, SP_KH_PUSHES, 1);
-               centerprint(attacker, "Your push is the best!");
-               bprint("The ", Team_ColoredFullName(teem), "^7 could not take care of the ", lostkey.netname, "^7 when ", attacker.netname, "^7 came\n");
+               //centerprint(attacker, "Your push is the best!"); // does this really need to exist?
        }
        else
        {
@@ -655,9 +619,10 @@ void kh_LoserTeam(float teem, entity lostkey)  // runs when a player pushes a fl
 
                        --j;
                }
-
-               bprint("The ", Team_ColoredFullName(teem), "^7 could not take care of the ", lostkey.netname, "\n");
        }
+       
+       Send_Notification(NOTIF_ANY, world, MSG_INFO, INFO_KEYHUNT_LOST, Team_ColoredFullName(teem), lostkey.netname);
+       
        play2all(kh_sound_destroy);
        te_tarexplosion(lostkey.origin);
 
@@ -711,11 +676,11 @@ void kh_Key_Think()  // runs all the time
                {
                        if(head.team == kh_interferemsg_team)
                                if(head.kh_next)
-                                       Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, "All keys are in your team's hands!\n\nMeet the other key carriers ^1NOW^7!", 0, 0);
+                                       Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_KEYHUNT_MEET);
                                else
-                                       Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, "All keys are in your team's hands!\n\nHelp the key carriers to meet!", 0, 0);
+                                       Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_KEYHUNT_HELP);
                        else
-                               Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, strcat("All keys are in the ", Team_ColoredFullName(kh_interferemsg_team), "^7's hands!\n\nInterfere ^1NOW^7!"), 0, 0);
+                               Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_KEYHUNT_INTERFERE, Team_ColoredFullName(kh_interferemsg_team));
                }
        }
 
@@ -774,7 +739,7 @@ void kh_Key_Spawn(entity initial_owner, float angle, float i)  // runs every tim
        key.kh_worldkeynext = kh_worldkeylist;
        kh_worldkeylist = key;
 
-       centerprint(initial_owner, strcat("You are starting with the ", key.netname, "\n"));  // message to player at start of round
+       Send_Notification(NOTIF_ONE, initial_owner, MSG_CENTER, CENTER_KEYHUNT_START, key.netname);
 
        WaypointSprite_Spawn("key-dropped", 0, 0, key, '0 0 1' * KH_KEY_WP_ZSHIFT, world, key.team, key, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAG, '0 1 1');
        key.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = kh_Key_waypointsprite_visible_for_player;
@@ -817,7 +782,8 @@ void kh_Key_DropOne(entity key)
 
        kh_Scores_Event(player, key, "dropkey", 0, 0);
        PlayerScore_Add(player, SP_KH_LOSSES, 1);
-       bprint(player.netname, "^7 dropped the ", key.netname, "\n");
+       Send_Notification(NOTIF_ANY, world, MSG_INFO, INFO_KEYHUNT_DROP, player.netname, key.netname);
+       
        kh_Key_AssignTo(key, world);
        makevectors(player.v_angle);
        key.velocity = W_CalculateProjectileVelocity(player.velocity, autocvar_g_balance_keyhunt_throwvelocity * v_forward, FALSE);
@@ -842,7 +808,7 @@ void kh_Key_DropAll(entity player, float suicide) // runs whenever a player dies
                {
                        kh_Scores_Event(player, key, "losekey", 0, 0);
                        PlayerScore_Add(player, SP_KH_LOSSES, 1);
-                       bprint(player.netname, "^7 died and lost the ", key.netname, "\n");
+                       Send_Notification(NOTIF_ANY, world, MSG_INFO, INFO_KEYHUNT_LOST, player.netname, key.netname);
                        kh_Key_AssignTo(key, world);
                        makevectors('-1 0 0' * (45 + 45 * random()) + '0 360 0' * random());
                        key.velocity = W_CalculateProjectileVelocity(player.velocity, autocvar_g_balance_keyhunt_dropvelocity * v_forward, FALSE);
@@ -888,24 +854,26 @@ void kh_WaitForPlayers()  // delay start of the round until enough players are p
 
        if(time < game_starttime)
        {
-               kh_Controller_SetThink_NoMsg(game_starttime - time + 0.1, kh_WaitForPlayers);
+               kh_Controller_SetThink(game_starttime - time + 0.1, kh_WaitForPlayers);
                return;
        }
 
        teams_missing = kh_CheckEnoughPlayers();
        if(teams_missing == "")
-               kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, "Round starts in ", 1, kh_StartRound);
+       {
+               Send_Notification(NOTIF_ANY, world, MSG_CENTER, CENTER_ARENA_ROUNDSTART, autocvar_g_balance_keyhunt_delay_round);
+               kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, kh_StartRound);
+       }
        else
-               kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, kh_WaitForPlayers);
+       {
+               Send_Notification(NOTIF_ANY, world, MSG_CENTER, CENTER_KEYHUNT_WAIT, teams_missing);
+               kh_Controller_SetThink(1, kh_WaitForPlayers);
+       }
 }
 
 void kh_EnableTrackingDevice()  // runs after each round
 {
-       entity player;
-
-       FOR_EACH_PLAYER(player)
-               if(clienttype(player) == CLIENTTYPE_REAL)
-                       Send_CSQC_Centerprint_Generic_Expire(player, CPID_KH_MSG);
+       Kill_Notification(NOTIF_ANY, world, MSG_CENTER, CENTER_KEYHUNT_HELP);
 
        kh_tracking_enabled = TRUE;
 }
@@ -918,20 +886,19 @@ void kh_StartRound()  // runs at the start of each round
 
        if(time < game_starttime)
        {
-               kh_Controller_SetThink_NoMsg(game_starttime - time + 0.1, kh_WaitForPlayers);
+               kh_Controller_SetThink(game_starttime - time + 0.1, kh_WaitForPlayers);
                return;
        }
 
        teams_missing = kh_CheckEnoughPlayers();
        if(teams_missing != "")
        {
-               kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, kh_WaitForPlayers);
+               kh_Controller_SetThink(1, kh_WaitForPlayers);
+               Send_Notification(NOTIF_ANY, world, MSG_CENTER, CENTER_KEYHUNT_WAIT, teams_missing);
                return;
        }
-
-       FOR_EACH_PLAYER(player)
-               if(clienttype(player) == CLIENTTYPE_REAL)
-                       Send_CSQC_Centerprint_Generic_Expire(player, CPID_KH_MSG);
+       
+       Kill_Notification(NOTIF_ANY, world, MSG_CENTER, CENTER_KEYHUNT_HELP);
 
        for(i = 0; i < kh_teams; ++i)
        {
@@ -951,7 +918,8 @@ void kh_StartRound()  // runs at the start of each round
        }
 
        kh_tracking_enabled = FALSE;
-       kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, "Scanning frequency range...", -1, kh_EnableTrackingDevice);
+       Send_Notification(NOTIF_ANY, world, MSG_CENTER, CENTER_KEYHUNT_SCAN);
+       kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, kh_EnableTrackingDevice);
 }
 
 float kh_HandleFrags(entity attacker, entity targ, float f)  // adds to the player score
@@ -1003,7 +971,7 @@ void kh_Initialize()  // sets up th KH environment
        // make a KH entity for controlling the game
        kh_controller = spawn();
        kh_controller.think = kh_Controller_Think;
-       kh_Controller_SetThink_NoMsg(0, kh_WaitForPlayers);
+       kh_Controller_SetThink(0, kh_WaitForPlayers);
 
        setmodel(kh_controller, "models/keyhunt/key.md3");
        kh_key_dropped = kh_controller.modelindex;
index 8ee8434293669b00a15501c92612f7c1d3eedf51..bda701f96a015dafd8440f35df82b22ae032e147 100644 (file)
@@ -9,4 +9,4 @@ float kh_Key_AllOwnedByWhichTeam();
 // used by arena.qc ready-restart:
 typedef void(void) kh_Think_t;
 void kh_StartRound();
-void kh_Controller_SetThink_NoMsg(float t, kh_Think_t func);
+void kh_Controller_SetThink(float t, kh_Think_t func);