Skip to content

Commit

Permalink
Add a new (default) healing method
Browse files Browse the repository at this point in the history
  • Loading branch information
lengran committed May 24, 2024
1 parent 078d97c commit 50da910
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 38 deletions.
14 changes: 10 additions & 4 deletions OpenPrefirePrac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,17 @@ public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
case 2:
currentHp = currentHp + 25;
break;
case 3:
currentHp = 100;
break;
case 4:
currentHp = currentHp + 100;
break;
case 5:
currentHp = currentHp + 500;
break;
default:
currentHp = currentHp + 100;
currentHp = 100;
break;
}
SetPlayerHealth(owner, currentHp);
Expand Down Expand Up @@ -744,7 +750,7 @@ private void SetupPrefireMode(CCSPlayerController player)
// DrawGuidingLine(player);

// Setup player's HP
if (_playerStatuses[player.Slot].HealingMethod == 1 || _playerStatuses[player.Slot].HealingMethod == 4)
if (_playerStatuses[player.Slot].HealingMethod == 1 || _playerStatuses[player.Slot].HealingMethod == 5)
AddTimer(0.5f, () => SetPlayerHealth(player, 500));
AddTimer(1f, () => EquipPlayer(player));
AddTimer(1.5f, () => MovePlayer(player, false, _practices[practiceNo].Player.Position, _practices[practiceNo].Player.Rotation));
Expand Down Expand Up @@ -1426,9 +1432,9 @@ private void RegisterCommand()
return;
case "df":
int difficulty = 0;
if (int.TryParse(commandInfo.ArgByIndex(2), out difficulty) && difficulty > 0 && difficulty <= 5)
if (int.TryParse(commandInfo.ArgByIndex(2), out difficulty) && difficulty > 0 && difficulty <= 6)
{
ChangeDifficulty(player, 5 - difficulty);
ChangeDifficulty(player, 6 - difficulty);
return;
}
player.PrintToChat($" {ChatColors.Green}[OpenPrefirePrac] {ChatColors.White} {_translator!.Translate(player, "difficulty.help")}");
Expand Down
5 changes: 3 additions & 2 deletions PlayerStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public class PlayerStatus
* 0: No healing
* 1: Init hp 500 with no healing
* 2: +25hp for each kill
* 3: +100hp for each kill (default)
* 4: +500hp for each kill
* 3: Reheal to 100hp after a kill (default)
* 4: +100hp for each kill
* 5: +500hp for each kill
*/
public int HealingMethod = 3;

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ Explanation of values:
- 0: No healing.
- 1: Init hp 500 with no healing.
- 2: +25hp for each kill.
- 3: +100hp for each kill.
- 4: +500hp for each kill.
- 3: Reheal to 100hp after a kill.
- 4: +100hp for each kill.
- 5: +500hp for each kill.
- Training Mode
- 0: Random mode, randomly spawn some targets.
- 1: Full mode, all targets.
Expand Down
17 changes: 1 addition & 16 deletions ServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ public class DefaultConfig

private string _moduleDirectory = "";

// public DefaultConfig(int difficulty, int trainingMode, int botWeapon)
// {
// Difficulty = difficulty;
// TrainingMode = trainingMode;
// BotWeapon = botWeapon;
// }

public DefaultConfig()
{
// DeserializeConstructor
Expand All @@ -35,12 +28,6 @@ public void LoadDefaultSettings()
{
string path = $"{_moduleDirectory}/default_cfg.json";

// Read default settings from PlayerStatus.cs
// PlayerStatus tmpStatus = new PlayerStatus();
// int tmpDifficulty = tmpStatus.HealingMethod;
// int tmpTrainingMode = tmpStatus.TrainingMode;
// int tmpBotWeapon = tmpStatus.BotWeapon;

if (!File.Exists(path))
{
// Use default settings
Expand All @@ -62,7 +49,7 @@ public void LoadDefaultSettings()
{
DefaultConfig jsonConfig = JsonSerializer.Deserialize<DefaultConfig>(jsonString, options)!;

if (jsonConfig.Difficulty > -1 && jsonConfig.Difficulty < 5)
if (jsonConfig.Difficulty > -1 && jsonConfig.Difficulty < 6)
{
Difficulty = jsonConfig.Difficulty;
}
Expand All @@ -86,7 +73,5 @@ public void LoadDefaultSettings()
Console.WriteLine("[OpenPrefirePrac] Failed to load custom settings. Will use default settings.");
}
}

// _defaultPlayerSettings = new DefaultConfig(tmpDifficulty, tmpTrainingMode, tmpBotWeapon);
}
}
5 changes: 3 additions & 2 deletions default_cfg.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// 0: No healing
// 1: Init hp 500 with no healing
// 2: +25hp for each kill
// 3: +100hp for each kill (default)
// 4: +500hp for each kill
// 3: Reheal to 100hp after a kill
// 4: +100hp for each kill
// 5: +500hp for each kill
"Difficulty": 3,
// Training Mode:
// 0: Random mode, randomly spawn some targets.
Expand Down
9 changes: 5 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mainmenu.exit": "Exit prefire mode.",
"mainmenu.difficulty": "Current difficulty: {0}.",
"mainmenu.mode": "Current practice mode: {0}.",
"mainmenu.help": "Usage: !prefire [PURPLE][Shortcut] [option][NORMAL]\u2029With no shortcuts, this command brings up the main menu.\u2029\u2029Available shortcuts:\u2029[PURPLE]prac[NORMAL] [1-{0}]: Start practicing on a selected route.\u2029[PURPLE]map[NORMAL] [map name]: Switch to another map.\u2029[PURPLE]df[NORMAL] [1-5]: Set the difficulty.\u2029[PURPLE]mode[NORMAL] [rand/full]: Set training mode.\u2029[PURPLE]bw[NORMAL] [rand/ump/ak/sct/awp]: Set weapons for bots.\u2029[PURPLE]lang[NORMAL] [en/pt/zh]: Set language. en for English, pt para português, 中文选择 zh。\u2029[PURPLE]exit[NORMAL]: Stop practicing.",
"mainmenu.help": "Usage: !prefire [PURPLE][Shortcut] [option][NORMAL]\u2029With no shortcuts, this command brings up the main menu.\u2029\u2029Available shortcuts:\u2029[PURPLE]prac[NORMAL] [1-{0}]: Start practicing on a selected route.\u2029[PURPLE]map[NORMAL] [map name]: Switch to another map.\u2029[PURPLE]df[NORMAL] [1-6]: Set the difficulty.\u2029[PURPLE]mode[NORMAL] [rand/full]: Set training mode.\u2029[PURPLE]bw[NORMAL] [rand/ump/ak/sct/awp]: Set weapons for bots.\u2029[PURPLE]lang[NORMAL] [en/pt/zh]: Set language. en for English, pt para português, 中文选择 zh。\u2029[PURPLE]exit[NORMAL]: Stop practicing.",
"mainmenu.shortcut_prompt": "Type [PURPLE]!prefire help[NORMAL] for usage of shortcut commands.",
"mainmenu.close_menu": "Exit this menu.",
"mainmenu.menu_closed": "The menu has been closed.",
Expand All @@ -25,10 +25,11 @@
"difficulty.0": "Hardest - 100HP",
"difficulty.1": "Harder - 500HP",
"difficulty.2": "Hard - +25HP per kill",
"difficulty.3": "Normal - +100HP per kill",
"difficulty.4": "Easy - +500HP per kill",
"difficulty.3": "Normal - Reheal to 100hp after a kill",
"difficulty.4": "Easier - +100HP per kill",
"difficulty.5": "Easy - +500HP per kill",
"difficulty.set": "Difficulty has been set to: {0}.",
"difficulty.help": "Usage: !prefire df [PURPLE][1-5][NORMAL]",
"difficulty.help": "Usage: !prefire df [PURPLE][1-6][NORMAL]",
"weaponmenu.title": "Set weapons for bots",
"weaponmenu.random": "Random",
"weaponmenu.set": "Bot weapon is set to {0}.",
Expand Down
9 changes: 5 additions & 4 deletions lang/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mainmenu.exit": "Sair do modo de prefire",
"mainmenu.difficulty": "Dificuldade atual: {0}.",
"mainmenu.mode": "Modo de prática atual: {0}",
"mainmenu.help": "Uso: !prefire [PURPLE][Shortcut] [option][NORMAL]\u2029Sem atalhos, esse comando abre o menu principal.\u2029Atalhos disponíveis:\u2029[PURPLE]prac[NORMAL] [1-{0}]: Iniciar a prática em uma rota selecionada.\u2029[PURPLE]map[NORMAL] [map name]: Mudar para outro mapa.\u2029[PURPLE]df[NORMAL] [1-5]: Definir a dificuldade.\u2029[PURPLE]mode[NORMAL] [rand/full]: Definir o modo de treinamento.\u2029[PURPLE]bw[NORMAL] [rand/ump/ak/sct/awp]: Definir armas para bots.\u2029[PURPLE]lang[NORMAL] [en/pt/zh]: Definir a configuração de idioma. en for English, pt para português, 中文选择 zh。\u2029[PURPLE]exit[NORMAL]: Pare de praticar.",
"mainmenu.help": "Uso: !prefire [PURPLE][Shortcut] [option][NORMAL]\u2029Sem atalhos, esse comando abre o menu principal.\u2029Atalhos disponíveis:\u2029[PURPLE]prac[NORMAL] [1-{0}]: Iniciar a prática em uma rota selecionada.\u2029[PURPLE]map[NORMAL] [map name]: Mudar para outro mapa.\u2029[PURPLE]df[NORMAL] [1-6]: Definir a dificuldade.\u2029[PURPLE]mode[NORMAL] [rand/full]: Definir o modo de treinamento.\u2029[PURPLE]bw[NORMAL] [rand/ump/ak/sct/awp]: Definir armas para bots.\u2029[PURPLE]lang[NORMAL] [en/pt/zh]: Definir a configuração de idioma. en for English, pt para português, 中文选择 zh。\u2029[PURPLE]exit[NORMAL]: Pare de praticar.",
"mainmenu.shortcut_prompt": "Digite [PURPLE]!prefire help[NORMAL] para usar os comandos de atalho.",
"mainmenu.close_menu": "Sair desse menu.",
"mainmenu.menu_closed": "O menu foi fechado.",
Expand All @@ -25,10 +25,11 @@
"difficulty.0": "Hardest - 100HP",
"difficulty.1": "Harder - 500HP",
"difficulty.2": "Hard - +25HP por eliminação",
"difficulty.3": "Normal - +100HP por eliminação",
"difficulty.4": "Easy - +500HP por eliminação",
"difficulty.3": "Normal - Recuperação de 100hp após uma morte",
"difficulty.4": "Easier - +100HP por eliminação",
"difficulty.5": "Easy - +500HP por eliminação",
"difficulty.set": "A dificuldade foi definida para: {0}.",
"difficulty.help": "Uso: !prefire df [PURPLE][1-5][NORMAL]",
"difficulty.help": "Uso: !prefire df [PURPLE][1-6][NORMAL]",
"weaponmenu.title": "Definir armas para bots",
"weaponmenu.random": "Aleatório",
"weaponmenu.set": "A arma do bot está definida como {0}.",
Expand Down
9 changes: 5 additions & 4 deletions lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mainmenu.exit": "退出预瞄训练",
"mainmenu.difficulty": "当前难度: {0}。",
"mainmenu.mode": "当前训练模式: {0}",
"mainmenu.help": "用法: !prefire [PURPLE][快捷命令] [选项][NORMAL]\u2029没有指定快捷命令时,该指令会打开预瞄插件主菜单。\u2029支持的快捷指令:\u2029[PURPLE]prac[NORMAL] [1-{0}]: 开始选定编号的训练。\u2029[PURPLE]map[NORMAL] [地图名]: 更换到指定的地图。\u2029[PURPLE]df[NORMAL] [1-5]: 设置难度\u2029[PURPLE]mode[NORMAL] [rand/full]: 设置训练模式。\u2029[PURPLE]bw[NORMAL] [rand/ump/ak/sct/awp]: 设置 bot 所使用的武器。\u2029[PURPLE]lang[NORMAL] [en/pt/zh]: 修改语言设定。en for English, pt para português, 中文选择 zh。\u2029[PURPLE]exit[NORMAL]: 强制退出当前训练。",
"mainmenu.help": "用法: !prefire [PURPLE][快捷命令] [选项][NORMAL]\u2029没有指定快捷命令时,该指令会打开预瞄插件主菜单。\u2029支持的快捷指令:\u2029[PURPLE]prac[NORMAL] [1-{0}]: 开始选定编号的训练。\u2029[PURPLE]map[NORMAL] [地图名]: 更换到指定的地图。\u2029[PURPLE]df[NORMAL] [1-6]: 设置难度\u2029[PURPLE]mode[NORMAL] [rand/full]: 设置训练模式。\u2029[PURPLE]bw[NORMAL] [rand/ump/ak/sct/awp]: 设置 bot 所使用的武器。\u2029[PURPLE]lang[NORMAL] [en/pt/zh]: 修改语言设定。en for English, pt para português, 中文选择 zh。\u2029[PURPLE]exit[NORMAL]: 强制退出当前训练。",
"mainmenu.shortcut_prompt": "输入[PURPLE]!prefire help[NORMAL]可查询快捷指令的使用方法。",
"mainmenu.close_menu": "退出当前菜单",
"mainmenu.menu_closed": "菜单已关闭。",
Expand All @@ -25,10 +25,11 @@
"difficulty.0": "惨烈 - 初始 100HP",
"difficulty.1": "传奇 - 初始 500HP",
"difficulty.2": "困难 - 每个击杀恢复 25HP",
"difficulty.3": "正常 - 每个击杀恢复 100HP",
"difficulty.4": "简单 - 每个击杀恢复 500HP",
"difficulty.3": "正常 - 击杀后回满血量",
"difficulty.4": "简单 - 每个击杀恢复 100HP",
"difficulty.5": "无害 - 每个击杀恢复 500HP",
"difficulty.set": "难度已设置为:{0}。",
"difficulty.help": "用法: !prefire df [PURPLE][1-5][NORMAL]",
"difficulty.help": "用法: !prefire df [PURPLE][1-6][NORMAL]",
"weaponmenu.title": "设置 bot 所使用的武器",
"weaponmenu.random": "随机",
"weaponmenu.set": "Bot 使用的武器已设置为 {0}。",
Expand Down

0 comments on commit 50da910

Please sign in to comment.