General > Features & Articles

Advanced Development Tutorial for FOnline

<< < (2/3) > >>

Slowhand:
5. 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.



Dialog:



Source:

Pastebin link.

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


--- Code: ---#define LVAR_q_tut_killmobs_loc (701)
#define LVAR_q_tut_killmobs_prog (702)

--- End code ---

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


--- Code: ---   $ 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.
**********

--- End code ---

Slowhand:
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.)

What the code does is, that it will try to put the critters on random positions surrounding a spot.

Main code - unrefined yet.

Slowhand:
6. Perk: Mysterious Stranger

Description:

If you have this perk, from time to time, a mysterious stranger appears out of the blue and tries to help you. This stranger might be there when you encounter difficulties in your travels, or sometimes even in remote zones, caves, hidden vaults, when you feel ill or are crippled. In the future he might even open locked doors for you, if you fail to do so.

Purpose:(One step toward RP.)

The reason for this perk, besides coolness, is to introduce the stat Charisma back into the game. (for servers who abandon it totally PvP wise) The perk should help people who want to role-play with higher Charisma than 1. The perk should be takeable with lower Charisma as well, but Charisma shall have a great effect on strength of the perk, this is why most of the timers depend on Charisma. Ofc, RP logic can surface as well, I leave to everyone's imagination why someone would help a charismatic person more often or for longer period of time. Even if the perk is reduced to a minimum of only random encounter appearance, or support perk, I suggest that Charisma dependency shall be dominant. The code is free for everyone to use it as they wish, gl, hf and may the stranger be with you.

Specification:

From time to time, a mysterious stranger will help the player, regarding the rules below.


* The Mysterious Stranger will spawn and act accordingly if the player has the perk and when:

* The player enters a random encounter, will stay for a duration and help the player.
* The player is attacked while being crippled, will try to doctor the player and then join the fight.
* The player is below half health points and is attacked, will try to heal the player and then join the fight.
* The player fails to open a lock, will try to open the lock and stay for a duration. - not implemented (yet?) -
* The Cooldown of the Mysterious Stranger spawn shall be dependent on the player's Charisma, with the suggested formulas:

* Chance for MS to spawn at random encounter: X + Y * CH + U * LK (Min V, Max Z)
* Chance for MS to spawn for FA in non Town Control maps: X + CH * LK * U (Min V, Max Z)
* Chance for MS to spawn for Doctor: X + CH * LK * U (Min V, Max Z)
* FA and Doctor spawn block mechanic cooldown: X / CHA); (This is mechanic is explained in detail below)
* Death time of Mysterious Stranger cooldown: X /CHA -  and shall be much higher than encounter cooldown.
* Encounter spawn cooldown shall share the timer with with special spawns.
* The Duration of the Mysterious Stranger aid shall be also dependent on the player's Charisma, with suggested formulas:

* Duration of aid for Encounter shall last: X + Y * CH seconds in RT combat.
* Duration of aid for Encounter shall last: X + Y * CH turns in TB combat. - unavailable due to SDK bugs regarding TB events -
* The Strenght of the Mysterious Stranger shall depend on the Level and the Charisma of the player:

* Level of the MS shall be the Level of the player + 3.
* The Level cap of the Mysterious Stranger shall be dependent on the players Charisma.
* The Perk, Stat and Inventory composition of the Mysterious Stranger shall better with the higher Charisma the player has.
* A Random factor can be introduced when determining the Strength of the Mysterious Stranger. - not implemented -
* If the player's luck is very low, the Mysterious Stranger can be Jinxed. Good Luck!
* AI - The Mysterious Stranger shall behave as:

* If the player is attacked, the attacker shall be added to the Mysterious Strangers target list, with medium priority.
* If the player is crippled, the Mysterious Stranger will try to doctor, with high priority, but only once per spawn session.
* If the player is below half health points, the Mysterious Stranger will try to First Aid, with high priority, but only once per spawn session.
* If another player is attacking, the Mysterious Stranger shall change target to it. - not implemented -
* Integration into projects/servers:

* All of the parameters of the Mysterious Stranger mechanic shall be configurable.
* Special triggers shall be disableable with macros from header.
* Solutions shall be chosen, to conflict minimally with optimized code parts, like combat.fos
* Integration shall be documented in the tutorials as well, just like the mechanics.
* Testing:

* Test file shall be supplied with a few scripts written to ease testing.
* There shall be a use case testing document to follow for testers, or developers after modifications.
Known bugs:

Code review:

* Wipe:  what's the point of checking if object is valid() when it's passed by reference?
* Wipe: lot of unneded stuff at least from 2238/reloaded pov - own MS_LOG when you could use debug@WLog(), own get/set lvar instead of utils@Get/SetetLvar(),
* Wipe: perkeditor and reloaded - hahahahahhaha
* Wipe:  or better yet, return( chance >= Random(0,100) ); !

Slowhand:
6.1 Perk - Mysterious Stranger - Installation


How to install:


* Installing the module:

* Copy the source from the pastebin links.

* perk_ms.fos - main source
* perk_ms_h.fos - header file
* perk_ms_test.fos - test helping functions
* Add the source files to the script list ("Server\scripts\scripts.cfg"):

* @ server module perk_ms   # Mysterious Stranger perk
* @ server module perk_ms_test # Mysterious Stranger perk testing
* Add the game variables to the variable list ("Server\scripts\_vars.fos"):

* Add these lines to the header part: _vars.fos header
* Add these lines to the body part: _vars.fos body
* Edit the "main.fos" and add following codes:

* Add to imports: imports from perk_ms.fos and header
* Add to map entry point, right after declaration to "map_critter_in": MS calls/events entry point
* Add to map leaving point, right after declaration to "map_critter_out": MS despawn when exit
* Edit the "perks.fos" and add the following code:

* Add this code somewhere at the end of the code: perk init when taken first time
* You also need to use the perk editor to enable the Mysterious Stranger perk:

* Start the PerkEditor found at tools.
* Press "Load" and find the file named "Tools/PerkEditor/perks.xml"
* Find the perk named "Mysterious Stranger" on the left side, and double click it.
* Change "Disabled" to "Available on level" and press Apply.
* You can optionally save it as well, but not necessary, if you save, save it in a new file.
* Edit the "npc_ai.fos" file, chance the line defining the Mysterious Stranger AI to this one line (without the quotes):

* " /* 125 Mysterious Stranger                   */ 100,  50,      0,    50,    1,  A_BeCareful, AW_Whomever,    BW_RangedOvMelee, CU_StimsHurtLo, D_None,       D_Stay,      0, 0,                    RA_None,             2000,       200,          80,   2 /* Tough Person                          */,   2 /* Tough Person                          */,  PID_STIMPAK, 0, 0, "
* Add the following two lines to dialogue declarations:

* $   2200   perk_ms_test
* $   2201   perk_ms
* Create the following dialogue files to "Server\dialogues\" and copy paste the content:

* perk_ms.fodlg
* perk_ms_test.fodlg
* Add the following 2 lines to "Server\scripts\_dialogs.fos":

* #define DIALOG_perk_ms_test                     (2200)
* #define DIALOG_perk_ms_description              (2201)
* Installing testing map:

* Using the previous (basic) tutorials, create a map near new players spawn location, add an NPC to it, and add it to worldmap.
* Add the test dialogue to the NPC, this NPC can be used to check variables, test a few functions later on.
Setting up the module:

Every variable that is used to configure the module, can be find at the "ms_perk_h.fos" header file. To use the MS perk in production code, simply leave the variables as they are, or change some of them as your sense of balance dictates.

Setting up the module for testing:

To test the module, with or without the test module, it is advised to set the configuration variables to the following:

* __MS_ALLOW_DEBUG_LOG__ - if this variable is defined, it will allow testing logs, these can be checked at server interface.
* The following parameters relate to Cooldowns, time is measured in real time seconds:

* MS_BASE_RESPAWN_CD - change this value, to a shorter one, for faster encounter re-spawn: 30
* MS_BASE_MEDICAL_SPAWN_CD - change this value, to a shorter one, for faster medical re-spawn: 20
* MS_BASE_DEATH_CD - change this value to a shorter one, for faster rebirth of MS: 60
* MS_BASE_RT_DURATION - change this to a higher value, so MS lasts longer per spawn: 3600
* MS_RT_DURATION_FACTOR -  no need to change this, if you changed the base value for RT mode duration.
* The rest of the parameters relate to the Encoutner and Medical spawn chances. Just change base and max values above 100 and you will have an automatic true roll, else keep them as they are and raise your chars charisma.
* The last variable is "disabledMsMaps" is an array of maps, where the MS may not spawn for Medical emergencies. The TC town maps (only first map) are disabled by default, add more maps to disabled them, if you want to.

Slowhand:
7. Blackjack card game.

Introducing a Blackjack card game into the RP of FOnline.

What would be the most reasonable way that gambling skill would affect the course of the game? (It shall be true to gambling in rl, shall be fun, and shall not be exploitable or afk farmed easily (or at all?).)

Specification:

* Dialogue based with possibility to attach a new GUI for it.
* The pile of cards shall be pre-generated at each shuffle and not randomized at each draw.
* Gambling skill difference between host and player is checked, against a  roll, as usual.
* Game basic features:

* Hit - Can hit, unless at 21 or higher, which is a bust.
* Stand - Can stand down from 16.
* Double down - Can be taken after getting the first 2 cards, doubles the bet, but only 1 card is given.
* Split pairs (only once per deal) - Can split paris in two, doubling the bet, and playing them against dealer.
* Insurance - Can be taken if dealer has an Ace revealed.
* Even money - You have blackjack and dealer has an Ace revealed.
* Surrender - When you have 2 cards, must be taken as first option.
* The advantage of higher gambling skill:

* Info over the the number of card packs used (which would be random 4 - 8 after each session).
* Frequency of shuffling would be lower with better gambling + speech skill checks.
* Card counting: available as long as gambling skill is higher than of host and the intellect of player is above X, as this is the easiest ways to get advantage over host.
* Shuffle tracks: Occasionally on a critical or very hard roll on gambling + perception shuffling check, the player will be notified if there are way more high or low cards in the next X cards, if that is the case. ( 1/2 for low, or 3/4 high, have to make an estimation)
* Disadvantage of lower gambling skill:

* Basically missing out on the benefits, like: the character does not pay attention when the shuffling of cards happens, since he doesn't know that is important, so you miss that info.
* Other possibilities:

* Cheating 1: where the odds of high (7,8,9) or low cards (2,3,4) is reduced/raised, maybe the later could be added to some mini/repeatable quest or the host could be sweet talked /payed into changing the packs or whatever.. (would only create the possibility for it, but not the quest itself) In this case the host would give a hint for the player, until the cards are replaced.
* Cheating 2: where the player will be notified if the hole card is an Ace or 10.
* Cheating 3: Casino could cheat as well, cutting down some cards for player session, this should be able to be find out via mini quest/tip drunk gambler/speech etc. or simply by gambling check rolls.
* Different casinos could have different rules and special offers to promote themselves:

* Rule changes:

* Double after split. (default enabled)
* "Hit soft 17" - dealer has to draw a card if on soft 17.
* "Dealer wins ties" - dealer will win ties.
* "No Hole card" - dealer does not consult hole card until player finished his turns. (can't cheat to find out dealer's hole card)
* "No Black Jack after splitting Aces" - no bonus on Black Jack after splitting Aces.
* Side bets:

* "Royal Match" - Pays for suit matches.
* "Perfect Pair" - is an extra bet option before drawing cards, the player can bet if he gets pairs (Perfect, Colored, Mixed, No pairs)
* "Lucky Ladies" - pays for initial cards value of 20. (Pair of Queen of Hearts, Suit Pair, etc)
* Promotions:

* "Real" Blackjack pays higher than regular Blackjack. (11 to 2 instead of 3 to 2). (Real mean Ace of spades with a Blackjack card.)
What to keep in sight:

* It shall be configurable, so that mini quests or altering affects can differ from player to player and from session to session.
* Shall be expandable later on to a graphical design.
* Casino rules could be configurable, so that each session (or say,week) could be different, (or per player different odds) so that it can be tied to side quests to gather that info. (e.g.: Tip some wasted beggar or gambler to know the current situation / Or just the need to read the rules from dialogue so that botting is made harder.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version