Monster

This describes how Monster works, and what are all key properties of monster.


This is sub-layout for documentation pages

Top

1 Aggressivity

If monster is aggressive, then it will attack anyone within some radius \(r\), if he has no target assigned, and rules allow that

Aggressivity of monster is defined in map.json file, in the spawn point properties, as follows:

        "spawnPoints": {
        "monster": [{
          "nodeID": "N-7-5",
          "monsterID": "2",
          "__comment": "in seconds",
          "respawnSpeed": 300,
          "aggressive": 1
        }]}
      
where "aggressive" is one of the optional arguments.

2 Implementation - basic solution

The basic approach is to iterate all players within map, where is the monster. The players will be iterated every single time, monster gets updated, if monster is aggressive and has no combat target.
The complexity of this solution (for one monster) is \(O(n)\), \(n\) being the amount of players in map

3 Implementation - advanced solution

However, we can cut down the complexity for certain cases.
The idea is to use segments.
Therefore, algorithm in monster update() method will iterate only these players, that are in the same segment(s) as monster.
In worst case, we still remain at \(O(n)\), \(n\) being the amount of players in map,
that is because we can imagine case that all players in the map will be in one segment (one small area near monster), and monster will have no attack target, yet. (so, maybe when monster is killed, and respawns, but monster would have to be killed close to respawn point, which is difficult to arange, as monsters are mooving...)
Obviously, this is very improbable to happen, and even if we would create thousands of players, it would be extremelly difficult to arrange.
And even if so, the worst case