move part of ability not working, unsure why

afisakov

You can change this now in User CP.
Reaction score
37
I am working on adding an AOE hex to a tower-defense map. I based it off a triggered-hex another unit has in-game. So far I got the hex to work but cannot force the unit to resume moving again afterwards.
main ability:
JASS:
function Trig_hex_aoe_Conditions takes nothing returns boolean
  return (GetUnitTypeId(GetAttacker())=='o022') and GetUnitState(GetAttacker(),UNIT_STATE_MANA)>100.
endfunction

function hithexc takes nothing returns boolean
   return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetAttacker())) and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0.405 and (GetUnitAbilityLevel(GetFilterUnit(), 'ACmi') < 1) and (GetUnitAbilityLevel(GetFilterUnit(), 'Bams') < 1)
endfunction

function forcemove2 takes unit u1 returns nothing
call TriggerSleepAction(0.2)
call DisplayTextToForce( GetPlayersAll(), "1" )
   set udg_TempPoint = GetRectCenter(udg_Regions[GetUnitUserData(u1)])
   call IssuePointOrderLoc( u1, "move", udg_TempPoint )
   call RemoveLocation(udg_TempPoint)
endfunction
function forcemove2s takes unit u1, integer i returns nothing
local integer tr
call DisplayTextToForce( GetPlayersAll(), "1" )
if IsUnitInGroup(u1, udg_Red) then
   set tr=1
   elseif IsUnitInGroup(u1, udg_Blue) then
   set tr=2
   elseif IsUnitInGroup(u1, udg_Teal) then
   set tr=3
   elseif IsUnitInGroup(u1, udg_Purple) then
   set tr=4
   endif
   call PolledWait(i+0.1)
   set udg_TempPoint = GetRectCenter(udg_SiegeRegions[tr])
   call IssuePointOrderLoc( u1, "attack", udg_TempPoint )
   call RemoveLocation(udg_TempPoint)
endfunction

function hexem takes nothing returns nothing
local unit u=GetEnumUnit()
local unit u2
if IsUnitType(u, UNIT_TYPE_SUMMONED) then
   call UnitDamageTargetBJ(GetAttacker(),u, ( 4000.* udg_abp[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
else
   set u2=CreateUnit(GetOwningPlayer(GetAttacker()), 'n00C', GetUnitX(u),GetUnitY(u), 270.0)
   call UnitAddAbilityBJ( 'A02C', u2 )
   call SetUnitAbilityLevel(u2, 'A02C', udg_inthex)
   call IssueTargetOrderBJ( u2, "hex", u )
   call UnitApplyTimedLife(u2, 'BTLF', .5)
<b>   call DisplayTextToForce( GetPlayersAll(), &quot;0&quot; )
   if udg_Siege then
     call forcemove2s(u,udg_inthex)
   else
     call forcemove2(u)
   endif</b>
endif
set u=null
set u2=null
endfunction

function Trig_hex_aoe_Actions takes nothing returns nothing
local location tp1
local real hexl
local group tg
local integer pn=GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))
local real cx
if (GetUnitAbilityLevel(GetTriggerUnit(), &#039;ACmi&#039;) &lt; 1) and (GetUnitAbilityLevel(GetTriggerUnit(), &#039;Bams&#039;) &lt; 1) then
   set hexl=6.*Pow(.95,udg_hlev)*udg_abp[pn]
   set udg_inthex=R2I(hexl+.5)
   set cx=200*udg_mypc[pn]
   set tp1=GetUnitLoc(GetTriggerUnit())
   set tg=GetUnitsInRangeOfLocMatching(cx,tp1,Condition(function hithexc))
   call ForGroup(tg,function hexem)
   call DestroyGroup(tg)
   call RemoveLocation (tp1)
   call SetUnitState(GetAttacker(), UNIT_STATE_MANA, GetUnitState(GetAttacker(),UNIT_STATE_MANA)-100*(2.-udg_mypc[pn]) )
endif
set tg=null
set tp1=null
endfunction

//===========================================================================
function InitTrig_hex_aoe takes nothing returns nothing
   set gg_trg_hex_aoe = CreateTrigger(  )
   call TriggerRegisterPlayerUnitEventSimple( gg_trg_hex_aoe, Player(11), EVENT_PLAYER_UNIT_ATTACKED )
   call TriggerAddCondition( gg_trg_hex_aoe, Condition( function Trig_hex_aoe_Conditions ) )
   call TriggerAddAction( gg_trg_hex_aoe, function Trig_hex_aoe_Actions )
endfunction

I tried to use the displaytexttoplayersall function to troubleshoot, but now got stuck. I cannot figure out why it displays "0" repeatedly (multiple units in area), but not the "1".

the ability it was based on, in which the move again function does work:
JASS:
function Trig_Hexing_Tower_2_Conditions takes nothing returns boolean
   if not( (GetUnitTypeId(GetAttacker())==&#039;o011&#039;) or(GetUnitTypeId(GetAttacker())==&#039;o012&#039;) or(GetUnitTypeId(GetAttacker())==&#039;o015&#039;) ) then
     return false
   endif
   if GetUnitStateSwap(UNIT_STATE_MANA, GetAttacker())&lt;100. then
     return false
  endif
  return true
endfunction

function forcemove takes unit u1 returns nothing
call TriggerSleepAction(0.2)
   set udg_TempPoint = GetRectCenter(udg_Regions[GetUnitUserData(u1)])
   call IssuePointOrderLoc( u1, &quot;move&quot;, udg_TempPoint )
   call RemoveLocation(udg_TempPoint)
endfunction
function forcemoves takes unit u1, integer i returns nothing
local integer tr
if IsUnitInGroup(u1, udg_Red) then
   set tr=1
   elseif IsUnitInGroup(u1, udg_Blue) then
   set tr=2
   elseif IsUnitInGroup(u1, udg_Teal) then
   set tr=3
   elseif IsUnitInGroup(u1, udg_Purple) then
   set tr=4
   endif
   call PolledWait(i+0.1)
   set udg_TempPoint = GetRectCenter(udg_SiegeRegions[tr])
   call IssuePointOrderLoc( u1, &quot;attack&quot;, udg_TempPoint )
   call RemoveLocation(udg_TempPoint)
endfunction

function Trig_Hexing_Tower_2_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local unit u2
local real hexl
if (GetUnitAbilityLevel(u, &#039;BOhx&#039;) &lt; 1) and GetUnitUserData(GetAttacker())==0 then
if (GetUnitAbilityLevel(u, &#039;ACmi&#039;) &lt; 1) and (GetUnitAbilityLevel(u, &#039;Bams&#039;) &lt; 1) then
   if IsUnitType(u, UNIT_TYPE_SUMMONED) then
   call UnitDamageTargetBJ(GetAttacker(),u, ( 900.* udg_abp[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
   else
   set u2=CreateUnit(GetOwningPlayer(GetAttacker()), &#039;n00C&#039;, GetUnitX(u),GetUnitY(u), 270.0)
   call UnitAddAbilityBJ( &#039;A02C&#039;, u2 )
   set hexl=10.*Pow(.95,udg_hlev)*udg_abp[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))]
   call SetUnitAbilityLevel(u2, &#039;A02C&#039;, R2I(hexl+.5))
   call IssueTargetOrderBJ( u2, &quot;hex&quot;, u )
   call UnitApplyTimedLife(u2, &#039;BTLF&#039;, .5)
   if udg_Siege then
     call forcemoves(u,R2I(hexl+.5))
   else
     call forcemove(u)
   endif
   endif
   call SetUnitState(GetAttacker(), UNIT_STATE_MANA, GetUnitState(GetAttacker(),UNIT_STATE_MANA)-100*(2.-udg_mypc[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))]) )
endif
endif
set u=null
set u2=null
endfunction

//===========================================================================
function InitTrig_Hexing_Tower_2 takes nothing returns nothing
  set gg_trg_Hexing_Tower_2 = CreateTrigger(  )
  call TriggerRegisterPlayerUnitEventSimple( gg_trg_Hexing_Tower_2, Player(11), EVENT_PLAYER_UNIT_ATTACKED )
  call TriggerAddCondition( gg_trg_Hexing_Tower_2, Condition( function Trig_Hexing_Tower_2_Conditions ) )
  call TriggerAddAction( gg_trg_Hexing_Tower_2, function Trig_Hexing_Tower_2_Actions )
endfunction
ps. udg_siege is a boolean, game does not give me a syntax error when saving in world editor, and once again the hex itself works, something goes wrong after the display "0" command and the display "1" command does not run.

Thanks in advance for the help
 
Last edited:

afisakov

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

JASS:


in a callback.
Thanks for the tip, unfortunately it only half-fixes my problem.
Removing the wait makes the game message appear properly, but the move still does not work.
I tested the change on the base ability trigger, and removing the wait there made it stop working. It seems I need the delay to get units to obey orders after they have been hexed, simultaneous orders fail.

Any ideas on a workaround? or why the triggersleepaction was ok in the base trigger?

p.s. I already tried using PolledWait and it created the same problem.
 

jonas

You can change this now in User CP.
Reaction score
66
Any ideas on a workaround?
Wait before the callback.

or why the triggersleepaction was ok in the base trigger?
Because it was not in a callback.

p.s. I already tried using PolledWait and it created the same problem.
Because it is a TriggerSleepAction.

Maybe you will understand better if you imagine the callback to be executed as a loop. Unit n+1 is only considered once unit n has been completely processed. So if you wait in the callback, then the waits would accumulate, which is certainly not what you want.


Oh, another thing. If you have to do something, then wait; or you have to wait repeatedly, you can use callback, wait, callback; or a timer and a global group/list of groups, where the callback of the timer runs the ForGroup.
 
Last edited:

afisakov

You can change this now in User CP.
Reaction score
37
Maybe you will understand better if you imagine the callback to be executed as a loop. Unit n+1 is only considered once unit n has been completely processed. So if you wait in the callback, then the waits would accumulate, which is certainly not what you want.


Oh, another thing. If you have to do something, then wait; or you have to wait repeatedly, you can use callback, wait, callback; or a timer and a global group/list of groups, where the callback of the timer runs the ForGroup.

Thank you!I had assumed that since the wait was in a different function it would not affect the callforgroup function. but thinking of it as 1 big loop really helped me visualize the problem. I rebuilt the trigger based on more transparent loops and finally got it to work :)
JASS:
function Trig_hex_aoe_Conditions takes nothing returns boolean
  return (GetUnitTypeId(GetAttacker())==&#039;o022&#039;) and GetUnitState(GetAttacker(),UNIT_STATE_MANA)&gt;100.
endfunction

function hithexc takes nothing returns boolean
   return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetAttacker())) and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)&gt;0.405 and (GetUnitAbilityLevel(GetFilterUnit(), &#039;ACmi&#039;) &lt; 1) and (GetUnitAbilityLevel(GetFilterUnit(), &#039;Bams&#039;) &lt; 1)
endfunction

function Trig_hex_aoe_Actions takes nothing returns nothing
local location tp1
local real hexl
local group tg
local group tg2=CreateGroup()
local unit u
local unit u2
local integer pn=GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))
local integer i
local real cx
if (GetUnitAbilityLevel(GetTriggerUnit(), &#039;ACmi&#039;) &lt; 1) and (GetUnitAbilityLevel(GetTriggerUnit(), &#039;Bams&#039;) &lt; 1) then
   set hexl=6.*Pow(.95,udg_hlev)*udg_abp[pn]
   if IsUnitType(GetTriggerUnit(), UNIT_TYPE_MECHANICAL) then
     set hexl=hexl*.7
   endif
   if udg_Siege then
     set hexl=hexl*.65
   endif
   if udg_Level==41 then
     set hexl=hexl*.6
   endif
   set udg_inthex=R2I(hexl+.5)
   set cx=240*udg_abp[pn]
   set tp1=GetUnitLoc(GetTriggerUnit())
   set tg=GetUnitsInRangeOfLocMatching(cx,tp1,Condition(function hithexc))
   call RemoveLocation (tp1)
   loop
     set u=FirstOfGroup(tg)
     exitwhen u==null
     call GroupRemoveUnit(tg, u)
     call GroupAddUnit(tg2, u)
     if IsUnitType(u, UNIT_TYPE_SUMMONED) then
       call UnitDamageTargetBJ(GetAttacker(),u, ( 4000.* udg_abp[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
     else
       set u2=CreateUnit(GetOwningPlayer(GetAttacker()), &#039;n00C&#039;, GetUnitX(u),GetUnitY(u), 270.0)
       call UnitAddAbilityBJ( &#039;A02C&#039;, u2 )
       call SetUnitAbilityLevel(u2, &#039;A02C&#039;, udg_inthex)
       call IssueTargetOrderBJ( u2, &quot;hex&quot;, u )
       call UnitApplyTimedLife(u2, &#039;BTLF&#039;, .5)
     endif
     set u=null
   endloop
  
   if udg_Siege then
   call PolledWait(udg_inthex+0.1)
   loop
     set u=FirstOfGroup(tg2)
     exitwhen u==null
     call GroupRemoveUnit(tg2, u)
     if IsUnitInGroup(u, udg_Red) then
     set i=1
     elseif IsUnitInGroup(u, udg_Blue) then
     set i=2
     elseif IsUnitInGroup(u, udg_Teal) then
     set i=3
     elseif IsUnitInGroup(u, udg_Purple) then
     set i=4
     endif
     set udg_TempPoint = GetRectCenter(udg_SiegeRegions<i>)
     call IssuePointOrderLoc( u, &quot;attack&quot;, udg_TempPoint )
     call RemoveLocation(udg_TempPoint)
     set u=null
   endloop
   else
   call PolledWait(0.2)
   loop
     set u=FirstOfGroup(tg2)
     exitwhen u==null
     call GroupRemoveUnit(tg2, u)
     set udg_TempPoint = GetRectCenter(udg_Regions[GetUnitUserData(u)])
     call IssuePointOrderLoc( u, &quot;move&quot;, udg_TempPoint )
     call RemoveLocation(udg_TempPoint)   
     set u=null
   endloop
   endif
   
   call DestroyGroup(tg)
   call DestroyGroup(tg2)
   call SetUnitState(GetAttacker(), UNIT_STATE_MANA, GetUnitState(GetAttacker(),UNIT_STATE_MANA)-100*(2.-udg_mypc[pn]) )
endif
set tg=null
set tg2=null
set tp1=null
set u2=null
endfunction

//===========================================================================
function InitTrig_hex_aoe takes nothing returns nothing
   set gg_trg_hex_aoe = CreateTrigger(  )
   call TriggerRegisterPlayerUnitEventSimple( gg_trg_hex_aoe, Player(11), EVENT_PLAYER_UNIT_ATTACKED )
   call TriggerAddCondition( gg_trg_hex_aoe, Condition( function Trig_hex_aoe_Conditions ) )
   call TriggerAddAction( gg_trg_hex_aoe, function Trig_hex_aoe_Actions )
endfunction
</i>
Posted the fixed version just in case someone was interested.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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