A Development Tutorial: Chapter 20: Difference between revisions

From FOnline: Reloaded Wiki
Jump to navigation Jump to search
(Created page with "{{Guide | name = A Development Tutorial: Chapter 20 | image = AWikiEditor.gif | description = Get the developer tools and try building new content for this game! | status = Pr...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
| image = AWikiEditor.gif
| image = AWikiEditor.gif
| description = Get the developer tools and try building new content for this game!
| description = Get the developer tools and try building new content for this game!
| season = All Seasons
| status = Progress Stopped
| status = Progress Stopped
| complete = 75%
| complete = 75%
| authors = Slowhand
| authors = Slowhand
| chapter = 20: A Simple Kill Quest
| chapter = 20: A Simple Kill Quest
| chapters = [[A Development Tutorial|Title Page]]<br>[[A Development Tutorial: Chapter 01|Development Kit Setup]]<br>[[A Development Tutorial: Chapter 02|Making Maps]]<br>[[A Development Tutorial: Chapter 03|The World Map Editor]]<br>[[A Development Tutorial: Chapter 04|NPC Dialogues]]<br>[[A Development Tutorial: Chapter 05|Create a 2-Map Zone]]<br>[[A Development Tutorial: Chapter 06|Monsters, Loot, and Scripts]]<br>[[A Development Tutorial: Chapter 07|Tracking Quest Progress]]<br>[[A Development Tutorial: Chapter 08|Scenery Scripts]]<br>[[A Development Tutorial: Chapter 09|Dialogue-to-Quest Location]]<br>Chapter 10<br>[[A Development Tutorial: Chapter 11|The Scripting Environment]]<br>[[A Development Tutorial: Chapter 12|Understanding Quest Scripts]]<br>Chapter 13<br>[[A Development Tutorial: Chapter 14|Dialogue: The "SAY" Menu]]<br>Chapter 15<br>[[A Development Tutorial: Chapter 15.01|Lockpick Cooldown]]<br>[[A Development Tutorial: Chapter 16|Repeatable Locations]]<br>[[A Development Tutorial: Chapter 17|Floating FA Text]]<br>[[A Development Tutorial: Chapter 18|Roulette Game]]<br>[[A Development Tutorial: Chapter 19|Dialogues vs Scripts]]<br>[[A Development Tutorial: Chapter 20|Simple Kill Quest]]<br>Chapter 21<br>[[A Development Tutorial: Chapter 22|Mysterious Stranger Perk]]<br>[[A Development Tutorial: Chapter 23|Perk Installation]]<br>[[A Development Tutorial: Chapter 24|Black Jack Game]]<br>[[A Development Tutorial: Chapter 25|Black Jack Installation]]<br>[[A Development Tutorial: Chapter 26|Sound Effects]]
| chapters = [[A Development Tutorial|Title Page]]<br>[[A Development Tutorial: Chapter 01|Development Kit Setup]]<br>[[A Development Tutorial: Chapter 02|Making Maps]]<br>[[A Development Tutorial: Chapter 03|The World Map Editor]]<br>[[A Development Tutorial: Chapter 04|NPC Dialogues]]<br>[[A Development Tutorial: Chapter 05|Create a 2-Map Zone]]<br>[[A Development Tutorial: Chapter 06|Monsters, Loot, and Scripts]]<br>[[A Development Tutorial: Chapter 07|Tracking Quest Progress]]<br>[[A Development Tutorial: Chapter 08|Scenery Scripts]]<br>[[A Development Tutorial: Chapter 09|Dialogue-to-Quest Location]]<br>Chapter 10<br>[[A Development Tutorial: Chapter 11|The Scripting Environment]]<br>[[A Development Tutorial: Chapter 12|Understanding Quest Scripts]]<br>Chapter 13<br>[[A Development Tutorial: Chapter 14|Dialogue: The "SAY" Menu]]<br>Chapter 15<br>[[A Development Tutorial: Chapter 15.01|Lockpick Cooldown]]<br>[[A Development Tutorial: Chapter 16|Repeatable Locations]]<br>[[A Development Tutorial: Chapter 17|Floating FA Text]]<br>[[A Development Tutorial: Chapter 18|Roulette Game]]<br>[[A Development Tutorial: Chapter 19|Dialogues vs Scripts]]<br>[[A Development Tutorial: Chapter 20|Simple Kill Quest]]<br>Chapter 21<br>[[A Development Tutorial: Chapter 22|Mysterious Stranger Perk]]<br>[[A Development Tutorial: Chapter 23|Perk Installation]]<br>[[A Development Tutorial: Chapter 24|Black Jack Game]]<br>[[A Development Tutorial: Chapter 25|Black Jack Installation]]<br>[[A Development Tutorial: Chapter 26|Sound Effects]]<br>[[A Development Tutorial: Chapter 27|Pro Tips]]
}}
}}


Line 54: Line 55:
**** @ server module quest_mob_kill
**** @ server module quest_mob_kill
* At this point all should work fine, try and test it.
* At this point all should work fine, try and test it.


==Understanding the Script==
==Understanding the Script==
 
* The script is written in a way, so you have easier time to know which parts to change when making your own quest.
    The script is written in a way, so you have easier time to know which parts to change when making your own quest.
* void r_SpawnLoc(..)
    void r_SpawnLoc(..)
** Responsible to spawn the quest location/map.
        Responsible to spawn the quest location/map.
** Should be called from dialogue result.
        Should be called from dialogue result.
** Parameters besides the two Critter types (default for dialogues) are two zone coordinates to form a rectangle (top left corner, bottom right corner) in which the quest location will be randomized.
        Parameters besides the two Critter types (default for dialogues) are two zone coordinates to form a rectangle (top left corner, bottom right corner) in which the quest location will be randomized.
** You can give an exact spot by entering the same values for the corners.
        You can give an exact spot by entering the same values for the corners.
** This function relies on two variables that are not controllable from the dialog, as maximum only 5 parameters could be given.
        This function relies on two variables that are not controllable from the dialog, as maximum only 5 parameters could be given.
*** LVAR_q_tut_killmobs_loc - this game variable stores the location ID generated, so later it can be deleted.
            LVAR_q_tut_killmobs_loc - this game variable stores the location ID generated, so later it can be deleted.
*** LOCATION_quest_killmobs - this is not a game variable, but only a define, it stores the value of the location prototype created before (91)
            LOCATION_quest_killmobs - this is not a game variable, but only a define, it stores the value of the location prototype created before (91)
*** (Relies means that you have to modify it in the script, and you can't set it through parameters, but later we might cover a way to solve this.)
            (Relies means that you have to modify it in the script, and you can't set it through parameters, but later we might cover a way to solve this.)
* void r_DeleteLoc(..)
    void r_DeleteLoc(..)
** Responsible for deleting the map, when the quest is finished.
        Responsible for deleting the map, when the quest is finished.
** Relies on the LVAR_q_tut_killmobs_loc variable as well, it will delete the location that is stored in this variable.
        Relies on the LVAR_q_tut_killmobs_loc variable as well, it will delete the location that is stored in this variable.
* void spawnQuestLocationWithCoords(..)
    void spawnQuestLocationWithCoords(..)
** This is the main logic for the location spawn, and the only variable you might need to change when you make more quests, is at the call to SetQuestGarbager(..), the LVAR_q_tut_killmobs_loc should be changed to your own variable name.
        This is the main logic for the location spawn, and the only variable you might need to change when you make more quests, is at the call to SetQuestGarbager(..), the LVAR_q_tut_killmobs_loc should be changed to your own variable name.


(image soon)
(image soon)


[[Category:Guides]]
[[Category:Guides]]

Latest revision as of 21:20, 22 September 2018

A Development Tutorial: Chapter 20
Get the developer tools and try building new content for this game!
Season All Seasons
Status Progress Stopped
Completion 75%
Authors Slowhand
This Chapter 20: A Simple Kill Quest
More Chapters Title Page
Development Kit Setup
Making Maps
The World Map Editor
NPC Dialogues
Create a 2-Map Zone
Monsters, Loot, and Scripts
Tracking Quest Progress
Scenery Scripts
Dialogue-to-Quest Location
Chapter 10
The Scripting Environment
Understanding Quest Scripts
Chapter 13
Dialogue: The "SAY" Menu
Chapter 15
Lockpick Cooldown
Repeatable Locations
Floating FA Text
Roulette Game
Dialogues vs Scripts
Simple Kill Quest
Chapter 21
Mysterious Stranger Perk
Perk Installation
Black Jack Game
Black Jack Installation
Sound Effects
Pro Tips
Notes {{{notes}}}


Writing a simple quest: Kill all monsters on a specific location.

As suggested/asked for, here is a simple quest. The player needs to go to a location, where he needs to kill all mobs. The location is private, so others can't interrupt him. When the mobs are killed (RP: for some reason the NPC will know) the player gets some reward.

Step by Step

  • Creating the Map
    • Use the previous tutorials to make a new map (I copied a random desert encounter) and name it as you like. ("q_tut_killmobs.fomap")
    • Design your map as you wish and add some monsters to it.
      • Set ScriptName to the filename of the script you will make later, without the extension. ("quest_mob_kill")
      • Set FuncName to the function you will use to initialize the behavior of the monsters. ("critter_init")
      • Set ST_TEAM_ID to the same number at each mob. ("10")
      • Set ST_NPC_ROLE to the same number at each mob. ("66")
    • Add some Entires with EntireNumber set to 0 so the player can enter the map. The player will appear at one of these Entires randomly.
  • Setting up the Map in WorldEditor
    • Using the info from previous tutorials, create a new map data and a location for your map. Make sure you remember the location ID you gave. (mine was 91)
  • Creating a New Dialogue
    • Add 2 new local game variables to be used in the quest:
      • The LVAR_q_tut_killmobs_loc will be used to store the location ID for later, so we can delete it when quest finished.
      • The LVAR_q_tut_killmobs_prog will be used to keep track of the progress of the quest.
      • In "Server/scripts/_vars.fos" add the following lines to the header section:
        • #define LVAR_q_tut_killmobs_loc (701)
        • #define LVAR_q_tut_killmobs_prog (702)
      • In "Server/scripts/_vars.fos" add the following lines to the body section:
        • $ 701 1 q_tut_killmobs_loc 0 0 0 4
        • **********
        • Stores the location ID generated by the tutorial quest, so it can be deleted later.
        • **********
        • $ 702 1 q_tut_killmobs_prog 0 0 0 4
        • **********
        • Follows the progress of the tutorial quest.
        • **********
    • Create a new dialog that suits you quests needs, I will present only an example here of the core mechanics in a picture.
      • The dialog has to keep track of the quest progress using the LVAR_q_tut_killmobs_prog variable.
      • When the quest is taken, a script shall be called that creates the location uniquely for the player, visible on the world map.
      • When the quest is finished, a script shall be called that deletes the location.
      • Reproduce the dialogue shown on the picture, as everything you need to know is visible.
      • Add the new dialogue to the dialogues list ("Server\dialogs\dialogs.lst") by adding the following line:
        • $ 2201 quest_tut_killmobs
  • Create the script to spawn the location, set the behavior of the monsters and delete the location when the quest is finished:
    • Create a new script file ("Server\scripts\quest_mob_kill.fos").
    • Add it to the script list:
      • Edit the scripts list file ("Server\scripts\scripts.cfg") and add the following line to the quests section:
        • @ server module quest_mob_kill
  • At this point all should work fine, try and test it.

Understanding the Script

  • The script is written in a way, so you have easier time to know which parts to change when making your own quest.
  • void r_SpawnLoc(..)
    • Responsible to spawn the quest location/map.
    • Should be called from dialogue result.
    • Parameters besides the two Critter types (default for dialogues) are two zone coordinates to form a rectangle (top left corner, bottom right corner) in which the quest location will be randomized.
    • You can give an exact spot by entering the same values for the corners.
    • This function relies on two variables that are not controllable from the dialog, as maximum only 5 parameters could be given.
      • LVAR_q_tut_killmobs_loc - this game variable stores the location ID generated, so later it can be deleted.
      • LOCATION_quest_killmobs - this is not a game variable, but only a define, it stores the value of the location prototype created before (91)
      • (Relies means that you have to modify it in the script, and you can't set it through parameters, but later we might cover a way to solve this.)
  • void r_DeleteLoc(..)
    • Responsible for deleting the map, when the quest is finished.
    • Relies on the LVAR_q_tut_killmobs_loc variable as well, it will delete the location that is stored in this variable.
  • void spawnQuestLocationWithCoords(..)
    • This is the main logic for the location spawn, and the only variable you might need to change when you make more quests, is at the call to SetQuestGarbager(..), the LVAR_q_tut_killmobs_loc should be changed to your own variable name.

(image soon)