DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ CanMakeGardenplot()

bool SpawnItemOnLocation::CanMakeGardenplot ( )
private

См. определение в файле ItemBase.c строка 5900

5905{
5906 override bool CanPutAsAttachment(EntityAI parent)
5907 {
5908 return true;
5909 }
5910};
5911
5913{
5914
5915};
5916
5917//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5918
5919class ItemBase extends InventoryItem
5920{
5924
5926
5927 static int m_DebugActionsMask;
5929 // ============================================
5930 // Variable Manipulation System
5931 // ============================================
5932 // Quantity
5933
5934 float m_VarQuantity;
5935 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5937 int m_VarQuantityMin;
5938 int m_VarQuantityMax;
5939 int m_Count;
5940 float m_VarStackMax;
5941 float m_StoreLoadedQuantity = float.LOWEST;
5942 // Wet
5943 float m_VarWet;
5944 float m_VarWetPrev;//for client to know wetness changed during synchronization
5945 float m_VarWetInit;
5946 float m_VarWetMin;
5947 float m_VarWetMax;
5948 // Cleanness
5949 int m_Cleanness;
5950 int m_CleannessInit;
5951 int m_CleannessMin;
5952 int m_CleannessMax;
5953 // impact sounds
5955 bool m_CanPlayImpactSound = true;
5956 float m_ImpactSpeed;
5958 //
5959 float m_HeatIsolation;
5960 float m_ItemModelLength;
5961 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5963 int m_VarLiquidType;
5964 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5965 int m_QuickBarBonus;
5966 bool m_IsBeingPlaced;
5967 bool m_IsHologram;
5968 bool m_IsTakeable;
5969 bool m_ThrowItemOnDrop;
5972 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5973 bool can_this_be_combined; //Check if item can be combined
5974 bool m_CanThisBeSplit; //Check if item can be split
5975 bool m_IsStoreLoad = false;
5976 bool m_CanShowQuantity;
5977 bool m_HasQuantityBar;
5978 protected bool m_CanBeDigged;
5979 protected bool m_IsResultOfSplit
5980
5981 string m_SoundAttType;
5982 // items color variables
5987 //-------------------------------------------------------
5988
5989 // light source managing
5991
5995
5996 //==============================================
5997 // agent system
5998 private int m_AttachedAgents;
5999
6001 void TransferModifiers(PlayerBase reciever);
6002
6003
6004 // Weapons & suppressors particle effects
6008 ref static map<string, int> m_WeaponTypeToID;
6009 static int m_LastRegisteredWeaponID = 0;
6010
6011 // Overheating effects
6013 float m_OverheatingShots;
6014 ref Timer m_CheckOverheating;
6015 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
6016 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
6017 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
6018 ref array <ref OverheatingParticle> m_OverheatingParticles;
6019
6021 protected bool m_HideSelectionsBySlot;
6022
6023 // Admin Log
6024 PluginAdminLog m_AdminLog;
6025
6026 // misc
6027 ref Timer m_PhysDropTimer;
6028
6029 // Attachment Locking variables
6030 ref array<int> m_CompatibleLocks;
6031 protected int m_LockType;
6032 protected ref EffectSound m_LockingSound;
6033 protected string m_LockSoundSet;
6034
6035 // ItemSoundHandler variables
6036 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
6037 protected int m_SoundSyncPlay; // id for sound to play
6038 protected int m_SoundSyncStop; // id for sound to stop
6039 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
6040
6042
6043 //temperature
6044 private float m_TemperaturePerQuantityWeight;
6045
6046 // -------------------------------------------------------------------------
6047 void ItemBase()
6048 {
6049 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
6053
6054 if (!g_Game.IsDedicatedServer())
6055 {
6056 if (HasMuzzle())
6057 {
6059
6061 {
6063 }
6064 }
6065
6067 m_ActionsInitialize = false;
6068 }
6069
6070 m_OldLocation = null;
6071
6072 if (g_Game.IsServer())
6073 {
6074 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
6075 }
6076
6077 if (ConfigIsExisting("headSelectionsToHide"))
6078 {
6080 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
6081 }
6082
6083 m_HideSelectionsBySlot = false;
6084 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
6085 {
6086 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
6087 }
6088
6089 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
6090
6091 m_IsResultOfSplit = false;
6092
6094 }
6095
6096 override void InitItemVariables()
6097 {
6098 super.InitItemVariables();
6099
6100 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
6101 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
6102 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
6103 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
6104 m_VarStackMax = ConfigGetFloat("varStackMax");
6105 m_Count = ConfigGetInt("count");
6106
6107 m_CanShowQuantity = ConfigGetBool("quantityShow");
6108 m_HasQuantityBar = ConfigGetBool("quantityBar");
6109
6110 m_CleannessInit = ConfigGetInt("varCleannessInit");
6112 m_CleannessMin = ConfigGetInt("varCleannessMin");
6113 m_CleannessMax = ConfigGetInt("varCleannessMax");
6114
6115 m_WantPlayImpactSound = false;
6116 m_ImpactSpeed = 0.0;
6117
6118 m_VarWetInit = ConfigGetFloat("varWetInit");
6120 m_VarWetMin = ConfigGetFloat("varWetMin");
6121 m_VarWetMax = ConfigGetFloat("varWetMax");
6122
6123 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
6124 if (IsLiquidContainer() && GetQuantity() != 0)
6126 m_IsBeingPlaced = false;
6127 m_IsHologram = false;
6128 m_IsTakeable = true;
6129 m_CanBeMovedOverride = false;
6133 m_CanBeDigged = ConfigGetBool("canBeDigged");
6134
6135 m_CompatibleLocks = new array<int>();
6136 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
6137 m_LockType = ConfigGetInt("lockType");
6138
6139 //Define if item can be split and set ability to be combined accordingly
6140 m_CanThisBeSplit = false;
6141 can_this_be_combined = false;
6142 if (ConfigIsExisting("canBeSplit"))
6143 {
6144 can_this_be_combined = ConfigGetBool("canBeSplit");
6146 }
6147
6148 m_ItemBehaviour = -1;
6149 if (ConfigIsExisting("itemBehaviour"))
6150 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
6151
6152 //RegisterNetSyncVariableInt("m_VariablesMask");
6153 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6154 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
6155 RegisterNetSyncVariableInt("m_VarLiquidType");
6156 RegisterNetSyncVariableInt("m_Cleanness",0,1);
6157
6158 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
6159 RegisterNetSyncVariableFloat("m_ImpactSpeed");
6160 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
6161
6162 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
6163 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
6164 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
6165 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
6166
6167 RegisterNetSyncVariableBool("m_IsBeingPlaced");
6168 RegisterNetSyncVariableBool("m_IsTakeable");
6169 RegisterNetSyncVariableBool("m_IsHologram");
6170
6173 {
6174 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
6175 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
6176 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
6177 }
6178
6179 m_LockSoundSet = ConfigGetString("lockSoundSet");
6180
6182 if (ConfigIsExisting("temperaturePerQuantityWeight"))
6183 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
6184
6185 m_SoundSyncSlotID = -1;
6186 }
6187
6188 override int GetQuickBarBonus()
6189 {
6190 return m_QuickBarBonus;
6191 }
6192
6193 void InitializeActions()
6194 {
6196 if (!m_InputActionMap)
6197 {
6199 m_InputActionMap = iam;
6200 SetActions();
6202 }
6203 }
6204
6205 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
6206 {
6208 {
6209 m_ActionsInitialize = true;
6211 }
6212
6213 actions = m_InputActionMap.Get(action_input_type);
6214 }
6215
6216 void SetActions()
6217 {
6218 AddAction(ActionTakeItem);
6219 AddAction(ActionTakeItemToHands);
6220 AddAction(ActionWorldCraft);
6222 AddAction(ActionAttachWithSwitch);
6223 }
6224
6225 void SetActionAnimOverrides(); // Override action animation for specific item
6226
6227 void AddAction(typename actionName)
6228 {
6229 ActionBase action = ActionManagerBase.GetAction(actionName);
6230
6231 if (!action)
6232 {
6233 Debug.LogError("Action " + actionName + " dosn't exist!");
6234 return;
6235 }
6236
6237 typename ai = action.GetInputType();
6238 if (!ai)
6239 {
6240 m_ActionsInitialize = false;
6241 return;
6242 }
6243
6244 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6245 if (!action_array)
6246 {
6247 action_array = new array<ActionBase_Basic>;
6248 m_InputActionMap.Insert(ai, action_array);
6249 }
6250 if (LogManager.IsActionLogEnable())
6251 {
6252 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
6253 }
6254
6255 if (action_array.Find(action) != -1)
6256 {
6257 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
6258 }
6259 else
6260 {
6261 action_array.Insert(action);
6262 }
6263 }
6264
6265 void RemoveAction(typename actionName)
6266 {
6267 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6268 ActionBase action = player.GetActionManager().GetAction(actionName);
6269 typename ai = action.GetInputType();
6270 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6271
6272 if (action_array)
6273 {
6274 action_array.RemoveItem(action);
6275 }
6276 }
6277
6278 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
6279 // Set -1 for params which should stay in default state
6280 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
6281 {
6282 ActionOverrideData overrideData = new ActionOverrideData();
6283 overrideData.m_CommandUID = commandUID;
6284 overrideData.m_CommandUIDProne = commandUIDProne;
6285 overrideData.m_StanceMask = stanceMask;
6286
6287 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
6288 if (!actionMap) // create new map of action > overidables map
6289 {
6290 actionMap = new TActionAnimOverrideMap();
6291 m_ItemActionOverrides.Insert(action, actionMap);
6292 }
6293
6294 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
6295
6296 }
6297
6298 void OnItemInHandsPlayerSwimStart(PlayerBase player);
6299
6300 ScriptedLightBase GetLight();
6301
6302 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6303 void LoadParticleConfigOnFire(int id)
6304 {
6305 if (!m_OnFireEffect)
6307
6310
6311 string config_to_search = "CfgVehicles";
6312 string muzzle_owner_config;
6313
6314 if (!m_OnFireEffect.Contains(id))
6315 {
6316 if (IsInherited(Weapon))
6317 config_to_search = "CfgWeapons";
6318
6319 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6320
6321 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
6322
6323 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
6324
6325 if (config_OnFire_subclass_count > 0)
6326 {
6327 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
6328
6329 for (int i = 0; i < config_OnFire_subclass_count; i++)
6330 {
6331 string particle_class = "";
6332 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
6333 string config_OnFire_entry = config_OnFire_class + particle_class;
6334 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
6335 WPOF_array.Insert(WPOF);
6336 }
6337
6338
6339 m_OnFireEffect.Insert(id, WPOF_array);
6340 }
6341 }
6342
6343 if (!m_OnBulletCasingEjectEffect.Contains(id))
6344 {
6345 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
6346 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6347
6348 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
6349
6350 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
6351
6352 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
6353 {
6354 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
6355
6356 for (i = 0; i < config_OnBulletCasingEject_count; i++)
6357 {
6358 string particle_class2 = "";
6359 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
6360 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
6361 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
6362 WPOBE_array.Insert(WPOBE);
6363 }
6364
6365
6366 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
6367 }
6368 }
6369 }
6370
6371 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6373 {
6376
6377 if (!m_OnOverheatingEffect.Contains(id))
6378 {
6379 string config_to_search = "CfgVehicles";
6380
6381 if (IsInherited(Weapon))
6382 config_to_search = "CfgWeapons";
6383
6384 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6385 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6386
6387 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
6388 {
6389
6390 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6391
6393 {
6394 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6395 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6396 Error(error);
6397 return;
6398 }
6399
6400 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6401 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6402
6403
6404
6405 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
6406 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6407
6408 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6409 {
6410 string particle_class = "";
6411 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6412 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6413 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
6414
6415 if (entry_type == CT_CLASS)
6416 {
6417 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6418 WPOOH_array.Insert(WPOF);
6419 }
6420 }
6421
6422
6423 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6424 }
6425 }
6426 }
6427
6428 float GetOverheatingValue()
6429 {
6430 return m_OverheatingShots;
6431 }
6432
6433 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6434 {
6435 if (m_MaxOverheatingValue > 0)
6436 {
6438
6439 if (!m_CheckOverheating)
6441
6443 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6444
6445 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6446 }
6447 }
6448
6449 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6450 {
6452 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6453
6455 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6456
6458 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6459
6461 {
6463 }
6464 }
6465
6467 {
6469 }
6470
6471 void OnOverheatingDecay()
6472 {
6473 if (m_MaxOverheatingValue > 0)
6474 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6475 else
6477
6478 if (m_OverheatingShots <= 0)
6479 {
6482 }
6483 else
6484 {
6485 if (!m_CheckOverheating)
6487
6489 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6490 }
6491
6492 CheckOverheating(this, "", this);
6493 }
6494
6495 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6496 {
6498 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6499 }
6500
6501 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6502 {
6504 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6506 }
6507
6508 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6509 {
6511 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6512 }
6513
6514 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6515 {
6517 m_OverheatingParticles = new array<ref OverheatingParticle>;
6518
6519 OverheatingParticle OP = new OverheatingParticle();
6520 OP.RegisterParticle(p);
6521 OP.SetOverheatingLimitMin(min_heat_coef);
6522 OP.SetOverheatingLimitMax(max_heat_coef);
6523 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6524
6525 m_OverheatingParticles.Insert(OP);
6526 }
6527
6528 float GetOverheatingCoef()
6529 {
6530 if (m_MaxOverheatingValue > 0)
6532
6533 return -1;
6534 }
6535
6537 {
6539 {
6540 float overheat_coef = GetOverheatingCoef();
6541 int count = m_OverheatingParticles.Count();
6542
6543 for (int i = count; i > 0; --i)
6544 {
6545 int id = i - 1;
6546 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6547 Particle p = OP.GetParticle();
6548
6549 float overheat_min = OP.GetOverheatingLimitMin();
6550 float overheat_max = OP.GetOverheatingLimitMax();
6551
6552 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6553 {
6554 if (p)
6555 {
6556 p.Stop();
6557 OP.RegisterParticle(null);
6558 }
6559 }
6560 }
6561 }
6562 }
6563
6565 {
6567 {
6568 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6569 {
6570 int id = i - 1;
6571 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6572
6573 if (OP)
6574 {
6575 Particle p = OP.GetParticle();
6576
6577 if (p)
6578 {
6579 p.Stop();
6580 }
6581
6582 delete OP;
6583 }
6584 }
6585
6586 m_OverheatingParticles.Clear();
6588 }
6589 }
6590
6592 float GetInfectionChance(int system = 0, Param param = null)
6593 {
6594 return 0.0;
6595 }
6596
6597
6598 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6599 {
6600 return 250;//default value
6601 }
6602
6603 float GetFilterDamageRatio()
6604 {
6605 return 0;
6606 }
6607
6609 bool HasMuzzle()
6610 {
6611 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6612 return true;
6613
6614 return false;
6615 }
6616
6618 int GetMuzzleID()
6619 {
6620 if (!m_WeaponTypeToID)
6621 m_WeaponTypeToID = new map<string, int>;
6622
6623 if (m_WeaponTypeToID.Contains(GetType()))
6624 {
6625 return m_WeaponTypeToID.Get(GetType());
6626 }
6627 else
6628 {
6629 // Register new weapon ID
6631 }
6632
6634 }
6635
6642 {
6643 return -1;
6644 }
6645
6646
6647
6648 // -------------------------------------------------------------------------
6649 void ~ItemBase()
6650 {
6651 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
6652 {
6653 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6654 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6655
6656 if (r_index >= 0)
6657 {
6658 InventoryLocation r_il = new InventoryLocation;
6659 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6660
6661 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6662 int r_type = r_il.GetType();
6663 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6664 {
6665 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6666 }
6667 else if (r_type == InventoryLocationType.ATTACHMENT)
6668 {
6669 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6670 }
6671
6672 }
6673
6674 player.GetHumanInventory().ClearUserReservedLocation(this);
6675 }
6676
6677 if (m_LockingSound)
6678 SEffectManager.DestroyEffect(m_LockingSound);
6679 }
6680
6681
6682
6683 // -------------------------------------------------------------------------
6684 static int GetDebugActionsMask()
6685 {
6686 return ItemBase.m_DebugActionsMask;
6687 }
6688
6689 static bool HasDebugActionsMask(int mask)
6690 {
6691 return ItemBase.m_DebugActionsMask & mask;
6692 }
6693
6694 static void SetDebugActionsMask(int mask)
6695 {
6696 ItemBase.m_DebugActionsMask = mask;
6697 }
6698
6699 static void AddDebugActionsMask(int mask)
6700 {
6701 ItemBase.m_DebugActionsMask |= mask;
6702 }
6703
6704 static void RemoveDebugActionsMask(int mask)
6705 {
6706 ItemBase.m_DebugActionsMask &= ~mask;
6707 }
6708
6709 static void ToggleDebugActionsMask(int mask)
6710 {
6711 if (HasDebugActionsMask(mask))
6712 {
6714 }
6715 else
6716 {
6717 AddDebugActionsMask(mask);
6718 }
6719 }
6720
6721 // -------------------------------------------------------------------------
6722 void SetCEBasedQuantity()
6723 {
6724 if (GetEconomyProfile())
6725 {
6726 float q_max = GetEconomyProfile().GetQuantityMax();
6727 if (q_max > 0)
6728 {
6729 float q_min = GetEconomyProfile().GetQuantityMin();
6730 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6731
6732 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6733 {
6734 ComponentEnergyManager comp = GetCompEM();
6735 if (comp && (comp.GetEnergyMaxPristine() || comp.GetEnergyAtSpawn()))//checking for a potential for energy, we need to check both values, as both are optional, only when both are set to 0, we know the item can't have energy
6736 {
6737 comp.SetEnergy0To1(quantity_randomized);
6738 }
6739 }
6740 else if (HasQuantity())
6741 {
6742 SetQuantityNormalized(quantity_randomized, false);
6743 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6744 }
6745
6746 }
6747 }
6748 }
6749
6751 void LockToParent()
6752 {
6753 EntityAI parent = GetHierarchyParent();
6754
6755 if (parent)
6756 {
6757 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6758 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6759 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6760 }
6761 }
6762
6764 void UnlockFromParent()
6765 {
6766 EntityAI parent = GetHierarchyParent();
6767
6768 if (parent)
6769 {
6770 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6771 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6772 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6773 }
6774 }
6775
6776 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6777 {
6778 /*
6779 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6780 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
6781 */
6782 ItemBase item2 = ItemBase.Cast(entity2);
6783
6784 if (g_Game.IsClient())
6785 {
6786 if (ScriptInputUserData.CanStoreInputUserData())
6787 {
6788 ScriptInputUserData ctx = new ScriptInputUserData;
6790 ctx.Write(-1);
6791 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6792 ctx.Write(i1);
6793 ctx.Write(item2);
6794 ctx.Write(use_stack_max);
6795 ctx.Write(-1);
6796 ctx.Send();
6797
6798 if (IsCombineAll(item2, use_stack_max))
6799 {
6800 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6801 }
6802 }
6803 }
6804 else if (!g_Game.IsMultiplayer())
6805 {
6806 CombineItems(item2, use_stack_max);
6807 }
6808 }
6809
6810 bool IsLiquidPresent()
6811 {
6812 return (GetLiquidType() != 0 && HasQuantity());
6813 }
6814
6815 bool IsLiquidContainer()
6816 {
6817 return m_LiquidContainerMask != 0;
6818 }
6819
6821 {
6822 return m_LiquidContainerMask;
6823 }
6824
6825 bool IsBloodContainer()
6826 {
6827 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6828 return false;
6829 }
6830
6831 bool IsNVG()
6832 {
6833 return false;
6834 }
6835
6838 bool IsExplosive()
6839 {
6840 return false;
6841 }
6842
6844 {
6845 return "";
6846 }
6847
6849
6850 bool IsLightSource()
6851 {
6852 return false;
6853 }
6854
6856 {
6857 return true;
6858 }
6859
6860 //--- ACTION CONDITIONS
6861 //direction
6862 bool IsFacingPlayer(PlayerBase player, string selection)
6863 {
6864 return true;
6865 }
6866
6867 bool IsPlayerInside(PlayerBase player, string selection)
6868 {
6869 return true;
6870 }
6871
6872 override bool CanObstruct()
6873 {
6874 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6875 return !player || !IsPlayerInside(player, "");
6876 }
6877
6878 override bool IsBeingPlaced()
6879 {
6880 return m_IsBeingPlaced;
6881 }
6882
6883 void SetIsBeingPlaced(bool is_being_placed)
6884 {
6885 m_IsBeingPlaced = is_being_placed;
6886 if (!is_being_placed)
6888 SetSynchDirty();
6889 }
6890
6891 //server-side
6892 void OnEndPlacement() {}
6893
6894 override bool IsHologram()
6895 {
6896 return m_IsHologram;
6897 }
6898
6899 bool CanBeDigged()
6900 {
6901 return m_CanBeDigged;
6902 }
6903
6905 {
6906 return 1;
6907 }
6908
6909 bool CanMakeGardenplot()
6910 {
6911 return false;
6912 }
6913
6914 void SetIsHologram(bool is_hologram)
6915 {
6916 m_IsHologram = is_hologram;
6917 SetSynchDirty();
6918 }
6919 /*
6920 protected float GetNutritionalEnergy()
6921 {
6922 Edible_Base edible = Edible_Base.Cast(this);
6923 return edible.GetFoodEnergy();
6924 }
6925
6926 protected float GetNutritionalWaterContent()
6927 {
6928 Edible_Base edible = Edible_Base.Cast(this);
6929 return edible.GetFoodWater();
6930 }
6931
6932 protected float GetNutritionalIndex()
6933 {
6934 Edible_Base edible = Edible_Base.Cast(this);
6935 return edible.GetFoodNutritionalIndex();
6936 }
6937
6938 protected float GetNutritionalFullnessIndex()
6939 {
6940 Edible_Base edible = Edible_Base.Cast(this);
6941 return edible.GetFoodTotalVolume();
6942 }
6943
6944 protected float GetNutritionalToxicity()
6945 {
6946 Edible_Base edible = Edible_Base.Cast(this);
6947 return edible.GetFoodToxicity();
6948
6949 }
6950 */
6951
6952
6953 // -------------------------------------------------------------------------
6954 override void OnMovedInsideCargo(EntityAI container)
6955 {
6956 super.OnMovedInsideCargo(container);
6957
6958 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6959 }
6960
6961 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6962 {
6963 super.EEItemLocationChanged(oldLoc, newLoc);
6964
6965 PlayerBase newPlayer = null;
6966 PlayerBase oldPlayer = null;
6967
6968 if (newLoc.GetParent())
6969 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6970
6971 if (oldLoc.GetParent())
6972 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6973
6974 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
6975 {
6976 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
6977
6978 if (rIndex >= 0)
6979 {
6980 InventoryLocation rIl = new InventoryLocation;
6981 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
6982
6983 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
6984 int rType = rIl.GetType();
6985 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
6986 {
6987 rIl.GetParent().GetOnReleaseLock().Invoke(this);
6988 }
6989 else if (rType == InventoryLocationType.ATTACHMENT)
6990 {
6991 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
6992 }
6993
6994 }
6995 }
6996
6997 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
6998 {
6999 if (newPlayer)
7000 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
7001
7002 if (newPlayer == oldPlayer)
7003 {
7004 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
7005 {
7006 if (oldLoc.GetType() == InventoryLocationType.CARGO)
7007 {
7008 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
7009 {
7010 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7011 }
7012 }
7013 else
7014 {
7015 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7016 }
7017 }
7018
7019 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
7020 {
7021 int type = oldLoc.GetType();
7022 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
7023 {
7024 oldLoc.GetParent().GetOnSetLock().Invoke(this);
7025 }
7026 else if (type == InventoryLocationType.ATTACHMENT)
7027 {
7028 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
7029 }
7030 }
7031 if (!m_OldLocation)
7032 {
7033 m_OldLocation = new InventoryLocation;
7034 }
7035 m_OldLocation.Copy(oldLoc);
7036 }
7037 else
7038 {
7039 if (m_OldLocation)
7040 {
7041 m_OldLocation.Reset();
7042 }
7043 }
7044
7045 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
7046 }
7047 else
7048 {
7049 if (newPlayer)
7050 {
7051 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
7052 if (resIndex >= 0)
7053 {
7054 InventoryLocation il = new InventoryLocation;
7055 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
7056 ItemBase it = ItemBase.Cast(il.GetItem());
7057 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
7058 int rel_type = il.GetType();
7059 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
7060 {
7061 il.GetParent().GetOnReleaseLock().Invoke(it);
7062 }
7063 else if (rel_type == InventoryLocationType.ATTACHMENT)
7064 {
7065 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
7066 }
7067 //it.GetOnReleaseLock().Invoke(it);
7068 }
7069 }
7070 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
7071 {
7072 //ThrowPhysically(oldPlayer, vector.Zero);
7073 m_ThrowItemOnDrop = false;
7074 }
7075
7076 if (m_OldLocation)
7077 {
7078 m_OldLocation.Reset();
7079 }
7080 }
7081
7082 if (oldLoc.GetType() == InventoryLocationType.TEMP)
7083 {
7084 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
7085 }
7086
7087 if (newLoc.GetType() == InventoryLocationType.TEMP)
7088 {
7089 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
7090 }
7091 }
7092
7093 override void EOnContact(IEntity other, Contact extra)
7094 {
7096 {
7097 int liquidType = -1;
7098 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
7099 if (impactSpeed > 0.0)
7100 {
7101 m_ImpactSpeed = impactSpeed;
7102 #ifndef SERVER
7103 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
7104 #else
7105 m_WantPlayImpactSound = true;
7106 SetSynchDirty();
7107 #endif
7108 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
7109 }
7110 }
7111
7112 #ifdef SERVER
7113 if (GetCompEM() && GetCompEM().IsPlugged())
7114 {
7115 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
7116 GetCompEM().UnplugThis();
7117 }
7118 #endif
7119 }
7120
7121 void RefreshPhysics();
7122
7123 override void OnCreatePhysics()
7124 {
7126 }
7127
7128 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7129 {
7130
7131 }
7132 // -------------------------------------------------------------------------
7133 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
7134 {
7135 super.OnItemLocationChanged(old_owner, new_owner);
7136
7137 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
7138 PlayerBase playerNew = PlayerBase.Cast(new_owner);
7139
7140 if (!relatedPlayer && playerNew)
7141 relatedPlayer = playerNew;
7142
7143 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
7144 {
7145 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
7146 if (actionMgr)
7147 {
7148 ActionBase currentAction = actionMgr.GetRunningAction();
7149 if (currentAction)
7150 currentAction.OnItemLocationChanged(this);
7151 }
7152 }
7153
7154 Man ownerPlayerOld = null;
7155 Man ownerPlayerNew = null;
7156
7157 if (old_owner)
7158 {
7159 if (old_owner.IsMan())
7160 {
7161 ownerPlayerOld = Man.Cast(old_owner);
7162 }
7163 else
7164 {
7165 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
7166 }
7167 }
7168 else
7169 {
7170 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
7171 {
7172 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
7173
7174 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
7175 {
7176 GetCompEM().UnplugThis();
7177 }
7178 }
7179 }
7180
7181 if (new_owner)
7182 {
7183 if (new_owner.IsMan())
7184 {
7185 ownerPlayerNew = Man.Cast(new_owner);
7186 }
7187 else
7188 {
7189 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
7190 }
7191 }
7192
7193 if (ownerPlayerOld != ownerPlayerNew)
7194 {
7195 if (ownerPlayerOld)
7196 {
7197 array<EntityAI> subItemsExit = new array<EntityAI>;
7198 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
7199 for (int i = 0; i < subItemsExit.Count(); i++)
7200 {
7201 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
7202 itemExit.OnInventoryExit(ownerPlayerOld);
7203 }
7204 }
7205
7206 if (ownerPlayerNew)
7207 {
7208 array<EntityAI> subItemsEnter = new array<EntityAI>;
7209 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
7210 for (int j = 0; j < subItemsEnter.Count(); j++)
7211 {
7212 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
7213 itemEnter.OnInventoryEnter(ownerPlayerNew);
7214 }
7215 }
7216 }
7217 else if (ownerPlayerNew != null)
7218 {
7219 PlayerBase nplayer;
7220 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
7221 {
7222 array<EntityAI> subItemsUpdate = new array<EntityAI>;
7223 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
7224 for (int k = 0; k < subItemsUpdate.Count(); k++)
7225 {
7226 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
7227 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
7228 }
7229 }
7230 }
7231
7232 if (old_owner)
7233 old_owner.OnChildItemRemoved(this);
7234 if (new_owner)
7235 new_owner.OnChildItemReceived(this);
7236 }
7237
7238 // -------------------------------------------------------------------------------
7239 override void EEDelete(EntityAI parent)
7240 {
7241 super.EEDelete(parent);
7242 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
7243 if (player)
7244 {
7245 OnInventoryExit(player);
7246
7247 if (player.IsAlive())
7248 {
7249 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7250 if (r_index >= 0)
7251 {
7252 InventoryLocation r_il = new InventoryLocation;
7253 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7254
7255 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7256 int r_type = r_il.GetType();
7257 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7258 {
7259 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7260 }
7261 else if (r_type == InventoryLocationType.ATTACHMENT)
7262 {
7263 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7264 }
7265
7266 }
7267
7268 player.RemoveQuickBarEntityShortcut(this);
7269 }
7270 }
7271 }
7272 // -------------------------------------------------------------------------------
7273 override void EEKilled(Object killer)
7274 {
7275 super.EEKilled(killer);
7276
7278 if (killer && killer.IsFireplace() && CanExplodeInFire())
7279 {
7280 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
7281 {
7282 if (IsMagazine())
7283 {
7284 if (Magazine.Cast(this).GetAmmoCount() > 0)
7285 {
7286 ExplodeAmmo();
7287 }
7288 }
7289 else
7290 {
7291 Explode(DamageType.EXPLOSION);
7292 }
7293 }
7294 }
7295 }
7296
7297 override void OnWasAttached(EntityAI parent, int slot_id)
7298 {
7299 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7300
7301 super.OnWasAttached(parent, slot_id);
7302
7303 if (HasQuantity())
7304 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7305
7306 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7307 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
7308 }
7309
7310 override void OnWasDetached(EntityAI parent, int slot_id)
7311 {
7312 super.OnWasDetached(parent, slot_id);
7313
7314 if (HasQuantity())
7315 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7316
7317 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
7318 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
7319 }
7320
7321 override string ChangeIntoOnAttach(string slot)
7322 {
7323 int idx;
7324 TStringArray inventory_slots = new TStringArray;
7325 TStringArray attach_types = new TStringArray;
7326
7327 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7328 if (inventory_slots.Count() < 1) //is string
7329 {
7330 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
7331 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
7332 }
7333 else //is array
7334 {
7335 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
7336 }
7337
7338 idx = inventory_slots.Find(slot);
7339 if (idx < 0)
7340 return "";
7341
7342 return attach_types.Get(idx);
7343 }
7344
7345 override string ChangeIntoOnDetach()
7346 {
7347 int idx = -1;
7348 string slot;
7349
7350 TStringArray inventory_slots = new TStringArray;
7351 TStringArray detach_types = new TStringArray;
7352
7353 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7354 if (inventory_slots.Count() < 1) //is string
7355 {
7356 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
7357 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7358 }
7359 else //is array
7360 {
7361 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
7362 if (detach_types.Count() < 1)
7363 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7364 }
7365
7366 for (int i = 0; i < inventory_slots.Count(); i++)
7367 {
7368 slot = inventory_slots.Get(i);
7369 }
7370
7371 if (slot != "")
7372 {
7373 if (detach_types.Count() == 1)
7374 idx = 0;
7375 else
7376 idx = inventory_slots.Find(slot);
7377 }
7378 if (idx < 0)
7379 return "";
7380
7381 return detach_types.Get(idx);
7382 }
7383
7384 void ExplodeAmmo()
7385 {
7386 //timer
7387 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7388
7389 //min/max time
7390 float min_time = 1;
7391 float max_time = 3;
7392 float delay = Math.RandomFloat(min_time, max_time);
7393
7394 explode_timer.Run(delay, this, "DoAmmoExplosion");
7395 }
7396
7397 void DoAmmoExplosion()
7398 {
7399 Magazine magazine = Magazine.Cast(this);
7400 int pop_sounds_count = 6;
7401 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7402
7403 //play sound
7404 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7405 string sound_name = pop_sounds[ sound_idx ];
7406 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
7407
7408 //remove ammo count
7409 magazine.ServerAddAmmoCount(-1);
7410
7411 //if condition then repeat -> ExplodeAmmo
7412 float min_temp_to_explode = 100; //min temperature for item to explode
7413
7414 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7415 {
7416 ExplodeAmmo();
7417 }
7418 }
7419
7420 // -------------------------------------------------------------------------------
7421 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7422 {
7423 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7424
7425 const int CHANCE_DAMAGE_CARGO = 4;
7426 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7427 const int CHANCE_DAMAGE_NOTHING = 2;
7428
7429 if (IsClothing() || IsContainer() || IsItemTent())
7430 {
7431 float dmg = damageResult.GetDamage("","Health") * -0.5;
7432 int chances;
7433 int rnd;
7434
7435 if (GetInventory().GetCargo())
7436 {
7437 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7438 rnd = Math.RandomInt(0,chances);
7439
7440 if (rnd < CHANCE_DAMAGE_CARGO)
7441 {
7442 DamageItemInCargo(dmg);
7443 }
7444 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7445 {
7447 }
7448 }
7449 else
7450 {
7451 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7452 rnd = Math.RandomInt(0,chances);
7453
7454 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7455 {
7457 }
7458 }
7459 }
7460 }
7461
7462 bool DamageItemInCargo(float damage)
7463 {
7464 CargoBase cargo = GetInventory().GetCargo();
7465 if (cargo)
7466 {
7467 int item_count = cargo.GetItemCount();
7468 if (item_count > 0)
7469 {
7470 int random_pick = Math.RandomInt(0, item_count);
7471 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
7472 if (!item.IsExplosive())
7473 {
7474 item.AddHealth("","",damage);
7475 return true;
7476 }
7477 }
7478 }
7479 return false;
7480 }
7481
7482 bool DamageItemAttachments(float damage)
7483 {
7484 GameInventory inventory = GetInventory();
7485 int attachment_count = inventory.AttachmentCount();
7486 if (attachment_count > 0)
7487 {
7488 int random_pick = Math.RandomInt(0, attachment_count);
7489 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
7490 if (!attachment.IsExplosive())
7491 {
7492 attachment.AddHealth("","",damage);
7493 return true;
7494 }
7495 }
7496 return false;
7497 }
7498
7499 override bool IsSplitable()
7500 {
7501 return m_CanThisBeSplit;
7502 }
7503 //----------------
7504 override bool CanBeSplit()
7505 {
7506 if (IsSplitable() && (GetQuantity() > 1))
7507 return GetInventory().CanRemoveEntity();
7508
7509 return false;
7510 }
7511
7512 protected bool ShouldSplitQuantity(float quantity)
7513 {
7514 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
7515 if (!IsSplitable())
7516 return false;
7517
7518 // nothing to split?
7519 if (GetQuantity() <= 1)
7520 return false;
7521
7522 // check if we should re-use the item instead of creating a new copy?
7523 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7524 int delta = GetQuantity() - quantity;
7525 if (delta == 0)
7526 return false;
7527
7528 // valid to split
7529 return true;
7530 }
7531
7532 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7533 {
7534 if (g_Game.IsClient())
7535 {
7536 if (ScriptInputUserData.CanStoreInputUserData())
7537 {
7538 ScriptInputUserData ctx = new ScriptInputUserData;
7540 ctx.Write(1);
7541 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7542 ctx.Write(i1);
7543 ctx.Write(destination_entity);
7544 ctx.Write(true);
7545 ctx.Write(slot_id);
7546 ctx.Send();
7547 }
7548 }
7549 else if (!g_Game.IsMultiplayer())
7550 {
7551 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
7552 }
7553 }
7554
7555 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7556 {
7557 float split_quantity_new;
7558 ItemBase new_item;
7559 float quantity = GetQuantity();
7560 float stack_max = GetTargetQuantityMax(slot_id);
7561 InventoryLocation loc = new InventoryLocation;
7562
7563 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7564 {
7565 if (stack_max <= GetQuantity())
7566 split_quantity_new = stack_max;
7567 else
7568 split_quantity_new = GetQuantity();
7569
7570 if (ShouldSplitQuantity(split_quantity_new))
7571 {
7572 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7573 if (new_item)
7574 {
7575 new_item.SetResultOfSplit(true);
7576 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7577 AddQuantity(-split_quantity_new, false, true);
7578 new_item.SetQuantity(split_quantity_new, false, true);
7579 }
7580 }
7581 }
7582 else if (destination_entity && slot_id == -1)
7583 {
7584 if (quantity > stack_max)
7585 split_quantity_new = stack_max;
7586 else
7587 split_quantity_new = quantity;
7588
7589 if (ShouldSplitQuantity(split_quantity_new))
7590 {
7591 GameInventory destinationInventory = destination_entity.GetInventory();
7592 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7593 {
7594 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7595 new_item = ItemBase.Cast(o);
7596 }
7597
7598 if (new_item)
7599 {
7600 new_item.SetResultOfSplit(true);
7601 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7602 AddQuantity(-split_quantity_new, false, true);
7603 new_item.SetQuantity(split_quantity_new, false, true);
7604 }
7605 }
7606 }
7607 else
7608 {
7609 if (stack_max != 0)
7610 {
7611 if (stack_max < GetQuantity())
7612 {
7613 split_quantity_new = GetQuantity() - stack_max;
7614 }
7615
7616 if (split_quantity_new == 0)
7617 {
7618 if (!g_Game.IsMultiplayer())
7619 player.PhysicalPredictiveDropItem(this);
7620 else
7621 player.ServerDropEntity(this);
7622 return;
7623 }
7624
7625 if (ShouldSplitQuantity(split_quantity_new))
7626 {
7627 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7628
7629 if (new_item)
7630 {
7631 new_item.SetResultOfSplit(true);
7632 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7633 SetQuantity(split_quantity_new, false, true);
7634 new_item.SetQuantity(stack_max, false, true);
7635 new_item.PlaceOnSurface();
7636 }
7637 }
7638 }
7639 }
7640 }
7641
7642 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7643 {
7644 float split_quantity_new;
7645 ItemBase new_item;
7646 float quantity = GetQuantity();
7647 float stack_max = GetTargetQuantityMax(slot_id);
7648 InventoryLocation loc = new InventoryLocation;
7649
7650 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7651 {
7652 if (stack_max <= GetQuantity())
7653 split_quantity_new = stack_max;
7654 else
7655 split_quantity_new = GetQuantity();
7656
7657 if (ShouldSplitQuantity(split_quantity_new))
7658 {
7659 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7660 if (new_item)
7661 {
7662 new_item.SetResultOfSplit(true);
7663 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7664 AddQuantity(-split_quantity_new, false, true);
7665 new_item.SetQuantity(split_quantity_new, false, true);
7666 }
7667 }
7668 }
7669 else if (destination_entity && slot_id == -1)
7670 {
7671 if (quantity > stack_max)
7672 split_quantity_new = stack_max;
7673 else
7674 split_quantity_new = quantity;
7675
7676 if (ShouldSplitQuantity(split_quantity_new))
7677 {
7678 GameInventory destinationInventory = destination_entity.GetInventory();
7679 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7680 {
7681 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7682 new_item = ItemBase.Cast(o);
7683 }
7684
7685 if (new_item)
7686 {
7687 new_item.SetResultOfSplit(true);
7688 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7689 AddQuantity(-split_quantity_new, false, true);
7690 new_item.SetQuantity(split_quantity_new, false, true);
7691 }
7692 }
7693 }
7694 else
7695 {
7696 if (stack_max != 0)
7697 {
7698 if (stack_max < GetQuantity())
7699 {
7700 split_quantity_new = GetQuantity() - stack_max;
7701 }
7702
7703 if (ShouldSplitQuantity(split_quantity_new))
7704 {
7705 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7706
7707 if (new_item)
7708 {
7709 new_item.SetResultOfSplit(true);
7710 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7711 SetQuantity(split_quantity_new, false, true);
7712 new_item.SetQuantity(stack_max, false, true);
7713 new_item.PlaceOnSurface();
7714 }
7715 }
7716 }
7717 }
7718 }
7719
7720 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7721 {
7722 if (g_Game.IsClient())
7723 {
7724 if (ScriptInputUserData.CanStoreInputUserData())
7725 {
7726 ScriptInputUserData ctx = new ScriptInputUserData;
7728 ctx.Write(4);
7729 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7730 ctx.Write(thiz);
7731 dst.WriteToContext(ctx);
7732 ctx.Send();
7733 }
7734 }
7735 else if (!g_Game.IsMultiplayer())
7736 {
7738 }
7739 }
7740
7741 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7742 {
7743 if (g_Game.IsClient())
7744 {
7745 if (ScriptInputUserData.CanStoreInputUserData())
7746 {
7747 ScriptInputUserData ctx = new ScriptInputUserData;
7749 ctx.Write(2);
7750 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7751 ctx.Write(dummy);
7752 ctx.Write(destination_entity);
7753 ctx.Write(true);
7754 ctx.Write(idx);
7755 ctx.Write(row);
7756 ctx.Write(col);
7757 ctx.Send();
7758 }
7759 }
7760 else if (!g_Game.IsMultiplayer())
7761 {
7762 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7763 }
7764 }
7765
7766 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7767 {
7769 }
7770
7771 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7772 {
7773 float quantity = GetQuantity();
7774 float split_quantity_new;
7775 ItemBase new_item;
7776 if (dst.IsValid())
7777 {
7778 int slot_id = dst.GetSlot();
7779 float stack_max = GetTargetQuantityMax(slot_id);
7780
7781 if (quantity > stack_max)
7782 split_quantity_new = stack_max;
7783 else
7784 split_quantity_new = quantity;
7785
7786 if (ShouldSplitQuantity(split_quantity_new))
7787 {
7788 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7789
7790 if (new_item)
7791 {
7792 new_item.SetResultOfSplit(true);
7793 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7794 AddQuantity(-split_quantity_new, false, true);
7795 new_item.SetQuantity(split_quantity_new, false, true);
7796 }
7797
7798 return new_item;
7799 }
7800 }
7801
7802 return null;
7803 }
7804
7805 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7806 {
7807 float quantity = GetQuantity();
7808 float split_quantity_new;
7809 ItemBase new_item;
7810 if (destination_entity)
7811 {
7812 float stackable = GetTargetQuantityMax();
7813 if (quantity > stackable)
7814 split_quantity_new = stackable;
7815 else
7816 split_quantity_new = quantity;
7817
7818 if (ShouldSplitQuantity(split_quantity_new))
7819 {
7820 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7821 if (new_item)
7822 {
7823 new_item.SetResultOfSplit(true);
7824 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7825 AddQuantity(-split_quantity_new, false, true);
7826 new_item.SetQuantity(split_quantity_new, false, true);
7827 }
7828 }
7829 }
7830 }
7831
7832 void SplitIntoStackMaxHandsClient(PlayerBase player)
7833 {
7834 if (g_Game.IsClient())
7835 {
7836 if (ScriptInputUserData.CanStoreInputUserData())
7837 {
7838 ScriptInputUserData ctx = new ScriptInputUserData;
7840 ctx.Write(3);
7841 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7842 ctx.Write(i1);
7843 ItemBase destination_entity = this;
7844 ctx.Write(destination_entity);
7845 ctx.Write(true);
7846 ctx.Write(0);
7847 ctx.Send();
7848 }
7849 }
7850 else if (!g_Game.IsMultiplayer())
7851 {
7852 SplitIntoStackMaxHands(player);
7853 }
7854 }
7855
7856 void SplitIntoStackMaxHands(PlayerBase player)
7857 {
7858 float quantity = GetQuantity();
7859 float split_quantity_new;
7860 ref ItemBase new_item;
7861 if (player)
7862 {
7863 float stackable = GetTargetQuantityMax();
7864 if (quantity > stackable)
7865 split_quantity_new = stackable;
7866 else
7867 split_quantity_new = quantity;
7868
7869 if (ShouldSplitQuantity(split_quantity_new))
7870 {
7871 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7872 new_item = ItemBase.Cast(in_hands);
7873 if (new_item)
7874 {
7875 new_item.SetResultOfSplit(true);
7876 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7877 AddQuantity(-split_quantity_new, false, true);
7878 new_item.SetQuantity(split_quantity_new, false, true);
7879 }
7880 }
7881 }
7882 }
7883
7884 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7885 {
7886 float quantity = GetQuantity();
7887 float split_quantity_new = Math.Floor(quantity * 0.5);
7888
7889 if (!ShouldSplitQuantity(split_quantity_new))
7890 return;
7891
7892 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7893
7894 if (new_item)
7895 {
7896 if (new_item.GetQuantityMax() < split_quantity_new)
7897 {
7898 split_quantity_new = new_item.GetQuantityMax();
7899 }
7900
7901 new_item.SetResultOfSplit(true);
7902 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7903
7904 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7905 {
7906 AddQuantity(-1, false, true);
7907 new_item.SetQuantity(1, false, true);
7908 }
7909 else
7910 {
7911 AddQuantity(-split_quantity_new, false, true);
7912 new_item.SetQuantity(split_quantity_new, false, true);
7913 }
7914 }
7915 }
7916
7917 void SplitItem(PlayerBase player)
7918 {
7919 float quantity = GetQuantity();
7920 float split_quantity_new = Math.Floor(quantity / 2);
7921
7922 if (!ShouldSplitQuantity(split_quantity_new))
7923 return;
7924
7925 InventoryLocation invloc = new InventoryLocation;
7926 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7927
7928 ItemBase new_item;
7929 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7930
7931 if (new_item)
7932 {
7933 if (new_item.GetQuantityMax() < split_quantity_new)
7934 {
7935 split_quantity_new = new_item.GetQuantityMax();
7936 }
7937 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7938 {
7939 AddQuantity(-1, false, true);
7940 new_item.SetQuantity(1, false, true);
7941 }
7942 else if (split_quantity_new > 1)
7943 {
7944 AddQuantity(-split_quantity_new, false, true);
7945 new_item.SetQuantity(split_quantity_new, false, true);
7946 }
7947 }
7948 }
7949
7951 void OnQuantityChanged(float delta)
7952 {
7953 SetWeightDirty();
7954 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7955
7956 if (parent)
7957 parent.OnAttachmentQuantityChangedEx(this, delta);
7958
7959 if (IsLiquidContainer())
7960 {
7961 if (GetQuantityNormalized() <= 0.0)
7962 {
7964 }
7965 else if (GetLiquidType() == LIQUID_NONE)
7966 {
7967 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7969 }
7970 }
7971 }
7972
7975 {
7976 // insert code here
7977 }
7978
7980 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7981 {
7983 }
7984
7985 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7986 {
7987 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7988
7989 if (g_Game.IsServer())
7990 {
7991 if (newLevel == GameConstants.STATE_RUINED)
7992 {
7994 EntityAI parent = GetHierarchyParent();
7995 if (parent && parent.IsFireplace())
7996 {
7997 CargoBase cargo = GetInventory().GetCargo();
7998 if (cargo)
7999 {
8000 for (int i = 0; i < cargo.GetItemCount(); ++i)
8001 {
8002 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
8003 }
8004 }
8005 }
8006 }
8007
8008 if (IsResultOfSplit())
8009 {
8010 // reset the splitting result flag, return to normal item behavior
8011 SetResultOfSplit(false);
8012 return;
8013 }
8014
8015 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
8016 {
8017 SetCleanness(0);//unclean the item upon damage dealt
8018 }
8019 }
8020 }
8021
8022 // just the split? TODO: verify
8023 override void OnRightClick()
8024 {
8025 super.OnRightClick();
8026
8027 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
8028 {
8029 if (g_Game.IsClient())
8030 {
8031 if (ScriptInputUserData.CanStoreInputUserData())
8032 {
8033 EntityAI root = GetHierarchyRoot();
8034 Man playerOwner = GetHierarchyRootPlayer();
8035 InventoryLocation dst = new InventoryLocation;
8036
8037 // If we have no hierarchy root player and the root is the same as this item the source item is in the vicinity so we want to create the new split item there also
8038 if (!playerOwner && root && root == this)
8039 {
8041 }
8042 else
8043 {
8044 // Check if we can place the new split item in the same parent where the source item is placed in or otherwise drop it in vicinity
8045 GetInventory().GetCurrentInventoryLocation(dst);
8046 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
8047 {
8048 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8049 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
8050 {
8052 }
8053 else
8054 {
8055 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
8056 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
8057 this shouldnt cause issues within this scope*/
8058 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
8059 {
8061 }
8062 else
8063 {
8064 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
8065 }
8066 }
8067 }
8068 }
8069
8070 ScriptInputUserData ctx = new ScriptInputUserData;
8072 ctx.Write(4);
8073 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8074 ctx.Write(thiz);
8075 dst.WriteToContext(ctx);
8076 ctx.Write(true); // dummy
8077 ctx.Send();
8078 }
8079 }
8080 else if (!g_Game.IsMultiplayer())
8081 {
8082 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
8083 }
8084 }
8085 }
8086
8087 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
8088 {
8089 if (root)
8090 {
8091 vector m4[4];
8092 root.GetTransform(m4);
8093 dst.SetGround(this, m4);
8094 }
8095 else
8096 {
8097 GetInventory().GetCurrentInventoryLocation(dst);
8098 }
8099 }
8100
8101 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
8102 {
8103 //TODO: delete check zero quantity check after fix double posts hands fsm events
8104 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
8105 return false;
8106
8107 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
8108 return false;
8109
8110 //can_this_be_combined = ConfigGetBool("canBeSplit");
8112 return false;
8113
8114
8115 Magazine mag = Magazine.Cast(this);
8116 if (mag)
8117 {
8118 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
8119 return false;
8120
8121 if (stack_max_limit)
8122 {
8123 Magazine other_mag = Magazine.Cast(other_item);
8124 if (other_item)
8125 {
8126 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
8127 return false;
8128 }
8129
8130 }
8131 }
8132 else
8133 {
8134 //TODO: delete check zero quantity check after fix double posts hands fsm events
8135 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
8136 return false;
8137
8138 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
8139 return false;
8140 }
8141
8142 PlayerBase player = null;
8143 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
8144 {
8145 if (player.GetInventory().HasAttachment(this))
8146 return false;
8147
8148 if (player.IsItemsToDelete())
8149 return false;
8150 }
8151
8152 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
8153 return false;
8154
8155 int slotID;
8156 string slotName;
8157 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
8158 return false;
8159
8160 return true;
8161 }
8162
8163 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
8164 {
8165 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
8166 }
8167
8168 bool IsResultOfSplit()
8169 {
8170 return m_IsResultOfSplit;
8171 }
8172
8173 void SetResultOfSplit(bool value)
8174 {
8175 m_IsResultOfSplit = value;
8176 }
8177
8178 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
8179 {
8180 return ComputeQuantityUsedEx(other_item, use_stack_max);
8181 }
8182
8183 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
8184 {
8185 float other_item_quantity = other_item.GetQuantity();
8186 float this_free_space;
8187
8188 float stack_max = GetQuantityMax();
8189
8190 this_free_space = stack_max - GetQuantity();
8191
8192 if (other_item_quantity > this_free_space)
8193 {
8194 return this_free_space;
8195 }
8196 else
8197 {
8198 return other_item_quantity;
8199 }
8200 }
8201
8202 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
8203 {
8204 CombineItems(ItemBase.Cast(entity2),use_stack_max);
8205 }
8206
8207 void CombineItems(ItemBase other_item, bool use_stack_max = true)
8208 {
8209 if (!CanBeCombined(other_item, false))
8210 return;
8211
8212 if (!IsMagazine() && other_item)
8213 {
8214 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
8215 if (quantity_used != 0)
8216 {
8217 float hp1 = GetHealth01("","");
8218 float hp2 = other_item.GetHealth01("","");
8219 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
8220 hpResult = hpResult / (GetQuantity() + quantity_used);
8221
8222 hpResult *= GetMaxHealth();
8223 Math.Round(hpResult);
8224 SetHealth("", "Health", hpResult);
8225
8226 AddQuantity(quantity_used);
8227 other_item.AddQuantity(-quantity_used);
8228 }
8229 }
8230 OnCombine(other_item);
8231 }
8232
8233 void OnCombine(ItemBase other_item)
8234 {
8235 #ifdef SERVER
8236 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
8237 GetHierarchyParent().IncreaseLifetimeUp();
8238 #endif
8239 };
8240
8241 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
8242 {
8243 PlayerBase p = PlayerBase.Cast(player);
8244
8245 array<int> recipesIds = p.m_Recipes;
8246 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8247 if (moduleRecipesManager)
8248 {
8249 EntityAI itemInHands = player.GetEntityInHands();
8250 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
8251 }
8252
8253 for (int i = 0;i < recipesIds.Count(); i++)
8254 {
8255 int key = recipesIds.Get(i);
8256 string recipeName = moduleRecipesManager.GetRecipeName(key);
8257 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
8258 }
8259 }
8260
8261 // -------------------------------------------------------------------------
8262 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
8263 {
8264 super.GetDebugActions(outputList);
8265
8266 //quantity
8267 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
8268 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
8269 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
8270 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
8271 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8272
8273 //health
8274 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
8275 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
8276 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
8277 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8278 //temperature
8279 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
8280 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
8281 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
8282 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8283
8284 //wet
8285 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
8286 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
8287 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8288
8289 //liquidtype
8290 if (IsLiquidContainer())
8291 {
8292 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
8293 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
8294 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8295 }
8296
8297 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
8298 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8299
8300 // watch
8301 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
8302 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
8303 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8304
8305 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
8306
8307 InventoryLocation loc = new InventoryLocation();
8308 GetInventory().GetCurrentInventoryLocation(loc);
8309 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
8310 {
8311 if (Gizmo_IsSupported())
8312 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
8313 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
8314 }
8315
8316 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
8317 }
8318
8319 // -------------------------------------------------------------------------
8320 // -------------------------------------------------------------------------
8321 // -------------------------------------------------------------------------
8322 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
8323 {
8324 super.OnAction(action_id, player, ctx);
8325
8326 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
8327 {
8328 switch (action_id)
8329 {
8330 case EActions.GIZMO_OBJECT:
8331 if (GetGizmoApi())
8332 GetGizmoApi().SelectObject(this);
8333 return true;
8334 case EActions.GIZMO_PHYSICS:
8335 if (GetGizmoApi())
8336 GetGizmoApi().SelectPhysics(GetPhysics());
8337 return true;
8338 }
8339 }
8340
8341 if (g_Game.IsServer())
8342 {
8343 switch (action_id)
8344 {
8345 case EActions.DELETE:
8346 Delete();
8347 return true;
8348 }
8349 }
8350
8351 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
8352 {
8353 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8354 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
8355 PlayerBase p = PlayerBase.Cast(player);
8356 if (EActions.RECIPES_RANGE_START < 1000)
8357 {
8358 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
8359 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
8360 }
8361 }
8362 #ifndef SERVER
8363 else if (action_id == EActions.WATCH_PLAYER)
8364 {
8365 PluginDeveloper.SetDeveloperItemClientEx(player);
8366 }
8367 #endif
8368 if (g_Game.IsServer())
8369 {
8370 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
8371 {
8372 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
8373 OnDebugButtonPressServer(id + 1);
8374 }
8375
8376 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
8377 {
8378 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
8379 InsertAgent(agent_id,100);
8380 }
8381
8382 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8383 {
8384 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8385 RemoveAgent(agent_id2);
8386 }
8387
8388 else if (action_id == EActions.ADD_QUANTITY)
8389 {
8390 if (IsMagazine())
8391 {
8392 Magazine mag = Magazine.Cast(this);
8393 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8394 }
8395 else
8396 {
8397 AddQuantity(GetQuantityMax() * 0.2);
8398 }
8399
8400 if (m_EM)
8401 {
8402 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8403 }
8404 //PrintVariables();
8405 }
8406
8407 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8408 {
8409 if (IsMagazine())
8410 {
8411 Magazine mag2 = Magazine.Cast(this);
8412 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8413 }
8414 else
8415 {
8416 AddQuantity(- GetQuantityMax() * 0.2);
8417 }
8418 if (m_EM)
8419 {
8420 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8421 }
8422 //PrintVariables();
8423 }
8424
8425 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8426 {
8427 SetQuantity(0);
8428
8429 if (m_EM)
8430 {
8431 m_EM.SetEnergy(0);
8432 }
8433 }
8434
8435 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8436 {
8438
8439 if (m_EM)
8440 {
8441 m_EM.SetEnergy(m_EM.GetEnergyMax());
8442 }
8443 }
8444
8445 else if (action_id == EActions.ADD_HEALTH)
8446 {
8447 AddHealth("","",GetMaxHealth("","Health")/5);
8448 }
8449 else if (action_id == EActions.REMOVE_HEALTH)
8450 {
8451 AddHealth("","",-GetMaxHealth("","Health")/5);
8452 }
8453 else if (action_id == EActions.DESTROY_HEALTH)
8454 {
8455 SetHealth01("","",0);
8456 }
8457 else if (action_id == EActions.WATCH_ITEM)
8458 {
8460 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8461 #ifdef DEVELOPER
8462 SetDebugDeveloper_item(this);
8463 #endif
8464 }
8465
8466 else if (action_id == EActions.ADD_TEMPERATURE)
8467 {
8468 AddTemperature(20);
8469 //PrintVariables();
8470 }
8471
8472 else if (action_id == EActions.REMOVE_TEMPERATURE)
8473 {
8474 AddTemperature(-20);
8475 //PrintVariables();
8476 }
8477
8478 else if (action_id == EActions.FLIP_FROZEN)
8479 {
8480 SetFrozen(!GetIsFrozen());
8481 //PrintVariables();
8482 }
8483
8484 else if (action_id == EActions.ADD_WETNESS)
8485 {
8486 AddWet(GetWetMax()/5);
8487 //PrintVariables();
8488 }
8489
8490 else if (action_id == EActions.REMOVE_WETNESS)
8491 {
8492 AddWet(-GetWetMax()/5);
8493 //PrintVariables();
8494 }
8495
8496 else if (action_id == EActions.LIQUIDTYPE_UP)
8497 {
8498 int curr_type = GetLiquidType();
8499 SetLiquidType(curr_type * 2);
8500 //AddWet(1);
8501 //PrintVariables();
8502 }
8503
8504 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8505 {
8506 int curr_type2 = GetLiquidType();
8507 SetLiquidType(curr_type2 / 2);
8508 }
8509
8510 else if (action_id == EActions.MAKE_SPECIAL)
8511 {
8512 auto debugParams = DebugSpawnParams.WithPlayer(player);
8513 OnDebugSpawnEx(debugParams);
8514 }
8515
8516 }
8517
8518
8519 return false;
8520 }
8521
8522 // -------------------------------------------------------------------------
8523
8524
8527 void OnActivatedByTripWire();
8528
8530 void OnActivatedByItem(notnull ItemBase item);
8531
8532 //----------------------------------------------------------------
8533 //returns true if item is able to explode when put in fire
8534 bool CanExplodeInFire()
8535 {
8536 return false;
8537 }
8538
8539 //----------------------------------------------------------------
8540 bool CanEat()
8541 {
8542 return true;
8543 }
8544
8545 //----------------------------------------------------------------
8546 override bool IsIgnoredByConstruction()
8547 {
8548 return true;
8549 }
8550
8551 //----------------------------------------------------------------
8552 //has FoodStages in config?
8553 bool HasFoodStage()
8554 {
8555 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8556 return g_Game.ConfigIsExisting(config_path);
8557 }
8558
8560 FoodStage GetFoodStage()
8561 {
8562 return null;
8563 }
8564
8565 bool CanBeCooked()
8566 {
8567 return false;
8568 }
8569
8570 bool CanBeCookedOnStick()
8571 {
8572 return false;
8573 }
8574
8576 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8578
8579 //----------------------------------------------------------------
8580 bool CanRepair(ItemBase item_repair_kit)
8581 {
8582 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8583 return module_repairing.CanRepair(this, item_repair_kit);
8584 }
8585
8586 //----------------------------------------------------------------
8587 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8588 {
8589 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8590 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8591 }
8592
8593 //----------------------------------------------------------------
8594 int GetItemSize()
8595 {
8596 /*
8597 vector v_size = this.ConfigGetVector("itemSize");
8598 int v_size_x = v_size[0];
8599 int v_size_y = v_size[1];
8600 int size = v_size_x * v_size_y;
8601 return size;
8602 */
8603
8604 return 1;
8605 }
8606
8607 //----------------------------------------------------------------
8608 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8609 bool CanBeMovedOverride()
8610 {
8611 return m_CanBeMovedOverride;
8612 }
8613
8614 //----------------------------------------------------------------
8615 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8616 void SetCanBeMovedOverride(bool setting)
8617 {
8618 m_CanBeMovedOverride = setting;
8619 }
8620
8621 //----------------------------------------------------------------
8629 void MessageToOwnerStatus(string text)
8630 {
8631 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8632
8633 if (player)
8634 {
8635 player.MessageStatus(text);
8636 }
8637 }
8638
8639 //----------------------------------------------------------------
8647 void MessageToOwnerAction(string text)
8648 {
8649 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8650
8651 if (player)
8652 {
8653 player.MessageAction(text);
8654 }
8655 }
8656
8657 //----------------------------------------------------------------
8665 void MessageToOwnerFriendly(string text)
8666 {
8667 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8668
8669 if (player)
8670 {
8671 player.MessageFriendly(text);
8672 }
8673 }
8674
8675 //----------------------------------------------------------------
8683 void MessageToOwnerImportant(string text)
8684 {
8685 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8686
8687 if (player)
8688 {
8689 player.MessageImportant(text);
8690 }
8691 }
8692
8693 override bool IsItemBase()
8694 {
8695 return true;
8696 }
8697
8698 // Checks if item is of questioned kind
8699 override bool KindOf(string tag)
8700 {
8701 bool found = false;
8702 string item_name = this.GetType();
8703 ref TStringArray item_tag_array = new TStringArray;
8704 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8705
8706 int array_size = item_tag_array.Count();
8707 for (int i = 0; i < array_size; i++)
8708 {
8709 if (item_tag_array.Get(i) == tag)
8710 {
8711 found = true;
8712 break;
8713 }
8714 }
8715 return found;
8716 }
8717
8718
8719 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8720 {
8721 //Debug.Log("OnRPC called");
8722 super.OnRPC(sender, rpc_type,ctx);
8723
8724 //Play soundset for attachment locking (ActionLockAttachment.c)
8725 switch (rpc_type)
8726 {
8727 #ifndef SERVER
8728 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8729 Param2<bool, string> p = new Param2<bool, string>(false, "");
8730
8731 if (!ctx.Read(p))
8732 return;
8733
8734 bool play = p.param1;
8735 string soundSet = p.param2;
8736
8737 if (play)
8738 {
8739 if (m_LockingSound)
8740 {
8742 {
8743 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8744 }
8745 }
8746 else
8747 {
8748 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8749 }
8750 }
8751 else
8752 {
8753 SEffectManager.DestroyEffect(m_LockingSound);
8754 }
8755
8756 break;
8757 #endif
8758
8759 }
8760
8761 if (GetWrittenNoteData())
8762 {
8763 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8764 }
8765 }
8766
8767 //-----------------------------
8768 // VARIABLE MANIPULATION SYSTEM
8769 //-----------------------------
8770 int NameToID(string name)
8771 {
8772 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8773 return plugin.GetID(name);
8774 }
8775
8776 string IDToName(int id)
8777 {
8778 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8779 return plugin.GetName(id);
8780 }
8781
8783 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8784 {
8785 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8786 //read the flags
8787 int varFlags;
8788 if (!ctx.Read(varFlags))
8789 return;
8790
8791 if (varFlags & ItemVariableFlags.FLOAT)
8792 {
8793 ReadVarsFromCTX(ctx);
8794 }
8795 }
8796
8797 override void SerializeNumericalVars(array<float> floats_out)
8798 {
8799 //some variables handled on EntityAI level already!
8800 super.SerializeNumericalVars(floats_out);
8801
8802 // the order of serialization must be the same as the order of de-serialization
8803 //--------------------------------------------
8804 if (IsVariableSet(VARIABLE_QUANTITY))
8805 {
8806 floats_out.Insert(m_VarQuantity);
8807 }
8808 //--------------------------------------------
8809 if (IsVariableSet(VARIABLE_WET))
8810 {
8811 floats_out.Insert(m_VarWet);
8812 }
8813 //--------------------------------------------
8814 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8815 {
8816 floats_out.Insert(m_VarLiquidType);
8817 }
8818 //--------------------------------------------
8819 if (IsVariableSet(VARIABLE_COLOR))
8820 {
8821 floats_out.Insert(m_ColorComponentR);
8822 floats_out.Insert(m_ColorComponentG);
8823 floats_out.Insert(m_ColorComponentB);
8824 floats_out.Insert(m_ColorComponentA);
8825 }
8826 //--------------------------------------------
8827 if (IsVariableSet(VARIABLE_CLEANNESS))
8828 {
8829 floats_out.Insert(m_Cleanness);
8830 }
8831 }
8832
8833 override void DeSerializeNumericalVars(array<float> floats)
8834 {
8835 //some variables handled on EntityAI level already!
8836 super.DeSerializeNumericalVars(floats);
8837
8838 // the order of serialization must be the same as the order of de-serialization
8839 int index = 0;
8840 int mask = Math.Round(floats.Get(index));
8841
8842 index++;
8843 //--------------------------------------------
8844 if (mask & VARIABLE_QUANTITY)
8845 {
8846 if (m_IsStoreLoad)
8847 {
8848 SetStoreLoadedQuantity(floats.Get(index));
8849 }
8850 else
8851 {
8852 float quantity = floats.Get(index);
8853 SetQuantity(quantity, true, false, false, false);
8854 }
8855 index++;
8856 }
8857 //--------------------------------------------
8858 if (mask & VARIABLE_WET)
8859 {
8860 float wet = floats.Get(index);
8861 SetWet(wet);
8862 index++;
8863 }
8864 //--------------------------------------------
8865 if (mask & VARIABLE_LIQUIDTYPE)
8866 {
8867 int liquidtype = Math.Round(floats.Get(index));
8868 SetLiquidType(liquidtype);
8869 index++;
8870 }
8871 //--------------------------------------------
8872 if (mask & VARIABLE_COLOR)
8873 {
8874 m_ColorComponentR = Math.Round(floats.Get(index));
8875 index++;
8876 m_ColorComponentG = Math.Round(floats.Get(index));
8877 index++;
8878 m_ColorComponentB = Math.Round(floats.Get(index));
8879 index++;
8880 m_ColorComponentA = Math.Round(floats.Get(index));
8881 index++;
8882 }
8883 //--------------------------------------------
8884 if (mask & VARIABLE_CLEANNESS)
8885 {
8886 int cleanness = Math.Round(floats.Get(index));
8887 SetCleanness(cleanness);
8888 index++;
8889 }
8890 }
8891
8892 override void WriteVarsToCTX(ParamsWriteContext ctx)
8893 {
8894 super.WriteVarsToCTX(ctx);
8895
8896 //--------------------------------------------
8897 if (IsVariableSet(VARIABLE_QUANTITY))
8898 {
8899 ctx.Write(GetQuantity());
8900 }
8901 //--------------------------------------------
8902 if (IsVariableSet(VARIABLE_WET))
8903 {
8904 ctx.Write(GetWet());
8905 }
8906 //--------------------------------------------
8907 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8908 {
8909 ctx.Write(GetLiquidType());
8910 }
8911 //--------------------------------------------
8912 if (IsVariableSet(VARIABLE_COLOR))
8913 {
8914 int r,g,b,a;
8915 GetColor(r,g,b,a);
8916 ctx.Write(r);
8917 ctx.Write(g);
8918 ctx.Write(b);
8919 ctx.Write(a);
8920 }
8921 //--------------------------------------------
8922 if (IsVariableSet(VARIABLE_CLEANNESS))
8923 {
8924 ctx.Write(GetCleanness());
8925 }
8926 }
8927
8928 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8929 {
8930 if (!super.ReadVarsFromCTX(ctx,version))
8931 return false;
8932
8933 int intValue;
8934 float value;
8935
8936 if (version < 140)
8937 {
8938 if (!ctx.Read(intValue))
8939 return false;
8940
8941 m_VariablesMask = intValue;
8942 }
8943
8944 if (m_VariablesMask & VARIABLE_QUANTITY)
8945 {
8946 if (!ctx.Read(value))
8947 return false;
8948
8949 if (IsStoreLoad())
8950 {
8952 }
8953 else
8954 {
8955 SetQuantity(value, true, false, false, false);
8956 }
8957 }
8958 //--------------------------------------------
8959 if (version < 140)
8960 {
8961 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8962 {
8963 if (!ctx.Read(value))
8964 return false;
8965 SetTemperatureDirect(value);
8966 }
8967 }
8968 //--------------------------------------------
8969 if (m_VariablesMask & VARIABLE_WET)
8970 {
8971 if (!ctx.Read(value))
8972 return false;
8973 SetWet(value);
8974 }
8975 //--------------------------------------------
8976 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8977 {
8978 if (!ctx.Read(intValue))
8979 return false;
8980 SetLiquidType(intValue);
8981 }
8982 //--------------------------------------------
8983 if (m_VariablesMask & VARIABLE_COLOR)
8984 {
8985 int r,g,b,a;
8986 if (!ctx.Read(r))
8987 return false;
8988 if (!ctx.Read(g))
8989 return false;
8990 if (!ctx.Read(b))
8991 return false;
8992 if (!ctx.Read(a))
8993 return false;
8994
8995 SetColor(r,g,b,a);
8996 }
8997 //--------------------------------------------
8998 if (m_VariablesMask & VARIABLE_CLEANNESS)
8999 {
9000 if (!ctx.Read(intValue))
9001 return false;
9002 SetCleanness(intValue);
9003 }
9004 //--------------------------------------------
9005 if (version >= 138 && version < 140)
9006 {
9007 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9008 {
9009 if (!ctx.Read(intValue))
9010 return false;
9011 SetFrozen(intValue);
9012 }
9013 }
9014
9015 return true;
9016 }
9017
9018 //----------------------------------------------------------------
9019 override bool OnStoreLoad(ParamsReadContext ctx, int version)
9020 {
9021 m_IsStoreLoad = true;
9023 {
9024 m_FixDamageSystemInit = true;
9025 }
9026
9027 if (!super.OnStoreLoad(ctx, version))
9028 {
9029 m_IsStoreLoad = false;
9030 return false;
9031 }
9032
9033 if (version >= 114)
9034 {
9035 bool hasQuickBarIndexSaved;
9036
9037 if (!ctx.Read(hasQuickBarIndexSaved))
9038 {
9039 m_IsStoreLoad = false;
9040 return false;
9041 }
9042
9043 if (hasQuickBarIndexSaved)
9044 {
9045 int itmQBIndex;
9046
9047 //Load quickbar item bind
9048 if (!ctx.Read(itmQBIndex))
9049 {
9050 m_IsStoreLoad = false;
9051 return false;
9052 }
9053
9054 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
9055 if (itmQBIndex != -1 && parentPlayer)
9056 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
9057 }
9058 }
9059 else
9060 {
9061 // Backup of how it used to be
9062 PlayerBase player;
9063 int itemQBIndex;
9064 if (version == int.MAX)
9065 {
9066 if (!ctx.Read(itemQBIndex))
9067 {
9068 m_IsStoreLoad = false;
9069 return false;
9070 }
9071 }
9072 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
9073 {
9074 //Load quickbar item bind
9075 if (!ctx.Read(itemQBIndex))
9076 {
9077 m_IsStoreLoad = false;
9078 return false;
9079 }
9080 if (itemQBIndex != -1 && player)
9081 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
9082 }
9083 }
9084
9085 if (version < 140)
9086 {
9087 // variable management system
9088 if (!LoadVariables(ctx, version))
9089 {
9090 m_IsStoreLoad = false;
9091 return false;
9092 }
9093 }
9094
9095 //agent trasmission system
9096 if (!LoadAgents(ctx, version))
9097 {
9098 m_IsStoreLoad = false;
9099 return false;
9100 }
9101 if (version >= 132)
9102 {
9103 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9104 if (raib)
9105 {
9106 if (!raib.OnStoreLoad(ctx,version))
9107 {
9108 m_IsStoreLoad = false;
9109 return false;
9110 }
9111 }
9112 }
9113
9114 m_IsStoreLoad = false;
9115 return true;
9116 }
9117
9118 //----------------------------------------------------------------
9119
9120 override void OnStoreSave(ParamsWriteContext ctx)
9121 {
9122 super.OnStoreSave(ctx);
9123
9124 PlayerBase player;
9125 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
9126 {
9127 ctx.Write(true); // Keep track of if we should actually read this in or not
9128 //Save quickbar item bind
9129 int itemQBIndex = -1;
9130 itemQBIndex = player.FindQuickBarEntityIndex(this);
9131 ctx.Write(itemQBIndex);
9132 }
9133 else
9134 {
9135 ctx.Write(false); // Keep track of if we should actually read this in or not
9136 }
9137
9138 SaveAgents(ctx);//agent trasmission system
9139
9140 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9141 if (raib)
9142 {
9143 raib.OnStoreSave(ctx);
9144 }
9145 }
9146 //----------------------------------------------------------------
9147
9148 override void AfterStoreLoad()
9149 {
9150 super.AfterStoreLoad();
9151
9153 {
9155 }
9156
9157 if (GetStoreLoadedQuantity() != float.LOWEST)
9158 {
9160 SetStoreLoadedQuantity(float.LOWEST);//IMPORTANT to do this !! we use 'm_StoreLoadedQuantity' inside SetQuantity to distinguish between initial quantity setting and the consequent(normal gameplay) calls
9161 }
9162 }
9163
9164 override void EEOnAfterLoad()
9165 {
9166 super.EEOnAfterLoad();
9167
9169 {
9170 m_FixDamageSystemInit = false;
9171 }
9172
9175 }
9176
9177 bool CanBeDisinfected()
9178 {
9179 return false;
9180 }
9181
9182
9183 //----------------------------------------------------------------
9184 override void OnVariablesSynchronized()
9185 {
9186 if (m_Initialized)
9187 {
9188 #ifdef PLATFORM_CONSOLE
9189 //bruteforce it is
9190 if (IsSplitable())
9191 {
9192 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
9193 if (menu)
9194 {
9195 menu.Refresh();
9196 }
9197 }
9198 #endif
9199 }
9200
9202 {
9203 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9204 m_WantPlayImpactSound = false;
9205 }
9206
9208 {
9209 SetWeightDirty();
9211 }
9212 if (m_VarWet != m_VarWetPrev)
9213 {
9216 }
9217
9218 if (m_SoundSyncPlay != 0)
9219 {
9222
9223 m_SoundSyncPlay = 0;
9224 m_SoundSyncSlotID = -1;
9225 }
9226 if (m_SoundSyncStop != 0)
9227 {
9229 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
9230 m_SoundSyncStop = 0;
9231 }
9232
9233 super.OnVariablesSynchronized();
9234 }
9235
9236 //------------------------- Quantity
9237 //----------------------------------------------------------------
9239 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
9240 {
9241 if (!IsServerCheck(allow_client))
9242 return false;
9243
9244 if (!HasQuantity())
9245 return false;
9246
9247 float min = GetQuantityMin();
9248 float max = GetQuantityMax();
9249
9250 if (value <= (min + 0.001))
9251 value = min;
9252
9253 if (value == min)
9254 {
9255 if (destroy_config)
9256 {
9257 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
9258 if (dstr)
9259 {
9260 m_VarQuantity = Math.Clamp(value, min, max);
9261 this.Delete();
9262 return true;
9263 }
9264 }
9265 else if (destroy_forced)
9266 {
9267 m_VarQuantity = Math.Clamp(value, min, max);
9268 this.Delete();
9269 return true;
9270 }
9271 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
9272 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
9273 }
9274
9275 float delta = m_VarQuantity;
9276 m_VarQuantity = Math.Clamp(value, min, max);
9277
9278 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9279 {
9280 EntityAI parent = GetHierarchyRoot();
9281 InventoryLocation iLoc = new InventoryLocation();
9282 GetInventory().GetCurrentInventoryLocation(iLoc);
9283 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
9284 {
9285 int iLocSlot = iLoc.GetSlot();
9286 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
9287 {
9288 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
9289 }
9290 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
9291 {
9292 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
9293 }
9294 }
9295 }
9296
9297 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
9298 {
9299 delta = m_VarQuantity - delta;
9300
9301 if (delta)
9302 OnQuantityChanged(delta);
9303 }
9304
9305 SetVariableMask(VARIABLE_QUANTITY);
9306
9307 return false;
9308 }
9309
9310 //----------------------------------------------------------------
9312 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
9313 {
9314 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
9315 }
9316 //----------------------------------------------------------------
9317 void SetQuantityMax()
9318 {
9319 float max = GetQuantityMax();
9320 SetQuantity(max);
9321 }
9322
9323 override void SetQuantityToMinimum()
9324 {
9325 float min = GetQuantityMin();
9326 SetQuantity(min);
9327 }
9328 //----------------------------------------------------------------
9330 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
9331 {
9332 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
9333 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
9334 SetQuantity(result, destroy_config, destroy_forced);
9335 }
9336
9337 //----------------------------------------------------------------
9339 override float GetQuantityNormalized()
9340 {
9341 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
9342 }
9343
9345 {
9346 return GetQuantityNormalized();
9347 }
9348
9349 /*void SetAmmoNormalized(float value)
9350 {
9351 float value_clamped = Math.Clamp(value, 0, 1);
9352 Magazine this_mag = Magazine.Cast(this);
9353 int max_rounds = this_mag.GetAmmoMax();
9354 int result = value * max_rounds;//can the rounded if higher precision is required
9355 this_mag.SetAmmoCount(result);
9356 }*/
9357 //----------------------------------------------------------------
9358 override int GetQuantityMax()
9359 {
9360 int slot = -1;
9361 GameInventory inventory = GetInventory();
9362 if (inventory)
9363 {
9364 InventoryLocation il = new InventoryLocation;
9365 inventory.GetCurrentInventoryLocation(il);
9366 slot = il.GetSlot();
9367 }
9368
9369 return GetTargetQuantityMax(slot);
9370 }
9371
9372 override int GetTargetQuantityMax(int attSlotID = -1)
9373 {
9374 float quantity_max = 0;
9375
9376 if (IsSplitable()) //only stackable/splitable items can check for stack size
9377 {
9378 if (attSlotID != -1)
9379 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
9380
9381 if (quantity_max <= 0)
9382 quantity_max = m_VarStackMax;
9383 }
9384
9385 if (quantity_max <= 0)
9386 quantity_max = m_VarQuantityMax;
9387
9388 return quantity_max;
9389 }
9390 //----------------------------------------------------------------
9391 override int GetQuantityMin()
9392 {
9393 return m_VarQuantityMin;
9394 }
9395 //----------------------------------------------------------------
9396 int GetQuantityInit()
9397 {
9398 return m_VarQuantityInit;
9399 }
9400
9401 //----------------------------------------------------------------
9402 override bool HasQuantity()
9403 {
9404 return !(GetQuantityMax() - GetQuantityMin() == 0);
9405 }
9406
9407 override float GetQuantity()
9408 {
9409 return m_VarQuantity;
9410 }
9411
9412 bool IsFullQuantity()
9413 {
9414 return GetQuantity() >= GetQuantityMax();
9415 }
9416
9417 //Calculates weight of single item without attachments and cargo
9418 override float GetSingleInventoryItemWeightEx()
9419 {
9420 //this needs to be first stored inside local variables, when returned directly during inside return call, the result is completely different due to enforce script bug
9421 float weightEx = GetWeightEx();//overall weight of the item
9422 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9423 return weightEx - special;
9424 }
9425
9426 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9428 {
9430 }
9431
9432 override protected float GetWeightSpecialized(bool forceRecalc = false)
9433 {
9434 if (IsSplitable()) //quantity determines size of the stack
9435 {
9436 #ifdef DEVELOPER
9437 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9438 {
9439 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9440 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9441 }
9442 #endif
9443
9444 return GetQuantity() * GetConfigWeightModified();
9445 }
9446 else if (HasEnergyManager())// items with energy manager
9447 {
9448 #ifdef DEVELOPER
9449 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9450 {
9451 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9452 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9453 }
9454 #endif
9455 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9456 }
9457 else//everything else
9458 {
9459 #ifdef DEVELOPER
9460 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9461 {
9462 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9463 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9464 }
9465 #endif
9466 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9467 }
9468 }
9469
9471 int GetNumberOfItems()
9472 {
9473 int item_count = 0;
9474 ItemBase item;
9475
9476 GameInventory inventory = GetInventory();
9477 CargoBase cargo = inventory.GetCargo();
9478 if (cargo != NULL)
9479 {
9480 item_count = cargo.GetItemCount();
9481 }
9482
9483 int nAttachments = inventory.AttachmentCount();
9484 for (int i = 0; i < nAttachments; ++i)
9485 {
9486 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
9487 if (item)
9488 item_count += item.GetNumberOfItems();
9489 }
9490 return item_count;
9491 }
9492
9494 float GetUnitWeight(bool include_wetness = true)
9495 {
9496 float weight = 0;
9497 float wetness = 1;
9498 if (include_wetness)
9499 wetness += GetWet();
9500 if (IsSplitable()) //quantity determines size of the stack
9501 {
9502 weight = wetness * m_ConfigWeight;
9503 }
9504 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9505 {
9506 weight = 1;
9507 }
9508 return weight;
9509 }
9510
9511 //-----------------------------------------------------------------
9512
9513 override void ClearInventory()
9514 {
9515 GameInventory inventory = GetInventory();
9516 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
9517 {
9518 array<EntityAI> items = new array<EntityAI>;
9519 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
9520 for (int i = 0; i < items.Count(); ++i)
9521 {
9522 ItemBase item = ItemBase.Cast(items.Get(i));
9523 if (item)
9524 {
9525 g_Game.ObjectDelete(item);
9526 }
9527 }
9528 }
9529 }
9530
9531 //------------------------- Energy
9532
9533 //----------------------------------------------------------------
9534 float GetEnergy()
9535 {
9536 float energy = 0;
9537 if (HasEnergyManager())
9538 {
9539 energy = GetCompEM().GetEnergy();
9540 }
9541 return energy;
9542 }
9543
9544
9545 override void OnEnergyConsumed()
9546 {
9547 super.OnEnergyConsumed();
9548
9550 }
9551
9552 override void OnEnergyAdded()
9553 {
9554 super.OnEnergyAdded();
9555
9557 }
9558
9559 // Converts energy (from Energy Manager) to quantity, if enabled.
9561 {
9562 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9563 {
9564 if (HasQuantity())
9565 {
9566 float energy_0to1 = GetCompEM().GetEnergy0To1();
9567 SetQuantityNormalized(energy_0to1);
9568 }
9569 }
9570 }
9571
9572 //----------------------------------------------------------------
9573 float GetHeatIsolationInit()
9574 {
9575 return ConfigGetFloat("heatIsolation");
9576 }
9577
9578 float GetHeatIsolation()
9579 {
9580 return m_HeatIsolation;
9581 }
9582
9583 float GetDryingIncrement(string pIncrementName)
9584 {
9585 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9586 if (g_Game.ConfigIsExisting(paramPath))
9587 return g_Game.ConfigGetFloat(paramPath);
9588
9589 return 0.0;
9590 }
9591
9592 float GetSoakingIncrement(string pIncrementName)
9593 {
9594 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9595 if (g_Game.ConfigIsExisting(paramPath))
9596 return g_Game.ConfigGetFloat(paramPath);
9597
9598 return 0.0;
9599 }
9600 //----------------------------------------------------------------
9601 override void SetWet(float value, bool allow_client = false)
9602 {
9603 if (!IsServerCheck(allow_client))
9604 return;
9605
9606 float min = GetWetMin();
9607 float max = GetWetMax();
9608
9609 float previousValue = m_VarWet;
9610
9611 m_VarWet = Math.Clamp(value, min, max);
9612
9613 if (previousValue != m_VarWet)
9614 {
9615 SetVariableMask(VARIABLE_WET);
9616 OnWetChanged(m_VarWet, previousValue);
9617 }
9618 }
9619 //----------------------------------------------------------------
9620 override void AddWet(float value)
9621 {
9622 SetWet(GetWet() + value);
9623 }
9624 //----------------------------------------------------------------
9625 override void SetWetMax()
9626 {
9628 }
9629 //----------------------------------------------------------------
9630 override float GetWet()
9631 {
9632 return m_VarWet;
9633 }
9634 //----------------------------------------------------------------
9635 override float GetWetMax()
9636 {
9637 return m_VarWetMax;
9638 }
9639 //----------------------------------------------------------------
9640 override float GetWetMin()
9641 {
9642 return m_VarWetMin;
9643 }
9644 //----------------------------------------------------------------
9645 override float GetWetInit()
9646 {
9647 return m_VarWetInit;
9648 }
9649 //----------------------------------------------------------------
9650 override void OnWetChanged(float newVal, float oldVal)
9651 {
9652 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9653 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9654 if (newLevel != oldLevel)
9655 {
9656 OnWetLevelChanged(newLevel,oldLevel);
9657 }
9658 }
9659
9660 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9661 {
9662 SetWeightDirty();
9663 }
9664
9665 override EWetnessLevel GetWetLevel()
9666 {
9667 return GetWetLevelInternal(m_VarWet);
9668 }
9669
9670 //----------------------------------------------------------------
9671
9672 override void SetStoreLoad(bool value)
9673 {
9674 m_IsStoreLoad = value;
9675 }
9676
9677 override bool IsStoreLoad()
9678 {
9679 return m_IsStoreLoad;
9680 }
9681
9682 override void SetStoreLoadedQuantity(float value)
9683 {
9684 m_StoreLoadedQuantity = value;
9685 }
9686
9687 override float GetStoreLoadedQuantity()
9688 {
9689 return m_StoreLoadedQuantity;
9690 }
9691
9692 //----------------------------------------------------------------
9693
9694 float GetItemModelLength()
9695 {
9696 if (ConfigIsExisting("itemModelLength"))
9697 {
9698 return ConfigGetFloat("itemModelLength");
9699 }
9700 return 0;
9701 }
9702
9703 float GetItemAttachOffset()
9704 {
9705 if (ConfigIsExisting("itemAttachOffset"))
9706 {
9707 return ConfigGetFloat("itemAttachOffset");
9708 }
9709 return 0;
9710 }
9711
9712 override void SetCleanness(int value, bool allow_client = false)
9713 {
9714 if (!IsServerCheck(allow_client))
9715 return;
9716
9717 int previousValue = m_Cleanness;
9718
9719 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9720
9721 if (previousValue != m_Cleanness)
9722 SetVariableMask(VARIABLE_CLEANNESS);
9723 }
9724
9725 override int GetCleanness()
9726 {
9727 return m_Cleanness;
9728 }
9729
9731 {
9732 return true;
9733 }
9734
9735 //----------------------------------------------------------------
9736 // ATTACHMENT LOCKING
9737 // Getters relevant to generic ActionLockAttachment
9738 int GetLockType()
9739 {
9740 return m_LockType;
9741 }
9742
9743 string GetLockSoundSet()
9744 {
9745 return m_LockSoundSet;
9746 }
9747
9748 //----------------------------------------------------------------
9749 //------------------------- Color
9750 // sets items color variable given color components
9751 override void SetColor(int r, int g, int b, int a)
9752 {
9757 SetVariableMask(VARIABLE_COLOR);
9758 }
9760 override void GetColor(out int r,out int g,out int b,out int a)
9761 {
9766 }
9767
9768 bool IsColorSet()
9769 {
9770 return IsVariableSet(VARIABLE_COLOR);
9771 }
9772
9774 string GetColorString()
9775 {
9776 int r,g,b,a;
9777 GetColor(r,g,b,a);
9778 r = r/255;
9779 g = g/255;
9780 b = b/255;
9781 a = a/255;
9782 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9783 }
9784 //----------------------------------------------------------------
9785 //------------------------- LiquidType
9786
9787 override void SetLiquidType(int value, bool allow_client = false)
9788 {
9789 if (!IsServerCheck(allow_client))
9790 return;
9791
9792 int old = m_VarLiquidType;
9793 m_VarLiquidType = value;
9794 OnLiquidTypeChanged(old,value);
9795 SetVariableMask(VARIABLE_LIQUIDTYPE);
9796 }
9797
9798 int GetLiquidTypeInit()
9799 {
9800 return ConfigGetInt("varLiquidTypeInit");
9801 }
9802
9803 override int GetLiquidType()
9804 {
9805 return m_VarLiquidType;
9806 }
9807
9808 protected void OnLiquidTypeChanged(int oldType, int newType)
9809 {
9810 if (newType == LIQUID_NONE && GetIsFrozen())
9811 SetFrozen(false);
9812 }
9813
9815 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9816 {
9817 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9818 }
9819
9820 // -------------------------------------------------------------------------
9822 void OnInventoryEnter(Man player)
9823 {
9824 PlayerBase nplayer;
9825 if (PlayerBase.CastTo(nplayer, player))
9826 {
9827 m_CanPlayImpactSound = true;
9828 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9829 }
9830 }
9831
9832 // -------------------------------------------------------------------------
9834 void OnInventoryExit(Man player)
9835 {
9836 PlayerBase nplayer;
9837 if (PlayerBase.CastTo(nplayer,player))
9838 {
9839 nplayer.SetEnableQuickBarEntityShortcut(this, false);
9840 }
9841
9842 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9843
9844 if (HasEnergyManager())
9845 {
9846 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9847 }
9848 }
9849
9850 // ADVANCED PLACEMENT EVENTS
9851 override void OnPlacementStarted(Man player)
9852 {
9853 super.OnPlacementStarted(player);
9854
9855 SetTakeable(false);
9856 }
9857
9858 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9859 {
9860 if (m_AdminLog)
9861 {
9862 m_AdminLog.OnPlacementComplete(player, this);
9863 }
9864
9865 super.OnPlacementComplete(player, position, orientation);
9866 }
9867
9868 //-----------------------------
9869 // AGENT SYSTEM
9870 //-----------------------------
9871 //--------------------------------------------------------------------------
9872 bool ContainsAgent(int agent_id)
9873 {
9874 if (agent_id & m_AttachedAgents)
9875 {
9876 return true;
9877 }
9878 else
9879 {
9880 return false;
9881 }
9882 }
9883
9884 //--------------------------------------------------------------------------
9885 override void RemoveAgent(int agent_id)
9886 {
9887 if (ContainsAgent(agent_id))
9888 {
9889 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9890 }
9891 }
9892
9893 //--------------------------------------------------------------------------
9894 override void RemoveAllAgents()
9895 {
9896 m_AttachedAgents = 0;
9897 }
9898 //--------------------------------------------------------------------------
9899 override void RemoveAllAgentsExcept(int agent_to_keep)
9900 {
9901 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9902 }
9903 // -------------------------------------------------------------------------
9904 override void InsertAgent(int agent, float count = 1)
9905 {
9906 if (count < 1)
9907 return;
9908 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9910 }
9911
9913 void TransferAgents(int agents)
9914 {
9916 }
9917
9918 // -------------------------------------------------------------------------
9919 override int GetAgents()
9920 {
9921 return m_AttachedAgents;
9922 }
9923 //----------------------------------------------------------------------
9924
9925 /*int GetContaminationType()
9926 {
9927 int contamination_type;
9928
9929 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9930 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9931 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9932 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9933
9934 Edible_Base edible = Edible_Base.Cast(this);
9935 int agents = GetAgents();
9936 if (edible)
9937 {
9938 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9939 if (profile)
9940 {
9941 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9942 }
9943 }
9944 if (agents & CONTAMINATED_MASK)
9945 {
9946 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9947 }
9948 if (agents & POISONED_MASK)
9949 {
9950 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9951 }
9952 if (agents & NERVE_GAS_MASK)
9953 {
9954 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9955 }
9956 if (agents & DIRTY_MASK)
9957 {
9958 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9959 }
9960
9961 return agents;
9962 }*/
9963
9964 // -------------------------------------------------------------------------
9965 bool LoadAgents(ParamsReadContext ctx, int version)
9966 {
9967 if (!ctx.Read(m_AttachedAgents))
9968 return false;
9969 return true;
9970 }
9971 // -------------------------------------------------------------------------
9973 {
9974
9976 }
9977 // -------------------------------------------------------------------------
9978
9980 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9981 {
9982 super.CheckForRoofLimited(timeTresholdMS);
9983
9984 float time = g_Game.GetTime();
9985 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9986 {
9987 m_PreviousRoofTestTime = time;
9988 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9989 }
9990 }
9991
9992 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9993 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9994 {
9995 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9996 {
9997 return 0;
9998 }
9999
10000 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
10001 {
10002 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
10003 if (filter)
10004 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
10005 else
10006 return 0;//otherwise return 0 when no filter attached
10007 }
10008
10009 string subclassPath, entryName;
10010
10011 switch (type)
10012 {
10013 case DEF_BIOLOGICAL:
10014 entryName = "biological";
10015 break;
10016 case DEF_CHEMICAL:
10017 entryName = "chemical";
10018 break;
10019 default:
10020 entryName = "biological";
10021 break;
10022 }
10023
10024 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
10025
10026 return g_Game.ConfigGetFloat(subclassPath + entryName);
10027 }
10028
10029
10030
10032 override void EEOnCECreate()
10033 {
10034 if (!IsMagazine())
10036
10038 }
10039
10040
10041 //-------------------------
10042 // OPEN/CLOSE USER ACTIONS
10043 //-------------------------
10045 void Open();
10046 void Close();
10047 bool IsOpen()
10048 {
10049 return true;
10050 }
10051
10052 override bool CanDisplayCargo()
10053 {
10054 return IsOpen();
10055 }
10056
10057
10058 // ------------------------------------------------------------
10059 // CONDITIONS
10060 // ------------------------------------------------------------
10061 override bool CanPutInCargo(EntityAI parent)
10062 {
10063 if (parent)
10064 {
10065 if (parent.IsInherited(DayZInfected))
10066 return true;
10067
10068 if (!parent.IsRuined())
10069 return true;
10070 }
10071
10072 return true;
10073 }
10074
10075 override bool CanPutAsAttachment(EntityAI parent)
10076 {
10077 if (!super.CanPutAsAttachment(parent))
10078 {
10079 return false;
10080 }
10081
10082 if (!IsRuined() && !parent.IsRuined())
10083 {
10084 return true;
10085 }
10086
10087 return false;
10088 }
10089
10090 override bool CanReceiveItemIntoCargo(EntityAI item)
10091 {
10092 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10093 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10094 // return false;
10095
10096 return super.CanReceiveItemIntoCargo(item);
10097 }
10098
10099 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
10100 {
10101 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10102 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10103 // return false;
10104
10105 GameInventory attachmentInv = attachment.GetInventory();
10106 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10107 {
10108 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10109 return false;
10110 }
10111
10112 InventoryLocation loc = new InventoryLocation();
10113 attachment.GetInventory().GetCurrentInventoryLocation(loc);
10114 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
10115 return false;
10116
10117 return super.CanReceiveAttachment(attachment, slotId);
10118 }
10119
10120 override bool CanReleaseAttachment(EntityAI attachment)
10121 {
10122 if (!super.CanReleaseAttachment(attachment))
10123 return false;
10124
10125 return GetInventory().AreChildrenAccessible();
10126 }
10127
10128 /*override bool CanLoadAttachment(EntityAI attachment)
10129 {
10130 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10131 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10132 // return false;
10133
10134 GameInventory attachmentInv = attachment.GetInventory();
10135 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10136 {
10137 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
10138 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
10139
10140 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10141 return false;
10142 }
10143
10144 return super.CanLoadAttachment(attachment);
10145 }*/
10146
10147 // Plays muzzle flash particle effects
10148 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10149 {
10150 int id = muzzle_owner.GetMuzzleID();
10151 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
10152
10153 if (WPOF_array)
10154 {
10155 for (int i = 0; i < WPOF_array.Count(); i++)
10156 {
10157 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
10158
10159 if (WPOF)
10160 {
10161 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
10162 }
10163 }
10164 }
10165 }
10166
10167 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
10168 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10169 {
10170 int id = muzzle_owner.GetMuzzleID();
10171 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
10172
10173 if (WPOBE_array)
10174 {
10175 for (int i = 0; i < WPOBE_array.Count(); i++)
10176 {
10177 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
10178
10179 if (WPOBE)
10180 {
10181 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10182 }
10183 }
10184 }
10185 }
10186
10187 // Plays all weapon overheating particles
10188 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10189 {
10190 int id = muzzle_owner.GetMuzzleID();
10191 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10192
10193 if (WPOOH_array)
10194 {
10195 for (int i = 0; i < WPOOH_array.Count(); i++)
10196 {
10197 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10198
10199 if (WPOOH)
10200 {
10201 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10202 }
10203 }
10204 }
10205 }
10206
10207 // Updates all weapon overheating particles
10208 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10209 {
10210 int id = muzzle_owner.GetMuzzleID();
10211 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10212
10213 if (WPOOH_array)
10214 {
10215 for (int i = 0; i < WPOOH_array.Count(); i++)
10216 {
10217 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10218
10219 if (WPOOH)
10220 {
10221 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10222 }
10223 }
10224 }
10225 }
10226
10227 // Stops overheating particles
10228 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10229 {
10230 int id = muzzle_owner.GetMuzzleID();
10231 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10232
10233 if (WPOOH_array)
10234 {
10235 for (int i = 0; i < WPOOH_array.Count(); i++)
10236 {
10237 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10238
10239 if (WPOOH)
10240 {
10241 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10242 }
10243 }
10244 }
10245 }
10246
10247 //----------------------------------------------------------------
10248 //Item Behaviour - unified approach
10249 override bool IsHeavyBehaviour()
10250 {
10251 if (m_ItemBehaviour == 0)
10252 {
10253 return true;
10254 }
10255
10256 return false;
10257 }
10258
10259 override bool IsOneHandedBehaviour()
10260 {
10261 if (m_ItemBehaviour == 1)
10262 {
10263 return true;
10264 }
10265
10266 return false;
10267 }
10268
10269 override bool IsTwoHandedBehaviour()
10270 {
10271 if (m_ItemBehaviour == 2)
10272 {
10273 return true;
10274 }
10275
10276 return false;
10277 }
10278
10279 bool IsDeployable()
10280 {
10281 return false;
10282 }
10283
10285 float GetDeployTime()
10286 {
10287 return UATimeSpent.DEFAULT_DEPLOY;
10288 }
10289
10290
10291 //----------------------------------------------------------------
10292 // Item Targeting (User Actions)
10293 override void SetTakeable(bool pState)
10294 {
10295 m_IsTakeable = pState;
10296 SetSynchDirty();
10297 }
10298
10299 override bool IsTakeable()
10300 {
10301 return m_IsTakeable;
10302 }
10303
10304 // For cases where we want to show object widget which cant be taken to hands
10306 {
10307 return false;
10308 }
10309
10311 protected void PreLoadSoundAttachmentType()
10312 {
10313 string att_type = "None";
10314
10315 if (ConfigIsExisting("soundAttType"))
10316 {
10317 att_type = ConfigGetString("soundAttType");
10318 }
10319
10320 m_SoundAttType = att_type;
10321 }
10322
10323 override string GetAttachmentSoundType()
10324 {
10325 return m_SoundAttType;
10326 }
10327
10328 //----------------------------------------------------------------
10329 //SOUNDS - ItemSoundHandler
10330 //----------------------------------------------------------------
10331
10332 string GetPlaceSoundset(); // played when deploy starts
10333 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
10334 string GetDeploySoundset(); // played when deploy sucessfully finishes
10335 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
10336 string GetFoldSoundset(); // played when fold sucessfully finishes
10337
10339 {
10340 if (!m_ItemSoundHandler)
10342
10343 return m_ItemSoundHandler;
10344 }
10345
10346 // override to initialize sounds
10347 protected void InitItemSounds()
10348 {
10349 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
10350 return;
10351
10353
10354 if (GetPlaceSoundset() != string.Empty)
10355 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
10356
10357 if (GetDeploySoundset() != string.Empty)
10358 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
10359
10360 SoundParameters params = new SoundParameters();
10361 params.m_Loop = true;
10362 if (GetLoopDeploySoundset() != string.Empty)
10363 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
10364 }
10365
10366 // Start sound using ItemSoundHandler
10367 void StartItemSoundServer(int id, int slotId)
10368 {
10369 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10370 {
10371 m_SoundSyncSlotID = slotId;
10372 m_SoundSyncPlay = id;
10373
10374 SetSynchDirty();
10375
10376 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
10377 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
10378 }
10379 }
10380
10381 void StartItemSoundServer(int id)
10382 {
10383 StartItemSoundServer(id, InventorySlots.INVALID);
10384 }
10385
10386 // Stop sound using ItemSoundHandler
10387 void StopItemSoundServer(int id)
10388 {
10389 if (!g_Game.IsServer())
10390 return;
10391
10392 m_SoundSyncStop = id;
10393 SetSynchDirty();
10394
10395 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10396 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
10397 }
10398
10399 protected void ClearStartItemSoundServer()
10400 {
10401 m_SoundSyncPlay = 0;
10402 m_SoundSyncSlotID = InventorySlots.INVALID;
10403 }
10404
10405 protected void ClearStopItemSoundServer()
10406 {
10407 m_SoundSyncStop = 0;
10408 }
10409
10410 void OnApply(PlayerBase player);
10411
10413 {
10414 return 1.0;
10415 };
10416 //returns applicable selection
10417 array<string> GetHeadHidingSelection()
10418 {
10420 }
10421
10423 {
10425 }
10426
10427 WrittenNoteData GetWrittenNoteData() {};
10428
10430 {
10431 SetDynamicPhysicsLifeTime(0.01);
10432 m_ItemBeingDroppedPhys = false;
10433 }
10434
10436 {
10437 array<string> zone_names = new array<string>;
10438 GetDamageZones(zone_names);
10439 for (int i = 0; i < zone_names.Count(); i++)
10440 {
10441 SetHealthMax(zone_names.Get(i),"Health");
10442 }
10443 SetHealthMax("","Health");
10444 }
10445
10447 void SetZoneDamageCEInit()
10448 {
10449 float global_health = GetHealth01("","Health");
10450 array<string> zones = new array<string>;
10451 GetDamageZones(zones);
10452 //set damage of all zones to match global health level
10453 for (int i = 0; i < zones.Count(); i++)
10454 {
10455 SetHealth01(zones.Get(i),"Health",global_health);
10456 }
10457 }
10458
10460 bool IsCoverFaceForShave(string slot_name)
10461 {
10462 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10463 }
10464
10465 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10466 {
10467 if (!hasRootAsPlayer)
10468 {
10469 if (refParentIB)
10470 {
10471 // parent is wet
10472 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10473 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10474 // parent has liquid inside
10475 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10476 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10477 // drying
10478 else if (m_VarWet > m_VarWetMin)
10479 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10480 }
10481 else
10482 {
10483 // drying on ground or inside non-itembase (car, ...)
10484 if (m_VarWet > m_VarWetMin)
10485 AddWet(-1 * delta * GetDryingIncrement("ground"));
10486 }
10487 }
10488 }
10489
10490 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10491 {
10493 {
10494 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10495 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10496 {
10497 float heatPermCoef = 1.0;
10498 EntityAI ent = this;
10499 while (ent)
10500 {
10501 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10502 ent = ent.GetHierarchyParent();
10503 }
10504
10505 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10506 }
10507 }
10508 }
10509
10510 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10511 {
10512 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10513 EntityAI parent = GetHierarchyParent();
10514 if (!parent)
10515 {
10516 hasParent = false;
10517 hasRootAsPlayer = false;
10518 }
10519 else
10520 {
10521 hasParent = true;
10522 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10523 refParentIB = ItemBase.Cast(parent);
10524 }
10525 }
10526
10527 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10528 {
10529 // this is stub, implemented on Edible_Base
10530 }
10531
10532 bool CanDecay()
10533 {
10534 // return true used on selected food clases so they can decay
10535 return false;
10536 }
10537
10538 protected bool CanProcessDecay()
10539 {
10540 // this is stub, implemented on Edible_Base class
10541 // used to determine whether it is still necessary for the food to decay
10542 return false;
10543 }
10544
10545 protected bool CanHaveWetness()
10546 {
10547 // return true used on selected items that have a wetness effect
10548 return false;
10549 }
10550
10552 bool CanBeConsumed(ConsumeConditionData data = null)
10553 {
10554 return !GetIsFrozen() && IsOpen();
10555 }
10556
10557 override void ProcessVariables()
10558 {
10559 bool hasParent = false, hasRootAsPlayer = false;
10560 ItemBase refParentIB;
10561
10562 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10563 bool foodDecay = g_Game.IsFoodDecayEnabled();
10564
10565 if (wwtu || foodDecay)
10566 {
10567 bool processWetness = wwtu && CanHaveWetness();
10568 bool processTemperature = wwtu && CanHaveTemperature();
10569 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10570
10571 if (processWetness || processTemperature || processDecay)
10572 {
10573 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10574
10575 if (processWetness)
10576 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10577
10578 if (processTemperature)
10579 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10580
10581 if (processDecay)
10582 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10583 }
10584 }
10585 }
10586
10589 {
10590 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10591 }
10592
10593 override float GetTemperatureFreezeThreshold()
10594 {
10596 return Liquid.GetFreezeThreshold(GetLiquidType());
10597
10598 return super.GetTemperatureFreezeThreshold();
10599 }
10600
10601 override float GetTemperatureThawThreshold()
10602 {
10604 return Liquid.GetThawThreshold(GetLiquidType());
10605
10606 return super.GetTemperatureThawThreshold();
10607 }
10608
10609 override float GetItemOverheatThreshold()
10610 {
10612 return Liquid.GetBoilThreshold(GetLiquidType());
10613
10614 return super.GetItemOverheatThreshold();
10615 }
10616
10617 override float GetTemperatureFreezeTime()
10618 {
10619 if (HasQuantity())
10620 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10621
10622 return super.GetTemperatureFreezeTime();
10623 }
10624
10625 override float GetTemperatureThawTime()
10626 {
10627 if (HasQuantity())
10628 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10629
10630 return super.GetTemperatureThawTime();
10631 }
10632
10634 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10636 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10637
10638 bool IsCargoException4x3(EntityAI item)
10639 {
10640 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10641 }
10642
10644 {
10645 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10646 }
10647
10649 void AddLightSourceItem(ItemBase lightsource)
10650 {
10651 m_LightSourceItem = lightsource;
10652 }
10653
10655 {
10656 m_LightSourceItem = null;
10657 }
10658
10660 {
10661 return m_LightSourceItem;
10662 }
10663
10665 array<int> GetValidFinishers()
10666 {
10667 return null;
10668 }
10669
10671 bool GetActionWidgetOverride(out typename name)
10672 {
10673 return false;
10674 }
10675
10676 bool PairWithDevice(notnull ItemBase otherDevice)
10677 {
10678 if (g_Game.IsServer())
10679 {
10680 ItemBase explosive = otherDevice;
10682 if (!trg)
10683 {
10684 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10685 explosive = this;
10686 }
10687
10688 explosive.PairRemote(trg);
10689 trg.SetControlledDevice(explosive);
10690
10691 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10692 trg.SetPersistentPairID(persistentID);
10693 explosive.SetPersistentPairID(persistentID);
10694
10695 return true;
10696 }
10697 return false;
10698 }
10699
10701 float GetBaitEffectivity()
10702 {
10703 float ret = 1.0;
10704 if (HasQuantity())
10705 ret *= GetQuantityNormalized();
10706 ret *= GetHealth01();
10707
10708 return ret;
10709 }
10710
10711 #ifdef DEVELOPER
10712 override void SetDebugItem()
10713 {
10714 super.SetDebugItem();
10715 _itemBase = this;
10716 }
10717
10718 override string GetDebugText()
10719 {
10720 string text = super.GetDebugText();
10721
10722 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10723 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10724
10725 return text;
10726 }
10727 #endif
10728
10729 bool CanBeUsedForSuicide()
10730 {
10731 return true;
10732 }
10733
10735 //DEPRECATED BELOW
10737 // Backwards compatibility
10738 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10739 {
10740 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10741 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10742 }
10743
10744 // replaced by ItemSoundHandler
10745 protected EffectSound m_SoundDeployFinish;
10746 protected EffectSound m_SoundPlace;
10747 protected EffectSound m_DeployLoopSoundEx;
10748 protected EffectSound m_SoundDeploy;
10749 bool m_IsPlaceSound;
10750 bool m_IsDeploySound;
10752
10753 string GetDeployFinishSoundset();
10754 void PlayDeploySound();
10755 void PlayDeployFinishSound();
10756 void PlayPlaceSound();
10757 void PlayDeployLoopSoundEx();
10758 void StopDeployLoopSoundEx();
10759 void SoundSynchRemoteReset();
10760 void SoundSynchRemote();
10761 bool UsesGlobalDeploy(){return false;}
10762 bool CanPlayDeployLoopSound(){return false;}
10764 bool IsPlaceSound(){return m_IsPlaceSound;}
10765 bool IsDeploySound(){return m_IsDeploySound;}
10766 void SetIsPlaceSound(bool is_place_sound);
10767 void SetIsDeploySound(bool is_deploy_sound);
10768
10769 [Obsolete("Use ItemSoundHandler instead")]
10771 void PlayAttachSound(string slot_type)
10772 {
10773 if (!g_Game.IsDedicatedServer())
10774 {
10775 if (ConfigIsExisting("attachSoundSet"))
10776 {
10777 string cfg_path = "";
10778 string soundset = "";
10779 string type_name = GetType();
10780
10781 TStringArray cfg_soundset_array = new TStringArray;
10782 TStringArray cfg_slot_array = new TStringArray;
10783 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10784 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10785
10786 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10787 {
10788 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10789 {
10790 if (cfg_slot_array[i] == slot_type)
10791 {
10792 soundset = cfg_soundset_array[i];
10793 break;
10794 }
10795 }
10796 }
10797
10798 if (soundset != "")
10799 {
10800 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10801 sound.SetAutodestroy(true);
10802 }
10803 }
10804 }
10805 }
10806
10807 void PlayDetachSound(string slot_type) {}
10808}
10809
10810EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10811{
10812 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10813 if (entity)
10814 {
10815 bool is_item = entity.IsInherited(ItemBase);
10816 if (is_item && full_quantity)
10817 {
10818 ItemBase item = ItemBase.Cast(entity);
10819 item.SetQuantity(item.GetQuantityInit());
10820 }
10821 }
10822 else
10823 {
10824 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10825 return NULL;
10826 }
10827 return entity;
10828}
10829
10830void SetupSpawnedItem(ItemBase item, float health, float quantity)
10831{
10832 if (item)
10833 {
10834 if (health > 0)
10835 item.SetHealth("", "", health);
10836
10837 if (item.CanHaveTemperature())
10838 {
10839 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10840 if (item.CanFreeze())
10841 item.SetFrozen(false);
10842 }
10843
10844 if (item.HasEnergyManager())
10845 {
10846 if (quantity >= 0)
10847 {
10848 item.GetCompEM().SetEnergy0To1(quantity);
10849 }
10850 else
10851 {
10852 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10853 }
10854 }
10855 else if (item.IsMagazine())
10856 {
10857 Magazine mag = Magazine.Cast(item);
10858 if (quantity >= 0)
10859 {
10860 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10861 }
10862 else
10863 {
10864 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10865 }
10866
10867 }
10868 else
10869 {
10870 if (quantity >= 0)
10871 {
10872 item.SetQuantityNormalized(quantity, false);
10873 }
10874 else
10875 {
10876 item.SetQuantity(Math.AbsFloat(quantity));
10877 }
10878
10879 }
10880 }
10881}
10882
10883#ifdef DEVELOPER
10884ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10885#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()