October 06, 2024, 12:37:38 pm
Username:

Password:

Topic: Basic Development Tutorial for FOnline. (Reloaded)  (Read 30771 times)

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
15. Modifying base mechanics - Only the easy parts.
« Reply #15 on: January 07, 2016, 06:10:33 pm »
15. Modifying base mechanics - Only the easy parts.
« Last Edit: January 07, 2016, 06:12:10 pm by Slowhand »

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
15.1 Modifying lock pick cooldown mechanic.
« Reply #16 on: January 07, 2016, 06:11:00 pm »
15.1 Modifying lock pick cooldown mechanic.

(Using Reloaded SDK source, version 2.)

This will be an example, how to spice up lock picking mechanic a bit, changing the value of cooldown from a static, to a dynamic value based on the player skill, tools used, lock difficulty and the random roll.


The script file of interest is "lockers.fos". Generally the usage of skills is defined in "main.fos", but this one there is empty.

I do not know how to explain this minor change in basic tutorial level, here is what the old code did:
  • .. skipping parts of code that do not interest us now, starting from line 60..
  • If lock pick skill is still in timeout then do display message, and do nothing.
  • If lock is already unlocked, or locker is open, do nothing.
  • Calculate the base lock picking value from player skill and lock complexity.
  • Add to this base the bonus from tools if in main hand slot.
  • Depending on random roll, delete the lock picks if in main hand.
  • Roll and check if failure or success and message the player accordingly.
  • Set the timeout for the skill.

The new mechanic:
  • Lock picks will break on critical failure only.
  • If the player tries to pick the lock without lock picks and critical failure occurs, he will hurt his fingers for random small amount damage and will trigger a higher cooldown.
  • If the lock is unpickable by the player (because of lack of skill + tools) and a critical success occurs, the player will receive a warning message, so he does not bother anymore.
  • If the lock pick simply fails, then the default timeout will be triggered, as before
  • If the lock pick is successful, then a cooldown between 25% and 75% of default will be triggered. This cooldown depends on the roll made to pick the lock. The transition between the values is linear, when the minimum cooldown will trigger if the (skill + tool bonus - lock difficulty) is higher or equal to 50, basically the bonus value of the expanded lock pick set. The maximum cooldown (3/4 of default cooldown) is triggered when the roll check barely made it. This way having way higher lock pick skill is more rewarding, since opening very easy locks will trigger a much shorter cooldown, sometimes allowing the player to loot and try to unlock another container if nearby.

Points of interest:

1. If you didn't so far, make sure you understand the CLAMP(x, min, max) macro:

What it does, is makes sure that a value is between boundaries, like the value of CLAMP(x, 1, 95) will be "x" if that is between 1 and 95, else if "x" is higher than 95, then the value will be 95 or if "x" is lower than 1 the value will be 1. The CLAMP macro is defined using the ternary operator "?:" (actually two of them embedded in each other), which has the following formula: "logical condition ? value_if_true : value_if_false", meaning that if the condition is true, the first value will be returned, else the last. It might be a bit confusing, because of the excessive usage of this operator, but you'll get used to it.

2. Random(x, y) function:

This will generate a random number between two values, the numbers are decimal. Most common use case is: int roll =Random(0, 100); In this case the "roll" variable will be used somewhere against a skill, critical or to hit check.

3. LOCKPICK_TIMEOUT(cr):

This a macro, it's a leftover of some old code, and it has been left there to note the old structure of the code. It is still used, but it is overridden to a static value, which makes the extra "cr" parameter useless. I keep using it and let the owner of the server who use this tutorial code to dispose of it if they want to. Basically, instead of this macro we could have used simply a value.

4. REAL_SECOND(s):

The LOCKPICK_TIMEOUT macro refers to this, and what this macro does transforms real time value into game value, hence the name "real".

5. Locker's parameters:

Lockers as simply Items, you can find a lot in mapper under container, and have 3 parameters regarding locking, which you can modify also in mapper.
  • LockerId - key with the same Id can open this locker.
  • LockerCondition - if 1, then it is open (but not necessarily unlocked, if not, then closed.
  • LockerComplexity - this is used to measure the difficulty of the lock.


The new code fragment to replace the old parts with in the script file: lockers.fos

Simply replace the old part with the new part, I did not copy the whole file into pastebin, but left enough context ( a few extra lines) and comments, so you can find where to copy paste from.
« Last Edit: January 07, 2016, 06:24:22 pm by Slowhand »

Henry

  • Wiki Administrator
  • Global Moderator
  • Posts: 869
  • Gravity is just a theory. Try Density.
    • View Profile
Re: Basic Development Tutorial for FOnline. (Reloaded)
« Reply #17 on: January 21, 2017, 02:56:34 am »
This guide and the next one (advanced) are now being added to the wiki. I believe we all owe Slowhand a lot of thanks for this. It's EXACTLY what this community needs for possible junior developers to get started in a strong way. It must have taken a TON of time to do all of this, and i'm very pleased to finally get it on the wiki in the Guides section.

If you like this game and are thinking about writing some new content for it (stories/quests, maps, NPC dialogues and more), Slowhand has made it a lot easier for you to get started!

SPECIAL THANKS TO SLOWHAND!

cthulchu

  • Supporter
  • Posts: 211
    • View Profile
Re: 2. Modifying existing maps with the Mapper.
« Reply #18 on: August 04, 2017, 02:20:21 am »
Slowhand, I want to say that this is an amazing tutorial. You did a great job, granting a lot of cool content to Reloaded. Thank you a lot!


I'll leave here some notes while working on my setup if you don't mind. You can incorporate some of these notes into the manual if you want.

1.
  • Launch Mapper and load the map of The Hub
  • Press enter after mapper started to get the console.
  • Type: "~hub" - to load the map.
  • Press F8 to disable mouse scrolling. (This can be very annoying, since even if the Mapper does not have focus, it will try to scroll while you are working with other apps.
  • Press Enter again, when the command line is empty, so the command line disappears, now you can use the arrow keys to scroll around.
Make sure you don't alt+tab when the console is opened. It's bugged. You won't be able to close the console if you do... Will have to relaunch the mapper. Oh and you'll lose the progress with no way to save it :)

OR you can just type Alt and it'll unfreeze the console :) hehe :)



2.
For some fooken reason Clean.bat doesn't clean the save folder.
Here's how the modified version should look like:

Added this string:
del save\*.fo

3.

And... It crashed. Stopped working. And I lost all progress. Don't forget to save your map periodically.
Quote
Save the map: "^tut_map1"

Happens every time I scroll through normal items. Have to hack around with ctrl+scroll

4.
I found some super helpful things that would help a lot during map building. Looks like the editor is a lot more functional than I thought. It's just it doesn't have nice documentation and GUI config menu system. But when you get used to it... You can create freaking awesome things relatively quickly.

  • Use selection. Select tiles. You can choose what kind of objects you select to make it better. You want to do it, trust me.
  • When you selected something, you can delete it with the del button
  • Alternatively, you can move selected objects, just change the cursor with the left click and then drag the objects to the new location
  • try to avoid having many objects at the same space, Like many different floor tiles in one hex. Looks like the editor doesn't handle those well.
  • You can copy selected objects with ctrl+c.
  • You can paste objects copied with ctrl+v. When you do it, the old selection disappear and you start to select object you just pasted so you could adjust their position easily.
  • Use TAB! It changes the way the selection works. Try select something. Now press tab and select something. Have you noticed the difference?
  • Sometimes the mapper glitches and stops showing you technical tiles even if you click the display button. Go to the technical items tab and click on them. Clicking on them not just selects them, but toggles their visibility, which is kinda useful.
  • Sometimes you'll find out the selection doesn't disappear. Try clicking alt, ctrl or shift. Helps.
  • Have you noticed those tabs where you choose basic categories of stuff to place? You do realize that some of them have hundreds if not thousands of them? Mkay, so... If you wanna scroll a lot, you can. Alt+scroll scrolls something like a thousand things at once.
     Ctrl scroll does hundreds, I think. Shift scroll does one screen of things.
  • Buuuut... You don't need it! Kek. If you just click again on the tab you have selected,
     you'll see a neat cool list of subgroups. They are tremendously useful. Mapping without them would take a lot more time.
WOWOWOW! I found a cool manual. Here it is:

Quote
To load a saved map, type "~<map name>" in the console.
TO save a map, type "^<map name> [/text] [/nopack]". "/text" to save it in text format, "/nopack" to save it in unpacked version.

Other commands, preceded with "*":
 new      create a new map;
 unload      unload the current map;
 scripts   list of scripts;
 size <w> <h>   set a new map size;
 dupl      search for items with the same pids, placed on the same hexes;
 scroll      search for scroll blockes, around which there are less than two other scroll blockers;
 pidpos <pid>   search for all items with a given pid;
 hex <hx> <hy>   search for all objects on a given hex.

To run a script function, use "#". Executed function must be of prototype "string FuncName(string)", string argument is passed from a console, and function results will be displayed in the message box. Default module is "main", to execute a function from another module use "@" (for example, "#module@MyFunc").
Example:
In console, "#MyFunc Hello wo";
In script, "string MyFunc(string my) { return my + "rld!"; }";
Result in the message box: "Result: Hello world!".

Scripts are placed in the "/data" directory. List of loaded scripts is in scripts.cfg. The main script is mapper_main.fos, which contains all reserved functions, and basic list of API functions.

The mapper does not support FO and FO2 map formats, as well as older FOnline map formats.

On the main panel, there is a range of buttons that group the objects by their type.
Below these buttons, there's a panel with buttons toggling the display of items in the map view.
On the right, there are buttons that determine which objects will be selected by clicking and dragging the mouse.
Other buttons:
Fast - displays list of often used items;
Ign - Ignore, shows ignored objects that are not rendered on the map;
Inv - Inventory, shows objects inside a container or inside critters' inventory;
Lst - List, shows all loaded maps and allows to switch between them.

Upon selecting an object, an option window will appear allowing to edit some of it's properties (marked green; white are not editable).
To add an object to Ignored objects list, click it with Ctrl on the object selection panel.
To add an object to the container or inventory, click it with Alt on the object selection panel.
To put an object in a critter's slot, click the item in it's inventory with Shift.

To apply a change in the object properties window to a range of selected objects (of the same type), click To All button.

To remove selected object(s), press Del.

To change direction of a critter, use middle mouse button.

To add a range of objects to already selected objects, hold Ctrl.

To change zoom, use mouse wheel.

To speed up scrolling of objects in the panel, use the following:
Shift - one page,
Ctrl - 100 elements,
Alt - 1000 elements.

To play animation of a selected critter, use "@" command with codes of desired animations. For instance, to play animations of movement, and then using, type "@abal" (case is ignored, as well as whitespaces). If no critter is selected, all critters on the map will play the animation. For information on animation codes, see http://modguide.nma-fallout.com/#Graphics011

To move a critter, hold down Shift and click the desired position.

Hotkeys:
F1: Enable/Disable display of items.
F2: Enable/Disable display of sceneries.
F3: Enable/Disable display of walls.
F4: Enable/Disable display of critter.
F5: Enable/Disable display of tiles.
F6: Enable/Disable display of frequently used objects.
F7: Hide/Show the main panel.
Shift + F7: Fix the position of the main panel (enabled by default).
F8: Enable/Disable scrolling with mouse.
F9: Hide/Show the object properties window.
Shift + F9: Fix the position of the object properties window (disabled by default).
F11: Set rain.
Shift + Escape: Exit the mapper.
Del: Delete the selected objects.
Ctrl + X: Cut objects.
Ctrl + C: Copy objects.
Ctrl + V: Paste objects.
Ctrl + A: Select all.
Ctrl + S: Enable/Disable ignoring of scroll blockers.
Ctrl + B: Show impassable hexes. Red are impassable, and not shootable through. Green are impassable, shootable through.
Ctrl + M: Display NPC information over their heads (this has few modes of display).
Ctrl + L: Save the log to a txt file.
Tab: Change the type of objects selection (diamond or rectangle).
+: Change time by 1 hour.
-: Change time by -1 hour.

Special Entires:
0 - default;
240 - starting position for a player who logged for a first time;
241 - starting position for players on a map with NoLogOff flag.
242 - replication.
243 - car entry point.
245 - vertibird entry point.
246 - boat entry point.

Okay, I think this list of tips is enough for a few days of map making for now.

5.

You have made a map, cleared the server cache, added the map into mapper, created a location, added the map to it, added it to the WM and... The server crashes, saying your map "doesn't exist"?

Someone didn't bother to set up adequate error reporting. Check your entry points and their codes. Your map must be visitable.

PPS

why does it add smileys... weird... Cuz I didn't post this smiley ->
« Last Edit: August 05, 2017, 05:49:45 pm by cthulchu »

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
Re: Basic Development Tutorial for FOnline. (Reloaded)
« Reply #19 on: August 04, 2017, 01:53:01 pm »
Thanks for the correction, I fixed the typos.

You get a smiley after free :), because everyone is happy for free stuff and BBCodes know this.

cthulchu

  • Supporter
  • Posts: 211
    • View Profile
Re: Basic Development Tutorial for FOnline. (Reloaded)
« Reply #20 on: August 05, 2017, 05:53:16 pm »
I have a few questions after making a few maps with the mapper.

  • What is this about? Kilgore said it's cuz maps needed at least one scenery object. Do they need it now? I remove this stuff from my maps and they work fine. Don't like legacy rubbish.
  • Why do we have all these empty fallout2 maps in the maps folder?
  • Water is tough. Are there nice and simple ways to make water easy? Tiles look the same, but don't stack. I found a way, but it's rather tricky
  • Is there a nice way to delete all objects that are duplicated on the same tile? I mean, there is *dupl, but it just returns a list of coordinates. Oh there is!!! #ClearTiles!
  • I found out the mapper uses server's scripting engine, so we can create custom scripts (macros-like) for the mapper. Is there an example of such script? I'm mostly interested in how to run those in the mapper.
  • Is there a way to remove everything that's underneath this thing I'm drag and dropping in the mapper?
  • Can we place a few tiles at a time? Like I want to make water, but then I want it automatically to restrict players to walk on it, so I need to put blockers on top at the same time...
  • Why do I have duplicates here?
  • How do I copy the answers in the dialogue editor? Or how do I use answers for dialogue A from a dialogue B... Looks like I'm missing something here. I could add a technical answer to A that would send the branch to dialogue B, but it's not very elegant

I have some more in-depth questions regarding server mechanics, but I'll ask them on fodev.

PS

Now we need an ultimate manual that would unite all the existing manuals. I have read five different manuals on mapping and each has brought something unique. And mapping is not the complex thing. This manual though is the best to start with.
« Last Edit: August 05, 2017, 06:35:04 pm by cthulchu »

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
Re: Basic Development Tutorial for FOnline. (Reloaded)
« Reply #21 on: August 05, 2017, 06:23:46 pm »
2. Why do we have all these empty fallout2 maps in the maps folder?

Because no one cleaned them up? I don't know, maybe Reloaded team knows. I wouldn't concern with details that are not part of your objective, whatever those are, simply because too much time can be wasted without finding sure answer.

9. How do I copy the answers in the dialogue editor? Or how do I use answers for dialogue A from a dialogue B... Looks like I'm missing something here. I could add a technical answer to A that would send the branch to dialogue B, but it's not very elegant

If the tool has missing features, you can use the files themselves, they are text based. Just open and copy paste.

10. I have some more in-depth questions regarding server mechanics, but I'll ask them on fodev.

Well, if it is related to FOnline: Reloaded, you should ask here first, as fodev is not based on Reloaded source.

Now we need an ultimate manual that would unite all the existing manuals. I have read five different manuals on mapping and each has brought something unique. And mapping is not the complex thing. This manual though is the best to start with.

Go ahead :)

cthulchu

  • Supporter
  • Posts: 211
    • View Profile
Re: 7. More on dialogs - Tracking quest progress.
« Reply #22 on: August 07, 2017, 10:37:28 pm »
  •    $   3   1   q_turo   0   0   1000   0
  • **********
  •    TuRo progress.
  • **********
the software fails to add vars. Could you please describe the significance of the flag property.

I mean, I saw the headers, but they are unclear:

Id   Type   Name      Start   Min   Max   Flags
**************************************************************************************
   $   1   0   car_id   0   0   0   4

What values of Flags mean what? I need a local map variable for an SE. Need it to die when a person leaves the map.

And the checkboxes. What's the meaning of them?

And what's the significance of having variables in the NPC or player? Do I understand it correctly that variables on an NPC can be accessed by other players while variable on a player can be accessed by other NPCs.

Therefore, if my "quest" is very local and affects only 1 npc and one player, it doesn't matter whether I choose NPC or player, I just have to be consistent. Am I understanding it correctly?

Would be nice to update that part of the manual.

And what is recheck?

And I need to do a hack. I've seen this logics somewhere: You talk to an npc, do something and then the same npc answers you with strings.
So what I intuitively did is:

if the var is 0, the player never interacted with the npc.
1 - interacted once, but never got to the end.
2 - went to the end and now has to get strings.
And here's what I get


How do I get the strings?

Thanks!
« Last Edit: August 08, 2017, 01:47:23 am by cthulchu »

Slowhand

  • Posts: 282
  • Go for the eye, Boo! Go for the eyes!
    • View Profile
Re: 7. More on dialogs - Tracking quest progress.
« Reply #23 on: August 08, 2017, 08:36:47 am »
  •    $   3   1   q_turo   0   0   1000   0
  • **********
  •    TuRo progress.
  • **********
the software fails to add vars. Could you please describe the significance of the flag property.

I mean, I saw the headers, but they are unclear:

Id   Type   Name      Start   Min   Max   Flags
**************************************************************************************
   $   1   0   car_id   0   0   0   4

What values of Flags mean what? I need a local map variable for an SE. Need it to die when a person leaves the map.

And the checkboxes. What's the meaning of them?

I don't know. The way I found out what I did, was to experiment and ask on fodev.net/irc. Didn't got exact specification. If you find out, let me know, or write a page on it.


And what's the significance of having variables in the NPC or player? Do I understand it correctly that variables on an NPC can be accessed by other players while variable on a player can be accessed by other NPCs.

Therefore, if my "quest" is very local and affects only 1 npc and one player, it doesn't matter whether I choose NPC or player, I just have to be consistent. Am I understanding it correctly?

Would be nice to update that part of the manual.


Try this to understand it better: Art of Dialogs

And what is recheck?

As check again? Make sure you did everything exactly as it you were supposed to. If you miss something it's hard to find out what and very frustrating. We need a better SDK.
Ah that recheck. Maybe I read something about it, but forgot, sorry.


And I need to do a hack. I've seen this logics somewhere: You talk to an npc, do something and then the same npc answers you with strings.
So what I intuitively did is:

if the var is 0, the player never interacted with the npc.
1 - interacted once, but never got to the end.
2 - went to the end and now has to get strings.
And here's what I get


How do I get the strings?

No clue about the strings, I even forgot there are strings in the dialog editor. I think I never used them.

Thanks!

You are welcome. To find out stuff, you need to experiment a lot and have even more patience. Basically it's learning by examples, just check other dialogues, how they use the strings or whatever you want to find out. I remember checking the Banker guy to find out how to use the 'ask' option in dialogues. If you played the game, that helps a lot, as you will know which NPC could have a script of dialog that you can check for examples.

If you find useful stuff, not covered, write a post about it.
« Last Edit: August 08, 2017, 08:39:11 am by Slowhand »

cthulchu

  • Supporter
  • Posts: 211
    • View Profile
Re: Basic Development Tutorial for FOnline. (Reloaded)
« Reply #24 on: August 08, 2017, 04:17:59 pm »
yeah, I just hoped you'd know.

And I believe some of the older npc's dialogues might be scripted without use of dialogues since the whole dialogueing system is a shortcut for scripts. Not sure when it was created and started being used. Maybe before hardcore work with dialogues it's better to start scripting to understand the real structure better. I'll see.

cthulchu

  • Supporter
  • Posts: 211
    • View Profile
Re: Basic Development Tutorial for FOnline. (Reloaded)
« Reply #25 on: August 09, 2017, 02:17:20 am »
Hey Slowhand, haven't you forgot to register your .fos in the section #8? I get this error:

Code: [Select]
[52:890] ProtoMap::BindSceneryScript - Map<pid<131>, name<se_oasis_cave_cth>>, Can't bind scenery function<s_Disassemble> in module<se_oasis.fos>. Scenery hexX<209>, hexY<101>
here's my .fos:

Code: [Select]
//  Includes some definitions
#include "_macros.fos"
#include "_dialogs.fos"
#include "_maps.fos"
#include "elevators_h.fos"
#include "factions_h.fos"
#include "mapdata_h.fos"
#include "messages_h.fos"
//  Function signature for player interactions with Scenery objects
bool s_Disassemble(Critter& player, Scenery& robot)
{

return RunDialog(player,robot.HexX, robot.HexY, 31338,false);
}

Don't mind the includes.
It compiles:
Code: [Select]
F:\Games\Fonline\Mapping\Server\scripts>ascompiler.exe se_oasis.fos -p prep.txt -d __SERVERs
Compiling se_oasis.fos ...
Success.
Time: 82,0483 ms.

F:\Games\Fonline\Mapping\Server\scripts>

I suspect I have to register my script either in scripts.cfg or in _scripts.fos I tried and it didn't work. Though maybe I did something wrong.
« Last Edit: August 09, 2017, 02:38:55 am by cthulchu »