Skip to content

Entity model ​

The asset tree lives in templates/assets/scripts. Entity types are declared in scripts/entities.xml, defined in scripts/entity_defs/*.def, and split into per-face scripts under scripts/base/, scripts/cell/, scripts/client/ and scripts/bots/.

Entity types ​

EntityFacesRole
AccountbaseLogin proxy; creates/restores avatars, hands the client over, then creates the cell
Avatarbase + cell + clientThe cultivator: cultivation, combat, inventory, sect membership, pets
Monstercell + clientDemon beast with the AI state machine; streamed aiState reaches client views
Petbase + cellCompanion; follows the owner (5) and teleports beyond 20
Formationbase + cellUp to 5 members within radius 10; +10% damage per member
SectbasePersistent roster (100 cap) with rank ladder and departments, funds, instanced sect maps, quest board (QUEST_ENTRY array)
TaskbaseLive quest instance (16 persisted fields: goal/progress/state/rewards); writeToDB(None, 1) sets autoload so live rows restore on boot; delivered rows removed via destroy(deleteFromDB=True)
NpccellStatic presence (npcKind catalog key): answers talk and offer requests from any avatar in range (5), replies straight to the caller's cell (onNpcTalkReply / onNpcOfferReply)
ArenaMgrbaseArena referee in service group 2: sweeps PENDING avatar rows from the shared DB, loads entrants, writes ACTIVE custody locks, drives the radar-driven boss fight and force-returns stuck entrants
MailbasePersistent mail row carrier: the entity lands one tbl_Mail row at send time (writeToDB then destroy() — deleteFromDB defaults to False, the row outlives the entity), attachments ride the engine nested child table tbl_Mail_attachments; recipients act on rows through executeRawDatabaseCommand, never loading the entity
ItembasePersistent item carrier (bag stacks, depot, mail-attachment slot shape)
Equipmentbase (Parent=Item)Wearable gear: slot, strengthen level, attribute bonuses
Talismanbase (Parent=Item)Charged AOE consumable (power 20, 30s, charges)
StorageBag / SpatialRing / StorageSpacebase (Parent=Item)Container item tiers (12/4/40 slots): capacity + contents ARRAY<ITEM_INFO> persisted to a per-tier table plus nested *_contents child rows; owned via the avatar bar dbids, resolved by ownerDbid+className scan, autoload-restored on boot
Trade / Mall / PartybaseSession faces for trading, shop catalog, parties
Spaces / Spacebase (+cell for Space)World/instance management; sect maps at spaceIndex = 1000 + sectDbid

Interfaces ​

scripts/entity_defs/interfaces/ holds 22 interface defs (ROLE, Cultivation, Combat, Equip, Ride, Fashion, Social, PetKeeper, TalismanUser, SectMember, QuestTaker, NpcTalker, ArenaGoer, MailUser, ContainerKeeper, Trader, Partier, Shopper, BountyHunter, MercCaptain, OpsVip, FormationCaster). The engine merges them into host modules at load (entitydef.cpp loadInterfaces; duplicate member names are rejected). Avatar's gameplay faces are split across these files — e.g. reqAttack/reqGoto/reqRadarPing live in Combat.def, and the object-level jump from a call site lands on the declaring interface file. NpcTalker carries the NPC interaction face (scan/talk/walk-to/take-offer on the cell, seen/talk relays on the base). ArenaGoer carries the cross-server arena entry face (reqArenaEnter exposed on the base, onArenaKill from the cell) alongside Avatar's persisted arenaState / arenaWins mailbox properties. MailUser carries the mailbox face (reqSendMail / reqMailFetch / reqClaimMail / reqDeleteMail exposed on the base, onMailHeader / onMailList / onMailResult client pushes, and the base->cell mailGrantItems grant -- all-or-nothing, replayed on a bag copy first -- whose settlement hook onMailItemsGranted(dbid, ok) reports the grant or, on ok=0, reverts the claimed row so the mail stays claimable; a cell lost mid-claim releases the reservation and answers the pending claim no-cell right at the loss). ContainerKeeper carries the container face (reqContainerOpen / reqContainerList / reqContainerPut / reqContainerTake exposed on the base, onContainerOpened / onContainerResult client pushes, the base->cell containerTakeFromBag / containerGrantItems pair, and the containerSeedItems drill seed), alongside Avatar's persisted containerBar property. Combat also carries the skill face (reqLearnSkill / reqCastSkill exposed on the base, the base->cell castSkill / applyPassiveSkill pair, the onSkillEvent settlement relay, and the mana resource next to the skillSlots ARRAY<SKILL_SLOT> consumption face).

Script faces ​

  • base/ — persistent proxies. Avatar.__init__ deliberately does not enter the space: all three avatar-acquisition paths hand the client over (giveClientTo) before calling enterSpace, because the cell-create message carries hasClient as of send time and a late witness attach cannot rescue a create already in flight.
  • cell/ — the live simulation. Avatar combat (attack range 3.5, damage 15, cooldown 1.5s, 10s spawn guard stamped on every cell entry), Inventory bag (20 slots, stacking), Monster + the AI helpers in monster_ai.py (idle/wander/chase/attack/return, aggro 12, attack 2, leash 30, wander 8, speed 3).
  • client/ — client stubs. A module must exist here (or the type must be flagged in entities.xml) for the type to have a client face at all; without one the entity is never streamed into client views.
  • bots/ — headless player AI. The bots component resolves client-face entity modules only from scripts/bots/, so every client-face entity type needs a same-named class there (they subclass the bots Avatar, mirroring the def-level <Parent> chain).
  • common/ — pure functions: cultivation.py (realms, five-element affinity, stacking, formation rules) pinned by pytest under tests/python/; DemoConsts.py holds the tuned numbers.

Cultivation numbers ​

  • Realms: QiRefining → Foundation → GoldenCore → NascentSoul → SpiritTransform, exp thresholds 0 / 100 / 300 / 900 / 2700.
  • Five-element affinity damage multipliers: overcome 1.5, generate 1.1, overcome-by 0.8, neutral 1.0 (cultivation.affinity).
  • Spell: 10 base damage, 2s cooldown. Kill rewards: 10 gold, 30 exp.
  • Level display steps every 50 exp; death respawns after 5s at full health with a 10s spawn guard.

Kode documentation