it shows a message x times based on ability level

jackall

You can change this now in User CP.
Reaction score
37
these are supposed to teleport a unit x.y seconds after its been ordered to move somewhere but for some reason...
JASS:
function Trig_learn_Actions takes nothing returns nothing
    if (GetLearnedSkill() == 'A000') then
      call TriggerRegisterUnitEvent( gg_trg_teleport, GetTriggerUnit(), EVENT_UNIT_ISSUED_POINT_ORDER )
    endif
endfunction

function InitTrig_learn takes nothing returns nothing
    set gg_trg_learn = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_learn, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddAction( gg_trg_learn, function Trig_learn_Actions )
endfunction


JASS:
function Trig_teleport_Actions takes nothing returns nothing
  local integer i = GetIssuedOrderId()
  local location whereTo = GetOrderPointLoc()
  local unit u = GetTriggerUnit()
  local location origin = GetUnitLoc(u)
  local real distToGo = DistanceBetweenPoints(whereTo,origin)
  local real toWait = distToGo / (GetUnitAbilityLevel(u,'A000') * 1000)
  local effect SFX
    if (i == 851986) or (i == 851971) then
      if distToGo <= 200 then
        call DisplayTextToPlayer(GetOwningPlayer(u),0,0,"Target is inside minimum range")
        return
      endif
      call IssueImmediateOrder(u,"stop")
      call TriggerSleepAction(toWait)
      set SFX = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl",whereTo)
      call SetUnitPositionLoc(u,whereTo)
      call DestroyEffect(SFX)
      call RemoveLocation(whereTo)
      call RemoveLocation(origin)
    elseif i != 851986 or i != 851971 then
      call DoNothing()
    endif
endfunction

function InitTrig_teleport takes nothing returns nothing
    set gg_trg_teleport = CreateTrigger(  )
    call TriggerAddAction( gg_trg_teleport, function Trig_teleport_Actions )
endfunction

...the second trigger shows the "Target is inside minimum range" 1/2/3 times, based on 'A000' level

edit: this could be used for a timed blink
also, the unit wont stop when its ordered
 

Nestharus

o-o
Reaction score
84
JASS:

if (GetLearnedSkill() == 'A000') then
      call TriggerRegisterUnitEvent( gg_trg_teleport, GetTriggerUnit(), EVENT_UNIT_ISSUED_POINT_ORDER )
    endif


Not sure if that would be a problem, but it looks like it'd be registering the ability every time you skilled it. If the ability is 3, it'd be running 3x, etc.


JASS:

call DoNothing()


Why...

JASS:

DistanceBetweenPoints(whereTo,origin)


why...




Shouldn't that be TriggerAddCondition? No point in using actions unless you plan on having dynamic triggers similar to Linux's grep command.

JASS:

local location whereTo = GetOrderPointLoc()


why.. lol


That's all for now. Fix up your script and I'll take another look : )
 

jackall

You can change this now in User CP.
Reaction score
37
why why why

JASS:
call DoNothing()
not sure about this one
JASS:
DistanceBetweenPoints(whereTo,origin)
because its distance based(notice the TriggerSleepAction line)
why condition?
JASS:
local location whereTo = GetOrderPointLoc()
because that trigger has to know where the unit is supposed to move

EDIT: thanks for the tip, it looks like the first one was the problem
JASS:
function Trig_learn_Actions takes nothing returns nothing
    if (GetLearnedSkill() == 'A000') and GetUnitAbilityLevel(GetTriggerUnit(),'A000') == 1 then
      call TriggerRegisterUnitEvent( gg_trg_teleport, GetTriggerUnit(), EVENT_UNIT_ISSUED_POINT_ORDER )
    endif
endfunction

function InitTrig_learn takes nothing returns nothing
    set gg_trg_learn = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_learn, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddAction( gg_trg_learn, function Trig_learn_Actions )
endfunction

i added the GetUnitAbilityLevel so that it will only register the event once
 

Nestharus

o-o
Reaction score
84
DoNothing() does nothing.. so why are you calling it...


DistanceBetweenPoints is not a native, it's a function... go into Function List and retrieve the contents and put them in inside of using the function :eek:.



You don't need a location handle unless you plan on using a given coordinate a lot, like in a trigger for 10 minutes or something. Just use x, y coordinates. GetOrderPointX and GetOrderPointY.

And why condition? Because it's faster, lol. It has to go through a whole mess to get to the actions, so only use actions if you must : ).


Oh yea, and don't use this-
JASS:


Use SetUnitX and SetUnitY. They are better : ).


Finally, add comments to the line where the script bugs.

I'm assuming it's this line, but add comments to clarify-
JASS:
      if distToGo <= 200 then
        call DisplayTextToPlayer(GetOwningPlayer(u),0,0,"Target is inside minimum range")
        return
      endif


And if it is that line, that means this is the issue-
JASS:
local real distToGo = DistanceBetweenPoints(whereTo,origin)



Oh yea, and get rid of this-
JASS:
call TriggerSleepAction(toWait)


Use timers mate : )



----------------------
Edit
----------------------

Ahh, apparently you solved the problem, good job : ).

Oh well, those tips for your script are still very handy ^^
 

jackall

You can change this now in User CP.
Reaction score
37
im just at the beginning :p... how do you expect me to use functions/natives that take up less memory than others? im still learning it although im finding the use of locations instead of coordinates alot easier
 
General chit-chat
Help Users

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top