wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 09-25-2011, 05:39 AM   #1
Yrth
User
 
Yrth's Avatar
 
Join Date: Jul 2010
Posts: 76

Yrth has little to show at this moment (4)

Default In over my head

So as anitarf knows, I like to try things that I have absolutely no idea how to do and then inevitably end up here asking someone to help fix what I (possibly) shouldn't have started in the first place.

Well this time its not any different.
Well its a little bit different, but not in a good way.
This time I have absolutely no idea how to do (the majority) of this

Mazes for people who've never played them (this is important if you don't know what a maze is but still want to help (<3s))
in mazes there's a path. In this example the path is ice. If you step off the path with your unit (you only have 1) your unit dies. In this example the death terrain is snow.


on a sidenote, this is for a friend. I probably never would name a map about lettuce.

so here's the idea
this struct remembers the initial terrain types (on initialization) at every 128x128 space in the given terrain change rects

this is an example of how the rects would be setup. I'll get to why there are 3 rects instead of 1 later.


what happens is this entire path is replaced with snow and then every x seconds a row or column is revealed. But also only so many (variable) rows/columns are revealed at a time.

what it looks like


the full path is placed above b/c it seemed like it'd make things easier to visualize when i did this.












skipping 1 frame





skipping 1 more



notice the bands of terrain switch from vertical to horizontal here







then 6 frames later





so I'll post the parts that I was able to do

Expand JASS:

this records the terrain types in the TerrainTypes[] array. because its using an array (as opposed to a hashtable or (maybe) a table) their indices matter. Thus the (sorta) switch statement on the value of startCorner tells the loop what corner to start in.

As is, it automatically chooses whether to add in horizontal or vertical bands by looking at the size of the rect horizontally vs. vertically.

so here's a few features i want to incorporate
integer TrailSize: this refers to how long of a trail is behind the "front"
real TimeStep: this refers to how long between each update to the trail

the first tricky part is that these (as i want them) are both specific to each rect.

another thing is that all these TerrainChangeRects will be (unless I'm doing this completely wrong) inside another struct like this:

Expand JASS:

this is kinda an ordered conglomeration of all the different TerrainRects. but this also has its own timer (period). Ie every x seconds (where x is the period) this "snake" of terrain change starts and goes through (completely separate from all other "snakes").

This is hard to explain and I'm sure it shows, so I attached a map from a friend that shows this concept of mazing in action. use arrow keys to control the mazer.
The way he did this level was a huge mass of individual terrain change calls (which this will do as well, just in a much, much lazier and easy way)

anyways I'm literally taking anything offered for this project
from actual code to death threats in the mail, everything is appreciated because I have absolutely no idea how to proceed from here.
Attached Files
File Type: w3m Platform Escape example.w3m (1.19 MB, 5 views)
Yrth is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 09-25-2011, 05:12 PM   #2
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

I think there are easier ways to approach this than the one you took. It seems like it would be easier to simply do manual data entry for each terrain tile than to make the path in the terrain editor and then read it with triggers, especially since that still requires data entry in the form of regions.

Sure, you can still draw the thing in the terrain editor first to see how it works out. Then, what I'd do is take a piece of paper with square grid lines on it and copy the layout, adding numbers to all rows and columns covered by the maze. Once that is done, I'd take the CineScript library and write a module for it that changes terrain tiles, with a public API consisting of a single function: function ScriptTerrainTile takes CineScript s, real timestamp, integer tilex, integer tiley, integer tiletype returns nothing

With this code and your sheet of paper, you could make a CineScript that gradually creates ice tiles along your maze. If you made the function that writes this CineScript take a terrain tile argument, you could then use it write both the script that creates ice tiles as well as the script that turns them back to snow. In game, you would just run these two scripts with a sufficient delay between them, at the ingame coordinates where the 0,0 tile on your paper is. The first script would be creating ice tiles and the second one, run later, would be turning those back into snow tiles.
__________________

Last edited by Anitarf : 09-25-2011 at 05:12 PM.
Anitarf is offline   Reply With Quote
Old 09-27-2011, 09:02 AM   #3
Yrth
User
 
Yrth's Avatar
 
Join Date: Jul 2010
Posts: 76

Yrth has little to show at this moment (4)

Default

If you have a chance could you give me a bit more direction than that?

I'm really bad at learning things from description.
I pick things up really quickly from examples though.

I think I'll take your advice and try hardcoding it first, but I'd like to create the module in a way that later on I can implement some sort of auto create.
Yrth is offline   Reply With Quote
Old 09-27-2011, 12:01 PM   #4
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Well, this is what a terrain type CineScript library would look like:
Collapse JASS:
library TerrainCineScript requires CineScript

    private struct TerrainTypeAction extends ScriptAction
        private real x
        private real y
        private integer typ
        private integer var
        private integer size
        private integer brush

        static method create takes CineScript s, real timestamp, real x, real y, integer typ, integer var, integer size, integer brush returns TerrainTypeAction
            local TerrainTypeAction this=TerrainTypeAction.allocate(s, timestamp, 0.0)
            set .x=x
            set .y=y
            set .typ=typ
            set .var=var
            set .size=size
            set .brush=brush
            return this
        endmethod
        method run takes nothing returns nothing
            call SetTerrainType(.parent.globalX(.x,.y),.parent.globalY(.x,.y),.typ, .var, .size, .brush)
        endmethod
    endstruct
    
    function ScriptTerrainType takes CineScript s, real timestamp, integer tileX, integer tileY, integer terType, integer variation, integer size, integer brushType returns nothing
        call TerrainTypeAction.create(s, timestamp, tileX*128.0, tileY*128.0, terType, variation, size, brushType)
    endfunction
    
endlibrary

Then, you would use it like this:

Collapse JASS:
globals
    private CineScript mazeMaker
    private CineScript mazeEraser
endglobals

private function WriteMazeScript takes integer terrainTile returns CineScript
    local CineScript s=CineScript.create()

    set s.x = X_COORDINATE_OF_BOTTOM_RIGHT_TILE
    set s.y = Y_COORDINATE_OF_BOTTOM_RIGHT_TILE

    // I made the tile changes below happen once per second,
    // but you can easily change this by modifying the speed of the script.
    set s.speed=1.0

    call ScriptTerrainType( s, 0,   0, 0,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 0,   0, 1,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 0,   0, 2,   terrainTile,-1, 1,0)

    call ScriptTerrainType( s, 1,  -1, 0,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 1,  -1, 2,   terrainTile,-1, 1,0)

    call ScriptTerrainType( s, 2,  -2, 0,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 2,  -2, 1,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 2,  -2, 2,   terrainTile,-1, 1,0)

    call ScriptTerrainType( s, 3,  -3, 1,   terrainTile,-1, 1,0)

    call ScriptTerrainType( s, 4,  -4, 0,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 4,  -4, 1,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 4,  -4, 2,   terrainTile,-1, 1,0)

    call ScriptTerrainType( s, 5,  -5, 0,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 5,  -5, 2,   terrainTile,-1, 1,0)

    call ScriptTerrainType( s, 6,  -6, 0,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 6,  -6, 1,   terrainTile,-1, 1,0)
    call ScriptTerrainType( s, 6,  -6, 2,   terrainTile,-1, 1,0)
    //...and so on.
endfunction

private function StartMaze takes nothing returns nothing
    call mazeMaker.run()
    // wait however long you like.
    call mazeEraser.run()
endfunction

private function Init takes nothing returns nothing
    set mazeMaker=WriteMazeScript( ICE_TILE )
    set mazeEraser=WriteMazeScript( SNOW_TILE )
endfunction
__________________
Anitarf is offline   Reply With Quote
Old 09-27-2011, 09:52 PM   #5
Yrth
User
 
Yrth's Avatar
 
Join Date: Jul 2010
Posts: 76

Yrth has little to show at this moment (4)

Default

This.
This is perfect
Thank you so much Ani

And wow, you can actually change the speed at any time too
thats incredibly cool

tytytyty
Yrth is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 02:52 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2020, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services