Objects spawned directly in the world (init.c / CE) are real BuildingBase entities, so attach a Search to them by classname - independent of the proxy framework (which needs a parent house; CCTCursorParent rejects parentless objects). - ActionYASearchObj: object-targeted (CCTNonRuined) Search; resolves the entry from target.GetObject().GetType() (substring), cooldown keyed by network id - modded BuildingBase.SetActions: attaches it to classes matching a search entry - Shared YAInteractionManager.PerformSearch() used by both proxy + object actions - Re-add vending_machine (works for standalone-spawned vending machines) Lets you make spawned loot boxes / vending machines lootable: add the classname (or a substring) as a 'search' entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4.2 KiB
YAInteraction
A DayZ server mod that adds interactable furniture (search for loot) and a two-stage repairable sink (repair, then gather water).
Requires @YAProxy — the furniture are proxies baked into house models, not entities. @YAProxy handles proxy detection + position sync; YAInteraction's actions extend
YAProxyActionBase. Load@YAProxybefore@YAInteraction(handled viarequiredAddons).
Features
- Searchable furniture — medical cabinet and fridge yield random items from weighted, config-defined loot tables. Per-object cooldown.
- Repairable sink — repair with a
Wrench/PipeWrench, then gather water into a held container. Per-player cooldown, configurable amount. - JSON-configured — interactables, loot tables and scalar tunables live in
JSON under
<ProfileFolder>/YAInteraction/. Defaults are written on first start and read (overriding defaults) on every start after. No target/loot classnames exist anywhere else in the codebase.
Target objects
Entries are matched by name as a substring, against either:
- a house proxy name (furniture baked into a building) via @YAProxy, or
- a standalone entity classname (objects spawned in the world via init.c / CE), targeted directly — no proxy needed.
| Name | Action | Loot table | Notes |
|---|---|---|---|
case_sink_a |
Repair → Gather Water | — | house proxy |
lekarnicka |
Search | MedTable | house proxy |
fridge |
Search | FoodTable | house proxy or standalone |
vending_machine |
Search | VendingTable | standalone only |
House-baked vending proxies can't be detected (the engine exposes no targetable object), but a vending machine spawned standalone (e.g.
CreateObjectEx("StaticObj_Furniture_vending_machine", …)in init.c) is a real entity and works. The same applies to any spawned object: add its classname (or a substring) to the registry as asearchentry to make it lootable.
Configuration files
Generated on first start under <ProfileFolder>/YAInteraction/:
settings.json— scalar tunables:WaterAmountMin,WaterAmountMax,SinkPlayerCooldownSec,ObjectCooldownSec.interactables.json— theInteractablesregistry and allLootTables. Each search entry hasSearchChance(% chance a search yields anything),SearchMin/SearchMax(item count on a successful search),CooldownSec, and aLootTableName.
Delete a file and restart to regenerate it from code defaults.
Structure
config.cpp / mod.cpp mod + script-module registration, metadata
scripts/3_Game shared game-layer placeholder (v2 hooks)
scripts/4_World/YAInteraction
Config/YAInteractionSettings.c serializable scalar settings (settings.json)
Config/YAInteractionData.c serializable registry + loot tables (interactables.json)
Config/YAInteractionConfigLoader.c JSON load/save + code defaults (singleton)
Config/YAInteractionConfig.c compile-time constants only
YALootTableManager.c weighted pick + item spawning
Entities/YAInteractionManager.c registry lookup + repair state
Actions/ Search / RepairSink / GatherWater actions
YAInteractionInit.c modded BuildingBase action injection
scripts/5_Mission/YAInteraction
YAInteractionMissionInit.c modded MissionServer.OnInit -> load config
Notes
- Config is loaded server-side at
MissionServer.OnInit(before any player connects). Clients fall back to in-code defaults for action injection. - Cooldowns and sink repair state are tracked in memory and reset on server
restart. CF persistence hooks are marked with
// TODO (v2). - All item and tool classnames are verified against the base game data.
Adding a new interactable
Edit interactables.json (add to Interactables, and a LootTables entry if
it searches), then restart. To change the built-in defaults, add one line to
BuildDefaultData() in YAInteractionConfigLoader.c:
d.Interactables.Insert(MakeEntry("Your_Classname", YAInteractionConfig.ACTION_SEARCH, YAInteractionConfig.TABLE_FOOD, Settings.ObjectCooldownSec));