create_world_leveldesign - ryzom/ryzomcore GitHub Wiki


title: Adding NPCs and mobs description: published: true date: 2023-03-14T15:46:47.818Z tags: editor: markdown dateCreated: 2023-03-10T15:51:38.956Z

Tool

Run _r_check.bat to enable the R: drive Run cmd_tools.bat to get the tools terminal From there type world_editor.exe and hit enter to launch

Project Organization

Open for example leveldesign/continents/fyros_newbie.worldedit This has primitives under leveldesign/primitives/fyros/nland/*.primitive Primitives are like different layers of AI and missions and so on For nland there's

  • botobject_fyros_nland.primitive: Bot objects are just static decorations that are placed by the leveldesigner. These are things like crates, towers, and decorative Mektoub Packers. Generally these don't move, but the idea is that these could be made to appear as needed at runtime, based on leveldesign needs.
  • deposit_fyros_nland.primitive: All the places where players can forage.
  • staticfauna_fyros_nland.primitive: Mobs groups that are placed by the levedesigner. This specifies for each spawn their spawn area, the area where they feed, and the area where they sleep. You can use this to make carnivores eat where the herbivores sleep.
  • task_fyros_nland.primitive: All the generic mission giver NPCs, and foraging zones for mission items.
  • urban_fyros_nland.primitive: All the common NPCs, like guards, merchants, and so on, go here.

Placing bot objects

Add the botobject primitive to the worldedit continent. Inside you add an npc_manager object, you can name it like bot_object_placename. Within the npc_manager, add an npc_zone, name it for example bot_object_crates, leave the settings to default. Inside that, add an npc_group, again leave all settings default. Then in the npc_group, add an npc_bot, enable is_stuck and set the sheet_client to object_3_crate for example. Click it in the tree, it'll be highlighted somewhere in the map. Drag it to where you like.

Use shortkeys "O" to see collisions in the landscape, and "D" to see more detail of the bot objects like direction. You can use the Turn (F7) (not Rotate) tool to turn around the bot object in another direction.

If the primitive is new, you'll need to register and identifier under leveldesign/primitives/file_index.cfg, and add it to load on the map in leveldesign/primitives/primitives.cfg.

(Maybe file_index.cfg will need to be autogenerated in the future, it's a hassle. The IDs give all your entities persistent unique identifiers. All entities have a unique ID within the primitive as well.)

Adding forage zones

Add a depositzone_list, this is just a folder Under that, add a depositzone With the deposit zone selected in the tree Enable "Edit points" mode Then enable "Add points" mode in the toolbar Click to draw the zone, it's counter clockwise Then hit Space to finish the zone Right click deposit zone and hit help to get all the help html for deposit zones, (maybe better to transfer those to the wiki!)

Adding static fauna spawns

If you don't have a headache yet, congrats on getting this far.

Open up or make a new static fauna primitive for your continent. Add a fauna node, this is just a nice folder to organize your mobs by area or whatever, you can name it like fauna_near_village or something Under this folder, add a group_fauna. This'll make three points, a spawn, food, and resting point. You can move the points around, and change the radius from the node's properties panel. In the group, then add a population node, just leave the properties default, and add a people node under that. There you pick the number of mobs to spawn, and the name of the creature sheet (Todo. Would be neat to see the actual names from the translation sheets instead of only the code names.) You can adjust some setting in the population node properties to specify whether the mob only respawns during the day or at night to make things more scary.

Adding NPCs

Guards

Like with bot objects, first make an npc_manager for your area Make an npc_folder under that for the guards if you like Then make an npc_zone, set ai_activity to guard, and ai_movement to wander In there, make an npc_group, default settings Add an npc_bot, and set a good sheet_client and visual options

For chat parameters, you can hook up some text from phrases to the menu like menu: MENU_WHOAMI WHOAMI_NEWB_FYROS_GUARD

Under equipment, it follows some format that looks like this

CU: 0
CH: 0 1 2 3
CL: 0
HAT

To add some custom behaviour when the guards start fighting or kill something Add an npc_group_event_handler, pick an event like bot_begin_fight Then under that add an npc_event_handler_action, for example say Under parameters for say, you can pick a phrase from translations data like say:GUARD_NEWB_FYROS_KILL_2

You can also use these events to run custom written AI scripts. You can have long running timed sequences by writing a scripted state machine with a counter and a big switch selection.

These events and actions are the same as the ones you use in Ring. Ring dialog is a big AI script state machine.

Merchants

Same initial setup as guards, but ai_activity on no_change, and ai_movement to stand_on_start_point. On the npc group, set bot_chat_parameters to shop : fyros or whichever is appropriate. You can also already set a bot_sheet_client base here for the whole group.

On chat paremeters, like following format:

shop:FYROS_NEWBIELAND_WEAPON_FYROS
menu: MENU_WHOAMI WHOAMI_NEWB_FYROS_MERCHANT_WEAPON

The shop types are defined in code/ryzom/server/data_shard/egs/shop_category.cfg.

Menu phrases are in leveldesign/translations

Mission

Mission script is different from AI script. AI script are executed by AI service and are global state of the NPC. Missions are executed by the EGS, and their state is tied to the player.

Create mission giver

Same initial as merchant, but without the bot chat parameters. On the npc_bot, just add a mission

A very simple generic mission looks like this

#C001V001_50000

#mission craft
#mission tags, intro and journal texts

replayable
solo

#pre requisites
mission_icon :  generic_craft
player_replay_timer : 43000
req_fame : fyros 0

#money reward declaration
decl_price : var_reward_money : icfm1pd 18 1,2

decl : faction : fyros
mission_title : TEMPLATE_TASK_CRAFT_6_TITLE; 9; fyros
mission_desc : TEMPLATE_TASK_CRAFT_INTRO_1; icfm1pd; 1; 18; var_reward_money; 0; 9; fyros

#steps
craft : icfm1pd 1 18
give_item : icfm1pd 1 18 : giver

#rewards
recv_money : icfm1pd 18 1,2
recv_fame : fyros 420

Missions can also be edited visually within node tree, instead of as a text script.

Notes on missions

You must handle when giving items to players the case when player's bag is full, there should be a separate dialog to loop around back to the item giving state.

If you modify AI state during the mission and AIS goes down, or server is rebooted, mission may get stuck or not work correctly anymore. We need exception handlers to resume or abort the mission in these cases. This needs to be trackable per NPC in some way and not for the entire mission, as NPCs may be in different continents.

If mission is aborted by player, AI state affected by the mission needs to be reset or proceed in a sane way as well.

Ring portal

Same process as mission npc group or bot object Then add a npc_bot with chat parameters

web: MENU_RING_ENTRY ring_access_point=1

and sheet_client object_karavan_device_neutrl_sel to get the standard ring portal model For decoration, can add three object_street_lamp npc_bot around it

⚠️ **GitHub.com Fallback** ⚠️