HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Terrain type issues

12-24-2007, 05:19 PM#1
burningice95
I have a spell that changes the terrain in a circular area around the caster to ice crown glaicer. However, the problem is that when the spell expires, the terrain needs to go back to how it was. I can't just change it to all one type of terrain, because there were may different tiles there (arranged in a specific pattern). Is there a way to store the type of each terrain at every point, and then restore it afterward (without some ridiculously big loop)

Thanks in advance!
12-24-2007, 07:41 PM#2
Captain Griffen
You have to loop through each one, store to an array or something, then loop back around and set it back in the end.
12-24-2007, 09:02 PM#3
burningice95
Loop through each point?
12-24-2007, 09:27 PM#4
CommanderZ
It should be okay to loop through one point for every square in the grid...the squares are imo 32*32.
12-24-2007, 10:22 PM#5
Captain Griffen
You have to loop through each tile. There are an infinite amount of points/locations in a given area.
12-25-2007, 12:29 AM#6
burningice95
I'm confused, could you write a rough version of it out for me?
12-25-2007, 03:58 AM#7
Zandose
Collapse JASS:
//rough version
find casting point
loop trough all x and y points (128 space between blocks)
save terrain types and variances
change terrain
wait
loop trought everything again and restore old terrain types and variances
done

Can't get it to work with a circle terrain change yet. Also, you'll notice the ability being casted and the terrain changing are not perfectly aligned. Blame blizzard for making each terrain block 128.00.
Collapse JASS:
//Finished version
scope Ice

globals
    constant integer AID_ABILITY = 'A000' //The ability used
    constant integer TID_TERRAINTYPE = 'Iice' //Whatever type of terrain you want to use.
    constant real RADIUS = 500.00 //size/area affected
    constant real RESET = 3.00 //How long to wait before changing the area back to normal
endglobals

private function Actions takes nothing returns nothing
    //Do I need to null or destroy the real, integers, and/or the ability location at the end?
    local real ax = GetLocationX(GetSpellTargetLoc())
    local real ay = GetLocationY(GetSpellTargetLoc())
    local real x = RADIUS / 2 //width
    local real y = RADIUS / 2 //height
    local integer array t //Terrain type
    local integer array v //Terrain variance
    local integer i = 0
    if GetSpellAbilityId() != AID_ABILITY then
        return //Stops the trigger if the ability casted isn't the right one (see above globals)
    endif
    call TriggerSleepAction(1.00)
    loop
        loop
            set i = i + 1
            set t[i] = GetTerrainType(ax + x, ay + y)
            set v[i] = GetTerrainVariance(ax + x, ay + y)
            call SetTerrainType(ax + x, ay + y, TID_TERRAINTYPE, -1, 1, 1)
            set y = y - 128
            exitwhen y <= (RADIUS / 2) * -1
        endloop
        set x = x - 128
        set y = RADIUS / 2
        exitwhen x <= (RADIUS / 2) * -1
    endloop
    call TriggerSleepAction(RESET)
    //If you want a more precise reset I can use a timer, and at the same time get rid of the two following loops. 
    set i = 0
    set x = RADIUS / 2 + 1
    set y = RADIUS / 2 + 1
    loop
        loop
            set i = i + 1
            call SetTerrainType(ax + x, ay + y, t[i], v[i], 1, 1)
            set y = y - 128
            exitwhen y <= (RADIUS / 2 * -1)
        endloop
        set x = x - 128
        set y = RADIUS / 2
        exitwhen x <= (RADIUS / 2 * -1)
    endloop
endfunction

public function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(trig, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
        set i = i + 1
        exitwhen i == 12
    endloop
    call TriggerAddAction(trig, function Actions)
endfunction

endscope
Attached Files
File type: w3xIce.w3x (12.5 KB)
12-25-2007, 05:13 AM#8
Ammorth
You have to watch out for double-casts. I would recommend storing the original terrain types to a global location (game-cache or an array) so that the spell can check to see if the tiles are already being affected.

Of course, if you don't plan to make this spell mui, ignore everything I said.
12-25-2007, 05:44 AM#9
Zandose
Tomorrow
12-25-2007, 09:28 PM#10
burningice95
Oh, using coordinates, duh


It does need to be MUI....

And Zandose...thanks!

+ rep
12-25-2007, 10:51 PM#11
Zandose
I will try to make it MUI but you'll have to wait. I'm baby sitting right now. lol. I tried to do it eariler today but I got into a lot of problems which I don't have time to fix yet.
12-26-2007, 12:02 AM#12
burningice95
Of course.
12-26-2007, 07:30 PM#13
Zandose
Sorry I've hit a bit of a snag. I have to go out again for a bit but when I get back I'll work on it again.

Does anyone know how to attach a struct (integer) to a timer? I need to carry the struct information over to another function through a timer.

Edit: No ABC please. I don't know how to use it.
12-26-2007, 07:53 PM#14
Captain Griffen
TimerAttach/GetTimerInt is probably the easiest way. H2I + GC is also acceptable and safe.
12-26-2007, 08:37 PM#15
Zandose
Quote:
Originally Posted by Captain Griffen
TimerAttach/GetTimerInt is probably the easiest way. H2I + GC is also acceptable and safe.
I'm assuming those are all systems and that I'm going to have to use one. I kind of wanted to know the method for doing it myself, but I'll try to use ABC. Uh, burningice95, sorry, but this is going to take a bit longer then I thought. Changing from one instant to multi-instant is a real pain in the butt, lol.