• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

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 63
Joined
Jan 18, 2005
Messages
27,156
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