First things first. I have never used PUI or implemented a skill that needed it, i have just stayed away from it. However i think the time has come when things would be a lot simpler if i use it.
For example:
In the above skill (In Conditions2 to be exact) i need to check whether the summoning unit == to the unit "dum" in the Update function.
Therefore i think i need PUI, but im not sure where to begin using it. I have read Cohadars "tutorial", but im not too smart, so i need it explain to me as if you were talking to an idiot.
For example:
JASS:
scope SoulTrail initializer Init
globals
private constant integer Abil_id = 039;A001039;
private constant integer Abil2_id = 039;A002039;
private constant integer Dummy_id = 039;u000039;
private constant real Interval = 0.10
private constant real Behind_dist = 50.00
private boolexpr TrueFilter = null
endglobals
//=======================================================================
private function Maxdist takes integer lvl returns real
return 1800.00-(200.00*lvl)
endfunction
//=======================================================================
private function DistanceXY takes real x1, real y1, real x2, real y2 returns real
return SquareRoot((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
endfunction
//=======================================================================
private function TrueFilt takes nothing returns boolean
return true
endfunction
//=======================================================================
private struct Data
timer t
trigger trig
unit cast
real castx
real casty
real dist
endstruct
//=======================================================================
private function Conditions2 takes nothing returns boolean
local Data d = GetTriggerStructA(GetTriggeringTrigger())
return IsUnitIllusion(GetTriggerUnit()) == true and GetUnitTypeId(GetSummoningUnit()) == Dummy_id and GetOwningPlayer(GetSummoningUnit()) == GetOwningPlayer(d.cast)
endfunction
//=======================================================================
private function Actions2 takes nothing returns nothing
local Data d = GetTriggerStructA(GetTriggeringTrigger())
local unit u = GetSummonedUnit()
call SetUnitPathing(u,false)
call SetUnitPathing(d.cast,false)
call SetUnitX(u,GetUnitX(d.cast)+Behind_dist*Cos((GetUnitFacing(d.cast)+180.00)*bj_DEGTORAD))
call SetUnitY(u,GetUnitY(d.cast)+Behind_dist*Sin((GetUnitFacing(d.cast)+180.00)*bj_DEGTORAD))
call SetUnitPathing(u,true)
call SetUnitPathing(d.cast,true)
set u = null
endfunction
//=======================================================================
private function Update takes nothing returns boolean
local Data d = GetTimerData(GetExpiredTimer())
local real x = GetUnitX(d.cast)
local real y = GetUnitY(d.cast)
local real dist = DistanceXY(d.castx,d.casty,x,y)
local integer lvl = GetUnitAbilityLevel(d.cast,Abil_id)
local unit dum
set d.dist = d.dist + dist
if d.dist >= Maxdist(lvl) then
debug call BJDebugMsg(R2S(d.dist))
set dum = CreateUnit(GetOwningPlayer(d.cast),Dummy_id,x,y,0.00)
call UnitAddAbility(dum,Abil2_id)
call SetUnitAbilityLevel(dum,Abil2_id,lvl)
call IssueTargetOrderById(dum,852274,d.cast)
set d.dist = 0.00
endif
set d.castx = x
set d.casty = y
set dum = null
return false
endfunction
//=======================================================================
private function Actions takes nothing returns nothing
local unit cast = GetTriggerUnit()
local Data d = Data.create()
local integer i = 0
if GetLearnedSkill() == Abil_id and GetUnitAbilityLevel(cast,Abil_id) == 1 and IsUnitIllusion(cast) == false then
set d = Data.create()
set d.cast = cast
set d.castx = GetUnitX(d.cast)
set d.casty = GetUnitY(d.cast)
set d.t = NewTimer()
call SetTimerData(d.t,d)
call TimerStart(d.t,Interval,true,function Update)
set d.trig = CreateTrigger()
call SetTriggerStructA(d.trig,d)
loop
call TriggerRegisterPlayerUnitEvent(d.trig,Player(i),EVENT_PLAYER_UNIT_SUMMON,TrueFilter)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(d.trig,Condition(function Conditions2))
call TriggerAddAction(d.trig,function Actions2)
endif
endfunction
//=======================================================================
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
local integer i = 0
set TrueFilter = Filter(function TrueFilt)
loop
call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_HERO_SKILL,TrueFilter)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction(trig,function Actions)
endfunction
endscope
In the above skill (In Conditions2 to be exact) i need to check whether the summoning unit == to the unit "dum" in the Update function.
Therefore i think i need PUI, but im not sure where to begin using it. I have read Cohadars "tutorial", but im not too smart, so i need it explain to me as if you were talking to an idiot.