Author Topic: TUTORIAL: Wall, Backdrop and Blockage CHanges  (Read 342 times)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9835
TUTORIAL: Wall, Backdrop and Blockage CHanges
« on: May 25, 2017, 04:19:00 PM »
Advanced Tutorial: Wall, Backdrop and Blockage Changes
To use a GPDL script to change the walls, overlays, doors, backdrops and blockage surrounding a map square:

   1)   Decide which walls (I'll use this term throughout to refer to overlays and doors as well), backdrops and/or blockage you want to change. Note the coordinates - if you want to change both sides of a wall, for example, there are two map cells involved, so two coordinates to note.
   2)   Determine how you're going to change the walls, backdrops and/or blockage - by which I mean what type of event will be used to trigger the change, for example a Question Yes/No Event or Text Statement Event or Quest Stage Event. The event need not be in one of the cells noted above, nor even on the same level.
   3)   For this tutorial, we will chain a Logic Block Event to contain our GPDL scripts


   4)   We will change the walls around and backdrop in the cell at 8,7. The message box on the right side shows the current statistics for the cell.
   5)   We will change backdrops within the cell, and the walls within the cell and on the opposit side, so one each in the four surrounding cells. We will leave the blockage as is for this change.


   6)   The functions that we will use in our scripts require 5 pieces of information: level number, x coordinate, y coordinate, direction facing, and value.
   The functions for this part of the tutorial are:
   $SetWall
   $SetOverlay
   $SetDoor
   $SetBackground
   We will use blockage a little later on.
   
   7)   This tutorial is using level 1, so we know the first bit of info is "1" - level numbers start at 1 and go through 255. Thanks to the note we made above we know that the second and third bits of info are "8" and "7", respectively (for the main cell, while the adjoining cells will have the second and third bits for their part of the script). The fourth piece of info is the direction facing - 0 = north, 1 = east, 2 = south, and 3 = west.
   8)   The fifth bit of info requires us to look at the wall slots editor (for walls) and the backdrop slots editor (for backdrops). The numbering for both starts at 1 in the upper left corner and counts up from left to right, top to bottom.


   9)   I'm using a Text Statement Event to explain the situation about changing walls, etc. I have a Question Yes/No Event chained after this to ask the player if they wish to change the walls, etc. and to this I chain on the "Yes" branch the Logic Block Event.
   10)   I want the previously given "Yes" answer to always cause the change, so I leave all Inputs and Gates as is and go down to First Action and set it to Always.
   11)   From the drop down menu select GPDL Function.
   12)   Press the elipses button to open the Script Editor to input the script.


   13)   I chose to put like with like functions, in a way that made sense to me. First, I changed the walls in the main cell - 8,7.
   14)I changed the walls in each adjoing cell so that the new look will be consistent inside and out.
   15)   I changed the door graphic on both sides of the wall.
   16)   Finally, I set a new backdrop on each side of the main cell to better match the new walls.
   17)   Always check the syntax before continuing, it will save you a lot of headaches later on.
   18)   Here's the script I used:
   
Code: [Select]
$SetWall (1,8,7,0,4);
$SetWall (1,8,7,1,4);
$SetWall (1,8,7,2,4);
$SetWall (1,8,7,3,5);
$SetWall (1,8,8,0,4);
$SetWall (1,7,7,1,5);
$SetWall (1,8,6,2,4);
$SetWall (1,9,7,3,4);
$SetDoor (1,8,7,3,5);
$SetDoor (1,7,7,1,5);
$SetBackground (1,8,7,0,1);
$SetBackground (1,8,7,1,1);
$SetBackground (1,8,7,2,1);
$SetBackground (1,8,7,3,1);
$RETURN;


   19)   I have another event at 5,7 in which following the same form as above, I willa ask the player if they wish to plant a tree, and the Logic Block event will be set up the same way, but this time I am adding a wall to where none was before, so will need to change the blockage to keep the player from just passing right through the new wall choice.
   20)   Here's the script I used:
   
Code: [Select]
$SetWall (1,4,7,1,8);
$SetBlockage (1,4,7,1,2);
$SetWall (1,5,7,3,8);
$SetBlockage (1,5,7,3,2);
$RETURN;


   21)   The $SetBlockage function follows the same pattern as the other functions used in this tutorial. The values match the corresponding slots shown.
   22)   Click OK as appropriate and Save your work. We're done.

For Further Consideration:
These functions can be used any place functions can be sued - Special Abilities, Spells, Items and Event Triggers. Additionally, there are "Get" versions of each to retrieve the current information allowing for use in conditionals and easily resetting the values to default values set in the Editor.
With a little planning, you could allow players to plant crops, cut down trees, decorate a dwelling, blast through walls, raize a village, etc. And you need not ask the player what she wants to do - you can change their environment based on anything - Quests, ASLs, time of day, day of the week (useful for crowds in a market place), etc.  Your imagination is your only limit.

Updated 17-05-30
Corrected wall numbering error to note that wall editor numbering starts at 1 in the upper-left hand corner.
« Last Edit: May 30, 2017, 05:59:38 PM by manikus »

Offline Milos Gulan

  • Hero Member
  • *****
  • Posts: 3152
Re: TUTORIAL: Wall, Backdrop and Blockage CHanges
« Reply #1 on: May 25, 2017, 11:44:03 PM »
Now this I will have to learn :)

Offline Dinonykos

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2338
    • Dinonykos Dungeon Craft
Re: TUTORIAL: Wall, Backdrop and Blockage CHanges
« Reply #2 on: May 29, 2017, 02:01:20 AM »
Great tutorial, Manikus!  :hello2:


   8)   The fifth bit of info requires us to look at the wall slots editor (for walls) and the backdrop slots editor (for backdrops). The numbering for both starts at 0 in the upper left corner and counts up from left to right, top to bottom.

Has this not changed? I think that by default, the numbering of the walls now starts with 1 "internally", too, but that you can change it to starting from 0. We had discussions about this earlier, e.g. here: http://ua.reonis.com/index.php?topic=3341.15
Find four contributions to the Pre-Generated Character Mini-Module Design Contest on my homepage.
New: THE AMBASSADOR'S LETTER, my contribution to the 7-day-challenge.
DINONYKOS DUNGEON CRAFT DESIGN HOMEPAGE

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9835
Re: TUTORIAL: Wall, Backdrop and Blockage CHanges
« Reply #3 on: May 30, 2017, 01:31:13 PM »
Great tutorial, Manikus!  :hello2:


   8)   The fifth bit of info requires us to look at the wall slots editor (for walls) and the backdrop slots editor (for backdrops). The numbering for both starts at 0 in the upper left corner and counts up from left to right, top to bottom.

Has this not changed? I think that by default, the numbering of the walls now starts with 1 "internally", too, but that you can change it to starting from 0. We had discussions about this earlier, e.g. here: http://ua.reonis.com/index.php?topic=3341.15
This tutorial was not updated. I will look into it (part of the reason posted was to remind myself that I needed to look at updating this one).

Thanks for pointing me in the right direction. 8)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9835
Re: TUTORIAL: Wall, Backdrop and Blockage CHanges
« Reply #4 on: May 30, 2017, 06:00:09 PM »
Updated the tutorial :D :D :D

Offline Milos Gulan

  • Hero Member
  • *****
  • Posts: 3152
Re: TUTORIAL: Wall, Backdrop and Blockage CHanges
« Reply #5 on: May 31, 2017, 09:48:39 AM »
Thank You very much, I should be learning this :). I am a bit busy now and need to update few of my older sprites and makes new walls. I am hoping that I will do it soon :icon_study:

Offline Darcnyss

  • Full Member
  • ***
  • Posts: 161
Re: TUTORIAL: Wall, Backdrop and Blockage CHanges
« Reply #6 on: June 01, 2017, 09:08:21 PM »
Nice! I can think of many fun things to do with this. Thank you, Manikus.