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

◆ OnCreatePhysics()

override void SpawnItemOnLocation::OnCreatePhysics ( )
private

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

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