All pastes #934975 Raw Edit

Basic Terrain Manipulation

public text v1 · immutable
·published 2008-03-09 06:51 UTC
rendered paste body
function raisePoint takes real x, real y returns nothing
    set x = x - ModuloReal(x, 128)
    set y = y - ModuloReal(y, 128)
    call TerrainDeformCrater( x, y, 64.0, -256.0, 1, true)
endfunction

function createWall takes real x1, real x2, real y1, real y2 returns nothing
  local real xInc
  local real yInc
  local real i
    if x1 > x2 then
        set xInc = x1
        set x1 = x2
        set x2 = xInc
    endif
    if y1 > y2 then
        set yInc = y1
        set y1 = y2
        set y2 = yInc
    endif
    if (x2 - x1) > (y2 - y1) then
        set i = (x2 - x1) / 128
    else
        set i = (y2 - y1) / 128
    endif
    set xInc = (x2 - x1)/i
    set yInc = (y2 - y1)/i
    loop
        exitwhen x1 >= x2 and y1 >= y2
        call raisePoint(x1, y1)
        set x1 = x1 + xInc
        set y1 = y1 + yInc
    endloop
endfunction




////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//////////////////////Testing Code//////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////

function Trig_testManipulate_Actions takes nothing returns nothing
  local real x = GetRandomReal( GetRectMinX(gg_rct_playArea1), GetRectMaxX(gg_rct_playArea1) )
  local real y = GetRandomReal(GetRectMinY(gg_rct_playArea1), GetRectMaxY(gg_rct_playArea1))
  local real x2 = x + GetRandomReal(-1500, 1500)
  local real y2 = y + GetRandomReal(-1500, 1500)
    call createWall(x, x2, y, y2)
    call PanCameraToForPlayer(Player(0), x, y)
endfunction

//===========================================================================
function InitTrig_testManipulate takes nothing returns nothing
    set gg_trg_testManipulate = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_testManipulate, Player(0), "asdf", true )
    call TriggerAddAction( gg_trg_testManipulate, function Trig_testManipulate_Actions )
endfunction