- Joined
- Dec 11, 2007
- Messages
- 755
I don't know a lot about jass, I have been trying to learn it for a while but have been mostly unsucsessful. I wrote this trigger that is supposed to make unit's spinn around the target, but it doesn't work.
I need help.
JASS:
globals
constant integer OOP_SpellID = 'A000'
constant integer OOP_DummyID = 'hpea'
constant real OOP_IdealDistance = 300.
constant real OOP_MoveSpeed = 15.
constant real OOP_TurnSpeed = 10
unit array OOP_Dummy
unit array OOP_Dummy_Target
integer array OOP_DummySlotFilled
group OOP_DummyGroup
endglobals
function OOP_MoveOrbs takes nothing returns nothing
local group g = OOP_DummyGroup
local unit temp
local integer i
local location targetPoint
local location dummyPoint
local real angle
local real angle2
local real distance
local real Xdistance
local real Ydistance
local real nudistance
local location nuPoint
call BJDebugMsg("I have pancakes")
loop
exitwhen CountUnitsInGroup(g) == 0
set i = 0
set temp = FirstOfGroup(g)
loop
exitwhen temp == OOP_Dummy[i]
set i = (i+1)
endloop
set dummyPoint = GetUnitLoc(temp)
set targetPoint = GetUnitLoc(OOP_Dummy_Target[i])
set angle = AngleBetweenPoints(targetPoint,dummyPoint)
set Xdistance = (GetLocationX(targetPoint)-GetLocationX(dummyPoint))
set Ydistance = (GetLocationY(targetPoint)-GetLocationY(dummyPoint))
set distance = SquareRoot((Xdistance * Xdistance) + (Ydistance * Ydistance))
if distance < OOP_IdealDistance then
set nudistance = distance+OOP_MoveSpeed
else
set nudistance = distance - OOP_MoveSpeed
endif
set angle2=angle+OOP_TurnSpeed
set nuPoint = PolarProjectionBJ( targetPoint, nudistance, angle2 )
call SetUnitX(temp, GetLocationX(nuPoint))
call SetUnitY(temp, GetLocationY(nuPoint))
//CLEANING UP-------------------------------------------------------------
call RemoveLocation(dummyPoint)
call RemoveLocation(targetPoint)
call RemoveLocation(nuPoint)
set temp = null
endloop
endfunction
function OOP_UnitRecycle takes unit temp, unit target returns nothing
local integer i = 0
loop
exitwhen OOP_DummySlotFilled[i] == 0
set i = (i+1)
endloop
set OOP_Dummy[i] = temp
set OOP_Dummy_Target[i] = target
set OOP_DummySlotFilled[i] = 1
call GroupAddUnit( OOP_DummyGroup, temp)
endfunction
function Trig_Orbs_Of_Protection_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == OOP_SpellID ) ) then
return false
endif
return true
endfunction
function OOP_CastTrig takes nothing returns nothing
local unit target = GetSpellTargetUnit()
local location tpoint = GetUnitLoc(target)
local unit dummy = CreateUnitAtLoc( GetOwningPlayer(GetSpellTargetUnit()), OOP_DummyID, tpoint, 0.)
call OOP_UnitRecycle( dummy, target)
endfunction
//===========================================================================
function InitTrig_Orbs_Of_Protection takes nothing returns nothing
local trigger gg_trg_Orbs_Of_Protection = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( gg_trg_Orbs_Of_Protection, 0.03 )
call TriggerAddAction( gg_trg_Orbs_Of_Protection, function OOP_MoveOrbs )
//---------------------------------------------------------------------------------------------------------------
set gg_trg_Orbs_Of_Protection = null
set gg_trg_Orbs_Of_Protection = CreateTrigger()
//---------------------------------------------------------------------------------------------------------------
call TriggerRegisterAnyUnitEventBJ( gg_trg_Orbs_Of_Protection, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Orbs_Of_Protection, Condition( function Trig_Orbs_Of_Protection_Conditions ) )
call TriggerAddAction( gg_trg_Orbs_Of_Protection, function OOP_CastTrig )
endfunction