-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEarthenBarrage.cs
171 lines (155 loc) · 4.42 KB
/
EarthenBarrage.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
// Earthen Barrage Scripting
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using ConsoleLib.Console;
using XRL;
using XRL.Liquids;
using XRL.Messages;
using XRL.Rules;
using XRL.UI;
using XRL.World;
using XRL.World.Anatomy;
using XRL.World.Capabilities;
using XRL.World.Parts;
using XRL.World.Parts.Mutation;
namespace XRL.World.Parts.Mutation
{
[Serializable]
public class Cleo_EarthenBarrage : BaseMutation
{
public const int COUNT = 1000;
public const int WILLPOWER_BASELINE = 16;
public const int WILLPOWER_FACTOR = 5;
public const int WILLPOWER_CEILING_FACTOR = 5;
public const int WILLPOWER_FLOOR_DIVISOR = 5;
public string Blueprint = "Ephemeral Stone";
public string CommandID;
public Guid EarthenBarrageActivatedAbilityID = Guid.Empty;
public EarthenBarrage()
{
DisplayName = "Earthen Barrage";
base.Type = "Mental";
}
public bool ActivateEarthenBarrage(
GameObject Actor,
GameObject Target = null,
IEvent FromEvent = null
)
{
if (!GameObject.Validate(ref Actor))
{
return false;
}
if (!Actor.IsActivatedAbilityUsable(ActivatedAbilityID))
{
return false;
}
BodyPart part = GetTargetBodyPart(Actor);
GameObject obj = GenerateObject();
if (part == null)
{
string msg = "You have no place available to hold " + (obj?.an() ?? "the result") + ".";
obj?.Obliterate();
return Actor.Fail(msg);
}
if (!CheckRealityDistortion(Actor, FromEvent))
{
obj?.Obliterate();
return false;
}
Actor.ReceiveObject(obj);
if (!GameObject.Validate(obj) || obj.InInventory != Actor)
{
obj?.Obliterate();
return Actor.Fail("Something went wrong.");
}
Event equipEv = Event.New("CommandEquipObject");
equipEv.SetParameter("Object", obj);
equipEv.SetParameter("BodyPart", part);
equipEv.SetSilent(true);
if (!Actor.FireEvent(equipEv))
{
obj?.Obliterate();
return Actor.Fail("Something went wrong.");
}
XDidYToZ(obj, "shimmer", "into existence in", Actor, (part.Type == "Thrown Weapon" ? "grasp" : part.GetOrdinalName()), IndefiniteSubject: true, PossessiveObject: true);
FromEvent?.RequestInterfaceExit();
return true;
}
private bool CheckRealityDistortion(GameObject Actor, IEvent FromEvent = null)
{
Event ev = Event.New("InitiateRealityDistortionLocal");
ev.SetParameter("Object", Actor);
ev.SetParameter("Device", this);
return Actor.FireEvent(ev, FromEvent);
}
private GameObject GenerateObject()
{
GameObject obj = GameObject.Create(Blueprint);
obj.SetIntProperty("NeverStack", 1);
obj.RemovePart("ExistenceSupport");
var xs = obj.RequirePart<ExistenceSupport>();
xs.SupportedBy = ParentObject;
xs.ValidateEveryTurn = true;
xs.SilentRemoval = true;
return obj;
}
public static BodyPart GetTargetBodyPart(GameObject Subject)
{
return Subject?.GetUnequippedPreferredBodyPartOrAlternate(
PreferredType: "Thrown Weapon",
AlternateType: "Hand"
);
}
public string GetDamage(int Level)
{
if (Level <= 1)
{
return "1d3";
}
if (Level <= 2)
{
return "1d4";
}
if (Level <= 3)
{
return "1d5";
}
if (Level <= 4)
{
return "1d4+1";
}
if (Level <= 5)
{
return "1d5+1";
}
if (Level <= 6)
{
return "1d4+2";
}
if (Level <= 7)
{
return "1d5+2";
}
if (Level <= 8)
{
return "1d4+3";
}
if (Level <= 9)
{
return "1d5+3";
}
if (Level > 9)
{
return "1d5+" + (Level - 6);
}
return "1d4+4";
}
public int GetEartenBarragePenetrationBonus()
{
return 4 + (base.Level - 1) / 2;
}
}
}