- Joined
- Jul 26, 2008
- Messages
- 1,009
I'm using XEColliders to create an orbital effect. Mostly it does straight lines but I figured I could manipulate it by setting loopControl to change the direction the unit rotates.
Well I haven't had much luck since my math is sub-par and setting the direction angle for a unit to move in a circle isn't easy nor are there tutorials I can adapt for it (Tried Daelin's static shapes tutorial)
Anyways, take a look, hopefully someone can help me make it so the xecollider rotates in a circle around the casting unit.
Well I haven't had much luck since my math is sub-par and setting the direction angle for a unit to move in a circle isn't easy nor are there tutorials I can adapt for it (Tried Daelin's static shapes tutorial)
Anyways, take a look, hopefully someone can help me make it so the xecollider rotates in a circle around the casting unit.
JASS:
scope Orb initializer init
globals
private constant integer SPELLID = 'puor'
endglobals
private struct Data extends xecollider
unit caster
method loopControl takes nothing returns nothing
local real dx = this.x - GetUnitX(this.caster)
local real dy = this.y - GetUnitY(this.caster)
local real dist = SquareRoot(dx * dx + dy * dy)
local real angle = bj_RADTODEG * Atan2( this.y - GetUnitY(this.caster), this.x - GetUnitX(this.caster)) - 5.00
local real x = this.x + dist * Cos(angle * bj_DEGTORAD)
local real y = this.y + dist * Sin(angle * bj_DEGTORAD)
set this.direction = bj_RADTODEG * Atan2( this.y - y, this.x - x )
endmethod
method onUnitHit takes unit target returns nothing
if IsUnitEnemy(target, GetOwningPlayer(this.caster)) then
call this.terminate()
endif
endmethod
static method Actions takes unit c returns nothing
local real angle = bj_RADTODEG * Atan2(GetUnitFacing(c) - GetUnitY(c), GetUnitFacing(c) - GetUnitX(c))
local Data xc = Data.create( GetUnitX(c)+200, GetUnitY(c)+200, 0 )
set xc.caster = c
set xc.fxpath = GetAbilityEffectById(SPELLID, EFFECT_TYPE_MISSILE, 0)
set xc.speed = 375
endmethod
static method Conditions takes nothing returns boolean
if GetSpellAbilityId() == SPELLID then
call Data.Actions(GetTriggerUnit())
endif
return false
endmethod
endstruct
//===========================================================================
public function init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, function Data.Conditions )
endfunction
endscope