-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStruct Spell Fire Missile.j
More file actions
executable file
·108 lines (93 loc) · 4.67 KB
/
Copy pathStruct Spell Fire Missile.j
File metadata and controls
executable file
·108 lines (93 loc) · 4.67 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
/// Elemental Mage
library StructSpellsSpellFireMissile requires Asl, StructSpellsSpellElementalMageDamageSpell
private struct SpellFireMissileType extends AMissileType
private Character m_character
private unit m_targetUnit
private static method burnTarget takes SpellFireMissile spell, unit caster, unit target returns nothing
local real damage = 0.0
local effect burnEffect = AddSpellEffectTargetById(SpellFireMissile.abilityId, EFFECT_TYPE_TARGET, target, "chest")
local real time = SpellFireMissile.time
loop
call TriggerSleepAction(1.0)
set time = time - 1.0
exitwhen (time <= 0.0 or AUnitSpell.enemyTargetLoopCondition(target))
set damage = SpellFireMissile.burnDamageStartValue + spell.level() * SpellFireMissile.burnDamageFactor
set damage = damage + spell.damageBonusFactor() * damage
call UnitDamageTargetBJ(caster, target, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE)
call Spell.showDamageTextTag(target, damage)
endloop
set caster = null
set target = null
call DestroyEffect(burnEffect)
set burnEffect = null
endmethod
private static method damage takes AMissile missile returns nothing
local thistype this = thistype(missile.missileType())
local unit caster = this.m_character.unit()
local integer level = GetUnitAbilityLevel(caster, SpellFireMissile.abilityId)
// TODO slow spellByAbilityId()
local SpellFireMissile spell = SpellFireMissile(this.m_character.spellByAbilityId(SpellFireMissile.abilityId)) // TODO slow function
local unit target = this.m_targetUnit
local real damage = SpellFireMissile.damageStartValue + level * SpellFireMissile.damageFactor
set damage = damage + spell.damageBonusFactor() * damage
call UnitDamageTargetBJ(caster, target, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE)
call ShowBashTextTagForPlayer(null, GetUnitX(target), GetUnitY(target), R2I(damage))
// execute since this method is called by .evaluate and the missile is destroyed afterwards
call thistype.burnTarget.execute(spell, caster, target)
set caster = null
set target = null
endmethod
private static method customOnDeathFunction takes AMissile missile returns nothing
local thistype this = thistype(missile.missileType())
if (not IsUnitDeadBJ(this.m_targetUnit)) then
call thistype.damage(missile)
endif
endmethod
public static method create takes Character character, unit targetUnit returns thistype
local thistype this = thistype.allocate()
set this.m_character = character
set this.m_targetUnit = targetUnit
call this.setOwner(character.player())
call this.setUnitType('n00E')
call this.setSpeed(700.0)
call this.setTargetSeeking(true)
call this.setDestroyOnDeath(true)
call this.setOnDeathFunction(thistype.customOnDeathFunction)
return this
endmethod
endstruct
struct SpellFireMissile extends SpellElementalMageDamageSpell
public static constant integer abilityId = 'A014'
public static constant integer favouriteAbilityId = 'A03K'
public static constant integer classSelectionAbilityId = 'A1KV'
public static constant integer classSelectionGrimoireAbilityId = 'A1KW'
public static constant integer maxLevel = 5
public static constant real damageStartValue = 35.0
public static constant real damageFactor = 15.0 // Schadens-Stufenfaktor (ab Stufe 1)
public static constant real burnDamageStartValue = 2.0
public static constant real burnDamageFactor = 2.0 // Schadens-Stufenfaktor (ab Stufe 1)
public static constant real time = 3.0 // Zeitkonstante (unverändert)
private method action takes nothing returns nothing
local unit caster = this.character().unit()
local unit target = GetSpellTargetUnit()
local SpellFireMissileType missileType = SpellFireMissileType.create(this.character(), target)
local AMissile missile = AMissile.create()
call missile.setMissileType(missileType)
call missile.setTargetWidget(target)
call missile.startFromUnit(caster)
debug call Print("Fire missile on " + GetUnitName(target))
set caster = null
set target = null
endmethod
public static method create takes Character character returns thistype
local thistype this = thistype.allocate(character, thistype.spellTypeNormal, thistype.maxLevel, thistype.abilityId, thistype.favouriteAbilityId, 0, 0, thistype.action)
call this.addGrimoireEntry('A1KV', 'A1KW')
call this.addGrimoireEntry('A0KP', 'A0KU')
call this.addGrimoireEntry('A0KQ', 'A0KV')
call this.addGrimoireEntry('A0KR', 'A0KW')
call this.addGrimoireEntry('A0KS', 'A0KX')
call this.addGrimoireEntry('A0KT', 'A0KY')
return this
endmethod
endstruct
endlibrary