NeuroToxin
New Member
- Reaction score
- 46
Okay, So In this spell, Im trying to tweak it to use .25 time, (its my spell) And for some reason, on the first cast, when I try to set him to the targeted units X, it doesn't, its actually quite a distance off, and then also, after the first cast, the caster just disappears entirely. Heres the code
JASS:
scope Windslash initializer init
//========================================================================================
//======================================SETUP============================================
//========================================================================================
globals
//The effect that's played with every attack
private constant string EFFECT_ON_HIT = "Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl"
//The ability code of the ability, "Wind Slash"
private constant integer ABILITY_CODE = 039;A000039;
//The ability code of the Crow Form ability (Should be the same unless you tampered with)
private constant integer CROW_FORM =039;Arav039;
//The effect attached to the weapon.
private constant string EFFECT_ON_WEAPON = "Abilities\\Spells\\Orc\\EtherealForm\\SpiritWalkerChange.mdl"
//The effect at the location of the unit being slammed (Final attack)
private constant string FINAL_EFFECT = "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl"
//Attack type for the damage
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
//Damage type for the damage
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
//Weapon type for the damage
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
//Animation to be played while the attack goes on.
private constant string ANIMATION_ATTACK = "attack"
//Attachment point for the EFFECT_ON_HIT
private constant string ATTACHMENT_POINT = "origin"
//Attachment point for the EFFECT_ON_WEAPON effect.
private constant string CASTER_ATTACH_POINT = "origin"
//The final effect to be played on each individual unit in the final AOE
private constant string FINAL_AOE_EFFECT = "Objects\\Spawnmodels\\Undead\\UndeadDissipate\\UndeadDissipate.mdl"
private constant string FINAL_ATTACHED = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
private group tempgroup = CreateGroup()
endglobals
private function Units takes unit u, player casterOwner returns boolean
return (not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)) and IsUnitEnemy(u, casterOwner)
endfunction
private function NUMBER_OF_SLASHES takes integer lvl returns real
return 4 + (lvl * 2.)
endfunction
private function HEIGHT takes integer lvl returns real
return 200 + (lvl * 25.)
endfunction
private function DAMAGE_PER_STRIKE takes integer lvl returns real
return (lvl * 6.25)
endfunction
private function RATE_OF_FLYING takes integer lvl returns real
return 600 + (lvl * 0.)
endfunction
private function FINAL_SPEED takes integer lvl returns real
return 25 + (lvl * 0.)
endfunction
private function FINAL_AOE_DAMAGE takes integer lvl returns real
return lvl * 40.
endfunction
private function FINAL_AOE takes integer lvl returns real
return lvl * 60.
endfunction
//========================================================================================
//=====================================ENDSETUP=========================================
//========================================================================================
private struct slash
unit Caster
unit Target
integer Tempint = 1
effect AttachedEffect
effect FinalEffect
static integer structtype
endstruct
private function FinalUnits takes nothing returns boolean
local slash s = slash.structtype
local unit f = GetFilterUnit()
local real damage = FINAL_AOE_DAMAGE(GetUnitAbilityLevel(s.Caster, ABILITY_CODE))
if GetUnitTypeId(f) != GetUnitTypeId(s.Caster) and Units(f, GetOwningPlayer(s.Caster)) then
call SetUnitX(s.Caster, GetUnitX(f))
call SetUnitY(s.Caster, GetUnitY(f))
call SetUnitAnimation(s.Caster, ANIMATION_ATTACK)
call UnitDamageTarget(s.Caster, f, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffectTarget(FINAL_AOE_EFFECT, f, ATTACHMENT_POINT))
endif
set f = null
return false
endfunction
private function userFunc takes nothing returns boolean
local slash s = KT_GetData()
local integer ability_level = GetUnitAbilityLevel(s.Caster, ABILITY_CODE)
local real fly_height = HEIGHT(ability_level) + 50 * s.Tempint
local real rate = RATE_OF_FLYING(ability_level)
local real damage = DAMAGE_PER_STRIKE(ability_level)
local real num_slashes = NUMBER_OF_SLASHES(ability_level)
local real final_attack_speed = FINAL_SPEED(ability_level)
local real radius = FINAL_AOE(ability_level)
local real offsetx
local real offsety
local real coffsetx
local real coffsety
local real angle
local real casterX = GetUnitX(s.Caster)
local real casterY = GetUnitY(s.Caster)
local real targetX = GetUnitX(s.Target)
local real targetY = GetUnitY(s.Target)
if s.Tempint < num_slashes and GetWidgetLife(s.Target) > .405 then
set angle = Atan2(targetY - casterY, targetX - casterX)
call SetUnitFlyHeight(s.Target, fly_height, rate)
call SetUnitFlyHeight(s.Caster, fly_height, (rate * .75))
set offsetx = targetX + 20 * Cos(angle)
set offsety = targetY + 20 * Sin(angle)
call SetUnitFacing(s.Caster, angle * bj_RADTODEG)
call SetUnitAnimation(s.Caster, ANIMATION_ATTACK)
call UnitDamageTarget(s.Caster, s.Target, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffectTarget(EFFECT_ON_HIT, s.Target, ATTACHMENT_POINT))
call SetUnitX(s.Target, offsetx)
call SetUnitY(s.Target, offsety)
set s.Tempint = s.Tempint + 1
elseif s.Tempint >= num_slashes or GetWidgetLife(s.Target) < .405 then
call SetUnitFlyHeight(s.Target, 0, 1000)
call SetUnitFlyHeight(s.Caster, 0, (rate * .75))
set s.FinalEffect = AddSpecialEffectTarget(FINAL_ATTACHED, s.Caster, ATTACHMENT_POINT)
call DestroyEffect(AddSpecialEffectTarget(EFFECT_ON_HIT, s.Target, ATTACHMENT_POINT))
call DestroyEffect(AddSpecialEffect(FINAL_EFFECT, targetX, targetY))
set slash.structtype = s
call GroupEnumUnitsInRange(tempgroup, targetX, targetY, radius, Filter(function FinalUnits))
call SelectUnit(s.Caster, true)
call DestroyEffect(s.AttachedEffect)
call DestroyEffect(s.FinalEffect)
call PauseUnit(s.Caster, false)
call PauseUnit(s.Target, false)
call s.destroy()
return true
endif
return false
endfunction
private function OnCast takes nothing returns boolean
local slash s
if GetSpellAbilityId() == ABILITY_CODE then
set s = slash.create()
set s.Caster = GetTriggerUnit()
set s.Target = GetSpellTargetUnit()
call ClearSelectionForPlayer(GetTriggerPlayer())
call PauseUnit(s.Caster, true)
call PauseUnit(s.Target, true)
call UnitAddAbility(s.Caster, CROW_FORM)
call UnitAddAbility(s.Target, CROW_FORM)
call UnitRemoveAbility(s.Caster, CROW_FORM)
call UnitRemoveAbility(s.Target, CROW_FORM)
set s.AttachedEffect = AddSpecialEffectTarget(EFFECT_ON_WEAPON, s.Caster, CASTER_ATTACH_POINT)
call SetUnitX(GetTriggerUnit(), GetUnitX(GetSpellTargetUnit()))
call SetUnitY(GetTriggerUnit(), GetUnitY(GetSpellTargetUnit()))
call KT_Add(function userFunc, s, .25)
endif
return false
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddCondition( t, Condition(function OnCast) )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endscope