DayZ 1.24
Loading...
Searching...
No Matches
StaticConstructionMethods Class Reference

Static Private Member Functions

static void SpawnConstructionMaterialPiles (notnull EntityAI entity, Man player, string cfg_path, string main_part_name, string damagezone_name="", bool is_base=false)
 spawns material from any construction; 'player' parameter optional
 

Detailed Description

Definition at line 1148 of file Construction.c.

Member Function Documentation

◆ SpawnConstructionMaterialPiles()

static void StaticConstructionMethods::SpawnConstructionMaterialPiles ( notnull EntityAI entity,
Man player,
string cfg_path,
string main_part_name,
string damagezone_name = "",
bool is_base = false )
inlinestaticprivate

spawns material from any construction; 'player' parameter optional

Definition at line 1151 of file Construction.c.

1152 {
1153 int child_count = GetGame().ConfigGetChildrenCount(cfg_path);
1154
1155 for (int i = 0; i < child_count; i++)
1156 {
1157 string child_name;
1158 GetGame().ConfigGetChildName(cfg_path, i, child_name);
1159
1160 //get type, quantity from material
1161 string config_path;
1162 string type;
1163 string slot_name;
1164 config_path = cfg_path + " " + child_name + " " + "type";
1165 GetGame().ConfigGetText(config_path, type);
1166 config_path = cfg_path + " " + child_name + " " + "slot_name";
1167 GetGame().ConfigGetText(config_path, slot_name);
1168 config_path = cfg_path + " " + child_name + " " + "quantity";
1169 float quantity = GetGame().ConfigGetFloat(config_path);
1170 config_path = cfg_path + " " + child_name + " " + "lockable";
1171 bool lockable = GetGame().ConfigGetInt(config_path);
1172
1173 //receive material quantity
1174 ItemBase attachment = ItemBase.Cast(entity.FindAttachmentBySlotName(slot_name));
1175 int slot_id;
1176
1177 //material still attached
1178 if (lockable) //if lockable
1179 {
1180 if (attachment)
1181 {
1183 attachment.GetInventory().GetCurrentInventoryLocation(src);
1184 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(entity) + " DropNonUsableMaterials UNlocking slot=" + src.GetSlot());
1185 entity.GetInventory().SetSlotLock(src.GetSlot(), false);
1186
1187 //detach if base
1188 if (is_base)
1189 {
1190 if (GetGame().IsMultiplayer() && player)
1191 {
1194 player.ServerTakeToDst(src, dst);
1195 }
1196 else
1197 entity.GetInventory().DropEntity(InventoryMode.PREDICTIVE, entity, attachment);
1198 }
1199 }
1200 }
1201 else
1202 {
1203 float pile_health;
1204 float qty_coef;
1205 vector destination = entity.GetPosition();
1206 //placed on helper memory point, if available
1207 if (entity.MemoryPointExists("" + main_part_name + "_materials"))
1208 {
1209 destination = entity.GetMemoryPointPos("" + main_part_name + "_materials");
1210 destination = GetGame().ObjectModelToWorld(entity, destination);
1211 }
1212 else if (entity.MemoryPointExists(main_part_name))
1213 {
1214 destination = entity.GetMemoryPointPos(main_part_name);
1215 destination = GetGame().ObjectModelToWorld(entity, destination);
1216 }
1217 //pile_health = GameConstants.DAMAGE_WORN_VALUE * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1218 pile_health = entity.GetHealth01(damagezone_name, "Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1219 qty_coef = 1 - (entity.GetHealthLevel(damagezone_name) * Construction.DECONSTURCT_MATERIAL_LOSS) - Construction.DECONSTURCT_MATERIAL_LOSS;
1220 quantity *= qty_coef;
1222 MiscGameplayFunctions.CreateItemBasePiles(type, destination, quantity, pile_health, true);
1223 }
1224 }
1225 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
void Construction(BaseBuildingBase parent)
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
Definition Inventory.c:1212
InventoryLocation.
static bool IsBaseBuildingLogEnable()
Definition Debug.c:779
Definition EnMath.c:7
proto native CGame GetGame()
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Floor(float f)
Returns floor of value.

References bsbDebugPrint(), Construction(), Math::Floor(), GetGame(), LogManager::IsBaseBuildingLogEnable(), Math::Max(), and GameInventory::SetGroundPosByOwner().

Referenced by TentBase::Deconstruct(), and ReceiveMaterialsServer().


The documentation for this class was generated from the following file: