-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStruct Spell Book Of Demonology.j
More file actions
255 lines (209 loc) · 10.1 KB
/
Copy pathStruct Spell Book Of Demonology.j
File metadata and controls
255 lines (209 loc) · 10.1 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
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
library StructSpellsSpellBookOfDemonology requires StructSpellsSpellBookCraftingSpell
struct SpellBookOfDemonologySacrificeChild extends SpellBookCraftingSpell
public static constant integer abilityId = 'A1V9'
private method condition takes nothing returns boolean
if (GetUnitTypeId(GetSpellTargetUnit()) == 'nvlk' or GetUnitTypeId(GetSpellTargetUnit()) == 'nvk2' or GetUnitTypeId(GetSpellTargetUnit()) == 'n084' or GetUnitTypeId(GetSpellTargetUnit()) == 'n085') then
debug call Print("Success")
return true
endif
debug call Print("Fail")
call this.character().displayMessage(ACharacter.messageTypeError, tre("Ziel muss ein Kind sein.", "Target has to be a child."))
return false
endmethod
private method action takes nothing returns nothing
call KillUnit(GetSpellTargetUnit())
// TODO Demonic effect
call Character(this.character()).displayItemAcquired(GetObjectName('I07C'), tre("Gefangen.", "Captured."))
call Character(this.character()).giveItem('I07C')
call Character(this.character()).craftItem('I07C')
endmethod
public static method create takes Character character returns thistype
return thistype.allocate(character, thistype.abilityId, thistype.condition, thistype.action)
endmethod
endstruct
struct SpellBookOfDemonologySacrificeAnimal extends SpellBookCraftingSpell
public static constant integer abilityId = 'A1VA'
private method condition takes nothing returns boolean
if (GetUnitTypeId(GetSpellTargetUnit()) == 'n02Y' or GetUnitTypeId(GetSpellTargetUnit()) == 'n02X' or GetUnitTypeId(GetSpellTargetUnit()) == 'n02N' or GetUnitTypeId(GetSpellTargetUnit()) == 'n06R' or GetUnitTypeId(GetSpellTargetUnit()) == 'n01K' or GetUnitTypeId(GetSpellTargetUnit()) == 'n083' or GetUnitTypeId(GetSpellTargetUnit()) == 'n00B' or GetUnitTypeId(GetSpellTargetUnit()) == 'h02K') then
debug call Print("Success")
return true
endif
debug call Print("Fail")
call this.character().displayMessage(ACharacter.messageTypeError, tre("Ziel muss ein Tier sein.", "Target has to be an animal."))
return false
endmethod
private method action takes nothing returns nothing
call KillUnit(GetSpellTargetUnit())
// TODO Demonic effect
call Character(this.character()).displayItemAcquired(GetObjectName('I07D'), tre("Gefangen.", "Captured."))
call Character(this.character()).giveItem('I07D')
call Character(this.character()).craftItem('I07D')
endmethod
public static method create takes Character character returns thistype
return thistype.allocate(character, thistype.abilityId, thistype.condition, thistype.action)
endmethod
endstruct
struct SpellBookOfDemonologyConjuration extends SpellBookCraftingSpell
public static constant integer abilityId = 'A1VB'
private static constant real time = 60.0
private method condition takes nothing returns boolean
if (this.character().inventory().totalItemTypeCharges('I07C') >= 1 and this.character().inventory().totalItemTypeCharges('I07D') >= 2) then
debug call Print("Success")
return true
endif
debug call Print("Fail")
call this.character().displayMessage(ACharacter.messageTypeError, tre("Benötigte Rohstoffe fehlen.", "Required resources are missing."))
return false
endmethod
private method action takes nothing returns nothing
local unit summoned = CreateUnit(this.character().player(), 'n086', GetUnitX(this.character().unit()), GetUnitY(this.character().unit()), 0.0)
call UnitApplyTimedLife(summoned, 'B010', thistype.time)
set summoned = CreateUnit(this.character().player(), 'n087', GetUnitX(this.character().unit()), GetUnitY(this.character().unit()), 0.0)
call UnitApplyTimedLife(summoned, 'B010', thistype.time)
set summoned = CreateUnit(this.character().player(), 'n088', GetUnitX(this.character().unit()), GetUnitY(this.character().unit()), 0.0)
call UnitApplyTimedLife(summoned, 'B010', thistype.time)
call this.character().inventory().removeItemType('I07C')
call this.character().inventory().removeItemType('I07D')
call this.character().inventory().removeItemType('I07D')
endmethod
public static method create takes Character character returns thistype
return thistype.allocate(character, thistype.abilityId, thistype.condition, thistype.action)
endmethod
endstruct
private struct SpellBookOfDemonologyBloodRitualBuffData
private Character m_character
private AGroup m_targets
private AIntegerVector m_dynamicLightnings
private effect m_effect
private timer m_updateTimer
private real m_elapsedTime
private static method timerFunctionUpdate takes nothing returns nothing
local thistype this = thistype(DmdfHashTable.global().handleInteger(GetExpiredTimer(), 0))
local real life = 0.0
local real totalLife = 0.0
local unit target = null
local integer i = 0
set this.m_elapsedTime = this.m_elapsedTime + TimerGetElapsed(GetExpiredTimer())
if (this.m_elapsedTime >= 12.0) then
call this.destroy()
else
set i = 0
loop
exitwhen (i == this.m_targets.units().size())
set target = this.m_targets.units()[i]
if (not IsUnitDeadBJ(target)) then
set life = GetUnitState(target, UNIT_STATE_MAX_LIFE) * 0.05
call SetUnitState(target, UNIT_STATE_LIFE, GetUnitState(target, UNIT_STATE_LIFE) - life)
call Spell.showLifeCostTextTag(target, life)
set totalLife = totalLife + life
set i = i + 1
else
call this.m_targets.units().erase(i)
endif
set target = null
endloop
call SetUnitState(target, UNIT_STATE_LIFE, GetUnitState(target, UNIT_STATE_LIFE) + totalLife)
call Spell.showLifeCostTextTag(this.m_character.unit(), totalLife)
endif
endmethod
public static method create takes Character character, AGroup targets returns thistype
local thistype this = thistype.allocate()
local integer i = 0
set this.m_character = character
set this.m_targets = targets
set this.m_effect = AddSpellEffectTargetById(SpellBookOfDemonologyBloodRitual.abilityId, EFFECT_TYPE_TARGET, character.unit(), "origin")
set this.m_dynamicLightnings = AIntegerVector.create()
set i = 0
loop
exitwhen (i == targets.units().size())
call this.m_dynamicLightnings.pushBack(ADynamicLightning.create(null, "AFOD", character.unit(), targets.units()[i]))
set i = i + 1
endloop
set this.m_updateTimer = CreateTimer()
call DmdfHashTable.global().setHandleInteger(this.m_updateTimer, 0, this)
call TimerStart(this.m_updateTimer, 0.01, true, function thistype.timerFunctionUpdate)
set this.m_elapsedTime = 0.0
return this
endmethod
private method onDestroy takes nothing returns nothing
local integer i = 0
call PauseTimer(this.m_updateTimer)
call DmdfHashTable.global().destroyTimer(this.m_updateTimer)
call DestroyEffect(this.m_effect)
set this.m_effect = null
set i = 0
loop
exitwhen (i == this.m_dynamicLightnings.size())
call ADynamicLightning(this.m_dynamicLightnings[i]).destroy()
set i = i + 1
endloop
call this.m_dynamicLightnings.destroy()
call this.m_targets.destroy()
endmethod
endstruct
struct SpellBookOfDemonologyBloodRitual extends SpellBookCraftingSpell
public static constant integer abilityId = 'A1VE'
public static constant real area = 300.0
private static method filter takes nothing returns boolean
return not IsUnitDeadBJ(GetFilterUnit())
endmethod
private method targets takes unit caster, real x, real y returns AGroup
local group targetGroup = CreateGroup()
local filterfunc filter = Filter(function thistype.filter)
local AGroup targets = AGroup.create()
call GroupEnumUnitsInRange(targetGroup, x, y, thistype.area, filter)
call targets.addGroup(targetGroup, true, false)
set targetGroup = null
call targets.removeAlliesOfUnit(caster)
call DestroyFilter(filter)
set filter = null
return targets
endmethod
private method condition takes nothing returns boolean
local AGroup targets = this.targets(this.character().unit(), GetSpellTargetX(), GetSpellTargetY())
local boolean result = not targets.units().empty()
if (not result) then
debug call Print("Success")
call this.character().displayMessage(ACharacter.messageTypeError, tre("Keine gültigen Ziele.", "No valid targets."))
call targets.destroy()
else
call DmdfHashTable.global().setHandleInteger(GetTriggeringTrigger(), 0, targets)
endif
return result
endmethod
private method action takes nothing returns nothing
local AGroup targets = AGroup(DmdfHashTable.global().handleInteger(GetTriggeringTrigger(), 0))
if (targets != 0) then
call SpellBookOfDemonologyBloodRitualBuffData.create(this.character(), targets)
endif
endmethod
public static method create takes Character character returns thistype
return thistype.allocate(character, thistype.abilityId, thistype.condition, thistype.action)
endmethod
endstruct
struct SpellBookOfDemonologyLordOfDarkness extends SpellBookCraftingSpell
public static constant integer abilityId = 'A1VD'
private static constant real time = 60.0
private method condition takes nothing returns boolean
if (this.character().inventory().totalItemTypeCharges('I07C') >= 2 and this.character().inventory().totalItemTypeCharges('I07D') >= 3) then
debug call Print("Success")
return true
endif
debug call Print("Fail")
call this.character().displayMessage(ACharacter.messageTypeError, tre("Benötigte Rohstoffe fehlen.", "Required resources are missing."))
return false
endmethod
private method action takes nothing returns nothing
local unit summoned = CreateUnit(this.character().player(), 'n08V', GetUnitX(this.character().unit()), GetUnitY(this.character().unit()), 0.0)
call UnitApplyTimedLife(summoned, 'B010', thistype.time)
call this.character().inventory().removeItemType('I07C')
call this.character().inventory().removeItemType('I07C')
call this.character().inventory().removeItemType('I07D')
call this.character().inventory().removeItemType('I07D')
call this.character().inventory().removeItemType('I07D')
endmethod
public static method create takes Character character returns thistype
return thistype.allocate(character, thistype.abilityId, thistype.condition, thistype.action)
endmethod
endstruct
endlibrary