diff --git a/src/ZoneServer/Commands/ChatCommands.Handlers.cs b/src/ZoneServer/Commands/ChatCommands.Handlers.cs index de7a5e38c..9c638db23 100644 --- a/src/ZoneServer/Commands/ChatCommands.Handlers.cs +++ b/src/ZoneServer/Commands/ChatCommands.Handlers.cs @@ -78,6 +78,7 @@ public ChatCommands() this.Add("recallmap", "[map id/name]", "Warps all characters on given map back.", this.HandleRecallMap); this.Add("recallall", "", "Warps all characters on the server back.", this.HandleRecallAll); this.Add("heal", "[hp] [sp] [stamina]", "Heals the character's HP, SP, and Stamina.", this.HandleHeal); + this.Add("alive", "", "Revives the character if dead, or fully heals if alive.", this.HandleAlive); this.Add("clearinv", "", "Removes all items from inventory.", this.HandleClearInventory); this.Add("addjob", " [circle]", "Adds a job to character.", this.HandleAddJob); this.Add("removejob", "", "Removes a job from character.", this.HandleRemoveJob); @@ -1348,7 +1349,7 @@ private static void RecallCharacters(Character sender, Character target, Charact } /// - /// Heals the target hp and optionally sp. + /// Heals the target hp and optionally sp/stamina. /// If no argument is given, heals fully. /// Can also heal negative values. /// @@ -1363,20 +1364,24 @@ private CommandResult HandleHeal(Character sender, Character target, string mess if (args.Count > 3) return CommandResult.InvalidArgument; + if (target.IsDead) + return CommandResult.Okay; + // TODO: Maybe refactor to take indexed arguments, named // ones, or combinations, so you can, for example, heal // stamina without specifying HP and SP like so: // >heal sp:10 - // Fully heal HP and SP if no arguments are given + // Fully heal HP, SP and Stamina if no arguments are given if (args.Count == 0) { target.ModifyHp(target.MaxHp); target.ModifySp(target.MaxSp); + target.ModifyStamina(target.MaxStamina); - sender.ServerMessage(Localization.Get("Healed HP and SP.")); + sender.ServerMessage(Localization.Get("Healed HP, SP and Stamina.")); if (sender != target) - target.ServerMessage(Localization.Get("Your HP and SP were healed by {0}."), sender.TeamName); + target.ServerMessage(Localization.Get("Your HP, SP and Stamina were healed by {0}."), sender.TeamName); } // Modify only HP if one argument is given else if (args.Count == 1) @@ -1432,6 +1437,40 @@ private CommandResult HandleHeal(Character sender, Character target, string mess target.ServerMessage(Localization.Get("{0} healed your HP by {1}, SP by {2}, and Stamina by {3} points."), sender.TeamName, hpAmount, spAmount, staminaAmount); } + if (target.Hp == 0) + { + // Commit sudoku + sender.Kill(target); + } + + return CommandResult.Okay; + } + + /// + /// Revives the character if dead, or fully heals if alive. + /// + /// + /// + /// + /// + /// + /// + private CommandResult HandleAlive(Character sender, Character target, string message, string command, Arguments + args) + { + if (target.IsDead) + { + // Revive in place like soul crystal + target.Resurrect(ResurrectOptions.TryAgain); + } + else + { + // Fully heal HP, SP and Stamina + target.ModifyHp(target.MaxHp); + target.ModifySp(target.MaxSp); + target.ModifyStamina(target.MaxStamina); + } + return CommandResult.Okay; } diff --git a/system/conf/commands.conf b/system/conf/commands.conf index 8bcb8605b..b4d16bf21 100644 --- a/system/conf/commands.conf +++ b/system/conf/commands.conf @@ -131,6 +131,9 @@ recallall : 50,-1 // Heals player hp and sp heal: 50,50 +// Revives player +alive: 50,0 + // Removes all items from target's inventory clearinv: 50,50