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

◆ OnItemAttachmentSlotChanged()

override void SpawnItemOnLocation::OnItemAttachmentSlotChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
private

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

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