Иконка ресурса

FREE AlwaysBonus : 1.1.1 1.1.1

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
// Reference: 0Harmony

/*
 * Exotic Plugins © 2023
 * File can not be copied, modified and/or distributed without the express permission from Tryhard
 * For support join our discord - https://discord.gg/YnbYaugRMh
 */

using Harmony;
using Newtonsoft.Json;
using System.Collections.Generic;
using System;
using UnityEngine;
using OpCodes = System.Reflection.Emit.OpCodes;

namespace Oxide.Plugins
{
    [Info("Always Bonus", "Tryhard", "1.1.1")]
    [Description("Hits X markers on trees and stars on nodes automatically")]
    public class AlwaysBonus : RustPlugin
    {
        #region Fields
        private const string InstanceId = "com.Tryhard.AlwaysBonus";
        private static HarmonyInstance _harmony;
        #endregion

        #region Harmony
        private void Loaded()
        {
            if (_harmony == null)
                _harmony = HarmonyInstance.Create(InstanceId);

            if (config.nodex)
                _harmony.Patch(AccessTools.Method(typeof(OreResourceEntity), nameof(OreResourceEntity.OnAttacked)), transpiler: new HarmonyMethod(typeof(OreResourceEntity_Patch), nameof(OreResourceEntity_Patch.Transpiler)));

            if (config.treex)
                _harmony.Patch(AccessTools.Method(typeof(TreeEntity), nameof(TreeEntity.DidHitMarker)), transpiler: new HarmonyMethod(typeof(TreeEntity_Patch), nameof(TreeEntity_Patch.Transpiler)));
        }

        private void Unload() => _harmony.UnpatchAll(InstanceId);

        public static class OreResourceEntity_Patch
        {
            [HarmonyTranspiler]
            public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
            {
                List<CodeInstruction> list = new List<CodeInstruction>(instructions);

                foreach (var instruction in list)
                {
                    if (instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 1.5f)
                    {
                        instruction.operand = 25f;
                        return list;
                    }
                }

                return list;
            }
        }

        public static class TreeEntity_Patch
        {
            [HarmonyTranspiler]
            public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
            {
                List<CodeInstruction> list = new List<CodeInstruction>()
                {
                    new CodeInstruction(OpCodes.Ldc_I4_1),
                    new CodeInstruction(OpCodes.Ret)
                };

                return list;
            }
        }

        #endregion

        #region Config
        static Configuration config;
        public class Configuration
        {
            [JsonProperty("Enable atuo tree X farming")]
            public bool treex = true;

            [JsonProperty("Enable atuo node star farming")]
            public bool nodex = true;
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<Configuration>();
                if (config == null) LoadDefaultConfig();
                SaveConfig();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                PrintWarning("Creating new config file.");
                LoadDefaultConfig();
            }
        }

        protected override void LoadDefaultConfig() => config = new Configuration();
        protected override void SaveConfig() => Config.WriteObject(config);
        #endregion
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху