Author Topic: Basic Development Tutorial for FOnline.  (Read 71206 times)

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
15. Modifying base mechanics - Only the easy parts.
« Reply #15 on: August 20, 2015, 05:39:56 pm »
15. Modifying base mechanics - Only the easy parts.

-to be edited later-

« Last Edit: January 07, 2016, 05:04:13 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
15.1 Modifying lock pick cooldown mechanic.
« Reply #16 on: August 20, 2015, 06:26:28 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, 07:24:49 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
??
« Reply #17 on: December 15, 2015, 01:39:56 am »
- to do later -
« Last Edit: January 08, 2016, 10:45:40 am by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #18 on: December 15, 2015, 01:41:32 am »
1
« Last Edit: December 18, 2015, 12:52:35 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #19 on: December 16, 2015, 08:04:47 am »
1
« Last Edit: December 18, 2015, 12:52:27 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #20 on: December 16, 2015, 08:08:26 am »
1
« Last Edit: December 18, 2015, 12:52:15 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #21 on: December 16, 2015, 08:11:12 am »
1
« Last Edit: December 18, 2015, 12:52:06 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #22 on: December 16, 2015, 08:12:36 am »
1
« Last Edit: December 18, 2015, 12:51:45 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #23 on: December 16, 2015, 08:13:44 am »
1
« Last Edit: December 18, 2015, 12:51:35 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #24 on: December 16, 2015, 08:15:24 am »
1
« Last Edit: December 18, 2015, 12:51:27 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #25 on: December 16, 2015, 08:18:44 am »
1
« Last Edit: December 18, 2015, 12:51:11 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
1
« Reply #26 on: December 16, 2015, 08:22:26 am »
1
« Last Edit: December 18, 2015, 12:51:02 pm by Slowhand »

Offline Slowhand

  • Go for the eyes, Boo! Go for the eyes!
a
« Reply #27 on: December 16, 2015, 08:23:31 am »
a
« Last Edit: December 18, 2015, 12:50:42 pm by Slowhand »

Offline Powerack

  • Administrátor na doživotí.
    • Powerackovo Doupě
Re: Basic Development Tutorial for FOnline.
« Reply #28 on: November 14, 2018, 03:37:27 pm »
Hi, I have a problem with the World Editor. This program started only once. I looked at the control and turned it off. When I tried to turn it on again, only a white window appeared and nothing went on. I tried running the program as an administrator, just like I tested compatibility with Windows XP and Windows 7. Nothing helps. I have Windows 10 Pro and .NET Framework 4 installed. Can you help me somehow? Thank you for your answer.
I am working on private server at: fonline.powerack.cz.
Why I cant use image in signature?

Offline Ghosthack

  • Rotator
  • Bytecruncher
Re: Basic Development Tutorial for FOnline.
« Reply #29 on: November 15, 2018, 07:39:29 pm »
Hi, I have a problem with the World Editor. This program started only once. I looked at the control and turned it off. When I tried to turn it on again, only a white window appeared and nothing went on. I tried running the program as an administrator, just like I tested compatibility with Windows XP and Windows 7. Nothing helps. I have Windows 10 Pro and .NET Framework 4 installed. Can you help me somehow? Thank you for your answer.

Hi, see https://fodev.net/forum/index.php/topic,30010.0.html - this is an old bug.