-
Notifications
You must be signed in to change notification settings - Fork 5
How loading creatures works
We currently have two tables that hold creatures:
1.creature_template - this holds information about each creature like health,mana and damage
2.creatures - this holds information about the creatures in the game. They have a unique ID (GUID), the creature_template entry (ID), the zone the sub_zone is in, the sub_zone they're spawned in.
When starting up the game, it firstly loads the player's zone. For example: Elwynn Forest Then, it gets the appropriate zone object from the ZONES dictionary that holds a class object for each zone. (This is used so we can easily hold information about which monsters are dead and not have to reload the monsters from the DB whenever a character re-enters a zone) Then, we use the zone's method of loading the creatures according to the sub_zone we're in. Example: We're in Elwynn Forest, Northshire Abbey. The method will return all creatures that are there.
The method returns REFERENCES to a dictionary - Key: Monster GUID, Value: Monster Object from class Monster in entities.py and a set of tuples inside the zone's class - ((Monster GUID, Monster Name)). This set is used to convert the player command "engage MonsterName" to a GUID which is used to point to the specific monster in the aforementioned dictionary.
The dictionary and set get passed as a reference to the combat.py module and when the monster is killed we delete it from the dictionary and set so that it cannot be engaged anymore.