private void AddSkillPoint(CommandArgs args) { try { SkillPlayer ply = PlayerManager.GetPlayer(args.Player.Index); SkillInformation info = ply.GetSkillInformation(Name); SkillInformation newInfo; if (info == null) { newInfo = new SkillInformation() { Name = this.Name, Value = 0 } } ; else { newInfo = new SkillInformation() { Name = this.Name, Value = info.Value + 1 } }; ply.SetSkillInformation(newInfo); } catch (Exception e) { //player is not logged in Console.WriteLine(e.Message); } }
private void OnPlayerTakesDamage(PlayerDamageEvent args) { try { SkillPlayer player = PlayerManager.GetPlayer(args.HurtPlayerIndex); SkillInformation info = player.GetSkillInformation(Name); if (info == null) { info = new SkillInformation() { Name = this.Name, Value = 0 }; player.SetSkillInformation(info); return; } if (info.Value > 0 && !args.PVP) { FireRocket(player, args.Damage, 1); } } catch (Exception e) { Console.WriteLine(e.Message); } }
private void OnPlayerDamagesNPC(NpcDamageEvent args) { try { SkillPlayer player = PlayerManager.GetPlayer(args.PlayerIndex); SkillInformation info = player.GetSkillInformation(Name); if (info == null) { info = new SkillInformation() { Name = this.Name, Value = 0 }; player.SetSkillInformation(info); return; } if (info.Value > 0) { double ratio = Math.Min(info.Value / 20.0, 1.0); int health = (int)Math.Ceiling(ratio * args.Damage); player.Player.Heal(health); } } catch (Exception e) { Console.WriteLine(e.Message); } }