# dbMobHandler Documentation ## Overview This document describes the database relationships and interactions for the `dbMobHandler` class. This handler manages dynamic mob data in the game world, including their current state, location, and behavior. ## Handler Class **File:** `src/engine/db/handlers/dbMobHandler.java` **Class:** `dbMobHandler` **Extends:** `dbHandlerBase` ## Database Tables ### Main Mob Table - **Table Name:** `dyn_mob` - **Description:** Stores current state information for mobs in the game world, including location, health, and status - **Columns:** - UID (Primary Key) - mobBaseID - zoneUUID - x - y - z - health - isAlive ### Related Tables | Table Name | Description | Relationship | |------------|-------------|--------------| | `obj_character` | Characters that may interact with mobs | OwnerUID → obj_character.UID | ## Key Queries ### Get Mob by UID ```sql SELECT * FROM dyn_mob WHERE `UID` = ? ``` **File:** `dbMobHandler.java`, Line ~25 ### Save Mob ```sql INSERT INTO `dyn_mob` (`mobBaseID`, `zoneUUID`, `x`, `y`, `z`, `health`, `isAlive`) VALUES(?,?,?,?,?,?,?) ``` **File:** `dbMobHandler.java`, Line ~40 ### Get Mobs by Zone ```sql SELECT * FROM dyn_mob WHERE `zoneUUID` = ? ``` **File:** `dbMobHandler.java`, Line ~55 ## Relationships 1. **Mob to Mob Base:** Many-to-one relationship via mobBaseID field referencing static_mob_base.UID 2. **Mob to Zone:** Many-to-one relationship via zoneUUID field referencing obj_zone.UID 3. **Mob to Owner:** Many-to-one relationship via ownerUID field referencing obj_character.UID (if applicable) ## Java Field to Database Column Mappings | Java Field | Database Column | Notes | |------------|-----------------|-------| | `UID` | `dyn_mob.UID` | Unique identifier for the mob | | `mobBaseID` | `dyn_mob.mobBaseID` | UID of the base mob definition | | `zoneUUID` | `dyn_mob.zoneUUID` | Zone where the mob is located | | `x` | `dyn_mob.x` | X coordinate of mob position | | `y` | `dyn_mob.y` | Y coordinate of mob position | | `z` | `dyn_mob.z` | Z coordinate of mob position | | `health` | `dyn_mob.health` | Current health of the mob | | `isAlive` | `dyn_mob.isAlive` | Flag indicating if mob is alive | | `other fields...` | Various columns | Other properties related to mob state |