forked from tdauth/dmdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStruct Spell Alpha.j
More file actions
70 lines (62 loc) · 3.68 KB
/
Struct Spell Alpha.j
File metadata and controls
70 lines (62 loc) · 3.68 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
/// Druid
library StructSpellsSpellAlpha requires Asl, StructGameCharacter, StructGameClasses, StructGameSpell, StructGameGrimoire, StructSpellsSpellBearForm, StructSpellsSpellCrowForm
struct SpellAlpha extends Spell
public static constant integer abilityId = 'A0FE'
public static constant integer favouriteAbilityId = 'A0FG'
public static constant integer classSelectionAbilityId = 'A03M'
public static constant integer classSelectionGrimoireAbilityId = 'A03Y'
public static constant integer maxLevel = 1
/// This ability is added to the animal form if this spell is learned.
public static constant integer castAbilityId = 'A0FF'
public static constant integer castSpellBookAbilityId = 'A1PJ'
public stub method onLearn takes nothing returns nothing
local Character character = Character(this.character())
// TODO slow spellByAbilityId()
local SpellBearForm spellBearForm = character.grimoire().spellByAbilityId(SpellBearForm.abilityId)
local SpellCrowForm spellCrowForm = character.grimoire().spellByAbilityId(SpellCrowForm.abilityId)
call super.onLearn()
if ((spellBearForm != 0 and spellBearForm.metamorphosis().isMorphed()) or (spellCrowForm != 0 and spellCrowForm.metamorphosis().isMorphed())) then
call UnitAddAbility(this.character().unit(), SpellAlpha.castSpellBookAbilityId)
call SetPlayerAbilityAvailable(this.character().player(), SpellAlpha.castSpellBookAbilityId, false)
endif
endmethod
public stub method onUnlearn takes nothing returns nothing
local Character character = Character(this.character())
// TODO slow spellByAbilityId()
local SpellBearForm spellBearForm = character.grimoire().spellByAbilityId(SpellBearForm.abilityId)
local SpellCrowForm spellCrowForm = character.grimoire().spellByAbilityId(SpellCrowForm.abilityId)
call super.onUnlearn()
if ((spellBearForm != 0 and spellBearForm.metamorphosis().isMorphed()) or (spellCrowForm != 0 and spellCrowForm.metamorphosis().isMorphed())) then
call UnitRemoveAbility(this.character().unit(), SpellAlpha.castSpellBookAbilityId)
call SetPlayerAbilityAvailable(this.character().player(), SpellAlpha.castSpellBookAbilityId, true)
endif
endmethod
/**
* When the level is changed while the character is already morphed, the ability has to be added or removed.
*/
public stub method setLevel takes integer level returns nothing
local Character character = Character(this.character())
// TODO slow spellByAbilityId()
local SpellBearForm spellBearForm = character.grimoire().spellByAbilityId(SpellBearForm.abilityId)
local SpellCrowForm spellCrowForm = character.grimoire().spellByAbilityId(SpellCrowForm.abilityId)
call super.setLevel(level)
if ((spellBearForm != 0 and spellBearForm.metamorphosis().isMorphed()) or (spellCrowForm != 0 and spellCrowForm.metamorphosis().isMorphed())) then
// Add Alpha spell
if (level > 0) then
call UnitAddAbility(this.character().unit(), SpellAlpha.castSpellBookAbilityId)
call SetPlayerAbilityAvailable(this.character().player(), SpellAlpha.castSpellBookAbilityId, false)
else
call UnitRemoveAbility(this.character().unit(), SpellAlpha.castSpellBookAbilityId)
call SetPlayerAbilityAvailable(this.character().player(), SpellAlpha.castSpellBookAbilityId, true)
endif
endif
endmethod
public static method create takes Character character returns thistype
local thistype this = thistype.allocate(character, Classes.druid(), Spell.spellTypeUltimate0, thistype.maxLevel, thistype.abilityId, thistype.favouriteAbilityId, 0, 0, 0)
call this.addGrimoireEntry('A03M', 'A03Y')
call this.addGrimoireEntry('A0FH', 'A0FI')
call this.setIsPassive(true)
return this
endmethod
endstruct
endlibrary