Objects Entity
The objects entity represents all interactive world elements including NPCs, enemies, doors, chests, and environmental objects.
Managing objects in the admin panel
Objects are in the Game Objects section of the admin sidebar, under Objects (/reldens-admin/objects). The same section holds everything attached to an object: Animations, Assets, Objects Items Inventory, Trade - Items Requirements, Trade - Items Rewards, Objects - Skills, Objects - Stats, Objects - Class Types and Objects - Target Options:
To create an object:
- Log in to the admin panel at /reldens-admin and open Game Objects > Objects.
- Click Create New (the form opens at /reldens-admin/objects/edit).
- Select the Room ID. The Layer Name field (required) turns into a select with the layers of that room map: pick the layer where the object is placed.
- Fill in the Tile Index, or click Pick in map and click the tile on the rendered room map. Leave it empty for respawn area objects.
- Select the Class Type (base, animation, npc, enemy, trader, drop, multiple or timing).
- Fill in the Object Class Key (required and unique, for example npc_2) and the Client Key (required, the object identity in the scene, for example people_town_2).
- Fill in the Title shown to the players and the Private Params and Client Params JSON (see "Configuration Parameters" below).
- Check Enabled and click Save.
- Add the object spritesheet in Game Objects > Assets: select the object, set the Asset Type (for example spritesheet), the Asset Key, the Asset File name and the frame size in Extra Params (for example {"frameWidth":52,"frameHeight":71}). See Object Sprites for the file location.
- Optionally add the object Animations, Objects - Stats and Objects - Skills (enemies), the trader items in Objects Items Inventory and the trade rules in Trade - Items Requirements and Trade - Items Rewards.
- Restart the server so the room loads the new object.
In the form, r marks a required field and u a field that must be unique. To place a copy of an object, open it, click Duplicate, change the object class key and the tile index, and save. The Assets list and form:
For many objects at once use the Objects Importer in the Wizards section.
Key Properties
- room_id: Parent room/map reference
- layer_name: Tilemap layer name for placement
- tile_index: Tile index within layer
- class_type: Object type classification reference
- object_class_key: Server-side class identifier
- client_key: Unique object instance identity in the scene (the texture comes from asset_key in client_params, which falls back to client_key when omitted)
- title: Display name
- private_params: Server-only JSON configuration
- client_params: Client-side JSON configuration (includes asset_key and the animation settings)
- enabled: Object active status
Class Types
The Class Type selects the server class of the object (see Objects Types Entity). The sample data has an example of each one:
- base (1) - an object with a body and no behavior, the starting point for custom classes.
- animation (2) - plays its animation when a player walks into it (runOnHit) or clicks it (runOnAction). The town house doors (door_3 to door_9) open when a player walks into them.
- npc (3) - shows a dialog with the content text and the options buttons when a player clicks it in range. The base class only shows the dialog; what each option does is implemented by a custom class, like the healer npc_2, the weapons master npc_4 and the quest NPC npc_5 of the theme plugins.
- enemy (4) - an NPC with stats and skills that fights the players. The enemies are usually spawned by a multiple object.
- trader (5) - an NPC that buys and sells the items of its Objects Items Inventory, the merchant npc_3 (see NPC Traders).
- drop (6) - the items dropped on the floor that the players pick up, created by the rewards and by the player death drops, not placed in the admin (see Rewards Entity).
- multiple (7) - spawns and respawns many objects in a respawn area layer, like the enemies and the mining rocks (see Enemy Respawn Flow).
- timing (8) - the player clicks it and waits for a progress bar to get an item, like the fishing spots (see Timed Objects).
A custom class registered for the Object Class Key (server/customClasses/objects/[object class key]) is used instead of the class type, so a single object can have its own behavior.
Private Params
The Private Params JSON stays on the server and every key becomes a property of the object instance, so it can set any value the class reads. The common keys:
- runOnAction / runOnHit - react when a player clicks the object / walks into it.
- roomVisible / playerVisible - send the object animation to every player in the room / to the player that triggered it.
- collisionType, collisionResponse, hasState, bodyMass, collisionGroup - the physical body (see Collision Configuration).
- xFix / yFix - pixels added to the body position on the tile.
- interactionArea - pixels around the object where the player can interact (default from the server/objects/actions/interactionsDistance config for the NPCs).
- randomMovement - walk around the original position (see Random Movement).
- sendInvalidOptionMessage - NPCs answer when a player sends an option that does not exist.
Enemy keys:
- isAggressive and interactionRadio - aggressive enemies start the battle when a player walks in their respawn area within that radius in pixels (0 is the whole area).
- startBattleOnHit (true) - start the battle when the player touches the enemy.
- battleTimeOff (20000) - milliseconds without attacks before the enemy stops chasing the player.
- chaseMultiple (false) - the enemy accepts battles with more than one player at the same time.
- defaultSkillKey, defaultSkillTarget and defaultAffectedProperty - an extra skill without an Objects - Skills row (defaults from the server/enemies/default config).
The multiple objects add shouldRespawn, childObjectType or childObjectClassKey, and their private params are passed to every spawned object.
Client Params
The Client Params JSON is sent to the game client:
- asset_key - the texture (defaults to the client key), plus the animation settings frameStart, frameEnd, repeat, autoStart, hideOnComplete, restartTime, positionFix and the per direction animations (see Object Animations Engine).
- content and options - the NPC dialog text and buttons, each option is {"label":"Heal HP","value":1}.
- ui and template - the object has a dialog box, by default /assets/html/dialog-box.html.
- isInteractive - the sprite can be clicked (always on for the NPCs).
- classKey - client custom class of the object, and timingDuration for the timing objects.
The sample healer (npc_2, npc type with the Healer custom class):
// Private Params
{"runOnAction":true,"playerVisible":true,"sendInvalidOptionMessage":true,"collisionType":4,"hasState":true}
// Client Params
{"content":"Hello traveler! I can restore your health, would you like me to do it?","options":{"1":{"label":"Heal HP","value":1},"2":{"label":"Nothing...","value":2},"3":{"label":"Need some MP","value":3}},"ui":true,"autoStart":true,"animations":{"healer_1_down":{"start":0,"end":2},"healer_1_left":{"start":0,"end":2},"healer_1_right":{"start":0,"end":2},"healer_1_up":{"start":0,"end":2}}}
Related Data
- Objects - Stats and Objects - Skills - the enemy stats and the skills it uses (see Objects Stats and Objects Skills).
- Objects Items Inventory, Trade - Items Requirements and Trade - Items Rewards - what the traders sell and their exchange rules.
- Animations and Assets - the extra animations and the spritesheets of the object.
- Respawn > Respawn Areas - the amount of objects and the respawn time of the multiple objects (see Respawn Areas Entity).
Database Relations
- rooms: Parent room/map
- objects_types: Object type classification
- objects_animations: Animation configurations
- objects_assets: Sprite/asset configurations
- objects_items_inventory: Inventory contents
- objects_items_requirements: Interaction requirements
- objects_items_rewards: Interaction rewards
- objects_skills: Assigned skills
- objects_stats: Stat overrides
- respawn: Respawn configuration
Placement
The objects are not placed in the map file: each row says the room, the map layer and the tile index where the object is created when the room starts, and the multiple objects use all the tiles of their respawn area layer instead of a tile index. The Pick in map button of the form shows the room map to click the tile.
Related Documentation
- Object Animations Engine - How client_key, asset_key and the client_params animation settings become an animated sprite.
- Respawn Areas Entity - Objects that spawn and respawn enemies or resources on a map layer.
- Admin Panel Guide - How the room, layer name and tile index fields of the objects form are filled.
reldens