| 01-04-2008, 02:46 AM | #1 |
Hello I've been trying to learn how to use ABC struct attachment, and Jass, and have tried to make a spell that moves the casting unit in a circle with the radius between the caster and the targeted location. I've come up with this, but it hasn't been working. Help me please. JASS:scope BoomerangABC globals constant integer AID_BOOMERANGABC = 'A000' endglobals globals private constant real PERIOD = 0.04 private constant real SLIDE_SPEED = 600. endglobals private struct SpellData unit boomerangcaster real distance integer ticks location radius real angle = 0.0 endstruct private function Timer_Actions takes nothing returns nothing local integer i = 1 local SpellData data local real x local real y local location temppoint local timer t = GetExpiredTimer() set data = GetTimerStructA(t) set data.angle = (data.angle +(360/ (SLIDE_SPEED*PERIOD))) set temppoint = PolarProjectionBJ(data.radius, data.distance, data.angle) set x = GetLocationX(temppoint) set y =GetLocationY(temppoint) call SetUnitPosition(data.boomerangcaster, x, y) set data.ticks = data.ticks - 1 if data.ticks <= 0 then call SetUnitPathing( data.boomerangcaster, true ) call PauseUnit( data.boomerangcaster, false ) call data.destroy() call ClearTimerStructA(t) // We must clear attachments before destroying timer call DestroyTimer(t) endif endfunction private function Actions takes nothing returns nothing local SpellData data = SpellData.create() local location target = GetSpellTargetLoc() local timer t = CreateTimer() local real Dx local real Dy local real D local real angle set data.boomerangcaster = GetTriggerUnit() set Dx = GetLocationX(target) - GetUnitX(data.boomerangcaster) set Dy = GetLocationY(target) - GetUnitY(data.boomerangcaster) set data.distance = (SquareRoot(Dx * Dx + Dy * Dy)) //calculates distance of radius set angle = AngleBetweenPoints(target, GetUnitLoc(data.boomerangcaster)) set data.radius = PolarProjectionBJ(target,data.distance, angle)//calculates center of circle call RemoveLocation(target) set D = data.distance * 3.14//calculates circumference set data.ticks = R2I(D / (SLIDE_SPEED*PERIOD)) call SetUnitPathing( data.boomerangcaster, false ) call PauseUnit( data.boomerangcaster, true) // attaching a struct to a timer call SetTimerStructA(t, data) call TimerStart(t,PERIOD,true,function Timer_Actions) set t = null endfunction //=========================================================================== private function SpellComparision takes nothing returns boolean return GetSpellAbilityId() == AID_BOOMERANGABC endfunction //=========================================================================== public function InitTrig takes nothing returns nothing local trigger trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( trig, Condition( function SpellComparision ) ) call TriggerAddAction( trig, function Actions) endfunction endscope |
| 01-04-2008, 12:27 PM | #2 |
Please define "hasn't been working" browsing big blocks of code with no idea of what to fix is hard. |
| 01-04-2008, 04:17 PM | #4 |
I already answered your question on thehelper. You actually registered in here just to ask me that lol. |
