-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStruct Spell Emblaze.j
More file actions
executable file
·118 lines (99 loc) · 4.96 KB
/
Copy pathStruct Spell Emblaze.j
File metadata and controls
executable file
·118 lines (99 loc) · 4.96 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
/// Elemental Mage
library StructSpellsSpellEmblaze requires Asl, StructGameClasses, StructGameSpell
// TODO remove on unit death or removal
private struct BuffData
private SpellEmblaze m_spell
private unit m_target
private effect m_effect
private integer m_damage
private real m_time
private timer m_timer
private static method timerFunctionRemove takes nothing returns nothing
local thistype this = thistype(DmdfHashTable.global().handleInteger(GetExpiredTimer(), 0))
call SpellEmblaze.removeBuff.evaluate(this.m_spell.character().unit(), this.m_target)
call this.destroy()
endmethod
public static method create takes SpellEmblaze spell, unit target returns thistype
local thistype this = thistype.allocate()
set this.m_spell = spell
set this.m_target = target
set this.m_damage = SpellEmblaze.damageStartValue + SpellEmblaze.damageLevelFactor * spell.level()
set this.m_time = SpellEmblaze.time
debug call Print("Emblaze: Before buff.")
debug call Print("Emblaze: With " + R2S(this.m_damage) + " damage.")
call AUnitAddBonus(target, A_BONUS_TYPE_DAMAGE, this.m_damage)
call Spell.showWeaponDamageTextTag(target, this.m_damage)
set this.m_effect = AddSpecialEffectTarget("Models\\Effects\\Emblaze.mdx", target, "origin")
set this.m_timer = CreateTimer()
call DmdfHashTable.global().setHandleInteger(this.m_timer, 0, this)
call TimerStart(this.m_timer, this.m_time, false, function thistype.timerFunctionRemove)
return this
endmethod
private method onDestroy takes nothing returns nothing
call PauseTimer(this.m_timer)
call DmdfHashTable.global().destroyTimer(this.m_timer)
set this.m_timer = null
call DestroyEffect(this.m_effect)
set this.m_effect = null
call Spell.showWeaponDamageTextTag(this.m_target, -this.m_damage)
call AUnitAddBonus(this.m_target, A_BONUS_TYPE_DAMAGE, -this.m_damage)
set this.m_target = null
endmethod
endstruct
private struct Buff extends ABuff
public stub method onAdd takes unit source, unit whichUnit, integer index returns nothing
local Character character = Character.getCharacterByUnit(source)
local BuffData buffData = 0
if (index > 0) then
// remove old buff data first
set buffData = BuffData(DmdfHashTable.global().handleInteger(whichUnit, DMDF_HASHTABLE_KEY_BUFFEMBLAZE))
call buffData.destroy()
endif
// TODO slow spellByAbilityId()
set buffData = BuffData.create(character.grimoire().spellByAbilityId(SpellEmblaze.abilityId), whichUnit)
call DmdfHashTable.global().setHandleInteger(whichUnit, DMDF_HASHTABLE_KEY_BUFFEMBLAZE, buffData)
endmethod
public stub method onRemove takes unit source, unit whichUnit, integer index returns nothing
endmethod
public static method create takes integer buffId returns thistype
local thistype this = thistype.allocate(buffId)
return this
endmethod
endstruct
/// Der Elementarmagier kann die Waffen seiner Verbündeten 2 Minuten lang entzünden und ihren Schaden um die Stufe des Verbündeten erhöhen.
struct SpellEmblaze extends Spell
public static constant integer abilityId = 'A01C'
public static constant integer favouriteAbilityId = 'A03H'
public static constant integer classSelectionAbilityId = 'A1KN'
public static constant integer classSelectionGrimoireAbilityId = 'A1KO'
public static constant integer buffAbilityId = 'A1IY'
public static constant integer maxLevel = 5
public static constant real time = 30.0
public static constant integer damageStartValue = 5
public static constant integer damageLevelFactor = 5
private static Buff m_buff
/// Multiple Buffs: Stop old buff and start new. Do not stack. It would be too unfair.
private method action takes nothing returns nothing
debug call Print("EMBLAZE!!!")
debug call Print("Source: " + GetUnitName(this.character().unit()) + " target: " + GetUnitName(GetSpellTargetUnit()))
debug call Print("With buff: " + I2S(thistype.m_buff))
call thistype.m_buff.add(this.character().unit(), GetSpellTargetUnit())
endmethod
public static method create takes Character character returns thistype
local thistype this = thistype.allocate(character, Classes.elementalMage(), Spell.spellTypeNormal, thistype.maxLevel, thistype.abilityId, thistype.favouriteAbilityId, 0, 0, thistype.action)
call this.addGrimoireEntry('A1KN', 'A1KO')
call this.addGrimoireEntry('A0TR', 'A0TW')
call this.addGrimoireEntry('A0TS', 'A0TX')
call this.addGrimoireEntry('A0TT', 'A0TY')
call this.addGrimoireEntry('A0TU', 'A0TZ')
call this.addGrimoireEntry('A0TV', 'A0U0')
return this
endmethod
private static method onInit takes nothing returns nothing
set thistype.m_buff = Buff.create(thistype.buffAbilityId)
endmethod
public static method removeBuff takes unit source, unit target returns nothing
call thistype.m_buff.remove(source, target)
endmethod
endstruct
endlibrary