Sliding Trigger Won't Work

ShadowInTheD

Active Member
Reaction score
12
I basically have 2 triggers, one is supposed to make a wisp for each user, and set the wisp = udg_TempUnit in a loop, and it's supposed to create a repeating timer. The first trigger sets up the second. The second uses the location of udg_TempUnit to move the unit to it's location offset by 10 facing it's direction, and it's supposed to check this every 3 seconds. Is there any problems, and if so, can you help me? Thanks in advance, + Rep

EDIT: There's 2 things that aren't actually happening, the text in the second trigger isn't displaying, and the units don't slide!

Here are my 2 triggers

JASS:
function Test_My_Skills_Actions takes nothing returns nothing
local integer i  = 0
local integer I = GetPlayers()
local location l = GetRectCenter(GetPlayableMapRect())
loop
exitwhen i>I
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call CreateNUnitsAtLoc(1,'ewsp',Player(i),l,bj_UNIT_FACING)
set udg_TempUnit<i> = GetLastCreatedUnit()
call DisplayTextToForce (GetPlayersAll(),&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
set i = i + 1
endif
endloop
call StartTimerBJ(udg_Timer,true,.03)
call RemoveLocation( l )
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
call TriggerAddAction(t, function Test_My_Skills_Actions)
endfunction</i>


JASS:
function Ice_Skating_Actions takes nothing returns nothing
local location l
local integer i = 0
local integer I = GetPlayers()
loop
exitwhen i&gt;I
set l = GetUnitLoc(udg_TempUnit<i>)
if GetTerrainTypeBJ(l) == &#039;Nice&#039; then
call SetUnitPositionLoc(udg_TempUnit<i>,PolarProjectionBJ(l,10,bj_UNIT_FACING))
set i = i + 1
call RemoveLocation(l)
call DisplayTextToForce(GetPlayersAll(),&quot;Does this work???&quot;)
endif
endloop
endfunction

//=====================================
function InitTrig_Ice_Skating takes nothing returns nothing
local trigger p = CreateTrigger()
call TriggerRegisterTimerExpireEvent(p,udg_Timer)
call TriggerAddAction(p,function Ice_Skating_Actions)
endfunction</i></i>
 

Charapanga

New Member
Reaction score
46
I dont have the editor infront of me but i think
JASS:
local integer I = GetPlayers()

does not return an integer
you might wanna change it with bj_MAX_PLAYER_SLOTS <- i'm not sure that's the right syntax, check under constants in your Function list.
 

ShadowInTheD

Active Member
Reaction score
12
I for sure know that the local integer I = GetPlayers() DOES work... it makes the wisp for the players that are playing.

EDIT: I know 2 possible things can be wrong, TempUnit isn't getting set to last created unit, or the timer isn't repeating or starting.. The text isn't displaying, so I don't know which 1 it actually is. Also, there could be something wrong with the 2nd condition checking terrain type.
 

Vetadors

New Member
Reaction score
1
There are a simple trigger u can do:
Trigger:
  • Ice Lol
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Icecrown Glacier - Ice
            • Then - Actions
              • Set Temp_Location = ((Position of Unit) offset by 10.00 towards (Facing of Unit) degrees)
              • Unit - Move (Picked unit) instantly to Temp_Location
            • Else - Actions
              • Custom script: call RemoveLocation(udg_TempPoint)
 

ShadowInTheD

Active Member
Reaction score
12
Number 1, I wanted to do it in JASS ><, and 2, that trigger will leak... and it's not MPI... if I wanted to do it in GUI, I would have...... I want to know why the JASS trigger won't work, not an alternative.
 

darkbeer

Beer is Good!
Reaction score
84
well you shouldt use the ugly BJs and theres no need for 2 triggers^^

JASS:
function Timer takes nothing returns nothing
local location l
local integer i = 0
local integer I = GetPlayers()
loop
exitwhen i&gt;I
set l = GetUnitLoc(udg_TempUnit<i>)
if GetTerrainTypeBJ(l) == &#039;Nice&#039; then //you sure this is called &#039;Nice&#039;? xD
call SetUnitPositionLoc(udg_TempUnit<i>,PolarProjectionBJ(l,10,bj_UNIT_FACING)) //LEAAAAAAAAAAAAAAK <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" /> (polar projection creates another point that should be cleaned)
set i = i + 1
call RemoveLocation(l)
call DisplayTextToForce(GetPlayersAll(),&quot;Does this work???&quot;) //put it outside the loop to see if GetPlayers() might return 0
endif
endloop
endfunction

function Test_My_Skills_Actions takes nothing returns nothing
local integer i  = 0
local integer I = GetPlayers()
local location l = GetRectCenter(GetPlayableMapRect())
loop
exitwhen i&gt;I
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call CreateNUnitsAtLoc(1,&#039;ewsp&#039;,Player(i),l,bj_UNIT_FACING)
set udg_TempUnit<i> = GetLastCreatedUnit()
call DisplayTextToForce (GetPlayersAll(),&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
set i = i + 1
endif
endloop
call TimerStart(udg_Timer,.03,true, function Timer) //no BJ, no need for a 2nd trigger^^
call RemoveLocation( l )
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
call TriggerAddAction(t, function Test_My_Skills_Actions)
endfunction

</i></i></i>


you really could improve this^^
mby use a group instead think its easier and makes things MUI instead of MPI :)
and i hope youre using newGen then use the global block instead of the udg_ variables^^

well i was bored so i thought i should show you how it could look like^^

JASS:
scope Sliding
//########################################################################

globals
    private group SlidingUnits  = CreateGroup()
    private timer Timer         = CreateTimer()
endglobals

private function GroupLoop takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real X = GetUnitX(u)
    local real Y = GetUnitY(u)
    
    if GetTerrainType(X,Y) == &#039;Nice&#039; then
        call SetUnitX(u, X + 10 * Cos(GetUnitFacing(u) * bj_DEGTORAD))
        call SetUnitY(u, X + 10 * Cos(GetUnitFacing(u) * bj_DEGTORAD))
        call BJDebugMsg(&quot;Moving &quot; + GetUnitName(u) + &quot; to 10 towards its facing&quot;)
    endif
    
    set u = null
endfunction

private function Loop takes nothing returns nothing    
    call ForGroup(SlidingUnits, function GroupLoop)
endfunction

private function Actions takes nothing returns nothing
    local integer i  = 0
    local integer I = GetPlayers()
    local real X = GetRectCenterX(bj_mapInitialPlayableArea)
    local real Y = GetRectCenterY(bj_mapInitialPlayableArea)
    local unit u
    
    loop
        exitwhen i&gt;I
        if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
            set u = CreateUnit(Player(i),&#039;ewsp&#039;,X,Y,bj_UNIT_FACING)
            call GroupAddUnit(SlidingUnits, u)
            call BJDebugMsg(&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
        endif
        set i = i + 1
    endloop
    
    set u = null
    call TimerStart(Timer,.03,true, function Loop)
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

//####################################################
endscope
 

ShadowInTheD

Active Member
Reaction score
12
Ofc, you never told me how to fix it nor what the problem was, and MUI isn't needable, and I will clean up leaks later >.>...
 

darkbeer

Beer is Good!
Reaction score
84
my bad, just used comments^^

put the Message outside the loop to see if the 2nd trigger is actually fired

check if the id of the terrain is correct! thats my guess, since GetPlayers() worked in the first trigger. (one of them should be causing the problem)

add an else to the terrain type check and under it a message.

else it should work
 

darkbeer

Beer is Good!
Reaction score
84
rofl
just tested and found out:
besides that my testing trigger worked fine.

JASS:
function Test_My_Skills_Actions takes nothing returns nothing
local integer i  = 0
local integer I = GetPlayers()
local location l = GetRectCenter(GetPlayableMapRect())
loop
exitwhen i&gt;I
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call CreateNUnitsAtLoc(1,&#039;ewsp&#039;,Player(i),l,bj_UNIT_FACING)
set udg_TempUnit<i> = GetLastCreatedUnit()
call DisplayTextToForce (GetPlayersAll(),&quot;A Wisp has been created for &quot; + GetPlayerName(Player(i)) )
endif

set i = i + 1 &lt;-- outside if

endloop
call StartTimerBJ(udg_Timer,true,.03)
call RemoveLocation( l )
endfunction

//=======================
function InitTrig_Test_My_Skills takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,Player(0),&quot;-start&quot;,true)
call TriggerAddAction(t, function Test_My_Skills_Actions)
endfunction


</i>


move the set i = i +1 outside the if! ofc. else your loop never gets greater than GetPlayers() and finishes.

sorry always thinking too coplicated .... :banghead:
and please clean your PolarProjectionBJ leak^^

Edit.: rofl copyed wron trigger now its fine.
 

ShadowInTheD

Active Member
Reaction score
12
That wasn't even the problem.......... =( I tested it moving the i+1 thing, which would actually, never work....... it's supposed to be in the if.
 

darkbeer

Beer is Good!
Reaction score
84
i tested exactly your trigger and it worked with only changing that.

if you dont believe me add more debug messages and see for yourself.
 

ShadowInTheD

Active Member
Reaction score
12
Umm, i fucking tested it, and it fucking super lagged my comp...............................................................
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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