YALootBoxes/config.cpp
smthspec a84b6b1a2b Phase 2: structural/completeness fixes (correctness pass)
- config.cpp: fix script/config binding. Crates now inherit a shared
  YALootBoxes_Base config class (name-matches the script class) instead of
  relying on the non-binding simulationModule line. Base class changed from
  non-existent ContainerObject to vanilla Container_Base.
- Lootbox.c: same base class change; replace never-called GetActions
  override with the engine-correct SetActions()/AddAction().
- ActionOpen.c: BROKEN_BONE now uses player.SetBrokenLegs(eBrokenLegs.
  BROKEN_LEGS) instead of bogus GetHealthDamageManager().SetFracture();
  DecreaseHealth health-type arg empty-string changed to "Health" (3 sites).
- Config.c: restructure loot lists from a string-keyed map to a flat array
  of YALB_LootList{type,entries} for reliable JSON deserialization;
  GetLootListForType updated to linear scan; position made a ref array;
  document failEffects.chance as a weight, not a probability.
- loot_lists.json (configfiles.readme): match new array schema.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 21:49:37 +03:00

103 lines
No EOL
3 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
{
class gameScriptModule
{
value = "";
files[] = { "YALootBoxes/scripts/4_World" };
};
class worldScriptModule
{
value = "";
files[] = { "YALootBoxes/scripts/4_World" };
};
};
};
};
// ------------------------------------------------------------
// 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)";
};
};