## donderdag 12 januari 2012

### Speeds system explanation.

Basic Idea:

Mobs have a speed factor. Higher speed give more actions. Actions have a speed cost, higher values are bad. As they reduce the amount of actions that can be performed. For example, a knife stab has a speed cost of 7, but a battle axe has a speed cost of 14. When a mob takes an action, this cost is reduced from his current action point (AP) value. Each turn this value is increased by the mobs speed. Each turn has a certain amount of turn steps.

Example:
Say during a turn we have two mobs. One A with speed 12, a weaponspeed of 17, and a starting AP of -7, and we have mob B with speed 9, weaponspeed 11 and a starting AP of -1.

This is the progression of the turn:
 Turn 1 Step 0 1 2 3 4 5 6 7 8 9 10 11 12 13 AP, A -7 -6 -5 -4 -3 -2 -1 -17 -16 -15 -14 -13 -12 - AP, B -1 -11 -10 -9 -8 -7 -6 -5 -4 -3 - - - -
For end values of A = AP-12, and B = AP -3. With both having performed one action. A performed one attack at step 7, and B performed one attack at step 1.

Definitions:
- One loop of the speed system is called a turn. Each turn, there are a nr of steps equal to the highest speed of the mobs (this value is called maxSpeed). The current step is called the stepnr. The stepnr starts each turn at 0.
- The amount of steps in which a mob gets speedpoints (AP), is called his speed.
- The current (usually negative) amount of speedpoints, or action points, of a mob is called his AP. When this is at least zero, the mob can take an action. The current AP value is kept between turns.

Example 2:
We have mobs with speed: 12, 13, 8 and 7. The turn has 13 steps. But the mobs only get an AP if the current stepnr is lower than their speed. So the list of mobs above would stop getting AP’s at the following stepnrs 11, 12, 7 and 6 (resp). And the max stepnr would be 12 (maxSpeed -1).

This system allows for some interesting speed effects. Certain tactics and weapons have higher speed costs to balance them out. And damaging a mobs movement form could reduce his movement speed. (A wounded leg moves slower than a healthy leg is the assumption here). Which allows the addition of interesting ideas for the monster. Do you go with the stronger but slower leg, and use the kicking skill. Or do you go for the faster cheetah legs who decrease the movement action cost.

The system does have a few minor problems. It isn't currently clear what happens if two mobs have the same speed and current AP. Who gets to perform the first action. (I will probably go for the low tech, who is earlier in the mob list option).

But it is also deterministic. Which allows players to abuse the dumber AI. Tactics like pillar dancing and other abuses of higher speed are possible with this system. This makes the game a lot easier, as a higher speed mob can attack, and move away before the other mob can react. A system like dungeon crawls energy randomization would be interesting, or at least reduce one possible way of scumming. But for now I'll keep this system.

I think it is easy to abuse for high levels of speed and low levels of speed costs. A mob with speed 15 and using a dagger of quickness with speed cost of 3 could get 5 attacks each turn. If the weapon also has on hit/use procs it could do a lot of damage pretty fast.

When effects (paralization, or poison effects for example) are handled is also not defined yet. There are two main possibilities, just once each turn. (So high speed mobs do not get multiple effects each turn). Or Have them affect mobs once every x steps, Then a high speed mob gets affected faster by poison, and buffs run out quicker. The reason for that could be their high metabolism. Currently I'm favoring the once a turn system.

All issues for later of course. First job is to implement this system.

Implementation issue: Had a small problem with updating the list of monsters if you killed one during play. Another issue with the system, what happens when speed gets recalculated during a turn?