-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPolearmGrip.cs
159 lines (134 loc) · 5.12 KB
/
PolearmGrip.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
using System;
using System.Collections.Generic;
using XRL.Messages;
using XRL.Rules;
using XRL.UI;
using XRL.Language;
using XRL.World.Effects;
using XRL.World.AI.GoalHandlers;
using XRL.World.Parts;
using XRL.World.Anatomy;
using ConsoleLib.Console;
namespace XRL.World.Parts.Skill
{
[Serializable]
public class acegiak_Polearm_Grip : BaseSkill
{
public Guid ActivatedAbilityID = Guid.Empty;
public ActivatedAbilityEntry Ability = null;
public acegiak_Polearm_Grip()
{
DisplayName = "Polearm_Grip";
}
public override bool AllowStaticRegistration()
{
return true;
}
public override void Register(GameObject Object)
{
Object.RegisterPartEvent(this, "DealDamage");
Object.RegisterPartEvent(this, "CommandAcegiakPolearmGrip");
Object.RegisterPartEvent(this, "AIGetOffensiveMutationList");
Object.RegisterPartEvent(this, "BeginEquip");
Object.RegisterPartEvent(this, "EquipperUnequipped");
base.Register(Object);
}
public override bool AddSkill(GameObject GO)
{
ActivatedAbilityID = AddMyActivatedAbility("Double Grip", "CommandAcegiakPolearmGrip", "Skill", "You wield your polearm with two hands for additional damage.", "G", null, Toggleable: true, DefaultToggleState: false, ActiveToggle: true, IsAttack: false, IsRealityDistortionBased: false, IsWorldMapUsable: true, UITileDefault : Renderable.UITile("abilities/polearmdoublegrip.png", foregroundColorCode : 'Y', detailColorCode : 'W', noTileAlt : "G", noTileColor : '\0'), UITileToggleOn : Renderable.UITile("abilities/polearmdoublegripon.png", foregroundColorCode : 'Y', detailColorCode : 'W', noTileAlt : "G", noTileColor : '\0'), UITileDisabled : null, UITileCoolingDown : null);
Ability = ParentObject.ActivatedAbilities?.GetAbility(ActivatedAbilityID);
return true;
}
public override bool RemoveSkill(GameObject GO)
{
if (ActivatedAbilityID != Guid.Empty)
{
RemoveMyActivatedAbility(ref ActivatedAbilityID);
}
return true;
}
public GameObject GetPrimaryPolearm()
{
GameObject result = null;
int num = 0;
Body part = ParentObject.GetPart<Body>();
List<BodyPart> equippedParts = part.GetEquippedParts();
foreach (BodyPart item in equippedParts)
{
XRL.World.Parts.acegiak_Reach part2 = item.Equipped.GetPart<XRL.World.Parts.acegiak_Reach>();
if (part2 != null)
{
result = item.Equipped;
}
}
return result; }
public bool IsPrimaryPolearmEquipped()
{
return GetPrimaryPolearm() != null;
}
public void reEquip(GameObject who,GameObject what){
GameObject equipped = what.pPhysics.Equipped;
BodyPart bodyPart = equipped.FindEquippedObject(what);
if (bodyPart != null)
{
equipped.FireEvent(Event.New("CommandForceUnequipObject", "BodyPart", bodyPart));
equipped.FireEvent(Event.New("CommandForceEquipObject", "Object", what, "BodyPart", bodyPart));
}
}
public override bool FireEvent(Event E)
{
if (E.ID == "AIGetOffensiveMutationList")
{
int Distance = E.GetIntParameter("Distance");
GameObject Target = E.GetGameObjectParameter("Target");
if (Target == null) return true;
if (!IsPrimaryPolearmEquipped()) return true;
if (ParentObject.pPhysics != null && ParentObject.pPhysics.IsFrozen()) return true;
List<XRL.World.AI.GoalHandlers.AICommandList> CommandList = (List<XRL.World.AI.GoalHandlers.AICommandList>)E.GetParameter("List");
if (Ability != null && Ability.Cooldown <= 0 && Distance <= 1) CommandList.Add(new XRL.World.AI.GoalHandlers.AICommandList("CommandAcegiakPolearmGrip", 1));
return true;
}else if (E.ID == "CommandAcegiakPolearmGrip")
{
if (Ability == null)
{
return true;
}
Ability.ToggleState = !Ability.ToggleState;
if(IsPrimaryPolearmEquipped()){
if(Ability.ToggleState){
GetPrimaryPolearm().ApplyEffect(new acegiak_Gripped());
reEquip(ParentObject,GetPrimaryPolearm());
}else{
GetPrimaryPolearm().RemoveEffect(typeof(acegiak_Gripped));
reEquip(ParentObject,GetPrimaryPolearm());
}
}
}
if (E.ID == "BeginEquip")
{
if (Ability == null)
{
return true;
}
GameObject GO = E.GetParameter<GameObject>("Object");
if(GO.GetPart<acegiak_Reach>() != null){
if(Ability.ToggleState){
GO.ApplyEffect(new acegiak_Gripped());
}else{
GO.RemoveEffect(typeof(acegiak_Gripped));
}
}
return true;
}
if (E.ID == "EquipperUnequipped")
{
GameObject GO = E.GetParameter<GameObject>("Object");
if(GO.GetPart<acegiak_Reach>() != null){
GO.RemoveEffect(typeof(acegiak_Gripped));
}
return true;
}
return base.FireEvent(E);
}
}
}