-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathClass_Priest.cs
294 lines (261 loc) · 15.8 KB
/
Class_Priest.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using System.Reflection;
using Unity;
namespace ValheimLegends
{
public class Class_Priest
{
private static int Layermask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece_nonsolid", "terrain", "vehicle", "piece", "viewblock", "character", "character_net", "character_ghost", "Water");
private static GameObject GO_CastFX;
private static GameObject GO_Sanctify;
private static Projectile P_Sanctify;
private static StatusEffect SE_Fireball;
private static GameObject GO_Meteor;
private static Projectile P_Meteor;
private static StatusEffect SE_Meteor;
private static bool healCharging = false;
private static int healCount;
private static int healChargeAmount;
private static int healChargeAmountMax;
private static float healSkillGain = 0f;
public static void PurgeStatus_NearbyPlayers(Player healer, float radius, List<string> effectNames)
{
if(effectNames != null && effectNames.Count > 0)
{
List<Character> allCharacters = new List<Character>();
allCharacters.Clear();
Character.GetCharactersInRange(healer.transform.position, radius, allCharacters);
foreach (Character p in allCharacters)
{
if (!BaseAI.IsEnemy(p, healer))
{
foreach (string effect in effectNames)
{
if (p.GetSEMan().HaveStatusEffect(effect))
{
p.GetSEMan().RemoveStatusEffect(effect.GetStableHashCode());
break;
}
}
}
}
}
}
public static void HealNearbyPlayers(Player healer, float radius, float amount)
{
List<Character> allCharacters = new List<Character>();
allCharacters.Clear();
Character.GetCharactersInRange(healer.transform.position, radius, allCharacters);
foreach (Character p in allCharacters)
{
if (!BaseAI.IsEnemy(p, healer))
{
p.Heal(amount, true);
}
}
}
public static void Process_Input(Player player, ref float altitude)
{
System.Random rnd = new System.Random();
if (VL_Utility.Ability3_Input_Down)
{
if (!player.GetSEMan().HaveStatusEffect("SE_VL_Ability3_CD"))
{
//player.Message(MessageHud.MessageType.Center, "heal - starting");
if (player.GetStamina() >= VL_Utility.GetHealCost)
{
ValheimLegends.shouldUseGuardianPower = false;
ValheimLegends.isChanneling = true;
//Ability Cooldown
StatusEffect se_cd = (SE_Ability3_CD)ScriptableObject.CreateInstance(typeof(SE_Ability3_CD));
se_cd.m_ttl = VL_Utility.GetHealCooldownTime;
player.GetSEMan().AddStatusEffect(se_cd);
//Ability Cost
player.UseStamina(VL_Utility.GetHealCost);
//Skill influence
float sLevel = player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.AlterationSkillDef).m_level;
//Effects, animations, and sounds
((ZSyncAnimation)typeof(Player).GetField("m_zanim", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(player)).SetTrigger("gpower");
UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("fx_VL_HealPulse"), player.GetCenterPoint(), Quaternion.identity);
//Lingering effects
healCharging = true;
healChargeAmount = 0;
healChargeAmountMax = 60;
//Apply effects
List<string> effectList = new List<string>();
effectList.Clear();
effectList.Add("Burning");
effectList.Add("Poison");
effectList.Add("Frost");
effectList.Add("Wet");
effectList.Add("Smoked");
PurgeStatus_NearbyPlayers(player, 30f + .2f * sLevel, effectList);
HealNearbyPlayers(player, 30f + .2f * sLevel, (10f + sLevel) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestHeal);
//Skill gain
player.RaiseSkill(ValheimLegends.AlterationSkill, VL_Utility.GetHealSkillGain);
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Not enough stamina to begin heal : (" + player.GetStamina().ToString("#.#") + "/" + VL_Utility.GetHealCost + ")");
}
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Ability not ready");
}
}
else if (VL_Utility.Ability3_Input_Pressed && healCharging && player.GetStamina() > VL_Utility.GetHealCostPerUpdate && Mathf.Max(0f, altitude - player.transform.position.y) <= 1f)
{
healChargeAmount++;
player.UseStamina(VL_Utility.GetHealCostPerUpdate);
ValheimLegends.isChanneling = true;
VL_Utility.SetTimer();
if (healChargeAmount >= healChargeAmountMax)
{
healCount++;
healChargeAmount = 0;
((ZSyncAnimation)typeof(Player).GetField("m_zanim", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(player)).SetTrigger("gpower");
//((ZSyncAnimation)typeof(Player).GetField("m_zanim", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Player.m_localPlayer)).SetSpeed(1.5f);
UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("fx_VL_HealPulse"), player.GetCenterPoint(), Quaternion.identity);
float sLevel = player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.AlterationSkillDef).m_level;
HealNearbyPlayers(player, 20f + .2f * sLevel, ((healCount + sLevel * .3f) * 2f) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestHeal);
//Skill gain
player.RaiseSkill(ValheimLegends.AlterationSkill, VL_Utility.GetHealSkillGain * .5f);
}
}
else if((VL_Utility.Ability3_Input_Up || player.GetStamina() <= VL_Utility.GetHealCostPerUpdate || Mathf.Max(0f, altitude - player.transform.position.y) > 1f) && healCharging)
{
healCount = 0;
healChargeAmount = 0;
healCharging = false;
ValheimLegends.isChanneling = false;
}
else if (VL_Utility.Ability2_Input_Down)
{
if (!player.GetSEMan().HaveStatusEffect("SE_VL_Ability2_CD"))
{
if (player.GetStamina() >= VL_Utility.GetPurgeCost)
{
ValheimLegends.shouldUseGuardianPower = false;
//Skill influence
float sPurgeLevel = player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.EvocationSkillDef).m_level;
float sHealLevel = player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.AlterationSkillDef).m_level;
//Ability Cooldown
StatusEffect se_cd = (SE_Ability2_CD)ScriptableObject.CreateInstance(typeof(SE_Ability2_CD));
se_cd.m_ttl = VL_Utility.GetPurgeCooldownTime;
player.GetSEMan().AddStatusEffect(se_cd);
//Ability Cost
player.UseStamina(VL_Utility.GetPurgeCost);
//Effects, animations, and sounds
player.StartEmote("challenge");
GO_CastFX = UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("fx_VL_Purge"), player.GetCenterPoint(), Quaternion.identity);
//Lingering effects
//Apply effects
HealNearbyPlayers(player, 20f + (.2f * sHealLevel), .5f + UnityEngine.Random.Range(.4f, .6f) * sHealLevel * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestPurgeHeal);
List<Character> allCharacters = new List<Character>();
allCharacters.Clear();
Character.GetCharactersInRange(player.transform.position, 20f + (.2f * sPurgeLevel), allCharacters);
foreach (Character ch in allCharacters)
{
if (BaseAI.IsEnemy(player, ch) && VL_Utility.LOS_IsValid(ch, player.GetCenterPoint(), player.transform.position))
{
Vector3 direction = (ch.transform.position - player.transform.position);
HitData hitData = new HitData();
hitData.m_damage.m_spirit = UnityEngine.Random.Range(4f + (.4f * sPurgeLevel), 8f + (.8f * sPurgeLevel)) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestPurgeDamage;
hitData.m_damage.m_fire = UnityEngine.Random.Range(4f + (.4f * sPurgeLevel), 8f + (.8f * sPurgeLevel)) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestPurgeDamage;
hitData.m_pushForce = 0f;
hitData.m_point = ch.GetEyePoint();
hitData.m_dir = (player.transform.position - ch.transform.position);
hitData.m_skill = ValheimLegends.EvocationSkill;
ch.Damage(hitData);
}
}
//Skill gain
player.RaiseSkill(ValheimLegends.EvocationSkill, VL_Utility.GetPurgeSkillGain * .5f);
player.RaiseSkill(ValheimLegends.AlterationSkill, VL_Utility.GetPurgeSkillGain * .5f);
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Not enough stamina to for Purge: (" + player.GetStamina().ToString("#.#") + "/" + (VL_Utility.GetPurgeCost) +")");
}
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Ability not ready");
}
}
else if (VL_Utility.Ability1_Input_Down)
{
if (!player.GetSEMan().HaveStatusEffect("SE_VL_Ability1_CD"))
{
//player.Message(MessageHud.MessageType.Center, "Sanctify");
if (player.GetStamina() >= VL_Utility.GetSanctifyCost)
{
//Ability Cooldown
StatusEffect se_cd = (SE_Ability1_CD)ScriptableObject.CreateInstance(typeof(SE_Ability1_CD));
se_cd.m_ttl = VL_Utility.GetSanctifyCooldownTime;
player.GetSEMan().AddStatusEffect(se_cd);
//Ability Cost
player.UseStamina(VL_Utility.GetSanctifyCost);
//Skill influence
float sLevel = player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.EvocationSkillDef).m_level;
//Effects, animations, and sounds
//player.StartEmote("cheer");
((ZSyncAnimation)typeof(Player).GetField("m_zanim", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(player)).SetTrigger("battleaxe_attack0");
//UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("fx_guardstone_activate"), player.transform.position, Quaternion.identity);
//Lingering effects
//Apply effects
RaycastHit hitInfo = default(RaycastHit);
Vector3 position = player.transform.position;
Vector3 target = (!Physics.Raycast(player.GetEyePoint(), player.GetLookDir(), out hitInfo, float.PositiveInfinity, Layermask) || !(bool)hitInfo.collider) ? (position + player.GetLookDir() * 1000f) : hitInfo.point;
Vector3 vector = target + player.transform.up * 12f;
GameObject prefab = ZNetScene.instance.GetPrefab("VL_SanctifyHammer");
GO_Sanctify = UnityEngine.Object.Instantiate(prefab, vector, Quaternion.identity);
P_Sanctify = GO_Sanctify.GetComponent<Projectile>();
P_Sanctify.name = "Sanctify";
P_Sanctify.m_respawnItemOnHit = false;
P_Sanctify.m_spawnOnHit = null;
P_Sanctify.m_ttl = 30f;
P_Sanctify.m_gravity = 9f;
P_Sanctify.m_rayRadius = 1f;
P_Sanctify.m_aoe = 8f + (.04f * sLevel);
GO_Sanctify.transform.localScale = Vector3.one;
HitData hitData = new HitData();
hitData.m_damage.m_fire = UnityEngine.Random.Range(10f + (.5f * sLevel), 20f + (.75f * sLevel)) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestSanctify;
hitData.m_damage.m_blunt = UnityEngine.Random.Range(10f + (.5f * sLevel), 20f + (.75f * sLevel)) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestSanctify;
hitData.m_damage.m_spirit = UnityEngine.Random.Range(10f + (.5f * sLevel), 20f + (.75f * sLevel)) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_priestSanctify;
hitData.SetAttacker(player);
hitData.m_pushForce = 50f;
hitData.m_skill = ValheimLegends.EvocationSkill;
//Vector3 a = Vector3.MoveTowards(GO_Sanctify.transform.position, target, 1f);
P_Sanctify.Setup(player, new Vector3(0f, -1f, 0f), -1f, hitData, null, null);
Traverse.Create(root: P_Sanctify).Field("m_skill").SetValue(ValheimLegends.EvocationSkill);
GO_Sanctify = null;
//Skill gain
player.RaiseSkill(ValheimLegends.EvocationSkill, VL_Utility.GetSanctifySkillGain);
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Not enough stamina for Sanctify: (" + player.GetStamina().ToString("#.#") + "/" + VL_Utility.GetSanctifyCost + ")");
}
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Ability not ready");
}
}
else
{
ValheimLegends.isChanneling = false;
}
}
}
}