Frozenhelfir
set Gwypaas = Guhveepaws
- Reaction score
- 56
I'm trying out this awesome looking system, but for some reason it always starts on the caster, and then bounces to nearby enemies, even though the "only hit enemies" boolean is true and the setup should start it on the target of casting unit.
JASS:
scope ChainStun initializer init{
private hashtable ht = InitHashtable()
#define private SPELL_ID = 039;A00C039;
private int array numberOfBounces[10]
private int array damageDealt[10]
private bool Cond(){
return GetSpellAbilityId() == SPELL_ID
}
private void UnStun(){
int htKey = GetHandleId(GetExpiredTimer())
PauseUnit(LoadUnitHandle(ht,htKey,0),false)
DestroyEffect(LoadEffectHandle(ht,htKey,1))
Timer.release(GetExpiredTimer())
}
private void StunUnits(int id, unit target){
timer t = Timer.get()
effect e = AddSpecialEffectTarget("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl",target,"origin")
SaveUnitHandle(ht,GetHandleId(t),0,target)
SaveEffectHandle(ht,GetHandleId(t),1,e)
if GetUnitPointValue(target) == 1 {
PauseUnit(target,true)
TimerStart(t,0.75,false,function UnStun) //humans get stunned for way less!
}
else {
PauseUnit(target,true)
TimerStart(t,2.00,false,function UnStun)
}
e = null
t = null
}
private void Act(){
unit u = GetTriggerUnit()
unit target = GetSpellAbilityUnit()
int abilityLevel = GetUnitAbilityLevel(GetTriggerUnit(),SPELL_ID)
ChainLightning(u,u,target,"CLPB",damageDealt[abilityLevel-1],numberOfBounces[abilityLevel-1]) // caster/source is the casting unit, target should be who it starts on, yet it starts on caster <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown :(" loading="lazy" data-shortname=":(" />
ChainLightning_ColorLast(1,0,0)
// Special.
ChainLightningEx(u,u,"CLPB",StunUnits,true,numberOfBounces[abilityLevel-1])
ChainLightning_StartLastEx(target) // should start on the unit I cast the spell on!
ChainLightning_ColorLast(1,0,0)
}
private void init(){
trigger t = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
TriggerAddCondition(t,Condition(function Cond))
TriggerAddAction(t,function Act)
numberOfBounces[0] = 3
damageDealt[0] = 100
numberOfBounces[1]= 4
damageDealt[1]= 100
numberOfBounces[2]= 5
damageDealt[2]= 100
numberOfBounces[3]= 5
damageDealt[3]= 200
numberOfBounces[4]= 6
damageDealt[4]= 200
numberOfBounces[5]= 7
damageDealt[5]= 200
numberOfBounces[6]= 7
damageDealt[6]= 300
numberOfBounces[7]= 8
damageDealt[7]= 300
numberOfBounces[8]= 9
damageDealt[8]= 300
numberOfBounces[9]= 10
damageDealt[9]= 300
}
}