Data Model
The schema lives in Moondog.Core and is created with EF Core migrations.
Entities
User
- Identity fields via ASP.NET Core Identity
DisplayNameRole(PlayerorAdmin)CreatedAt,LastLoginAt
Item
- Id (authored, stable), Name (unique), Stackable, Weight, Category (Resource/Equipment/Consumable/PetEquipment/RefinedMaterial)
- DurabilityValue, BasePrice, Sellable, Unsellable
- Damage (nullable), WeaponType (nullable: Melee/Bow/Crossbow/Throwing)
- ProjectileSpeed, ProjectileRadius, AmmoType (item id reference), Range
- Description
- Resists (text,
category:percentpairs such asvenom:20: status-effect resists while worn) - CuresEffectId (nullable, status_effects): a consumable that ends that effect (an antivenom)
- GivesEffectId (nullable, status_effects): a consumable that starts that effect (a draught)
NodeType
- Id (authored), Name, Appearance, optional ModelPath (one scene, or several separated by
|as model variants), Kind (Resource/Sawmill/Crusher/Smelter/Kiln/Vendor/Taskmaster/Spawner/Creature) - SkillId (gathering skill), optional yields via NodeTypeYield
NodeTypeYield
- NodeTypeId + ItemId (composite key)
- Quantity, RequiresSkillId (lore gate), RequiresLevel
WorldEntity
- Id (identity), NodeTypeId (nullable), OwnerId (nullable)
- Position (X, Y, Z), RotationY (degrees), NpcData (jsonb for vendors/trainers/spawners/creatures/pets)
- Variant (nullable): which of its node type's
|-separated models it wears, counting from 1 - EntityKind (Box/Node/Vendor/Taskmaster/Spawner/Creature/Pet/Pack)
Skill
- Id (authored), Name, Category (Craft/General/Lore/Pet Combat), AdvancesBy (Use/Purchase)
- ParentId (skill tree), MaterialItemId (for Lore), RequiredSkillId (prerequisite)
- Description
CharacterSkill
- CharacterId + SkillId (unique)
- Level, Experience, UpdatedAt
Recipe
- Id (authored), Verb, StationKind, DurationSeconds
- RequiredSkillId (nullable), RequiredLevel (nullable)
RecipeInput / RecipeOutput
- RecipeId + ItemId (composite key)
- Quantity, IsPrimary (output only)
CraftingJob
- Id, CharacterId, StationEntityId, RecipeId
- AccumulatedMs, RunningSince (nullable), DurationMs, Quality
- CreatedAt
EntityDepletion
- EntityId (PK), DepletedAt, RefillsAt
CharacterItem
- Id, CharacterId, ItemId, Quantity, Quality (nullable), Durability/MaxDurability (nullable)
- Equipped, Slot (Head/Chest/Legs/Feet/Hands/MainHand/OffHand/Neck/Ring1/Ring2/Quiver/Belt)
- CreatedAt
Creature
- Id (authored), Name, Kind, Appearance, BaseHp, BaseDamage, AttackCooldownSec, MoveSpeed
- SkillXpReward, SkillId (advances on kill)
- PetSkillIds (csv of skill ids for taming)
- OnHitEffectId (nullable, status_effects), OnHitChance (0-1): a status effect its hits may give
- Its kind (
creature_kinds) carries Resists,category:percentpairs, for its creatures and pets
Smaller tables and columns (plain SQL)
node_types.RegrowSeconds: above 0, a picked-clean node is full again that long afterwater_bodies.Depth: water only counts down to Level - Depth (the ruin's flooded passage)hoard_loots: CharacterId + EntityId, LootedAt -- when each player last took from a hoardcharacter_tags: CharacterId + Tag, Source, SetAt -- player tags that NPC conversation checks branch on (cascades with the character)
Inscription (inscriptions, plain SQL)
- Id, Key (the level file's panel, unique), Title, X, Y, Z, Text
character_inscriptions: CharacterId + InscriptionId, Clarity (0-1, the best a character has made out), FirstReadAt: their Lore journal- Migration
BuildersInscriptions; see Dungeons
StatusEffect (status_effects)
- Id, Name (unique), Category (what resists name, e.g.
venom) - DamagePerTick, TickSec, DurationSec, Tint (
#rrggbb, the health bar's colour), Description - Migration
SpidersAndStatusEffects; see Creatures
CreatureInstance
- EntityId (PK), CreatureId, CurrentHp, State, LastCombatAt
CreatureLoot
- CreatureId + ItemId (composite key)
- MinQty, MaxQty, Chance, IsPrimary
Pet
- Id, CharacterId (owner), CreatureId (template), Name
- Level, CurrentHp, MaxHp, BaseDamage, AttackCooldownSec, MoveSpeed
- Experience, PetState (Following/Attacking/Staying/Dead)
- CreatedAt, UpdatedAt
PetItem
- Id, PetId, ItemId, Quantity, Quality (nullable), Equipped, Slot (Collar/Saddle/Charm)
- CreatedAt
PetSkill
- Id, PetId, SkillId, Level, Experience, CreatedAt, UpdatedAt
- Unique (PetId, SkillId)
Character (updated fields)
- Stamina (int, default 50) — current stamina pool
- MaxStamina (int, default 50) — maximum stamina
- StaminaRegen (float, default 5.0) — stamina recovered per second
Important indexes and constraints
- Character name is unique.
- Server status name is unique.
- Character belongs to user with cascade delete.
- Sessions and bans use foreign keys to users.
- CharacterSkill (CharacterId, SkillId) unique — enables upsert advancement.
- CharacterItem (CharacterId, ItemId) index — not unique (non-stacking items need multiple rows).
- Pet (CharacterId) — one active pet per character (enforced by application logic).
- PetSkill (PetId, SkillId) unique.
JSON payloads
Commands and audit details are stored as jsonb/text to keep the control protocol flexible.
Additional entities seeded/changed in Step 12 migration:
Item (changed/seed)
ProjectileSpeed(float, default 40.0) — units per second for projectile travelProjectileRadius(float, default 0.1) — sphere-sweep collision radiusAmmoType(int, nullable) — references matching ammo item idRange(float, default 0.0) — max effective distanceWeaponTypeextended: Melee / Bow / Crossbow / Throwing
Character (changed/seed)
Stamina(int, default 50) — current stamina; drained by Block/Parry/DodgeMaxStamina(int, default 50) — maximum stamina capStaminaRegen(float, default 5.0) — regenerated per server tick
Migration 20261025120000_Step12RangedCombat.cs (new)
- Adds columns to
itemsandcharactersDB tables - Seeds ranged weapons: Bow (item 20), Crossbow (item 21), Throwing Knife (item 22)
- Seeds ammo: Arrows (item 23), Bolts (item 24), Throwing Knives (item 25)
- Sets starting stamina (50/50/5.0) for all existing characters
Client Items (Equipment Panel)
- Quiver slot — new
Slotvalue "Quiver"; holds ammo items only - Ammo items: Arrows (item 23), Bolts (item 24), Throwing Knives (item 25)
- Ammo consumed on
ClientFireProjectileRPC, validated server-side
Projectile System (Phase 2)
ClientFireProjectileRPC → server validates weapon drawn + ammo + stamina → spawns projectile entity- Projectile ticks each physics frame:
pos += vel * dt, lifetime countdown, sphere-sweep collision vs creatures - Arrow radius 0.1, Bolt 0.15, Thrown 0.2 — matches 30Hz tick rate
ReceiveProjectileSpawnRPC (server → all clients) — visual spawnReceiveProjectileHitRPC (server → shooter) — impact effect, damage application
Active Defense (Phase 3)
| Action | Stamina Cost | Window | Cooldown | Effect |
|---|---|---|---|---|
| Block (hold) | 5/s | Continuous | None | 50% damage reduction |
| Parry (tap) | 15 | 0.3s | 1.5s | Stagger attacker, riposte window 0.5s |
| Dodge (double-tap WASD) | 25 | 0.4s iframe | 2s | Full iframe, moves 4m |
Housing / Personal Space (Step 19)
housing_plots table
Id(serial PK)ZoneId(integer, NOT NULL)Position(jsonb, NOT NULL) — {x, y, z}Size(text, default 'Small') — 'Small', 'Medium', 'Large'Price(integer, NOT NULL)OwnerId(uuid, nullable, FK → characters.Id)PurchasedAt(timestamptz, nullable)Permission(text, default 'Private') — 'Private', 'Friends', 'Guild', 'Party', 'Public'
housing_objects table
Id(serial PK)PlotId(integer, FK → housing_plots.Id, ON DELETE CASCADE)ItemId(integer, NOT NULL) — furniture itemPosition(jsonb, NOT NULL) — {x, y, z, rot}Data(jsonb, default '{}') — state (open/closed, fuel, etc.)
Plot Permissions
- Private: only owner
- Friends: owner + friends list
- Guild: owner + guild members
- Party: owner + party members
- Public: anyone
RPCs
| RPC | Mode | Args |
|---|---|---|
ClientBuyPlot | any_peer | plotId |
ClientPlaceObject | any_peer | plotId, itemId, x, y, z, rot |
ClientRemoveObject | any_peer | objectId |
ClientSetPlotPermission | any_peer | plotId, permission |
ReceivePlotUpdate | authority | plotId, data |
ReceiveObjectPlaced | any_peer | objectId, plotId, itemId, x, y, z, rot |
ReceiveObjectRemoved | any_peer | objectId |
Farming (Step 20)
See Farming.
crops table
Id(serial PK),Name(text, unique)Model(text) — how the bed draws it: flax, turnip, potatoCropItemId(integer, FK → items.Id) — what a harvest givesWetHours(real) — hours the bed must be wet to ripen itYieldMin,YieldMax(integer) — how many of the crop a harvest givesSeedItemId(integer, nullable, FK → items.Id),SeedMin,SeedMax— seed handed back with it
crop_seeds table
ItemId(integer PK, FK → items.Id) — an item that can be plantedCropId(integer, FK → crops.Id, ON DELETE CASCADE)
garden_beds table
One row per planted bed; an empty bed has none.
FurnitureId(uuid PK, FK → housing_furniture.Id, ON DELETE CASCADE)CropId(integer, FK → crops.Id)PlantedAt(timestamptz)WetMs(bigint) — wet time banked by earlier wateringsWateredAt(timestamptz, nullable) — the latest watering; it counts for up to 24 hours
A Water Pail's waterings are character_items.Stats.water.
housing_wells and housing_well_deliveries
A plot's well, the same columns as housing_stables (PlotId PK, Design,
X, Z, RotationY, Stage, BuildSeconds, BuildMs, BuildRunningSince), and what
was handed over to its site, as housing_stable_deliveries. Its design is
the housing_designs row well, Kind Well.
Guilds / Clans (Step 18)
guilds table
Id(serial PK)Name(text, NOT NULL, UNIQUE)Tag(text, NOT NULL, UNIQUE) — 2-5 char abbreviationLeaderId(uuid, FK → characters.Id)Level(integer, default 1)XP(bigint, default 0)Gold(integer, default 0)CreatedAt(timestamptz, default now())MOTD(text, default '')
guild_ranks table
Id(serial PK)GuildId(integer, FK → guilds.Id, ON DELETE CASCADE)Name(text, NOT NULL)Order(integer, NOT NULL)Permissions(jsonb, default '{}')- UNIQUE (GuildId, Order)
guild_members table
Id(serial PK)GuildId(integer, FK → guilds.Id, ON DELETE CASCADE)CharacterId(uuid, FK → characters.Id)RankId(integer, FK → guild_ranks.Id)JoinedAt(timestamptz, default now())ContributionXP(bigint, default 0)- UNIQUE (CharacterId)
guild_bank table
Id(serial PK)GuildId(integer, FK → guilds.Id, ON DELETE CASCADE)ItemRowId(integer, NOT NULL)Quantity(integer, default 1)DepositedBy(uuid, FK → characters.Id)DepositedAt(timestamptz, default now())
Default Ranks
- Leader (order 0): all permissions
- Officer (order 1): invite, kick, bank withdraw/deposit
- Member (order 2): bank deposit only
Permissions JSON
{
canInvite: true,
canKick: true,
canPromote: false,
canBankWithdraw: true,
canBankDeposit: true
}
RPCs
| RPC | Mode | Args |
|---|---|---|
ClientGuildCreate | any_peer | name, tag |
ClientGuildInvite | any_peer | targetCharacterId |
ClientGuildAccept | any_peer | guildId |
ClientGuildDecline | any_peer | guildId |
ClientGuildLeave | any_peer | — |
ClientGuildKick | any_peer | targetCharacterId |
ClientGuildPromote | any_peer | targetCharacterId, rankOrder |
ClientGuildSetRank | any_peer | rankName, permissions, order |
ClientGuildBankDeposit | any_peer | itemRowId, quantity |
ClientGuildBankWithdraw | any_peer | itemRowId, quantity |
ReceiveGuildUpdate | authority | guildId, data |
Trading & Market (Step 17)
trades table
Id(serial PK)PlayerA(uuid, FK → characters.Id)PlayerB(uuid, FK → characters.Id)State(text, default 'Pending') — 'Pending', 'Accepted', 'Confirmed', 'Completed', 'Cancelled'PlayerAItems(jsonb, default '[]')PlayerBItems(jsonb, default '[]')PlayerAGold(integer, default 0)PlayerBGold(integer, default 0)CreatedAt(timestamptz, default now())CompletedAt(timestamptz, nullable)
auction_listings table
Id(serial PK)SellerId(uuid, FK → characters.Id)ItemRowId(integer) — character_items rowQuantity(integer, NOT NULL)UnitPrice(integer, NOT NULL)BuyoutPrice(integer, nullable)DurationHours(integer, default 48)ListedAt(timestamptz, default now())ExpiresAt(timestamptz, NOT NULL)BuyerId(uuid, nullable, FK → characters.Id)SoldAt(timestamptz, nullable)Status(text, default 'Active') — 'Active', 'Sold', 'Expired', 'Cancelled'
Direct Trade Flow
- Player A sends ClientTradeRequest to Player B
- Player B accepts via ClientTradeAccept
- Both add items/gold via ClientTradeAddItem/ClientTradeAddGold
- Both confirm via ClientTradeConfirm
- Server validates and executes exchange atomically
Auction House Flow
- Player lists item via ClientAuctionList (validates ownership + quantity)
- Other players buy via ClientAuctionBuy (validates gold + status)
- Seller cancels via ClientAuctionCancel (only if Active)
- Expired listings auto-return items (TODO: background job)
RPCs
| RPC | Mode | Args |
|---|---|---|
ClientTradeRequest | any_peer | targetCharacterId |
ClientTradeAccept | any_peer | tradeId |
ClientTradeAddItem | any_peer | tradeId, itemRowId, quantity |
ClientTradeAddGold | any_peer | tradeId, amount |
ClientTradeConfirm | any_peer | tradeId |
ClientTradeCancel | any_peer | tradeId |
ReceiveTradeUpdate | authority | tradeId, state |
ClientAuctionList | any_peer | itemRowId, quantity, unitPrice, durationHours |
ClientAuctionBuy | any_peer | listingId |
ClientAuctionCancel | any_peer | listingId |
Party & Group Systems (Step 16)
parties table
Id(serial PK)LeaderId(uuid, FK → characters.Id)LootMode(text, default 'RoundRobin') — 'RoundRobin', 'NeedGreed', 'Master'CreatedAt(timestamptz, default now())
party_members table
Id(serial PK)PartyId(integer, FK → parties.Id, ON DELETE CASCADE)CharacterId(uuid, FK → characters.Id)JoinedAt(timestamptz, default now())- UNIQUE (PartyId, CharacterId)
Loot Modes
- RoundRobin: items distributed in turn order
- NeedGreed: players roll Need/Greed, highest Need wins
- Master: leader assigns loot manually
RPCs
| RPC | Mode | Args |
|---|---|---|
ClientPartyInvite | any_peer | targetCharacterId |
ClientPartyAccept | any_peer | partyId |
ClientPartyDecline | any_peer | partyId |
ClientPartyLeave | any_peer | — |
ClientPartyKick | any_peer | targetCharacterId (leader only) |
ReceivePartyUpdate | authority | partyId, members, lootMode |
ClientPartySetLootMode | any_peer | lootMode |
World Events (Step 15)
world_events table
Id(serial PK)Name(text, NOT NULL)EventType(text) — 'Invasion', 'Boss', 'ResourceSurge', 'Rift'ZoneId(integer, NOT NULL)SpawnEntityId(integer, nullable)Schedule(jsonb) — cron-like or intervalDurationSec(integer, default 1800)MinPlayers(integer, default 1)MaxPlayers(integer, default 50)RewardTable(jsonb, NOT NULL)Active(boolean, default false)StartedAt(timestamptz, nullable)EndsAt(timestamptz, nullable)
event_participation table
Id(serial PK)EventId(integer, FK → world_events.Id)CharacterId(uuid, FK → characters.Id)Contribution(integer, default 0)RewardClaimed(boolean, default false)
Event Lifecycle
Scheduled → Active → Completed/Failed → Cooldown
RPCs
| RPC | Mode | Args |
|---|---|---|
ClientJoinEvent | any_peer | eventId |
ClientLeaveEvent | any_peer | eventId |
ReceiveEventStart | any_peer | eventId, eventName, durationSec, maxPlayers |
ReceiveEventUpdate | any_peer | eventId, contribution, total |
ReceiveEventEnd | any_peer | eventId, success |
Quest System (Step 14)
quests table
Id(serial PK)Name(text, NOT NULL)Description(text)MinLevel(integer, default 1)PrereqQuestId(integer, FK → quests.Id)Repeatable(boolean, default false)Data(jsonb, NOT NULL) — steps, objectives, rewards
character_quests table
Id(serial PK)CharacterId(uuid, FK → characters.Id)QuestId(integer, FK → quests.Id)State(text) — 'Active', 'Completed', 'Failed', 'Abandoned'CurrentStep(integer, default 0)Progress(jsonb, default '{}') — objectiveId → countStartedAt(timestamptz, default now())CompletedAt(timestamptz, nullable)
Quest JSON Schema
{
steps: [
{
id: 1,
objectives: [
{type: Kill, target: Wolf, count: 5},
{type: Collect, itemId: 103, count: 10}
],
rewards: {xp: 100, gold: 50, items: [{itemId: 100, qty: 1}]},
nextStep: 2
}
],
prereqs: [{questId: 5, state: Completed}],
repeatable: false
}
Objective Types
- Kill: creatureId + count
- Collect: itemId + count (inventory check)
- Interact: entityId (world entity)
- Reach: zoneId + radius
- Talk: npcEntityId + dialogueNode
- Craft: recipeId + count
RPCs
| RPC | Mode | Args |
|---|---|---|
ClientAcceptQuest | any_peer | questId |
ClientAbandonQuest | any_peer | questId |
ReceiveQuestUpdate | authority | questId, state, step, progress |
ClientInteractNPC | any_peer | npcEntityId |
AI & Navigation (Step 13)
world_entities additions
- (int, nullable) — references patrol_paths.Id
- (float, default 30.0) — distance from spawn before returning
- (float, default 20.0) — distance at which creatures aggro
- (text, nullable) — archetype name for behavior
patrol_paths table
- (serial PK)
- (text, unique)
- (jsonb) — array of {x, y, z} positions
- (boolean, default true)
Creature AI State Machine
States: Idle → Patrol → Chase → Attack → Flee → Return
- Threat table with decay (10%/sec out of combat)
- Aggro on damage (threat += damage * 1.5)
- Leash: soft (25m warn, 35m force return)
- Patrol: half speed along waypoint path
- Flee: 1.5x speed away from target for 3s
- Return: heal to full, resume patrol/idle
RPCs
| RPC | Mode | Args |
|---|---|---|
| any_peer | entityId, state, targetId | |
| any_peer | entityId, x, y, z, rotY |
Ranged Weapons (Phase 4)
| Weapon | ProjectileType | Speed | Range | Damage | AmmoType |
|---|---|---|---|---|---|
| Bow | arrow | 40 | 30 | 8 | arrow |
| Crossbow | bolt | 35 | 25 | 12 | bolt |
| Throwing Knife | thrown | 50 | 15 | 6 | throwing |
Acceptance Criteria (Phase 0–2)
- Ranged: Player equips bow + quiver, fires arrows, hits creature at 20m, creature takes damage
- Block: Hold RMB → 50% damage reduction, stamina drains 5/s
- Parry: Tap RMB within 0.3s of hit → attacker staggered, riposte window
- Dodge: Double-tap direction → 0.4s iframe, moves 4m, 25 stamina
- Stamina: Drains on actions, regens 5.0/s, blocks actions at 0
- Projectile: Arrow travels at 40 units/tick, sphere-sweep collision, hits at range
- All existing checks green
Last updated: Step 12 Phase 0–4 (data model, defense, ranged weapons)