-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMageEruption.cs
119 lines (110 loc) · 7.09 KB
/
MageEruption.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.IO;
using System.Reflection;
using BepInEx;
using BepInEx.Configuration;
using R2API;
using RoR2;
using RoR2.Skills;
using EntityStates;
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace MageEruption
{
[BepInDependency(R2API.ContentManagement.R2APIContentManager.PluginGUID)]
[BepInDependency(LanguageAPI.PluginGUID)]
[BepInPlugin(PluginGUID, PluginName, PluginVersion)]
public class MageEruption : BaseUnityPlugin
{
public const string PluginGUID = PluginAuthor + "." + PluginName;
public const string PluginAuthor = "gaforb";
public const string PluginName = "MageEruption";
public const string PluginVersion = "3.2.0";
public static ConfigEntry<bool> VFXoff { get; set; }
public static ConfigEntry<bool> IsSprint { get; set; }
public static ConfigEntry<bool> IsSpecial { get; set; }
public static ConfigEntry<float> BlastDmg { get; set; }
public static ConfigEntry<float> BlastArea { get; set; }
public static ConfigEntry<float> BlastProc { get; set; }
public static ConfigEntry<float> BlastForce { get; set; }
public static ConfigEntry<float> Cooldown { get; set; }
public static ConfigEntry<int> Stocks { get; set; }
public void Awake()
{
MageEruption.VFXoff = base.Config.Bind<bool>("General", "Use simple explosion", false, "Disables some graphical effects, improving performance.");
MageEruption.IsSprint = base.Config.Bind<bool>("General", "Force sprinting", false, "Makes Eruption work like other utility skills and force sprint. if True, using Flamethrower during Eruption will waste the Flamethrower stock.");
MageEruption.IsSpecial = base.Config.Bind<bool>("General", "Move to special", false, "Adds Eruption to the Special slot instead of the Utility slot.");
MageEruption.BlastDmg = base.Config.Bind<float>("Values", "Blast damage", 3.6f, "How much damage the initial blast deals. 1 = 100%. Setting to 0 will still apply burn.");
MageEruption.BlastArea = base.Config.Bind<float>("Values", "Blast area", 8f, "How much range the intial blast has. Set to 0 to disable blast attack completely");
MageEruption.BlastProc = base.Config.Bind<float>("Values", "Blast proc coefficient", 1f, "How well Eruption triggers item effects. Also effects burn duration.");
MageEruption.BlastForce = base.Config.Bind<float>("Values", "Blast force", 12f, "How much Eruption knocks back enemies.");
MageEruption.Cooldown = base.Config.Bind<float>("Values", "Cooldown", 7f, "How long Eruption takes to recharge.");
MageEruption.Stocks = base.Config.Bind<int>("Values", "Stocks", 1, "Number of stocks Eruption has.");
LanguageAPI.Add("MAGE_ERUPTION_FIRE", "Eruption");
LanguageAPI.Add("MAGE_ERUPTION_DESCRIPTION", "Blast forward" + ((MageEruption.BlastArea.Value > 0f) ? (", " + ((MageEruption.BlastDmg.Value > 0f) ? string.Format("dealing <style=cIsDamage>{0}%</style> damage and ", MageEruption.BlastDmg.Value * 100f) : "") + "<style=cIsDamage>igniting</style> nearby enemies") : "") + "." + ((MageEruption.Stocks.Value != 1) ? string.Format(" Holds up to {0} charges.", MageEruption.Stocks.Value) : ""));
SkillDef skillDef = ScriptableObject.CreateInstance<SkillDef>();
skillDef.activationState = new SerializableEntityStateType(typeof(MageEruptionState));
skillDef.activationStateMachineName = "Body";
skillDef.baseMaxStock = Mathf.Max(MageEruption.Stocks.Value, 1);
skillDef.baseRechargeInterval = Mathf.Max(MageEruption.Cooldown.Value, 0.5f);
skillDef.beginSkillCooldownOnSkillEnd = false;
skillDef.canceledFromSprinting = false;
skillDef.forceSprintDuringState = MageEruption.IsSprint.Value;
skillDef.cancelSprintingOnActivation = !MageEruption.IsSprint.Value;
skillDef.isCombatSkill = (MageEruption.BlastArea.Value > 0f);
skillDef.fullRestockOnAssign = true;
skillDef.interruptPriority = InterruptPriority.PrioritySkill;
skillDef.mustKeyPress = true;
skillDef.rechargeStock = 1;
skillDef.requiredStock = 1;
skillDef.stockToConsume = 1;
skillDef.icon = MageEruption.SpriteFromFile("eruption.png");
skillDef.skillName = "MAGE_ERUPTION_FIRE";
skillDef.skillNameToken = "MAGE_ERUPTION_FIRE";
skillDef.skillDescriptionToken = "MAGE_ERUPTION_DESCRIPTION";
GameObject mageBodyprefab = Addressables.LoadAssetAsync<GameObject>("mage").WaitForCompletion();
bool wasAdded;
ContentAddition.AddEntityState(typeof(MageEruptionState), out wasAdded);
ContentAddition.AddSkillDef(skillDef);
//idk why I can't put the if statement up here instead but whatever this works
SkillFamily skillFamily = Addressables.LoadAssetAsync<SkillFamily>("RoR2/Base/Mage/MageBodySpecialFamily.asset").WaitForCompletion();
SkillFamily skillFamily2 = Addressables.LoadAssetAsync<SkillFamily>("RoR2/Base/Mage/MageBodyUtilityFamily.asset").WaitForCompletion();
if (IsSpecial.Value)
{
Array.Resize<SkillFamily.Variant>(ref skillFamily.variants, skillFamily.variants.Length + 1);
SkillFamily.Variant[] variants = skillFamily.variants;
int num = skillFamily.variants.Length - 1;
SkillFamily.Variant variant = default(SkillFamily.Variant);
variant.skillDef = skillDef;
variant.unlockableDef = null;
variant.viewableNode = new ViewablesCatalog.Node(skillDef.skillNameToken, false, null);
variants[num] = variant;
}
else
{
Array.Resize<SkillFamily.Variant>(ref skillFamily2.variants, skillFamily2.variants.Length + 1);
SkillFamily.Variant[] variants2 = skillFamily2.variants;
int num2 = skillFamily2.variants.Length - 1;
SkillFamily.Variant variant = default(SkillFamily.Variant);
variant.skillDef = skillDef;
variant.unlockableDef = null;
variant.viewableNode = new ViewablesCatalog.Node(skillDef.skillNameToken, false, null);
variants2[num2] = variant;
}
}
public static Sprite SpriteFromFile(string name)
{
Texture2D texture2D = new Texture2D(2, 2);
try
{
ImageConversion.LoadImage(texture2D, File.ReadAllBytes(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name)));
}
catch (FileNotFoundException ex)
{
Debug.LogError("Failed to read file at " + ex.FileName);
return null;
}
return Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.height, (float)texture2D.width), new Vector2(0.5f, 0.5f), 100f);
}
}
}