Cokemonkey11
Spell Reviewer
- Joined
- May 9, 2006
- Messages
- 3,575
See http://www.hiveworkshop.com/forums/1145080-post3.html for problem.
Last edited:
scope fireboltNew
struct structFirebolt
real direction
unit bird
real distance
unit target
endstruct
globals
private timer time
private structFirebolt array sDatabase
private integer dbIndex=0
endglobals
function fireboltNewT takes nothing returns nothing
local integer iLoop=0
local structFirebolt sCurrent
local group close=CreateGroup()
loop
exitwhen iLoop>=dbIndex
set sCurrent=sDatabase[iLoop]
call SetUnitPositionLoc(sCurrent.bird,PolarProjectionBJ(GetUnitLoc(sCurrent.bird),20,sCurrent.direction))
call SetUnitPositionLoc(sCurrent.bird,PolarProjectionBJ(GetUnitLoc(sCurrent.bird),6,AngleBetweenPoints(GetUnitLoc(sCurrent.bird),GetUnitLoc(sCurrent.target))))
call GroupEnumUnitsInRangeOfLoc(close,GetUnitLoc(sCurrent.bird),75,null)
loop
exitwhen FirstOfGroup(close)==null
if GetOwningPlayer(FirstOfGroup(close))!=GetOwningPlayer(sCurrent.bird) and IsPlayerAlly(GetOwningPlayer(FirstOfGroup(close)),GetOwningPlayer(sCurrent.bird))!=true then
call UnitDamageTarget(sCurrent.bird,FirstOfGroup(close),10,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(close,FirstOfGroup(close))
endloop
call DestroyGroup(close)
set sCurrent.distance=sCurrent.distance+20
if sCurrent.distance>1600 then
set sDatabase[dbIndex]=sDatabase[iLoop]
set dbIndex=dbIndex-1
call KillUnit(sCurrent.bird)
endif
set iLoop=iLoop+1
if dbIndex==0 then
call DestroyTimer(time)
endif
endloop
endfunction
function fireboltNewC takes nothing returns boolean
return GetSpellAbilityId()=='A000'
endfunction
function fireboltNewA takes nothing returns nothing
local structFirebolt sTemp=structFirebolt.create()
local location target=PolarProjectionBJ(GetUnitLoc(GetSpellAbilityUnit()),75,GetUnitFacing(GetSpellAbilityUnit()))
local group getTarget=CreateGroup()
set sTemp.direction=GetUnitFacing(GetSpellAbilityUnit())
set sTemp.bird=CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(target),GetLocationY(target),sTemp.direction)
set sTemp.distance=0
call GroupEnumUnitsInRangeOfLoc(getTarget,GetSpellTargetLoc(),200,null)
set sTemp.target=getRandU(getTarget)
if dbIndex==0 then
set time=CreateTimer()
call TimerStart(time,.03,true,function fireboltNewT)
endif
set sDatabase[dbIndex]=sTemp
set dbIndex=dbIndex+1
call DestroyGroup(getTarget)
endfunction
function InitTrig_fireboltNew takes nothing returns nothing
set gg_trg_fireboltNew=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_fireboltNew,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_fireboltNew,Condition(function fireboltNewC))
call TriggerAddAction(gg_trg_firebolt,function fireboltNewA)
endfunction
endscope
function fireboltNewA takes nothing returns nothing
local structFirebolt sTemp=structFirebolt.create()
local location target=PolarProjectionBJ(GetUnitLoc(GetSpellAbilityUnit()),75,GetUnitFacing(GetSpellAbilityUnit()))
local group getTarget=CreateGroup()
call BJDebugMsg("Locals declared")
set sTemp.direction=GetUnitFacing(GetSpellAbilityUnit())
set sTemp.bird=CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()),'h001',GetLocationX(target),GetLocationY(target),sTemp.direction)
set sTemp.distance=0
call BJDebugMsg("Struct members set")
call GroupEnumUnitsInRangeOfLoc(getTarget,GetSpellTargetLoc(),200,null)
set sTemp.target=getRandU(getTarget)
call BJDebugMsg("Group enumerated")
if dbIndex==0 then
set time=CreateTimer()
call TimerStart(time,.03,true,function fireboltNewT)
endif
set sDatabase[dbIndex]=sTemp
set dbIndex=dbIndex+1
call BJDebugMsg("end")
call DestroyGroup(getTarget)
endfunction
call TriggerAddCondition(gg_trg_fireboltNew,Condition(function fireboltNewC))
call TriggerAddAction(gg_trg_firebolt,function fireboltNewA)