• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Modify Code

Status
Not open for further replies.
Level 13
Joined
Jun 10, 2007
Messages
780
Can someone modify these codes so that instead of making units slide on northrend ice to slide on lordaeron summer dirt?

JASS:
function Trig_Slides_Actions takes nothing returns nothing
    local group g1
    local group g2
    local location p
    local location p2
    local unit u
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 11
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set g1 = GetUnitsOfPlayerAndTypeId(ConvertedPlayer(GetForLoopIndexA()), 'hpea')
        set u = GroupPickRandomUnit(g1)
        set p = GetUnitLoc(u)
        if ( IsUnitAliveBJ(u) == true ) then
            if ( GetTerrainTypeBJ(p) == 'Nice' ) then
                set p2 = PolarProjectionBJ(p,7, GetUnitFacing(u))
                call SetUnitPositionLoc( u, p2 )
                call RemoveLocation( p2 )
            endif
        endif
        call RemoveLocation( p )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction
function InitTrig_Slides takes nothing returns nothing
    set gg_trg_Slides = CreateTrigger(  )

    call TriggerRegisterTimerEventPeriodic( gg_trg_Slides, 0.02 )
    call TriggerAddAction( gg_trg_Slides, function Trig_Slides_Actions )
endfunction

Can you please change this one to lordaeron summer dirt as well?

JASS:
function Trig_Skate_Conditions takes nothing returns boolean
    if ( GetBooleanOr(  GetIssuedOrderIdBJ() == String2OrderIdBJ("smart") , GetIssuedOrderIdBJ() == String2OrderIdBJ("move") ) ) then
        return true
    endif
    return false
endfunction

function Trig_Skate_Actions takes nothing returns nothing
    local location p
    local location p2
    set p = GetUnitLoc(GetOrderedUnit())
    if ( GetTerrainTypeBJ(p) == 'Nice' ) then
        set p2 = GetOrderPointLoc()
        call SetUnitPositionLocFacingBJ( GetTriggerUnit(), PolarProjectionBJ(p, 1.00, DistanceBetweenPoints(p, p2)), AngleBetweenPoints(p, p2) )
        call RemoveLocation( p2 )
    endif
    call RemoveLocation( p )
endfunction

function InitTrig_Skate takes nothing returns nothing
    set gg_trg_Skate = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Skate, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddCondition( gg_trg_Skate, Condition( function Trig_Skate_Conditions ) )
    call TriggerAddAction( gg_trg_Skate, function Trig_Skate_Actions )
endfunction
 
Last edited by a moderator:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
Yes, both jass scripts are run by the trigger they are in, and thus turning it on and off turns them on and off.

WARNING
The top script leaks 250 (50 runs per second leaking 5 each) non nulled locals a second and 550 (50 runs per second looping 11 times per run leaking 1 per loop) groups a second.

The bottom script leaks 2 non nulled locals a fire.

SOLUTION
Null all local handles at the end of the function to remove the non nulled local leaks.

Destroy all groups in the upper script after they have been used in the loop (before they are replaced with a new group).

If you do not want to fix this you run the risk of your map becomming unplayable with in a few minutes of playing due to too many leaks, the choice is yours to make and so I strongly recomend you remove all leaks in atleast the upper script atleast as that leaks a unbareable ammount.
 
Status
Not open for further replies.
Top