using System; using System.Linq; using System.Reflection; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; using Oxide.Core; using Oxide.Core.Plugins; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Facepunch; #region Changelogs and ToDo /********************************************************************** * * 1.0.0 : - Initial release * **********************************************************************/ #endregion namespace Oxide.Plugins { [Info("FrankiesPower", "Krungh Crow", "1.0.0")] [Description("hp and dmg multipliers for Frankensteinpet")] class FrankiesPower : RustPlugin { #region Variables const string _HPBoost_Perm = "frankiespower.health"; const string _AttBoost_Perm = "frankiespower.damage"; const string Chat_Perm = "frankiespower.chat"; ulong chaticon = 0; string prefix; bool Debug = false; float _MultiplierHP; float _MultiplierAtt; #endregion #region Configuration void Init() { if (!LoadConfigVariables()) { Puts("Config file issue detected. Please delete file, or check syntax and fix."); return; } permission.RegisterPermission(Chat_Perm, this); permission.RegisterPermission(_HPBoost_Perm, this); permission.RegisterPermission(_AttBoost_Perm, this); Debug = configData.PlugCFG.Debug; prefix = configData.PlugCFG.Prefix; chaticon = configData.PlugCFG.Chaticon; if (Debug) Puts($"[Debug] trigger for Debug is true"); _MultiplierHP = configData.FrankCFG.MultiplierHealth; _MultiplierAtt = configData.FrankCFG.MultiplierAttack; } private ConfigData configData; class ConfigData { [JsonProperty(PropertyName = "Main config")] public SettingsPlugin PlugCFG = new SettingsPlugin(); [JsonProperty(PropertyName = "Frankie config")] public FrankieSetup FrankCFG = new FrankieSetup(); } class SettingsPlugin { [JsonProperty(PropertyName = "Debug")] public bool Debug = false; [JsonProperty(PropertyName = "Chat Steam64ID")] public ulong Chaticon = 0; [JsonProperty(PropertyName = "Chat Prefix")] public string Prefix = "[FrankiesP] "; } class FrankieSetup { [JsonProperty(PropertyName = "HP multiplier")] public float MultiplierHealth = 3.0f; [JsonProperty(PropertyName = "Attack multiplier")] public float MultiplierAttack = 1.1f; } private bool LoadConfigVariables() { try { configData = Config.ReadObject(); } catch { return false; } SaveConf(); return true; } protected override void LoadDefaultConfig() { Puts("Fresh install detected Creating a new config file."); configData = new ConfigData(); SaveConf(); } void SaveConf() => Config.WriteObject(configData, true); #endregion #region LanguageAPI protected override void LoadDefaultMessages() { lang.RegisterMessages(new Dictionary { ["Info"] = "\nAvailable Commands\n/frankiesp info : Shows info on version/author and commands", ["InvalidInput"] = "Please enter a valid command!", ["Frankie_Spawned"] = "Frankie is boosted with {0}HP and {1} Strength", ["Version"] = "Version : V", ["NoPermission"] = "You do not have permission to use that command!", }, this); } #endregion #region Commands [ChatCommand("frankiesp")] private void FrankiesP(BasePlayer player, string command, string[] args) { if (!permission.UserHasPermission(player.UserIDString, Chat_Perm)) { Player.Message(player, prefix + string.Format(msg("NoPermission", player.UserIDString)), chaticon); if (Debug) Puts($"[Debug] {player} had no permission for using Commands"); return; } if (args.Length == 0) { Player.Message(player, prefix + string.Format(msg("InvalidInput", player.UserIDString)), chaticon); } else { if (args[0].ToLower() == "info") { Player.Message(player, prefix + string.Format(msg("Version", player.UserIDString)) + this.Version.ToString() + " By : " + this.Author.ToString() + msg("Info") , chaticon); return; } else { Player.Message(player, prefix + string.Format(msg("InvalidInput", player.UserIDString)), chaticon); } } } #endregion #region Hooks void OnEntitySpawned(FrankensteinPet frankie) { if (frankie == null) return; NextTick(() => { var _ownerplayer = frankie.OwnerID; string _OwnerIdString = frankie.OwnerID.ToString(); global::BasePlayer player = global::BasePlayer.FindByID(_ownerplayer); if (Debug) Puts($"[Debug] frankie start health : [{frankie.MaxHealth()}]"); var _Health = frankie.MaxHealth(); if (permission.UserHasPermission(_OwnerIdString, _HPBoost_Perm)) { frankie.InitializeHealth(_Health * _MultiplierHP, _Health * _MultiplierHP); if (Debug) Puts($"[Debug] frankie Health multiplier: [x {_MultiplierHP}]"); if (Debug) Puts($"[Debug] frankie boosted health : [{frankie.MaxHealth()}]"); } if (Debug) Puts($"[Debug] frankie base attack damage : [{frankie.BaseAttackDamge}]"); if (permission.UserHasPermission(_OwnerIdString, _AttBoost_Perm)) { if (Debug) Puts($"[Debug] frankie attack multiplier: [x {_MultiplierAtt}]"); frankie.BaseAttackDamge = frankie.BaseAttackDamge * _MultiplierAtt; if (Debug) Puts($"[Debug] frankie boosted attack damage : [{frankie.BaseAttackDamge}]"); if (Debug) Puts($"[Debug] frankie base attack rate : [{frankie.BaseAttackRate}]"); } if(permission.UserHasPermission(_OwnerIdString, _HPBoost_Perm)|| permission.UserHasPermission(_OwnerIdString, _AttBoost_Perm)) { if (player != null && !player.IsSleeping()) { var _MaxHealth = frankie.MaxHealth(); var _Attackdamage = frankie.BaseAttackDamge; Player.Message(player, prefix + string.Format(msg($"Frankie_Spawned", _OwnerIdString),_MaxHealth, _Attackdamage), chaticon); } if (Debug) Puts($"[Debug] [{player}] has perms (HP and/or Att)"); } }); } #endregion #region Message helper private string msg(string key, string id = null) => lang.GetMessage(key, this, id); //Player.Message(player, prefix + string.Format(msg("InvalidInput", player.UserIDString)), chaticon); #endregion } }