From 6760ce909272c59c0a77f3285c59f97890843f24 Mon Sep 17 00:00:00 2001 From: WessTorn Date: Wed, 17 Jan 2024 16:45:12 +0300 Subject: [PATCH] add 1x1 (duel) mode --- data/lang/mixsystem.txt | 12 ++++++- scripting/include/hns-match/addition/cmds.inc | 31 +++++++++++++++++- .../include/hns-match/addition/cvars.inc | 4 +++ .../include/hns-match/addition/hnsmenu.inc | 32 ++++++++++++++++--- scripting/include/hns-match/globals.inc | 3 +- .../include/hns-match/modes/mode_mix.inl | 30 +++++++++++++++++ 6 files changed, 104 insertions(+), 8 deletions(-) diff --git a/data/lang/mixsystem.txt b/data/lang/mixsystem.txt index 6e90701..c43e6d0 100644 --- a/data/lang/mixsystem.txt +++ b/data/lang/mixsystem.txt @@ -26,6 +26,7 @@ MODE_ALREADY = This mode already started! MODE_NOT_MIX = This command is not available during the match! MODE_SET_MR = ^3%n^1 change mode to ^3MR^1! MODE_SET_WT = ^3%n^1 change mode to ^3Wintime^1! +MODE_SET_DUEL = ^3%n^1 change mode to ^3Duel^1! GAME_NOTSTARTED = Game not started or already paused (use /unpause) GAME_PAUSED = ^3%n^1 paused the game! @@ -75,12 +76,14 @@ STOP_DM = ^3%n^1 stopped ^3deathmatch^1 mode SCORE_TIME = TT [^3%s^1] %d vs %d [^3%s^1] CT (^3%d^1/^3%d^1 rounds) (^3%s^1 diff) SCORE_TIME_WT = TT [^3%s^1] vs [^3%s^1] CT (^3%s^1 diff) +SCORE_DUEL = Score: TT - ^3%d^1 vs ^3%d^1 - CT SCORE_NOT = Sorry, but game ain't started atm SAME_TIMER = Same Timers! OVERTIME! Playing +2 Rounds TT_WIN = TT win the match! (^3%s^1 difference) MR_WIN = %s win the match! (^3%s^1 difference) +DUEL_WIN = Player ^3%n^1 (^3TT^1) win duel! SHOW_TOP = Show top (^3/top^1) CAP_CHOOSE = ^3%n^1 choosing captains... @@ -145,6 +148,7 @@ MENU_STNGS_ROUNDTIME = Roundtime: \y%.1f MENU_STNGS_FREEZETIME = Freezetime: \y%d MENU_STNGS_MAXROUND = Maxrounds: \y%d \d(%d rounds)^n MENU_STNGS_WINTIME = Wintime: \y%.0f^n +MENU_STNGS_DUEL = Maxrounds: \y%d^n MENU_STNGS_ONEHP_ON = 1 HP Mode (Skill): \yOff^n MENU_STNGS_ONEHP_OFF = 1 HP Mode (Skill): \yOn^n MENU_STNGS_FLASH = Flash: \y%d @@ -154,6 +158,7 @@ MENU_STNGS_AA = Airaccelerate \y%d^n MENU_MODE_TITLE = \rChoose game mode MENU_MODE_MR = MR System MENU_MODE_WINTIME = Wintime +MENU_MODE_DUEL = Duel VOTE_MR = ^3%n^1 voted for ^3MR^1! VOTE_WT = ^3%n^1 voted for ^3Wintime^1! @@ -202,6 +207,7 @@ MODE_ALREADY = Этот режим уже запущен! MODE_NOT_MIX = Эта команда недоступна во время матча! MODE_SET_MR = ^3%n^1 изменил режим на ^3MR^1! MODE_SET_WT = ^3%n^1 изменил режим на ^3Wintime^1! +MODE_SET_DUEL = ^3%n^1 изменил режим на ^3Duel^1! GAME_NOTSTARTED = Игра приостановлена, используйте (^1say /unpause^1). GAME_PAUSED = ^3%n^1 приостановил игру! @@ -249,13 +255,15 @@ STOP_CAP = ^3%n^1 остановил режим ^3капитанов^1. STOP_DM = ^3%n^1 остановил ^3ДМ^1 режим. SCORE_TIME = TT [^3%s^1] %d vs %d [^3%s^1] CT (^3%d^1/^3%d^1 раундов) (^3%s^1 разрыв) -SCORE_TIME_WT = TT [^3%s^1] vs [^3%s^1] CT (^3%s^1 разрыв) +SCORE_TIME_WT = TT [^3%s^1] vs [^3%s^1] CT (^3%s^1 разрыв) +SCORE_DUEL = Счет: TT - ^3%d^1 vs ^3%d^1 - CT SCORE_NOT = Извините, но игра не запущена. SAME_TIMER = Время равное! ОВЕРТАЙМ! Начало доп. игры (+2 раунда). TT_WIN = ТТ Выиграли игру! (^3%s^1 разрыв) MR_WIN = %s Выиграли игру! (^3%s^1 разрыв) +DUEL_WIN = Игрок ^3%n^1 (^3TT^1) выиграл дуэль! SHOW_TOP = Показать топ игроков (^3/top^1). CAP_CHOOSE = ^3%n^1 выбирает капитанов... @@ -320,6 +328,7 @@ MENU_STNGS_ROUNDTIME = Roundtime: \y%.1f MENU_STNGS_FREEZETIME = Freezetime: \y%d MENU_STNGS_MAXROUND = Maxrounds: \y%d \d(%d раундов)^n MENU_STNGS_WINTIME = Wintime: \y%.0f^n +MENU_STNGS_DUEL = Maxrounds: \y%d^n MENU_STNGS_ONEHP_ON = 1 HP Mode (Skill): \yOff^n MENU_STNGS_ONEHP_OFF = 1 HP Mode (Skill): \yOn^n MENU_STNGS_FLASH = Flash: \y%d @@ -329,6 +338,7 @@ MENU_STNGS_AA = Airaccelerate \y%d^n MENU_MODE_TITLE = \rВыберите режим игры: MENU_MODE_MR = MR System MENU_MODE_WINTIME = Wintime +MENU_MODE_DUEL = Duel VOTE_MR = ^3%n^1 выбрал ^3MR^1! VOTE_WT = ^3%n^1 выбрал ^3Wintime^1! diff --git a/scripting/include/hns-match/addition/cmds.inc b/scripting/include/hns-match/addition/cmds.inc index 7543d07..1c53354 100644 --- a/scripting/include/hns-match/addition/cmds.inc +++ b/scripting/include/hns-match/addition/cmds.inc @@ -17,7 +17,8 @@ stock cmds_init() { RegisterSayCmd("mode", "type", "menuSelectMode", access, "Mode match menu"); RegisterSayCmd("mr", "maxround", "cmdMrMode", access, "Choose MR mode"); - RegisterSayCmd("timer", "wintime", "cmdWintimeMode", access, "Choost Wintime mode"); + RegisterSayCmd("timer", "wintime", "cmdWintimeMode", access, "Choose Wintime mode"); + RegisterSayCmd("duel", "versus", "cmdDuelMode", access, "Choose 1x1 mode"); RegisterSayCmd("pub", "public", "cmdPubMode", access, "Public mode"); RegisterSayCmd("dm", "deathmatch", "cmdDMMode", access, "DeathMatch mode"); //RegisterSayCmd("zm", "zombie", "cmdZMMode", access, "Zombie mode"); @@ -164,6 +165,27 @@ public cmdWintimeMode(id) { return PLUGIN_HANDLED; } +public cmdDuelMode(id) { + if (!getUserInAccess(id)) { + return PLUGIN_HANDLED; + } + + if (g_iCurrentRules == RULES_DUEL) { + chat_print(0, "%l", "MODE_ALREADY"); + return PLUGIN_HANDLED; + } + + if (g_iCurrentMode == MODE_MIX) { + chat_print(0, "%l", "MODE_NOT_MIX"); + return PLUGIN_HANDLED; + } + + chat_print(0, "%l", "MODE_SET_DUEL", id); + g_iCurrentRules = RULES_DUEL; + + return PLUGIN_HANDLED; +} + public cmdPubMode(id) { if (!getUserInAccess(id)) { return PLUGIN_HANDLED; @@ -632,6 +654,13 @@ public cmdShowTimers(id) { chat_print(id, "%L", id, "SCORE_TIME_WT", szTimeToWin[HNS_TEAM_B], szTimeToWin[HNS_TEAM_A], szTimeDiff); } } + case RULES_DUEL: { + if (g_isTeamTT == HNS_TEAM_A) { + chat_print(id, "%L", id, "SCORE_DUEL", g_eMatchInfo[e_iRoundsPlayed][HNS_TEAM_A], g_eMatchInfo[e_iRoundsPlayed][HNS_TEAM_B]); + } else { + chat_print(id, "%L", id, "SCORE_DUEL", g_eMatchInfo[e_iRoundsPlayed][HNS_TEAM_B], g_eMatchInfo[e_iRoundsPlayed][HNS_TEAM_A]); + } + } } return PLUGIN_HANDLED; diff --git a/scripting/include/hns-match/addition/cvars.inc b/scripting/include/hns-match/addition/cvars.inc index 08f1216..2fb8d0b 100644 --- a/scripting/include/hns-match/addition/cvars.inc +++ b/scripting/include/hns-match/addition/cvars.inc @@ -5,6 +5,7 @@ enum _: CVARS RULES, Float:WINTIME, MAXROUNDS, + DUELROUNDS, HNSBOOST, ONEHPMODE, FLASH, @@ -32,6 +33,9 @@ stock cvars_init() { pCvar[MAXROUNDS] = create_cvar("hns_rounds", "6", FCVAR_NONE, "Match rounds (MR)", true, 0.0, true, 10.0); bind_pcvar_num(pCvar[MAXROUNDS], g_iSettings[MAXROUNDS]); + pCvar[DUELROUNDS] = create_cvar("hns_duel", "3", FCVAR_NONE, "Match 1x1 rounds", true, 0.0, true, 10.0); + bind_pcvar_num(pCvar[DUELROUNDS], g_iSettings[DUELROUNDS]); + pCvar[HNSBOOST] = create_cvar("hns_boost", "0", FCVAR_NONE, "Boost mode (0/1)", true, 0.0, true, 1.0); bind_pcvar_num(pCvar[HNSBOOST], g_iSettings[HNSBOOST]); diff --git a/scripting/include/hns-match/addition/hnsmenu.inc b/scripting/include/hns-match/addition/hnsmenu.inc index c1674aa..c202890 100644 --- a/scripting/include/hns-match/addition/hnsmenu.inc +++ b/scripting/include/hns-match/addition/hnsmenu.inc @@ -223,6 +223,9 @@ public settingsMatchMenu(id) { case RULES_TIMER: { formatex(szMsg, charsmax(szMsg), "%L", id, "MENU_STNGS_WINTIME", g_iSettings[WINTIME]); } + case RULES_DUEL: { + formatex(szMsg, charsmax(szMsg), "%L", id, "MENU_STNGS_DUEL", g_iSettings[WINTIME]); + } } menu_additem(hMenu, szMsg, "3"); @@ -300,6 +303,14 @@ public settingsMatchMenuHandler(id, hMenu, item) { else if (g_iSettings[WINTIME] >= 20.0) g_iSettings[WINTIME] = 10.0; } + case RULES_DUEL: { + if (g_iSettings[DUELROUNDS] <= 2) + g_iSettings[DUELROUNDS] = 3; + else if (g_iSettings[DUELROUNDS] <= 3) + g_iSettings[DUELROUNDS] = 4; + else if (g_iSettings[DUELROUNDS] >= 4) + g_iSettings[DUELROUNDS] = 2; + } } settingsMatchMenu(id); @@ -396,6 +407,9 @@ public menuSelectMode(id) { formatex(szMsg, charsmax(szMsg), "%L", id, "MENU_MODE_WINTIME"); menu_additem(hMenu, szMsg, "2"); + + formatex(szMsg, charsmax(szMsg), "%L", id, "MENU_MODE_DUEL"); + menu_additem(hMenu, szMsg, "3"); menu_setprop(hMenu, MPROP_EXIT, MEXIT_ALL); @@ -407,7 +421,7 @@ public menuSelectMode(id) { public HandlerSelectMode(id, hMenu, item) { if (item == MENU_EXIT) { menu_destroy(hMenu); - return; + return PLUGIN_HANDLED; } new szData[6], szName[64], iAccess, iCallback; @@ -416,11 +430,19 @@ public HandlerSelectMode(id, hMenu, item) { new index = str_to_num(szData); - if(index == 1) { - cmdMrMode(id); - } else { - cmdWintimeMode(id); + switch (index) { + case 1: { + cmdMrMode(id); + } + case 2: { + cmdWintimeMode(id); + } + case 3: { + cmdDuelMode(id); + } } + + return PLUGIN_HANDLED; } public StartVoteRules() { diff --git a/scripting/include/hns-match/globals.inc b/scripting/include/hns-match/globals.inc index b3fb874..dbb7b74 100644 --- a/scripting/include/hns-match/globals.inc +++ b/scripting/include/hns-match/globals.inc @@ -13,7 +13,8 @@ new g_PluginId; enum NATCH_RULES { RULES_MR, - RULES_TIMER + RULES_TIMER, + RULES_DUEL } new NATCH_RULES:g_iCurrentRules; diff --git a/scripting/include/hns-match/modes/mode_mix.inl b/scripting/include/hns-match/modes/mode_mix.inl index d5a3eb1..a74b456 100755 --- a/scripting/include/hns-match/modes/mode_mix.inl +++ b/scripting/include/hns-match/modes/mode_mix.inl @@ -215,6 +215,25 @@ public MixFinishedWT() { ExecuteForward(g_hForwards[MATCH_FINISH], _, 1); } +public MixFinishedDuel() { + g_iMatchStatus = MATCH_NONE; + + new iPlayers[MAX_PLAYERS], iNum; + get_players(iPlayers, iNum, "che", "TERRORIST"); + + chat_print(0, "%L", LANG_PLAYER, "DUEL_WIN", iPlayers[0]); + + setTaskHud(0, 1.0, 1, 255, 255, 255, 4.0, "%L", LANG_SERVER, "HUD_GAMEOVER"); + training_start(); + + g_bPlayersListLoaded = false; + arrayset(g_eMatchInfo, 0, MatchInfo_s); + TrieDestroy(g_tPlayerData); + remove_task(TASK_TIMER); + + ExecuteForward(g_hForwards[MATCH_FINISH], _, 1); +} + public mix_roundend(bool:win_ct) { if (g_eMatchState != STATE_ENABLED) { return; @@ -273,6 +292,17 @@ public mix_roundend(bool:win_ct) { mix_swap(); } } + case RULES_DUEL: { + if (win_ct) { + mix_swap(); + } else { + g_eMatchInfo[e_iRoundsPlayed][g_isTeamTT]++ + } + + if(g_eMatchInfo[e_iRoundsPlayed][g_isTeamTT] >= g_iSettings[DUELROUNDS]) { + MixFinishedDuel(); + } + } } }