Sliding Trigger Issues

Squirel

New Member
Reaction score
13
I am working on a sliding trigger that causes a footman to slide if he is on the tile Northrend - Ice. Here is my JASS (NOT vJASS) trigger. The problem with it is that the unit simply does not slide. He walks like normal. Can anyone see the problem?

JASS:
function Trig_Slide_Boolexpr takes location l returns boolean
    return GetTerrainTypeBJ(l) == 'Nice'
endfunction

function Slide_CopyGroup takes group g returns group
    set bj_groupAddGroupDest = CreateGroup()
    call ForGroup(g, function GroupAddGroupEnum)
    return bj_groupAddGroupDest
endfunction

function Trig_Sliding_UnitCheck takes nothing returns boolean
    return ( GetUnitTypeId(GetTriggerUnit()) == 'hfoo' )
endfunction

function Trig_Sliding_Actions takes nothing returns nothing
    local group a = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Sliding_UnitCheck))
    local group c
    local unit b
    local location original
    local location new
    local real speed
    local real facing
    set c = Slide_CopyGroup(a)
    loop
        set b = FirstOfGroup(c)
        exitwhen b == null
        if Trig_Slide_Boolexpr(GetUnitLoc(b)) then
            set original = GetUnitLoc(b)
            set facing = GetUnitFacing( b )
            set speed = 300
            set new = PolarProjectionBJ(original, speed*0.03, facing)
            call SetUnitPositionLoc( b, new )
        endif
        call GroupRemoveUnitSimple( b, c )
    endloop
    call DestroyGroup( a )
    call DestroyGroup( c )
    set b = null
    call RemoveLocation ( original )
    call RemoveLocation ( new )
endfunction

//===========================================================================
function InitTrig_Sliding takes nothing returns nothing
    set gg_trg_Sliding = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Sliding, 0.03 )
    call TriggerAddAction( gg_trg_Sliding, function Trig_Sliding_Actions )
endfunction
 

Squirel

New Member
Reaction score
13
Oh... Sorry. I've seen questions about JASS triggers in here before. I'll post stuff like this in that section from now on. Thanks! But I still need help...
 

Nexor

...
Reaction score
74
Yup that's it
You need to create them anytime you make a local group variable.
Do this to the other group variables too
 

Nexor

...
Reaction score
74
Hm I don't get this part:

JASS:
function Slide_CopyGroup takes group g returns group
    set bj_groupAddGroupDest = CreateGroup()
    call ForGroup(g, function GroupAddGroupEnum)
    return bj_groupAddGroupDest
endfunction


You simply set group C to group A ?

set c = a does the same :S

And the other thing is that this function could be inlined:

JASS:
function Trig_Slide_Boolexpr takes location l returns boolean
    return GetTerrainTypeBJ(l) == 'Nice'
endfunction


Also null your groups and locations after destroying/removing them
 

Squirel

New Member
Reaction score
13
Nexor:
Actually I don't get that part either. I got it off a tutorial. It is supposed to enumerate the units in the group then set those units to a new group.

TriggerHappy:
What you posted means nothing to me. Care to elaborate?
 
Reaction score
341
Wouldn't that get ALL the units on the map, not just the footmen?

I didn't take a look at your condition, jeez you should be able to figure it out from here.

JASS:
//
function Trig_Sliding_UnitCheck takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'hfoo' )
endfunction

function Trig_Sliding_Actions takes nothing returns nothing
    local group a = CreateGroup()
    call GroupEnumUnitsInRect(a, bj_mapInitialPlayableArea, Filter(function Trig_Sliding_UnitCheck))
    ...
 

Squirel

New Member
Reaction score
13
Thanks, +rep, and thanks again for putting up with my lack of skill... I'm pretty new to JASS.

One more issue: why is it that it will not let me turn my unit like you can in sliding mazes? I don't see what would be stopping me from changing the unit's facing by right-clicking so the unit turns... Am I missing something?

I found that by lowering the rate of refresh for the trigger, SOME of the issued orders move the unit. Why not all, and is there anything I can do to make it more smooth with the lower refresh time?
 

Teach101

New Member
Reaction score
4
Thanks, +rep, and thanks again for putting up with my lack of skill... I'm pretty new to JASS.

One more issue: why is it that it will not let me turn my unit like you can in sliding mazes? I don't see what would be stopping me from changing the unit's facing by right-clicking so the unit turns... Am I missing something?

I found that by lowering the rate of refresh for the trigger, SOME of the issued orders move the unit. Why not all, and is there anything I can do to make it more smooth with the lower refresh time?

I didn't look at your trigger... and if it's the same reasons as in GUI, then it's either from moving the unit to quickly or from pausing the unit.
If it looks choppy now... decrease the distance he moves.
 
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