using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Rust; using System; using System.Collections.Generic; using System.Globalization; using Rust; using Facepunch; using Facepunch.Extend; using System.Text.RegularExpressions; using System.Linq; using System.Text; using Oxide.Core; using Oxide.Core.Configuration; using Oxide.Core.Libraries; using Oxide.Core.Plugins; using Oxide.Game.Rust.Cui; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; using UnityEngine; namespace Oxide.Plugins { [Info("GongJiLi", "Default", "2.0")] public class GongJiLi : RustPlugin { ConfigData configData; string quanxian = "gongjili.use"; bool HasPermission(BasePlayer player, string perm) => permission.UserHasPermission(player.UserIDString, perm); public Dictionary Gjl = new Dictionary(); class ConfigData { [JsonProperty("skinid And attack power")] public Dictionary SD; } void LoadVariables() { LoadConfigVariables(); SaveConfig(); } protected override void LoadDefaultConfig() { var config = new ConfigData { SD = new Dictionary() { {11,100 }, {12,200}, {13,300} } }; SaveConfig(config); } void LoadConfigVariables() => configData = Config.ReadObject(); void SaveConfig(ConfigData config) => Config.WriteObject(config, true); void Init() { permission.RegisterPermission(quanxian, this); LoadVariables(); } void OnServerInitialized() { timer.Once(3f, () => { Gjl.Clear(); foreach (var keyValuePair in configData.SD) { if (!Gjl.ContainsKey(keyValuePair.Key)) { Gjl.Add(keyValuePair.Key, keyValuePair.Value); } } Config.WriteObject(configData); }); } void OnRocketLaunched(BasePlayer player, BaseEntity entity) { var explosive = entity as TimedExplosive; if (explosive == null) return; if (!HasPermission(player, quanxian)) return; var wp = player.GetActiveItem(); if (wp != null) { if (wp.skin != 0) { if (Gjl.ContainsKey(wp.skin)) { float sh; if (Gjl.TryGetValue(wp.skin, out sh)) { for (int i = 0; i < explosive.damageTypes.Count; i++) explosive.damageTypes[i].amount *= sh; } } } } } void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info) { if (entity == null || info == null) return; if (info.Initiator != null) { if (info.Initiator is BasePlayer) { var player = info.Initiator as BasePlayer; if (player.IsNpc) return; if (HasPermission(player, quanxian)) { if (info.Weapon != null) { var skin = info.Weapon.skinID; if (skin != 0) { if (Gjl.ContainsKey(info.Weapon.skinID)) { float sh; if (Gjl.TryGetValue(info.Weapon.skinID, out sh)) { info.damageTypes.ScaleAll(sh); } } } } else { var wp = player.GetActiveItem(); if (wp != null) { if (wp.skin != 0) { if (Gjl.ContainsKey(wp.skin)) { float sh; if (Gjl.TryGetValue(wp.skin, out sh)) { info.damageTypes.ScaleAll(sh); } } } } } } } } } } }