Structure / module placement: - Add scripts/5_Mission/YALootBoxes_MissionServer.c: a modded MissionServer that self-starts the manager in OnInit(). No init.c edit required anymore. - config.cpp: bind 5_Mission to missionScriptModule (4_World stays on worldScriptModule). Core logic correctly stays in 4_World; only the mission-lifecycle bootstrap lives in 5_Mission. Config create/read/write: - LoadAll now writes populated defaults for ALL four JSON files when missing (previously only main_config.json was generated; box_types/loot_lists/ spawn_locations were left empty, so a fresh install spawned nothing). - Add default-data factories (YALB_MkReq/MkFail/MkLoot/MkLoc/MkBoxType) and DefaultBoxTypes/DefaultLootLists/DefaultSpawnLocations builders mirroring configfiles.readme. The mod is now self-provisioning on first run. Docs: - Prefix.cpp: refreshed folder-layout summary; dropped stale init.c / simulationModule notes. - Manager.c: bootstrap comment now points to the 5_Mission self-start. - README.md: add Install & first-run section. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
111 lines
No EOL
3.7 KiB
C++
111 lines
No EOL
3.7 KiB
C++
// ============================================================
|
|
// FILE: config.cpp
|
|
// Place at mod root: YALootBoxes/config.cpp
|
|
// ============================================================
|
|
|
|
class CfgPatches
|
|
{
|
|
class YALootBoxes
|
|
{
|
|
units[] = {};
|
|
weapons[] = {};
|
|
requiredVersion = 0.1;
|
|
requiredAddons[] = { "DZ_Data", "DZ_Scripts" };
|
|
};
|
|
};
|
|
|
|
class CfgMods
|
|
{
|
|
class YALootBoxes
|
|
{
|
|
dir = "YALootBoxes";
|
|
picture = "";
|
|
action = "";
|
|
hideName = 1;
|
|
hidePicture = 1;
|
|
name = "YALootBoxes";
|
|
credits = "";
|
|
author = "";
|
|
authorID = "0";
|
|
version = "1.0.0";
|
|
extra = 0;
|
|
type = "mod";
|
|
dependencies[] = { "Game", "World", "Mission" };
|
|
|
|
class defs
|
|
{
|
|
// 4_World code (PlayerBase, Container_Base, ActionContinuousBase,
|
|
// ActionData, etc.) must load ONLY into the World script module.
|
|
// Binding it to gameScriptModule too forces it to compile inside
|
|
// 3_Game - where those World types don't exist yet - which is what
|
|
// produced all the "Unknown type" errors and aborted the server.
|
|
class worldScriptModule
|
|
{
|
|
value = "";
|
|
files[] = { "YALootBoxes/scripts/4_World" };
|
|
};
|
|
// 5_Mission bootstrap: a modded MissionServer that self-starts the
|
|
// lootbox manager. Lives in the Mission module because that's the
|
|
// only module with a mission-lifecycle entry point (OnInit).
|
|
class missionScriptModule
|
|
{
|
|
value = "";
|
|
files[] = { "YALootBoxes/scripts/5_Mission" };
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
// ------------------------------------------------------------
|
|
// Lootbox entity classes.
|
|
//
|
|
// BINDING: DayZ binds a CfgVehicles class to a script class by
|
|
// NAME. The three crate classes below do NOT each need their own
|
|
// script class - instead they all inherit from a shared config
|
|
// class "YALootBoxes_Base" whose name matches the script class in
|
|
// YALootBoxes_Lootbox.c. The engine walks the config inheritance
|
|
// chain upward until it finds a matching script class, so every
|
|
// crate resolves to the YALootBoxes_Base script type. The old
|
|
// "simulationModule" line did NOT do this and has been removed.
|
|
//
|
|
// BASE CLASS: these inherit from vanilla "Container_Base" (a real
|
|
// lootable container base). "ContainerObject" used previously is
|
|
// not a vanilla class. >>> VERIFY against your SDK <<< and, if the
|
|
// crate spawns with no cargo space, add a Cargo grid definition
|
|
// (e.g. itemsCargoSize[] = {x,y};) to YALootBoxes_Base below - the
|
|
// wooden_crate model + Container_Base may need it to hold loot.
|
|
//
|
|
// MODEL: wooden_crate.p3d path is a placeholder; replace with a
|
|
// real p3d you have. >>> VERIFY model path against your SDK <<<
|
|
// ------------------------------------------------------------
|
|
class CfgVehicles
|
|
{
|
|
class Container_Base;
|
|
|
|
// Shared, non-spawnable base. Name MUST match the script class
|
|
// "YALootBoxes_Base" in YALootBoxes_Lootbox.c for binding.
|
|
class YALootBoxes_Base : Container_Base
|
|
{
|
|
scope = 0;
|
|
vehicleClass = "Containers";
|
|
model = "\dz\structures\wood\wooden_crate.p3d";
|
|
};
|
|
|
|
class YALootBoxes_Crate_Military : YALootBoxes_Base
|
|
{
|
|
scope = 2;
|
|
displayName = "Military Crate (Locked)";
|
|
};
|
|
|
|
class YALootBoxes_Crate_Medical : YALootBoxes_Base
|
|
{
|
|
scope = 2;
|
|
displayName = "Medical Crate (Locked)";
|
|
};
|
|
|
|
class YALootBoxes_Crate_Industrial : YALootBoxes_Base
|
|
{
|
|
scope = 2;
|
|
displayName = "Industrial Crate (Locked)";
|
|
};
|
|
}; |