- Joined
- May 12, 2018
- Messages
- 145
I want to create a ability that if A uses a spell to B, A and B are teleported halfway point between A and B. (Same as Chaos Knight's Reality Rift in DotA)
But I'm having a hard time getting these math formulas. Below is my example script.
but this has a problem that they bounce off big time each the units' point and offset are changed.
But I'm having a hard time getting these math formulas. Below is my example script.
but this has a problem that they bounce off big time each the units' point and offset are changed.
JASS:
library FelbornChaosKnightRealityRift requires SpellEffectEvent, PluginSpellEffect, Utilities
globals
private constant integer AID = 'A0AD'
endglobals
private struct RealityRift
private static method onCast takes nothing returns nothing
local real x0 = Spell.source.x
local real y0 = Spell.source.y
local real x1 = Spell.target.x
local real y1 = Spell.target.y
local real angle = Atan2(y1 - y0, x1 - x0)
local real xOffset = 0
local real yOffset = 0
set xOffset = x0 + (x1 - x0) * Cos(angle) * 0.5
set yOffset = y0 + (y1 - y0) * Sin(angle) * 0.5
call SetUnitX(Spell.source.unit, xOffset)
call SetUnitY(Spell.source.unit, yOffset)
call SetUnitX(Spell.target.unit, xOffset)
call SetUnitY(Spell.target.unit, yOffset)
endmethod
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(AID, function thistype.onCast)
endmethod
endstruct
endlibrary
Last edited: