November 23, 2026, 07:20:34 am
Username:

Password:

Topic: 1. Downloading and setting up the Development Kit.  (Read 5353 times)

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
14. Writing a simple quest: Kill all monsters on a specific location.
« Reply #15 on: August 24, 2015, 03:58:07 pm »
14. 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
    • The last line in the dialog, will set the progress to zero when the quest is finished, which means it can be retaken. I left that there for testing purposes, but probably this is not desired, so simply remove it.
  • 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.




Dialog:



Source:

Pastebin link.

"Server/scripts/_vars.fos" - Header part

Code: [Select]
#define LVAR_q_tut_killmobs_loc (701)
#define LVAR_q_tut_killmobs_prog (702)

"Server/scripts/_vars.fos" - Body part

Code: [Select]
   $ 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.
**********
« Last Edit: August 24, 2015, 04:24:01 pm by Slowhand »

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
15.1 Fork: Template - Dialogue driven, no need to edit script.
« Reply #16 on: August 24, 2015, 04:07:56 pm »
15.1 Kill all monsters on a specific location: Template (Dialogue driven, so the script does not have to be altered at all.)

« Last Edit: August 24, 2015, 04:15:39 pm by Slowhand »

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
15.2 Fork: The location is given, but the position of mobs random.
« Reply #17 on: August 24, 2015, 04:09:29 pm »
15.2 Kill all mobs on a specific location. The location is given, but the position of mobs is randomized.

Explanation and code refinement in progress, until I do that, here is an example that works. (Need to add a dialogue, and a few variables which should be self explanatory if the code is understood.)

Main code - unrefined yet.

« Last Edit: August 24, 2015, 04:16:50 pm by Slowhand »

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
Re: Basic Development Tutorial for FOnline: Reloaded
« Reply #18 on: December 24, 2015, 07:34:06 am »
The tutorial has been restructured. I will need 2 new threads in workshop, with the same name as on fodev:

Advanced Development Tutorial for FOnline   
FOnline SDK scripts overview.

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
Re: Basic Development Tutorial for FOnline: Reloaded
« Reply #19 on: December 25, 2015, 01:23:46 pm »
I cannot remove this thread/topic. Since this have been cleared up, everything moved, reorganized, including other players answers, questions, feedback, I believe this can be deleted and some of the other threads made stickied.