Klokreations

You are not connected. Please login or register

Adding Multiple Weather Types to FEXP

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Adding Multiple Weather Types to FEXP on Thu Feb 07, 2013 10:56 pm

Klokinator

avatar
Admin
So let's say you want to have rain and snow that affects unit movement like in pretty much every fire emblem game ever. You might want to make it turn based or make it for the whole map, but you don't know how to make weather occur. Well, let's take a trip on the learning train!

While the majority of this is thanks to yeti, I did type up the entire bottom section of code myself and verified it to make sure it works. I just want to make that clear. Also, even if you're NOT planning to have weather types in your game, I'd still add it in case you change your mind later, especially since it's so goddamn easy to do now that I've done the hard part!

Find 'def tile_move_cost(terr)' in the 'Game_Event(Unit)' script around line 875 and change
Code:
val = TERRAIN_COSTS[terr][@class_move_type - 1]
to be
Code:
val = TERRAIN_COSTS[terr][@class_move_type - 1][$game_screen.weather_type]

After that, go to the Terrain Data script, located in the upper Configuration section. Find the section of code that appears here:

Code:

TERRAIN_COSTS =
{
    # Infantry/Adept, Heavy/Magus, Armor, Mount, Flier
    0 =>  [-1,-1,-1,-1,-1], # -- (Debug)
    1 =>  [ 1, 1, 1, 1, 1], # Plains
    2 =>  [ 1, 1, 1, 1, 1], # Road
    3 =>  [ 1, 1, 1, 1, 1], # Village
    4 =>  [-1,-1,-1,-1,-1], # Village (Closed)
    5 =>  [ 1, 1, 1, 1, 1], # House
    6 =>  [ 1, 1, 1, 1, 1], # Armory
    7 =>  [ 1, 1, 1, 1, 1], # Vendor
    8 =>  [ 1, 1, 1, 1, 1], # Arena
    10 => [ 2, 2, 2, 2, 1], # Fort
    11 => [ 1, 1, 1, 1, 1], # Gate (Castle)
    12 => [ 2, 2, 2, 3, 1], # Forest
    13 => [-1,-1,-1,-1, 1], # Thicket
    14 => [ 1, 1, 1, 1, 1], # Sand
    15 => [ 1, 2, 3, 4, 1], # Desert
    16 => [ 5,-1,-1,-1, 1], # River
    17 => [ 3, 4,-1, 6, 1], # Hill
    18 => [-1,-1,-1,-1, 1], # Peak
    19 => [ 1, 1, 1, 1, 1], # Bridge
    21 => [-1,-1,-1,-1, 1], # Sea
    22 => [-1,-1,-1,-1, 1], # Lake
    23 => [ 1, 1, 1, 1, 1], # Floor
    25 => [-1,-1,-1,-1, 1], # Fence
    26 => [-1,-1,-1,-1,-1], # Wall
    27 => [-1,-1,-1,-1,-1], # WallW
    29 => [ 2, 2, 2, 3, 1], # Pillar
    30 => [-1,-1,-1,-1,-1], # Door
    31 => [ 1, 1, 1, 1, 1], # Throne
    32 => [ 1, 1, 1, 1, 1], # Chest (Opened)
    33 => [ 1, 1, 1, 1, 1], # Chest
    34 => [-1,-1,-1,-1,-1], # Roof
    35 => [ 1, 1, 1, 1, 1], # Gate (Fort)
    37 => [ 2, 2, 2, 2, 1], # Ruins (Destroyed
    38 => [-1,-1,-1,-1, 1], # Cliff
    44 => [-1,-1,-1,-1,-1], # -- (Castle)
    45 => [ 1, 1, 1, 1, 1], # Stairs
    46 => [-1,-1,-1,-1, 1], # -- (Village))
    51 => [-1,-1,-1,-1,-1], # Snag
    52 => [ 1, 1, 1, 1, 1], # Bridge (Snag)
    54 => [-1,-1,-1,-1, 1], # Deeps
    55 => [ 1, 1, 1, 1, 1], # Ruins (Visitable)
    56 => [ 1, 1, 1, 1, 1], # Inn
    57 => [-1,-1,-1,-1, 1], # Barrel
    60 => [-1,-1,-1,-1, 1], # Water
    61 => [-1,-1,-1,-1, 1], # Gunnel
    62 => [ 1, 1, 1, 1, 1], # Deck
    63 => [-1,-1,-1,-1,-1], # Brace
    64 => [-1,-1,-1,-1,-1], # Mast
}

And change it to this:

Code:

TERRAIN_COSTS =
{
    # Light Infantry, Heavy Infantry, Armor, Mount, Flier
    # TERRAIN COSTS ORDER: Normal, Rain, Snow, Storm
   
    # Debug Tiles
    0 =>  [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # Plains
    1 =>  [ [1,2,2,2], [1,2,2,2], [1,2,2,2], [1,2,2,2], [1,2,2,2]],
   
    # Road   
    2 =>  [ [1,2,2,2], [1,2,2,2], [1,2,2,2], [1,2,2,2], [1,2,2,2]],
   
    # Village
    3 =>  [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Village (Closed)
    4 =>  [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # House
    5 =>  [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Armory
    6 =>  [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Vendor
    7 =>  [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Arena
    8 =>  [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Fort
    10 => [ [2,2,2,2], [2,2,2,2], [2,2,2,2], [3,3,3,3], [1,1,1,1]],
   
    # Gate (Castle)
    11 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Forest
    12 => [ [2,3,3,3], [2,3,3,3], [2,3,3,3], [3,4,4,4], [1,2,2,2]],
   
    # Thicket
    13 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Sand
    14 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Desert
    15 => [ [1,1,1,1], [2,2,2,2], [3,3,3,3], [4,4,4,4], [1,1,1,1]],
   
    # River
    16 => [ [5,5,5,5], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Hill
    17 => [ [3,3,3,3], [4,4,4,4], [-1,-1,-1,-1], [6,6,6,6], [1,1,1,1]],
   
    # Peak
    18 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Bridge
    19 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Sea
    21 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Lake
    22 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Floor
    23 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Fence
    25 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Wall
    26 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # WallW
    27 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # Pillar
    29 => [ [2,2,2,2], [2,2,2,2], [2,2,2,2], [4,4,4,4], [1,1,1,1]],
   
    # Door
    30 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # Throne
    31 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Chest (Opened)
    32 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Chest
    33 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Roof
    34 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # Gate (Fort)
    35 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Ruins (Destroyed)
    37 => [ [2,2,2,2], [2,2,2,2], [2,2,2,2], [2,2,2,2], [1,1,1,1]],
   
    # Cliff
    38 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Castle (Building)
    44 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # Stairs
    45 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Village (Closed entrance)
    46 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Snag
    51 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # Bridge (Snag)
    52 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Deeps
    54 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Ruins (Visitable)
    55 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Inn
    56 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Barrel
    57 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Water
    60 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Gunnel
    61 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [1,1,1,1]],
   
    # Deck
    62 => [ [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1], [1,1,1,1]],
   
    # Brace
    63 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
   
    # Mast
    64 => [ [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1], [-1,-1,-1,-1]],
}

This will change the 5 digits in the original code into an array of 5 sections, each section with 4 numbers. This is how it boils down:

Code:

    # Hill      (Light)    (Heavy)      (Armor)      (Mount)    (Flier)
    17 => [ [3,3,3,3], [4,4,4,4], [-1,-1,-1,-1], [6,6,6,6], [1,1,1,1]],

As you can see, the individual 5 digits now each has an array, and inside the array the four numbers correspond, in order, to: Normal Weather, Rainy, Snowy, and Stormy. This will allow you to set your own movement costs as needed for the weather types.

BUT KLOK! How do I set the weather type ingame? Easy peasy.

Open up an event and look for the button titled "Weather Effects", like so:



And from there just choose one of these four options:



Always set the frames to 0, it doesn't affect anything anyway.



And just like that, you can use inclemental weather in your game!


Credits to Bwdyeti and Kieran32 for a large part of this tutorial, I just fleshed it out and made it simpler.


___________________________________
http://klokreations.forumotion.com

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum