- Joined
- Jul 3, 2011
- Messages
- 251
Hi guys, i am relatively new to JASS and i am trying to make Mirana's Arrow from DotA, however i need a little help, it worked at one point but it would hit multiple units instead of one, i changed that and now as soon as the arrow is made it gets destroyed.
There is an error i am aware of but i do not know how to solve it.
Any help with the code and efficiency would be of great use, will give rep for any helpers.
There is an error i am aware of but i do not know how to solve it.
I do not know how to get the triggering player, i do not know if it is possible to take a force by calling units in range, i have also tried creating a function which returns a force and it did not work.
JASS:
if IsUnitEnemy(FU, GetTriggerPlayer())
JASS:
function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function DGF takes nothing returns boolean
local unit FU = GetFilterUnit()
local boolean BJ = false
if IsUnitEnemy(FU, GetTriggerPlayer()) and GetWidgetLife(FU) > 0.405 and not IsUnitType(FU, UNIT_TYPE_STRUCTURE) and not IsUnitType(FU, UNIT_TYPE_MECHANICAL) and not (GetUnitAbilityLevel(FU, 'Bams') > 0) then
set BJ = true
endif
set FU = null
return BJ
endfunction
function Loop takes nothing returns nothing
local timer Timer = GetExpiredTimer()
local integer ID = GetHandleId(Timer)
local unit AU = LoadUnitHandle(udg_Hash, ID, 1)
local real Angle = LoadReal(udg_Hash, ID, 2)
local real Duration = LoadReal(udg_Hash, ID, 3)
local real SLI = LoadReal(udg_Hash, ID, 4)
local real X = GetUnitX(AU)
local real X2 = X + 25 * Cos(Angle * bj_DEGTORAD)
local real Y = GetUnitY(AU)
local real Y2 = Y + 25 * Sin(Angle * bj_DEGTORAD)
local unit DG
local unit DU
local integer SL = (R2I(SLI) / 20)
local integer ID2
if SL == 0 then
set SL = 1
endif
if Duration <= 0 or not (GetRectMinX(bj_mapInitialPlayableArea) <= X) and not (X <= GetRectMaxX(bj_mapInitialPlayableArea)) and not (GetRectMinY(bj_mapInitialPlayableArea) <= Y) and not (Y <= GetRectMaxY(bj_mapInitialPlayableArea))then
call PauseTimer(Timer)
call DestroyTimer(Timer)
call FlushChildHashtable(udg_Hash, ID)
call KillUnit(AU)
else
set Duration = Duration - 1
call SaveReal(udg_Hash, ID, 3, Duration)
call GroupEnumUnitsInRange(bj_lastCreatedGroup, X, Y, 100, Filter(function DGF))
set DG = FirstOfGroup(bj_lastCreatedGroup)
if DG == null then
set SLI = SLI + 1
call SaveReal(udg_Hash, ID, 4, SLI)
call SetUnitPosition(AU, X2, Y2)
else
set DU = CreateUnit(GetOwningPlayer(AU), 'h000', X, Y, Angle)
call UnitApplyTimedLife(DU, 'BTFL', 2.00)
call ShowUnit(DU, false)
call SetUnitAbilityLevel(DU, 'A001', SL)
call IssueTargetOrder(DU, "thunderbolt", DG)
call PauseTimer(Timer)
call DestroyTimer(Timer)
call FlushChildHashtable(udg_Hash, ID)
call KillUnit(AU)
endif
endif
set AU = null
endfunction
function Start takes nothing returns nothing
local timer Timer = CreateTimer()
local integer ID = GetHandleId(Timer)
local real SLI = 0
local real Duration = 120
local unit TU = GetTriggerUnit()
local real X = GetUnitX(TU)
local real Y = GetUnitY(TU)
local real Angle = GetUnitFacing(TU)
local unit AU = CreateUnit(GetTriggerPlayer(), 'h000', X, Y, Angle)
call SaveUnitHandle(udg_Hash, ID, 1, AU)
call SaveReal(udg_Hash, ID, 2, Angle)
call SaveReal(udg_Hash, ID, 3, Duration)
call SaveReal(udg_Hash, ID, 4, SLI)
call TimerStart(Timer, 0.05, true, function Loop)
set TU = null
set AU = null
set Timer = null
endfunction
function InitTrig_Arrow takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Start )
set udg_Hash = InitHashtable()
set t = null
endfunction
Any help with the code and efficiency would be of great use, will give rep for any helpers.