Spellcaster Studios

Make it happen…

RPG system – Part IV

Practically finished the technological aspects of the RPG system, with the addition of channeled and area-of-effect (AOE) abilities.

Had to change some of the RPG flow because of the periodic effects.

The problem was that it caused some erratic behaviors; considering that we had an “heartbeat” in the system, ticking every 2 seconds. So, every periodic effect (like resource regeneration, healing or damage effect, etc)  would trigger every 2 seconds. So, let’s imagine our enemy has a buff that restores some health every 2 seconds, and we are casting a channeled spell that does some damage also every 2 seconds, for 6 seconds:

Time (seconds) Effect Note
0 HB  
2 HB We start casting the channeled spell
4 HBD  
6 HBD  
8 HBD Casting finishes
10 HB  
12 HB  

 

where ‘H’ is the heartbeat, ‘B’ is the buff and ‘D’ is the damage. This seems alright (besides the fact that the smallest granularity of a periodic effect is 2 seconds).

Problem is when we don’t start casting at the exact moment of the heartbeat:

Time (seconds) Effect Note
0 HB  
1   We start casting the channeled spell
2 HBD  
4 HBD  
6 HBD  
7   Casting finishes
8 HB  
10 HB  

 

As you can see, we still get 3 ticks (tick is the effect of a periodic spell being applied) of the spell (as intended)… But while in the first case, we saw the first effect 2 seconds after the cast, on the second case, we see the first effect only 1 second after… This will lead to effects that aren’t clear for the player, since the “time” is indexed to an invisible heartbeat, instead of the time when the spell was casted.

Besides, the periodic behavior can only be felt every two seconds, so when the spell is affect by a stat like haste, it might make some effects disappear altogether. For example, lets imagine we have 100% haste, so each spell is twice as fast… That means that we should get a tick every 1 second, instead of 2 (getting a total of 6 ticks, instead of 3):

Time (seconds) Effect Note
0 HB  
1   We start casting the channeled spell
2 HBD  
3 D Damage should be felt, but isn’t because it’s not on a heartbeat “frame”
4 HBD  
5 D Damage should be felt, but isn’t because it’s not on a heartbeat “frame”
6 HBD  
7 D Casting finishes, and damage should be felt, but isn’t because it’s not on a heartbeat “frame”
8 HB  
10 HB  

 

So, in this case, haste would become useless for periodic effects, which is silly…

The way we fixed this is by having every ability have it’s internal heartbeat, which makes the system become way more predictable and (more importantly), makes the control of that heartbeat more organic (you can have spells that have a heartbeat of one second, and that will be affected by haste).

So, on the two examples above:

Time (seconds) Effect Note
0 HB  
1   We start casting the channeled spell
2 HB  
3 D Damage is applied
4 HB  
5 D Damage is applied
6 HB  
7 D Casting finishes, damage is applied
8 HB  
10 HB  

 

Time (seconds) Effect Note
0 HB  
1   We start casting the channeled spell
2 HBD Damage is applied
3 D Damage is applied
4 HBD Damage is applied
5 D Damage is applied
6 HBD Damage is applied
7 D Casting finishes, damage is applied
8 HB  
10 HB  

 

So the behavior becomes more “correct” with what was actually intended…

One final question that might arise is: why bother with ticks/heartbeats? Why not make the behaviors “realtime” dependent… In that case, if we wanted to elapse 30ms of time, we could just see what was the total effect (for example 100 damage in 6 seconds), and divide it evenly in time (would mean 0.5 damage in those 30 ms).

The problem with that is that the numbers make less “intuitive” sense, which makes it harder to balance. Another reason was that we would have to keep some historical data so that we would only display the aggregate of one or two seconds of effects (to display to the player, or for eventual add-ons, etc)… Finally, the game logic would become much harder for complex effects, like a periodic spell that deals increasingly larger damage (for example, a spell could deal 20 damage on first tick, 30 on the second, and 40 on the third; this would be a cool spell to have with haste, since every tick extension you could get that way was a large increase of damage… So normal speed would be 90 damage over 6 seconds (15 dps), and with enough haste to get another tick, you’d get 140 damage (23 dps)… that’s a big improvement, and hopefully it would lead players to find creatures and items that would increase haste instead of critical, for example). This could be implemented in a realtime fashion, but it would be much harder to implement, debug and change.

Now that this is done, I can start setting in stone the abilities of all the creatures the player will find in the game…

Comment