-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathClass_Ranger.cs
More file actions
228 lines (203 loc) · 12.9 KB
/
Copy pathClass_Ranger.cs
File metadata and controls
228 lines (203 loc) · 12.9 KB
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
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;
namespace ValheimLegends
{
public class Class_Ranger
{
private static int Script_Layermask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece_nonsolid", "terrain", "vehicle", "piece", "viewblock");
private static GameObject GO_CastFX;
public static GameObject GO_Wolf;
public static void Process_Input(Player player)
{
System.Random rnd = new System.Random();
Vector3 pVec = default(Vector3);
if (VL_Utility.Ability3_Input_Down)
{
if (!player.GetSEMan().HaveStatusEffect("SE_VL_Ability3_CD"))
{
//adds a status effect where projectiles deal bonus damage, increases number of bow projectiles fired
//player.Message(MessageHud.MessageType.Center, "Power Shot");
if (player.GetStamina() >= VL_Utility.GetPowerShotCost(player))
{
//Ability Cooldown
StatusEffect se_cd = (SE_Ability3_CD)ScriptableObject.CreateInstance(typeof(SE_Ability3_CD));
se_cd.m_ttl = VL_Utility.GetPowerShotCooldown(player);
player.GetSEMan().AddStatusEffect(se_cd);
//Ability Costffffffffffffxd
player.UseStamina(VL_Utility.GetPowerShotCost(player));
//Effects, animations, and sounds
//((ZSyncAnimation)typeof(Player).GetField("m_zanim", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Player.m_localPlayer)).SetTrigger("cheer");
UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("fx_crit"), player.GetCenterPoint(), Quaternion.identity);
//Lingering effects
SE_PowerShot se_powershot = (SE_PowerShot)ScriptableObject.CreateInstance(typeof(SE_PowerShot));
se_powershot.m_ttl = SE_PowerShot.m_baseTTL + Mathf.RoundToInt(.05f * player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.DisciplineSkillDef).m_level);
se_powershot.hitCount = Mathf.RoundToInt(3f + .05f * player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.DisciplineSkillDef).m_level);
//Apply effects
if (player.GetSEMan().HaveStatusEffect("SE_VL_PowerShot"))
{
StatusEffect se_pw_rem = player.GetSEMan().GetStatusEffect("SE_VL_PowerShot".GetStableHashCode());
player.GetSEMan().RemoveStatusEffect(se_pw_rem);
}
player.GetSEMan().AddStatusEffect(se_powershot);
//Skill gain
player.RaiseSkill(ValheimLegends.DisciplineSkill, VL_Utility.GetPowerShotSkillGain(player));
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Not enough stamina for Power Shot: (" + player.GetStamina().ToString("#.#") + "/" + VL_Utility.GetPowerShotCost(player) + ")");
}
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Ability not ready");
}
}
else if(VL_Utility.Ability2_Input_Down)
{
if (!player.GetSEMan().HaveStatusEffect("SE_VL_Ability2_CD"))
{
//summons a wolf companion
//player.Message(MessageHud.MessageType.Center, "Summon Wolf");
if (player.GetStamina() >= VL_Utility.GetSummonWolfCost(player))
{
//Ability Cooldown
StatusEffect se_cd = (SE_Ability2_CD)ScriptableObject.CreateInstance(typeof(SE_Ability2_CD));
se_cd.m_ttl = VL_Utility.GetSummonWolfCooldown(player);
player.GetSEMan().AddStatusEffect(se_cd);
//Skill influence
float sLevel = player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.ConjurationSkillDef).m_level;
//Ability Cost
player.UseStamina(VL_Utility.GetSummonWolfCost(player));
//Effects, animations, and sounds
//((ZSyncAnimation)typeof(Player).GetField("m_zanim", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Player.m_localPlayer)).SetTrigger("cheer");
player.StartEmote("cheer", true);
//((ZSyncAnimation)typeof(Player).GetField("m_zanim", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Player.m_localPlayer)).SetSpeed(1f);
//Lingering effects
//Apply effects
pVec = player.transform.position + player.transform.forward * 4f;
GameObject prefab = ZNetScene.instance.GetPrefab("VL_ShadowWolf"); //ZNetScene.instance.GetPrefab("VL_RangerWolf");
//prefab.AddComponent<CharacterTimedDestruction>();
prefab.GetComponent<CharacterTimedDestruction>().m_timeoutMin = 600f;
prefab.GetComponent<CharacterTimedDestruction>().m_timeoutMin = 600f;
//prefab.GetComponent<Character>().SetMaxHealth();
//prefab.GetComponent<Character>().m_swimSpeed = 2f;
GO_Wolf = UnityEngine.Object.Instantiate(prefab, pVec, Quaternion.identity);
Character ch = GO_Wolf.GetComponent<Character>();
ch.m_name = "Shadow Wolf";
UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("vfx_Potion_stamina_medium"), ch.transform.position, Quaternion.identity);
UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("vfx_WishbonePing"), ch.transform.position, Quaternion.identity);
if (ch != null)
{
ch.m_faction = Character.Faction.Players;
ch.SetTamed(true);
ch.SetMaxHealth(25 + (9 * sLevel));
ch.transform.localScale = (0.5f + (.015f * sLevel)) * Vector3.one;
ch.m_swimSpeed *= 2f;
CharacterTimedDestruction td = GO_Wolf.GetComponent<CharacterTimedDestruction>();
if (td != null)
{
//ZLog.Log("td valid: " + td2.isActiveAndEnabled + " timeout min " + td2.m_timeoutMin + " timeout max " + td2.m_timeoutMax);
//td.m_triggerOnAwake = true;
td.m_timeoutMin = 600f;
td.m_timeoutMax = td.m_timeoutMin;
td.Trigger();
}
SE_Companion se_companion = (SE_Companion)ScriptableObject.CreateInstance(typeof(SE_Companion));
se_companion.m_ttl = SE_Companion.m_baseTTL;
se_companion.damageModifier = (.05f + (.01f * sLevel)) * VL_GlobalConfigs.g_DamageModifer * VL_GlobalConfigs.c_rangerShadowWolf;
se_companion.healthRegen = 1f + (.1f * sLevel);
se_companion.speedModifier = 1.2f;
se_companion.summoner = player;
//CharacterDrop comp = ch.GetComponent<CharacterDrop>();
MonsterAI ai = ch.GetBaseAI() as MonsterAI;
ai.SetFollowTarget(player.gameObject);
//if (comp != null)
//{
// comp.m_drops.Clear();
// //foreach (CharacterDrop.Drop d in comp.m_drops)
// //{
// // d.m_chance = 0f;
// //}
//}
ch.GetSEMan().AddStatusEffect(se_companion);
//apply wolf buff, buff prevents loot drops, makes wolf not suck
}
//Skill gain
player.RaiseSkill(ValheimLegends.ConjurationSkill, VL_Utility.GetSummonWolfSkillGain(player));
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Not enough stamina to Summon Wolf: (" + player.GetStamina().ToString("#.#") + "/" + VL_Utility.GetSummonWolfCost(player) + ")");
}
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Ability not ready");
}
}
else if (VL_Utility.Ability1_Input_Down)
{
if (!player.GetSEMan().HaveStatusEffect("SE_VL_Ability1_CD"))
{
//enables improved sneak, rapid movement during sneak
//player.Message(MessageHud.MessageType.Center, "Shadow stalk");
if (player.GetStamina() >= VL_Utility.GetShadowStalkCost(player))
{
//Skill Influence
float sLevel = player.GetSkills().GetSkillList().FirstOrDefault((Skills.Skill x) => x.m_info == ValheimLegends.DisciplineSkillDef).m_level;
//Ability Cooldown
StatusEffect se_cd = (SE_Ability1_CD)ScriptableObject.CreateInstance(typeof(SE_Ability1_CD));
se_cd.m_ttl = VL_Utility.GetShadowStalkCooldown(player);
player.GetSEMan().AddStatusEffect(se_cd);
//Ability Cost
player.UseStamina(VL_Utility.GetShadowStalkCost(player));
//Effects, animations, and sounds
GameObject effect = ZNetScene.instance.GetPrefab("vfx_odin_despawn");
UnityEngine.Object.Instantiate(effect, player.transform.position, Quaternion.identity);
UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("sfx_wraith_death"), player.transform.position, Quaternion.identity);
//Lingering effects
SE_ShadowStalk se_shadowstalk = (SE_ShadowStalk)ScriptableObject.CreateInstance(typeof(SE_ShadowStalk));
se_shadowstalk.m_ttl = SE_ShadowStalk.m_baseTTL * (1f + (.02f * sLevel));
se_shadowstalk.speedAmount = 1.5f + (.01f * sLevel) * VL_GlobalConfigs.c_rangerShadowStalk;
se_shadowstalk.speedDuration = 3f + (.03f * sLevel);
//Apply effects
player.GetSEMan().AddStatusEffect(se_shadowstalk);
List<Character> allCharacters = new List<Character>();
allCharacters.Clear();
Character.GetCharactersInRange(player.GetCenterPoint(), 500f, allCharacters);
foreach (Character ch in allCharacters)
{
if (ch.GetBaseAI() != null && ch.GetBaseAI() is MonsterAI && ch.GetBaseAI().IsEnemy(player))
{
MonsterAI ai = ch.GetBaseAI() as MonsterAI;
if (ai != null && ai.GetTargetCreature() == player)
{
Traverse.Create(root: ai).Field("m_alerted").SetValue(false);
Traverse.Create(root: ai).Field("m_targetCreature").SetValue(null);
}
}
}
//Skill gain
player.RaiseSkill(ValheimLegends.DisciplineSkill, VL_Utility.GetShadowStalkSkillGain(player));
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Not enough stamina for Shadow Stalk: (" + player.GetStamina().ToString("#.#") + "/" + VL_Utility.GetShadowStalkCost(player) + ")");
}
}
else
{
player.Message(MessageHud.MessageType.TopLeft, "Ability not ready");
}
}
}
}
}