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

◆ OnItemLocationChanged()

override void SpawnItemOnLocation::OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
private

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

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

Используется в Entity::EEItemLocationChanged().