-
Notifications
You must be signed in to change notification settings - Fork 0
/
INEQ_BloodskalBlade.psc
314 lines (273 loc) · 11.5 KB
/
INEQ_BloodskalBlade.psc
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
Scriptname INEQ_BloodskalBlade extends INEQ_AbilityBase1H
{Attached to the ability's magic effect}
;=========================================== Properties ===========================================================================>
Message Property MainMenu Auto
Message Property ChargeOptionsMenu Auto
Spell Property DLC2BloodskalBladeSpellHoriz Auto
Spell Property DLC2BloodskalBladeSpellVert Auto
bool Property bBalanced Auto Hidden
bool Property bUseCharges Auto Hidden
int Property ChargeMode Auto Hidden ; 0=shared charges, 1=prioritize local, 2=only use local charges
Int Property ChargeCost Auto Hidden
float Property ChargeDistance Auto Hidden ; 1000.0, should be high relative to ChargeMagickaSiphon
float Property ChargeMagickaMP Auto Hidden
int Property ChargeMagickaPR Auto Hidden
;========================================== Autoreadonly ==========================================================================>
int Property DEFChargeMode = 0 Autoreadonly
int Property DEFMaxLocalCharge = 4 Autoreadonly
int Property DEFChargeCost = 2 Autoreadonly
float Property DEFChargeDistance = 500.0 Autoreadonly
float Property DEFChargeMagickaMP = 200.0 Autoreadonly
int Property DEFChargeMagickaPR = 50 Autoreadonly
String Property WeaponSwing = "weaponSwing" Autoreadonly
String Property PWStanding2H = "AttackPowerStanding_FXstart" Autoreadonly
String Property PWRight2H = "AttackPowerRight_FXstart" Autoreadonly
String Property PWLeft2H = "AttackPowerLeft_FXstart" Autoreadonly
String Property PWForward2H = "AttackPowerForward_FXstart" Autoreadonly
String Property PWBackward2H = "AttackPowerBackward_FXstart" Autoreadonly
;=========================================== Variables ============================================================================>
;===============================================================================================================================
;==================================== Maintenance ================================================
;================================================================================================
Function RestoreDefaultFields()
parent.RestoreDefaultFields()
bUseCharges = True
bBalanced = True
MaxLocalCharge = DEFMaxLocalCharge
ChargeCost = DEFChargeCost
ChargeDistance = DEFChargeDistance
ChargeMagickaMP = DEFChargeMagickaMP
ChargeMagickaPR = DEFChargeMagickaPR
EndFunction
;===============================================================================================================================
;==================================== States ================================================
;================================================================================================
State Equipped
Event OnBeginState()
int itemType = SelfRef.getEquippedItemType(1)
if itemType == 5
GoToState("Equipped2HGreatsword")
elseif itemType == 6
GoToState("Equipped2HOther")
elseif itemType > 0 && itemType < 5
GoToState("Equipped1H")
endif
RegisterForRecharge()
EndEvent
EndState
;___________________________________________________________________________________________________________________________
State Equipped1H
Event OnBeginState()
RegisterForAnimationEvent(SelfRef, WeaponSwing)
EndEvent
Event OnAnimationEvent(ObjectReference akSource, string EventName)
if SelfRef.GetAnimationVariableBool("bAllowRotation") && !SelfRef.GetAnimationVariableBool("isBlocking") &&\
!SelfRef.GetAnimationVariableBool("isBashing") && !SelfRef.GetAnimationVariableBool("isSneaking")
if !bUseCharges || hasCharge()
if SelfRef.GetAnimationVariableFloat("Speed") == 0
DLC2BloodskalBladeSpellVert.cast(selfRef)
else
float direction = selfRef.GetAnimationVariableFloat( "Direction" )
if (direction == 0.25 || direction == 0.75)
DLC2BloodskalBladeSpellHoriz.cast(SelfRef)
else
DLC2BloodskalBladeSpellVert.cast(selfRef)
endif
endif
endif
endif
EndEvent
Event OnEndState()
UnregisterForAnimationEvent(SelfRef, WeaponSwing)
EndEvent
EndState
;___________________________________________________________________________________________________________________________
State Equipped2HOther
Event OnBeginState()
RegisterForAnimationEvent(SelfRef, WeaponSwing)
EndEvent
Event OnAnimationEvent(ObjectReference akSource, string EventName)
if SelfRef.GetAnimationVariableBool("bAllowRotation") && !SelfRef.GetAnimationVariableBool("isBlocking") &&\
!SelfRef.GetAnimationVariableBool("isBashing") && !SelfRef.GetAnimationVariableBool("isSneaking")
if !bUseCharges || hasCharge()
if SelfRef.GetAnimationVariableFloat("Speed") == 0
DLC2BloodskalBladeSpellVert.cast(SelfRef)
else
float direction = selfRef.GetAnimationVariableFloat( "Direction" )
if (direction == 0.00 || direction == 1.00)
DLC2BloodskalBladeSpellVert.cast(selfRef)
;elseif (direction == 0.25 || direction == 0.75 || direction == 0.5)
else
DLC2BloodskalBladeSpellHoriz.cast(SelfRef)
endif
endif
endif
endif
EndEvent
Event OnEndState()
UnregisterForAnimationEvent(SelfRef, WeaponSwing)
EndEvent
EndState
;___________________________________________________________________________________________________________________________
State Equipped2HGreatsword
Event OnBeginState()
registerForAnimationEvent(SelfRef, PWStanding2H)
registerForAnimationEvent(SelfRef, PWRight2H)
registerForAnimationEvent(SelfRef, PWLeft2H)
registerForAnimationEvent(SelfRef, PWBackward2H)
registerForAnimationEvent(SelfRef, PWForward2H)
EndEvent
Event OnAnimationEvent(ObjectReference akSource, string EventName)
if !bUseCharges || hasCharge()
if EventName == PWStanding2H|| EventName == PWForward2H
DLC2BloodskalBladeSpellVert.cast(selfRef)
;elseif EventName == PWBackward2H || EventName == PWRight2H || EventName == PWLeft2H
else
DLC2BloodskalBladeSpellHoriz.cast(SelfRef)
endif
endif
EndEvent
Event OnEndState()
unregisterForAnimationEvent(SelfRef, PWStanding2H)
unregisterForAnimationEvent(SelfRef, PWRight2H)
unregisterForAnimationEvent(SelfRef, PWLeft2H)
unregisterForAnimationEvent(SelfRef, PWBackward2H)
unregisterForAnimationEvent(SelfRef, PWForward2H)
EndEvent
EndState
;===============================================================================================================================
;==================================== Functions ================================================
;================================================================================================
; Returns whether the necessary charges were obtained
bool function hasCharge()
if ChargeMode == 0 ; shared priority
int shared = GetSharedCharge()
if shared >= ChargeCost ; Attempts to use charges from shared first if available
return RequestSharedCharge(ChargeCost)
elseif shared + LocalCharge >= ChargeCost
RequestSharedCharge(shared) ; else uses remaining shared charges
removeLocalCharge(ChargeCost - shared) ; and use local charges to complete chage cost
return true
endif
elseif ChargeMode == 1 ; local priority
return removeLocalCharge(ChargeCost) || RequestSharedCharge(ChargeCost)
elseif ChargeMode == 2 ; local only
return removeLocalCharge(ChargeCost)
endif
return false
endfunction
;___________________________________________________________________________________________________________________________
; Removes and returns the number of requested charges from the local charge
int function removeLocalCharge(int iRequest)
if iRequest > 0 && LocalCharge >= iRequest
LocalCharge -= iRequest
Debug.Notification("Bloodskal Charges: " +LocalCharge)
RegisterForRecharge()
return iRequest
else
return 0
endif
EndFunction
;___________________________________________________________________________________________________________________________
; Adds charges up to max, and (un)registers recharge accordingly
function addLocalCharge(int charge = 1)
if LocalCharge != MaxLocalCharge
LocalCharge += charge
if LocalCharge < MaxLocalCharge
Debug.Notification("Bloodskal Charges: " +LocalCharge)
RegisterForRecharge()
return
else
LocalCharge = MaxLocalCharge
Debug.Notification("Bloodskal Charges: " +LocalCharge)
endif
endif
UnregisterForDistanceTravelledEvent()
UnregisterForMagickaSiphonEvent()
endFunction
;___________________________________________________________________________________________________________________________
; Recharge from distance travelled
function OnDistanceTravelledEvent()
addLocalCharge()
endfunction
;___________________________________________________________________________________________________________________________
; Recharge from magicak siphon
function OnMagickaSiphonEvent()
addLocalCharge()
EndFunction
;___________________________________________________________________________________________________________________________
; Register for any recharge sources
Function RegisterForRecharge(bool bForced = False)
RegisterForDistanceTravelledEvent(ChargeDistance, bForced)
RegisterForMagickaSiphonEvent(ChargeMagickaMP, ChargeMagickaPR, bForced)
EndFunction
;===============================================================================================================================
;==================================== Menus ================================================
;================================================================================================
Function AbilityMenu(INEQ_MenuButtonConditional Button, INEQ_ListenerMenu ListenerMenu, GlobalVariable MenuActive)
bool abMenu = True
int aiButton
while abMenu && MenuActive.Value
SetButtonMain(Button)
aiButton = MainMenu.Show()
if aiButton == 0
abMenu = False
elseif aiButton == 9 ; Cancel Menu
MenuActive.SetValue(0)
elseif aiButton == 1 ; Turn on Balanced
RestoreDefaultFields()
elseif aiButton == 2 ; Turn off Balanced
bBalanced = False
elseif aiButton == 3 ; Turn On Charges
bUseCharges = True
elseif aiButton == 4 ; Turn Off Charges
bUseCharges = False
elseif aiButton == 5 ; Set ChargeMode
ChargeMode = ListenerMenu.ChargeMode(ChargeMode, DEFChargeMode)
elseif aiButton == 6 ; Charge Options
MenuChargeOptions(ListenerMenu)
elseif aiButton == 7 ; Set Priority
ChargeMagickaPR = ListenerMenu.MagickaSiphonPriority(ChargeMagickaPR, DEFChargeMagickaPR)
endif
endwhile
RegisterForRecharge(True)
EndFunction
; Updates the Button to show the correct menu options
Function SetButtonMain(INEQ_MenuButtonConditional Button)
Button.clear()
if bBalanced
Button.set(2)
Button.set(7)
else
Button.set(1)
if bUseCharges
Button.set(4)
Button.set(6)
else
Button.set(3)
endif
endif
Button.set(5)
Button.set(7)
Button.set(9)
EndFunction
;___________________________________________________________________________________________________________________________
Function MenuChargeOptions(INEQ_ListenerMenu ListenerMenu)
bool abMenu = True
int aiButton
while abMenu
aiButton = ChargeOptionsMenu.Show()
if aiButton == 0
return
elseif aiButton == 1 ; Charge Cost
ChargeCost = ListenerMenu.ChargeCost(ChargeCost, DEFChargeCost)
elseif aiButton == 2 ; Charge Storage
MaxLocalCharge = ListenerMenu.ChargeStorage(MaxLocalCharge, DEFMaxLocalCharge)
RegisterForRecharge()
elseif aiButton == 3 ; Recharge MP
ChargeMagickaMP = ListenerMenu.MagickaSiphonCost(ChargeMagickaMP, DEFChargeMagickaMP)
elseif aiButton == 4 ; Recharge Distance
ChargeDistance = ListenerMenu.DistanceTravelledCost(ChargeDistance, DEFChargeDistance)
endif
endwhile
EndFunction