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

◆ IsTakeable()

override bool SpawnItemOnLocation::IsTakeable ( )
protected

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

9295{
9296 override bool CanPutAsAttachment(EntityAI parent)
9297 {
9298 return true;
9299 }
9300};
9301
9303{
9304
9305};
9306
9307//const bool QUANTITY_DEBUG_REMOVE_ME = false;
9308
9309class ItemBase extends InventoryItem
9310{
9314
9316
9317 static int m_DebugActionsMask;
9319 // ============================================
9320 // Variable Manipulation System
9321 // ============================================
9322 // Quantity
9323
9324 float m_VarQuantity;
9325 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
9327 int m_VarQuantityMin;
9328 int m_VarQuantityMax;
9329 int m_Count;
9330 float m_VarStackMax;
9331 float m_StoreLoadedQuantity = float.LOWEST;
9332 // Wet
9333 float m_VarWet;
9334 float m_VarWetPrev;//for client to know wetness changed during synchronization
9335 float m_VarWetInit;
9336 float m_VarWetMin;
9337 float m_VarWetMax;
9338 // Cleanness
9339 int m_Cleanness;
9340 int m_CleannessInit;
9341 int m_CleannessMin;
9342 int m_CleannessMax;
9343 // impact sounds
9345 bool m_CanPlayImpactSound = true;
9346 float m_ImpactSpeed;
9348 //
9349 float m_HeatIsolation;
9350 float m_ItemModelLength;
9351 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
9353 int m_VarLiquidType;
9354 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
9355 int m_QuickBarBonus;
9356 bool m_IsBeingPlaced;
9357 bool m_IsHologram;
9358 bool m_IsTakeable;
9359 bool m_ThrowItemOnDrop;
9362 bool m_FixDamageSystemInit = false; //can be changed on storage version check
9363 bool can_this_be_combined; //Check if item can be combined
9364 bool m_CanThisBeSplit; //Check if item can be split
9365 bool m_IsStoreLoad = false;
9366 bool m_CanShowQuantity;
9367 bool m_HasQuantityBar;
9368 protected bool m_CanBeDigged;
9369 protected bool m_IsResultOfSplit
9370
9371 string m_SoundAttType;
9372 // items color variables
9377 //-------------------------------------------------------
9378
9379 // light source managing
9381
9385
9386 //==============================================
9387 // agent system
9388 private int m_AttachedAgents;
9389
9391 void TransferModifiers(PlayerBase reciever);
9392
9393
9394 // Weapons & suppressors particle effects
9398 ref static map<string, int> m_WeaponTypeToID;
9399 static int m_LastRegisteredWeaponID = 0;
9400
9401 // Overheating effects
9403 float m_OverheatingShots;
9404 ref Timer m_CheckOverheating;
9405 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
9406 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
9407 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
9408 ref array <ref OverheatingParticle> m_OverheatingParticles;
9409
9411 protected bool m_HideSelectionsBySlot;
9412
9413 // Admin Log
9414 PluginAdminLog m_AdminLog;
9415
9416 // misc
9417 ref Timer m_PhysDropTimer;
9418
9419 // Attachment Locking variables
9420 ref array<int> m_CompatibleLocks;
9421 protected int m_LockType;
9422 protected ref EffectSound m_LockingSound;
9423 protected string m_LockSoundSet;
9424
9425 // ItemSoundHandler variables
9426 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
9427 protected int m_SoundSyncPlay; // id for sound to play
9428 protected int m_SoundSyncStop; // id for sound to stop
9429 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
9430
9432
9433 //temperature
9434 private float m_TemperaturePerQuantityWeight;
9435
9436 // -------------------------------------------------------------------------
9437 void ItemBase()
9438 {
9439 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9443
9444 if (!g_Game.IsDedicatedServer())
9445 {
9446 if (HasMuzzle())
9447 {
9449
9451 {
9453 }
9454 }
9455
9457 m_ActionsInitialize = false;
9458 }
9459
9460 m_OldLocation = null;
9461
9462 if (g_Game.IsServer())
9463 {
9464 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9465 }
9466
9467 if (ConfigIsExisting("headSelectionsToHide"))
9468 {
9470 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9471 }
9472
9473 m_HideSelectionsBySlot = false;
9474 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9475 {
9476 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9477 }
9478
9479 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9480
9481 m_IsResultOfSplit = false;
9482
9484 }
9485
9486 override void InitItemVariables()
9487 {
9488 super.InitItemVariables();
9489
9490 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9491 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9492 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9493 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9494 m_VarStackMax = ConfigGetFloat("varStackMax");
9495 m_Count = ConfigGetInt("count");
9496
9497 m_CanShowQuantity = ConfigGetBool("quantityShow");
9498 m_HasQuantityBar = ConfigGetBool("quantityBar");
9499
9500 m_CleannessInit = ConfigGetInt("varCleannessInit");
9502 m_CleannessMin = ConfigGetInt("varCleannessMin");
9503 m_CleannessMax = ConfigGetInt("varCleannessMax");
9504
9505 m_WantPlayImpactSound = false;
9506 m_ImpactSpeed = 0.0;
9507
9508 m_VarWetInit = ConfigGetFloat("varWetInit");
9510 m_VarWetMin = ConfigGetFloat("varWetMin");
9511 m_VarWetMax = ConfigGetFloat("varWetMax");
9512
9513 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9514 if (IsLiquidContainer() && GetQuantity() != 0)
9516 m_IsBeingPlaced = false;
9517 m_IsHologram = false;
9518 m_IsTakeable = true;
9519 m_CanBeMovedOverride = false;
9523 m_CanBeDigged = ConfigGetBool("canBeDigged");
9524
9525 m_CompatibleLocks = new array<int>();
9526 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9527 m_LockType = ConfigGetInt("lockType");
9528
9529 //Define if item can be split and set ability to be combined accordingly
9530 m_CanThisBeSplit = false;
9531 can_this_be_combined = false;
9532 if (ConfigIsExisting("canBeSplit"))
9533 {
9534 can_this_be_combined = ConfigGetBool("canBeSplit");
9536 }
9537
9538 m_ItemBehaviour = -1;
9539 if (ConfigIsExisting("itemBehaviour"))
9540 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9541
9542 //RegisterNetSyncVariableInt("m_VariablesMask");
9543 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9544 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9545 RegisterNetSyncVariableInt("m_VarLiquidType");
9546 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9547
9548 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9549 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9550 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9551
9552 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9553 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9554 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9555 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9556
9557 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9558 RegisterNetSyncVariableBool("m_IsTakeable");
9559 RegisterNetSyncVariableBool("m_IsHologram");
9560
9563 {
9564 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9565 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9566 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
9567 }
9568
9569 m_LockSoundSet = ConfigGetString("lockSoundSet");
9570
9572 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9573 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9574
9575 m_SoundSyncSlotID = -1;
9576 }
9577
9578 override int GetQuickBarBonus()
9579 {
9580 return m_QuickBarBonus;
9581 }
9582
9583 void InitializeActions()
9584 {
9586 if (!m_InputActionMap)
9587 {
9589 m_InputActionMap = iam;
9590 SetActions();
9592 }
9593 }
9594
9595 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9596 {
9598 {
9599 m_ActionsInitialize = true;
9601 }
9602
9603 actions = m_InputActionMap.Get(action_input_type);
9604 }
9605
9606 void SetActions()
9607 {
9608 AddAction(ActionTakeItem);
9609 AddAction(ActionTakeItemToHands);
9610 AddAction(ActionWorldCraft);
9612 AddAction(ActionAttachWithSwitch);
9613 }
9614
9615 void SetActionAnimOverrides(); // Override action animation for specific item
9616
9617 void AddAction(typename actionName)
9618 {
9619 ActionBase action = ActionManagerBase.GetAction(actionName);
9620
9621 if (!action)
9622 {
9623 Debug.LogError("Action " + actionName + " dosn't exist!");
9624 return;
9625 }
9626
9627 typename ai = action.GetInputType();
9628 if (!ai)
9629 {
9630 m_ActionsInitialize = false;
9631 return;
9632 }
9633
9634 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9635 if (!action_array)
9636 {
9637 action_array = new array<ActionBase_Basic>;
9638 m_InputActionMap.Insert(ai, action_array);
9639 }
9640 if (LogManager.IsActionLogEnable())
9641 {
9642 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9643 }
9644
9645 if (action_array.Find(action) != -1)
9646 {
9647 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9648 }
9649 else
9650 {
9651 action_array.Insert(action);
9652 }
9653 }
9654
9655 void RemoveAction(typename actionName)
9656 {
9657 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9658 ActionBase action = player.GetActionManager().GetAction(actionName);
9659 typename ai = action.GetInputType();
9660 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9661
9662 if (action_array)
9663 {
9664 action_array.RemoveItem(action);
9665 }
9666 }
9667
9668 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9669 // Set -1 for params which should stay in default state
9670 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9671 {
9672 ActionOverrideData overrideData = new ActionOverrideData();
9673 overrideData.m_CommandUID = commandUID;
9674 overrideData.m_CommandUIDProne = commandUIDProne;
9675 overrideData.m_StanceMask = stanceMask;
9676
9677 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9678 if (!actionMap) // create new map of action > overidables map
9679 {
9680 actionMap = new TActionAnimOverrideMap();
9681 m_ItemActionOverrides.Insert(action, actionMap);
9682 }
9683
9684 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9685
9686 }
9687
9688 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9689
9690 ScriptedLightBase GetLight();
9691
9692 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9693 void LoadParticleConfigOnFire(int id)
9694 {
9695 if (!m_OnFireEffect)
9697
9700
9701 string config_to_search = "CfgVehicles";
9702 string muzzle_owner_config;
9703
9704 if (!m_OnFireEffect.Contains(id))
9705 {
9706 if (IsInherited(Weapon))
9707 config_to_search = "CfgWeapons";
9708
9709 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9710
9711 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9712
9713 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
9714
9715 if (config_OnFire_subclass_count > 0)
9716 {
9717 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9718
9719 for (int i = 0; i < config_OnFire_subclass_count; i++)
9720 {
9721 string particle_class = "";
9722 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
9723 string config_OnFire_entry = config_OnFire_class + particle_class;
9724 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9725 WPOF_array.Insert(WPOF);
9726 }
9727
9728
9729 m_OnFireEffect.Insert(id, WPOF_array);
9730 }
9731 }
9732
9733 if (!m_OnBulletCasingEjectEffect.Contains(id))
9734 {
9735 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9736 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9737
9738 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9739
9740 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9741
9742 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9743 {
9744 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9745
9746 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9747 {
9748 string particle_class2 = "";
9749 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9750 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9751 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9752 WPOBE_array.Insert(WPOBE);
9753 }
9754
9755
9756 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9757 }
9758 }
9759 }
9760
9761 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9763 {
9766
9767 if (!m_OnOverheatingEffect.Contains(id))
9768 {
9769 string config_to_search = "CfgVehicles";
9770
9771 if (IsInherited(Weapon))
9772 config_to_search = "CfgWeapons";
9773
9774 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9775 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9776
9777 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
9778 {
9779
9780 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9781
9783 {
9784 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9785 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9786 Error(error);
9787 return;
9788 }
9789
9790 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9791 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9792
9793
9794
9795 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
9796 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9797
9798 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9799 {
9800 string particle_class = "";
9801 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9802 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9803 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
9804
9805 if (entry_type == CT_CLASS)
9806 {
9807 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9808 WPOOH_array.Insert(WPOF);
9809 }
9810 }
9811
9812
9813 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9814 }
9815 }
9816 }
9817
9818 float GetOverheatingValue()
9819 {
9820 return m_OverheatingShots;
9821 }
9822
9823 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9824 {
9825 if (m_MaxOverheatingValue > 0)
9826 {
9828
9829 if (!m_CheckOverheating)
9831
9833 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9834
9835 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9836 }
9837 }
9838
9839 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9840 {
9842 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9843
9845 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9846
9848 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9849
9851 {
9853 }
9854 }
9855
9857 {
9859 }
9860
9861 void OnOverheatingDecay()
9862 {
9863 if (m_MaxOverheatingValue > 0)
9864 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9865 else
9867
9868 if (m_OverheatingShots <= 0)
9869 {
9872 }
9873 else
9874 {
9875 if (!m_CheckOverheating)
9877
9879 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9880 }
9881
9882 CheckOverheating(this, "", this);
9883 }
9884
9885 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9886 {
9888 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9889 }
9890
9891 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9892 {
9894 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9896 }
9897
9898 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9899 {
9901 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9902 }
9903
9904 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9905 {
9907 m_OverheatingParticles = new array<ref OverheatingParticle>;
9908
9909 OverheatingParticle OP = new OverheatingParticle();
9910 OP.RegisterParticle(p);
9911 OP.SetOverheatingLimitMin(min_heat_coef);
9912 OP.SetOverheatingLimitMax(max_heat_coef);
9913 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9914
9915 m_OverheatingParticles.Insert(OP);
9916 }
9917
9918 float GetOverheatingCoef()
9919 {
9920 if (m_MaxOverheatingValue > 0)
9922
9923 return -1;
9924 }
9925
9927 {
9929 {
9930 float overheat_coef = GetOverheatingCoef();
9931 int count = m_OverheatingParticles.Count();
9932
9933 for (int i = count; i > 0; --i)
9934 {
9935 int id = i - 1;
9936 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9937 Particle p = OP.GetParticle();
9938
9939 float overheat_min = OP.GetOverheatingLimitMin();
9940 float overheat_max = OP.GetOverheatingLimitMax();
9941
9942 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9943 {
9944 if (p)
9945 {
9946 p.Stop();
9947 OP.RegisterParticle(null);
9948 }
9949 }
9950 }
9951 }
9952 }
9953
9955 {
9957 {
9958 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9959 {
9960 int id = i - 1;
9961 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9962
9963 if (OP)
9964 {
9965 Particle p = OP.GetParticle();
9966
9967 if (p)
9968 {
9969 p.Stop();
9970 }
9971
9972 delete OP;
9973 }
9974 }
9975
9976 m_OverheatingParticles.Clear();
9978 }
9979 }
9980
9982 float GetInfectionChance(int system = 0, Param param = null)
9983 {
9984 return 0.0;
9985 }
9986
9987
9988 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9989 {
9990 return 250;//default value
9991 }
9992
9993 float GetFilterDamageRatio()
9994 {
9995 return 0;
9996 }
9997
9999 bool HasMuzzle()
10000 {
10001 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
10002 return true;
10003
10004 return false;
10005 }
10006
10008 int GetMuzzleID()
10009 {
10010 if (!m_WeaponTypeToID)
10011 m_WeaponTypeToID = new map<string, int>;
10012
10013 if (m_WeaponTypeToID.Contains(GetType()))
10014 {
10015 return m_WeaponTypeToID.Get(GetType());
10016 }
10017 else
10018 {
10019 // Register new weapon ID
10021 }
10022
10024 }
10025
10032 {
10033 return -1;
10034 }
10035
10036
10037
10038 // -------------------------------------------------------------------------
10039 void ~ItemBase()
10040 {
10041 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
10042 {
10043 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10044 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10045
10046 if (r_index >= 0)
10047 {
10048 InventoryLocation r_il = new InventoryLocation;
10049 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10050
10051 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10052 int r_type = r_il.GetType();
10053 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10054 {
10055 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10056 }
10057 else if (r_type == InventoryLocationType.ATTACHMENT)
10058 {
10059 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10060 }
10061
10062 }
10063
10064 player.GetHumanInventory().ClearUserReservedLocation(this);
10065 }
10066
10067 if (m_LockingSound)
10068 SEffectManager.DestroyEffect(m_LockingSound);
10069 }
10070
10071
10072
10073 // -------------------------------------------------------------------------
10074 static int GetDebugActionsMask()
10075 {
10076 return ItemBase.m_DebugActionsMask;
10077 }
10078
10079 static bool HasDebugActionsMask(int mask)
10080 {
10081 return ItemBase.m_DebugActionsMask & mask;
10082 }
10083
10084 static void SetDebugActionsMask(int mask)
10085 {
10086 ItemBase.m_DebugActionsMask = mask;
10087 }
10088
10089 static void AddDebugActionsMask(int mask)
10090 {
10091 ItemBase.m_DebugActionsMask |= mask;
10092 }
10093
10094 static void RemoveDebugActionsMask(int mask)
10095 {
10096 ItemBase.m_DebugActionsMask &= ~mask;
10097 }
10098
10099 static void ToggleDebugActionsMask(int mask)
10100 {
10101 if (HasDebugActionsMask(mask))
10102 {
10104 }
10105 else
10106 {
10107 AddDebugActionsMask(mask);
10108 }
10109 }
10110
10111 // -------------------------------------------------------------------------
10112 void SetCEBasedQuantity()
10113 {
10114 if (GetEconomyProfile())
10115 {
10116 float q_max = GetEconomyProfile().GetQuantityMax();
10117 if (q_max > 0)
10118 {
10119 float q_min = GetEconomyProfile().GetQuantityMin();
10120 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
10121
10122 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
10123 {
10124 ComponentEnergyManager comp = GetCompEM();
10125 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
10126 {
10127 comp.SetEnergy0To1(quantity_randomized);
10128 }
10129 }
10130 else if (HasQuantity())
10131 {
10132 SetQuantityNormalized(quantity_randomized, false);
10133 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
10134 }
10135
10136 }
10137 }
10138 }
10139
10141 void LockToParent()
10142 {
10143 EntityAI parent = GetHierarchyParent();
10144
10145 if (parent)
10146 {
10147 InventoryLocation inventory_location_to_lock = new InventoryLocation;
10148 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
10149 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
10150 }
10151 }
10152
10154 void UnlockFromParent()
10155 {
10156 EntityAI parent = GetHierarchyParent();
10157
10158 if (parent)
10159 {
10160 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
10161 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
10162 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
10163 }
10164 }
10165
10166 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
10167 {
10168 /*
10169 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
10170 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
10171 */
10172 ItemBase item2 = ItemBase.Cast(entity2);
10173
10174 if (g_Game.IsClient())
10175 {
10176 if (ScriptInputUserData.CanStoreInputUserData())
10177 {
10178 ScriptInputUserData ctx = new ScriptInputUserData;
10180 ctx.Write(-1);
10181 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10182 ctx.Write(i1);
10183 ctx.Write(item2);
10184 ctx.Write(use_stack_max);
10185 ctx.Write(-1);
10186 ctx.Send();
10187
10188 if (IsCombineAll(item2, use_stack_max))
10189 {
10190 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
10191 }
10192 }
10193 }
10194 else if (!g_Game.IsMultiplayer())
10195 {
10196 CombineItems(item2, use_stack_max);
10197 }
10198 }
10199
10200 bool IsLiquidPresent()
10201 {
10202 return (GetLiquidType() != 0 && HasQuantity());
10203 }
10204
10205 bool IsLiquidContainer()
10206 {
10207 return m_LiquidContainerMask != 0;
10208 }
10209
10211 {
10212 return m_LiquidContainerMask;
10213 }
10214
10215 bool IsBloodContainer()
10216 {
10217 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
10218 return false;
10219 }
10220
10221 bool IsNVG()
10222 {
10223 return false;
10224 }
10225
10228 bool IsExplosive()
10229 {
10230 return false;
10231 }
10232
10234 {
10235 return "";
10236 }
10237
10239
10240 bool IsLightSource()
10241 {
10242 return false;
10243 }
10244
10246 {
10247 return true;
10248 }
10249
10250 //--- ACTION CONDITIONS
10251 //direction
10252 bool IsFacingPlayer(PlayerBase player, string selection)
10253 {
10254 return true;
10255 }
10256
10257 bool IsPlayerInside(PlayerBase player, string selection)
10258 {
10259 return true;
10260 }
10261
10262 override bool CanObstruct()
10263 {
10264 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10265 return !player || !IsPlayerInside(player, "");
10266 }
10267
10268 override bool IsBeingPlaced()
10269 {
10270 return m_IsBeingPlaced;
10271 }
10272
10273 void SetIsBeingPlaced(bool is_being_placed)
10274 {
10275 m_IsBeingPlaced = is_being_placed;
10276 if (!is_being_placed)
10278 SetSynchDirty();
10279 }
10280
10281 //server-side
10282 void OnEndPlacement() {}
10283
10284 override bool IsHologram()
10285 {
10286 return m_IsHologram;
10287 }
10288
10289 bool CanBeDigged()
10290 {
10291 return m_CanBeDigged;
10292 }
10293
10295 {
10296 return 1;
10297 }
10298
10299 bool CanMakeGardenplot()
10300 {
10301 return false;
10302 }
10303
10304 void SetIsHologram(bool is_hologram)
10305 {
10306 m_IsHologram = is_hologram;
10307 SetSynchDirty();
10308 }
10309 /*
10310 protected float GetNutritionalEnergy()
10311 {
10312 Edible_Base edible = Edible_Base.Cast(this);
10313 return edible.GetFoodEnergy();
10314 }
10315
10316 protected float GetNutritionalWaterContent()
10317 {
10318 Edible_Base edible = Edible_Base.Cast(this);
10319 return edible.GetFoodWater();
10320 }
10321
10322 protected float GetNutritionalIndex()
10323 {
10324 Edible_Base edible = Edible_Base.Cast(this);
10325 return edible.GetFoodNutritionalIndex();
10326 }
10327
10328 protected float GetNutritionalFullnessIndex()
10329 {
10330 Edible_Base edible = Edible_Base.Cast(this);
10331 return edible.GetFoodTotalVolume();
10332 }
10333
10334 protected float GetNutritionalToxicity()
10335 {
10336 Edible_Base edible = Edible_Base.Cast(this);
10337 return edible.GetFoodToxicity();
10338
10339 }
10340 */
10341
10342
10343 // -------------------------------------------------------------------------
10344 override void OnMovedInsideCargo(EntityAI container)
10345 {
10346 super.OnMovedInsideCargo(container);
10347
10348 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10349 }
10350
10351 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10352 {
10353 super.EEItemLocationChanged(oldLoc, newLoc);
10354
10355 PlayerBase newPlayer = null;
10356 PlayerBase oldPlayer = null;
10357
10358 if (newLoc.GetParent())
10359 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
10360
10361 if (oldLoc.GetParent())
10362 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
10363
10364 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
10365 {
10366 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
10367
10368 if (rIndex >= 0)
10369 {
10370 InventoryLocation rIl = new InventoryLocation;
10371 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
10372
10373 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
10374 int rType = rIl.GetType();
10375 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
10376 {
10377 rIl.GetParent().GetOnReleaseLock().Invoke(this);
10378 }
10379 else if (rType == InventoryLocationType.ATTACHMENT)
10380 {
10381 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
10382 }
10383
10384 }
10385 }
10386
10387 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
10388 {
10389 if (newPlayer)
10390 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
10391
10392 if (newPlayer == oldPlayer)
10393 {
10394 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
10395 {
10396 if (oldLoc.GetType() == InventoryLocationType.CARGO)
10397 {
10398 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
10399 {
10400 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10401 }
10402 }
10403 else
10404 {
10405 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10406 }
10407 }
10408
10409 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
10410 {
10411 int type = oldLoc.GetType();
10412 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
10413 {
10414 oldLoc.GetParent().GetOnSetLock().Invoke(this);
10415 }
10416 else if (type == InventoryLocationType.ATTACHMENT)
10417 {
10418 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
10419 }
10420 }
10421 if (!m_OldLocation)
10422 {
10423 m_OldLocation = new InventoryLocation;
10424 }
10425 m_OldLocation.Copy(oldLoc);
10426 }
10427 else
10428 {
10429 if (m_OldLocation)
10430 {
10431 m_OldLocation.Reset();
10432 }
10433 }
10434
10435 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
10436 }
10437 else
10438 {
10439 if (newPlayer)
10440 {
10441 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
10442 if (resIndex >= 0)
10443 {
10444 InventoryLocation il = new InventoryLocation;
10445 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
10446 ItemBase it = ItemBase.Cast(il.GetItem());
10447 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
10448 int rel_type = il.GetType();
10449 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10450 {
10451 il.GetParent().GetOnReleaseLock().Invoke(it);
10452 }
10453 else if (rel_type == InventoryLocationType.ATTACHMENT)
10454 {
10455 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10456 }
10457 //it.GetOnReleaseLock().Invoke(it);
10458 }
10459 }
10460 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10461 {
10462 //ThrowPhysically(oldPlayer, vector.Zero);
10463 m_ThrowItemOnDrop = false;
10464 }
10465
10466 if (m_OldLocation)
10467 {
10468 m_OldLocation.Reset();
10469 }
10470 }
10471
10472 if (oldLoc.GetType() == InventoryLocationType.TEMP)
10473 {
10474 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
10475 }
10476
10477 if (newLoc.GetType() == InventoryLocationType.TEMP)
10478 {
10479 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
10480 }
10481 }
10482
10483 override void EOnContact(IEntity other, Contact extra)
10484 {
10486 {
10487 int liquidType = -1;
10488 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10489 if (impactSpeed > 0.0)
10490 {
10491 m_ImpactSpeed = impactSpeed;
10492 #ifndef SERVER
10493 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10494 #else
10495 m_WantPlayImpactSound = true;
10496 SetSynchDirty();
10497 #endif
10498 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10499 }
10500 }
10501
10502 #ifdef SERVER
10503 if (GetCompEM() && GetCompEM().IsPlugged())
10504 {
10505 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10506 GetCompEM().UnplugThis();
10507 }
10508 #endif
10509 }
10510
10511 void RefreshPhysics();
10512
10513 override void OnCreatePhysics()
10514 {
10516 }
10517
10518 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10519 {
10520
10521 }
10522 // -------------------------------------------------------------------------
10523 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10524 {
10525 super.OnItemLocationChanged(old_owner, new_owner);
10526
10527 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10528 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10529
10530 if (!relatedPlayer && playerNew)
10531 relatedPlayer = playerNew;
10532
10533 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10534 {
10535 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10536 if (actionMgr)
10537 {
10538 ActionBase currentAction = actionMgr.GetRunningAction();
10539 if (currentAction)
10540 currentAction.OnItemLocationChanged(this);
10541 }
10542 }
10543
10544 Man ownerPlayerOld = null;
10545 Man ownerPlayerNew = null;
10546
10547 if (old_owner)
10548 {
10549 if (old_owner.IsMan())
10550 {
10551 ownerPlayerOld = Man.Cast(old_owner);
10552 }
10553 else
10554 {
10555 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10556 }
10557 }
10558 else
10559 {
10560 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10561 {
10562 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10563
10564 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10565 {
10566 GetCompEM().UnplugThis();
10567 }
10568 }
10569 }
10570
10571 if (new_owner)
10572 {
10573 if (new_owner.IsMan())
10574 {
10575 ownerPlayerNew = Man.Cast(new_owner);
10576 }
10577 else
10578 {
10579 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10580 }
10581 }
10582
10583 if (ownerPlayerOld != ownerPlayerNew)
10584 {
10585 if (ownerPlayerOld)
10586 {
10587 array<EntityAI> subItemsExit = new array<EntityAI>;
10588 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10589 for (int i = 0; i < subItemsExit.Count(); i++)
10590 {
10591 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10592 itemExit.OnInventoryExit(ownerPlayerOld);
10593 }
10594 }
10595
10596 if (ownerPlayerNew)
10597 {
10598 array<EntityAI> subItemsEnter = new array<EntityAI>;
10599 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10600 for (int j = 0; j < subItemsEnter.Count(); j++)
10601 {
10602 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10603 itemEnter.OnInventoryEnter(ownerPlayerNew);
10604 }
10605 }
10606 }
10607 else if (ownerPlayerNew != null)
10608 {
10609 PlayerBase nplayer;
10610 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10611 {
10612 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10613 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10614 for (int k = 0; k < subItemsUpdate.Count(); k++)
10615 {
10616 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10617 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10618 }
10619 }
10620 }
10621
10622 if (old_owner)
10623 old_owner.OnChildItemRemoved(this);
10624 if (new_owner)
10625 new_owner.OnChildItemReceived(this);
10626 }
10627
10628 // -------------------------------------------------------------------------------
10629 override void EEDelete(EntityAI parent)
10630 {
10631 super.EEDelete(parent);
10632 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10633 if (player)
10634 {
10635 OnInventoryExit(player);
10636
10637 if (player.IsAlive())
10638 {
10639 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10640 if (r_index >= 0)
10641 {
10642 InventoryLocation r_il = new InventoryLocation;
10643 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10644
10645 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10646 int r_type = r_il.GetType();
10647 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10648 {
10649 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10650 }
10651 else if (r_type == InventoryLocationType.ATTACHMENT)
10652 {
10653 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10654 }
10655
10656 }
10657
10658 player.RemoveQuickBarEntityShortcut(this);
10659 }
10660 }
10661 }
10662 // -------------------------------------------------------------------------------
10663 override void EEKilled(Object killer)
10664 {
10665 super.EEKilled(killer);
10666
10668 if (killer && killer.IsFireplace() && CanExplodeInFire())
10669 {
10670 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10671 {
10672 if (IsMagazine())
10673 {
10674 if (Magazine.Cast(this).GetAmmoCount() > 0)
10675 {
10676 ExplodeAmmo();
10677 }
10678 }
10679 else
10680 {
10681 Explode(DamageType.EXPLOSION);
10682 }
10683 }
10684 }
10685 }
10686
10687 override void OnWasAttached(EntityAI parent, int slot_id)
10688 {
10689 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10690
10691 super.OnWasAttached(parent, slot_id);
10692
10693 if (HasQuantity())
10694 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10695
10696 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10697 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
10698 }
10699
10700 override void OnWasDetached(EntityAI parent, int slot_id)
10701 {
10702 super.OnWasDetached(parent, slot_id);
10703
10704 if (HasQuantity())
10705 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10706
10707 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10708 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
10709 }
10710
10711 override string ChangeIntoOnAttach(string slot)
10712 {
10713 int idx;
10714 TStringArray inventory_slots = new TStringArray;
10715 TStringArray attach_types = new TStringArray;
10716
10717 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10718 if (inventory_slots.Count() < 1) //is string
10719 {
10720 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10721 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10722 }
10723 else //is array
10724 {
10725 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10726 }
10727
10728 idx = inventory_slots.Find(slot);
10729 if (idx < 0)
10730 return "";
10731
10732 return attach_types.Get(idx);
10733 }
10734
10735 override string ChangeIntoOnDetach()
10736 {
10737 int idx = -1;
10738 string slot;
10739
10740 TStringArray inventory_slots = new TStringArray;
10741 TStringArray detach_types = new TStringArray;
10742
10743 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10744 if (inventory_slots.Count() < 1) //is string
10745 {
10746 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10747 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10748 }
10749 else //is array
10750 {
10751 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10752 if (detach_types.Count() < 1)
10753 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10754 }
10755
10756 for (int i = 0; i < inventory_slots.Count(); i++)
10757 {
10758 slot = inventory_slots.Get(i);
10759 }
10760
10761 if (slot != "")
10762 {
10763 if (detach_types.Count() == 1)
10764 idx = 0;
10765 else
10766 idx = inventory_slots.Find(slot);
10767 }
10768 if (idx < 0)
10769 return "";
10770
10771 return detach_types.Get(idx);
10772 }
10773
10774 void ExplodeAmmo()
10775 {
10776 //timer
10777 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10778
10779 //min/max time
10780 float min_time = 1;
10781 float max_time = 3;
10782 float delay = Math.RandomFloat(min_time, max_time);
10783
10784 explode_timer.Run(delay, this, "DoAmmoExplosion");
10785 }
10786
10787 void DoAmmoExplosion()
10788 {
10789 Magazine magazine = Magazine.Cast(this);
10790 int pop_sounds_count = 6;
10791 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10792
10793 //play sound
10794 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10795 string sound_name = pop_sounds[ sound_idx ];
10796 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
10797
10798 //remove ammo count
10799 magazine.ServerAddAmmoCount(-1);
10800
10801 //if condition then repeat -> ExplodeAmmo
10802 float min_temp_to_explode = 100; //min temperature for item to explode
10803
10804 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10805 {
10806 ExplodeAmmo();
10807 }
10808 }
10809
10810 // -------------------------------------------------------------------------------
10811 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10812 {
10813 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10814
10815 const int CHANCE_DAMAGE_CARGO = 4;
10816 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10817 const int CHANCE_DAMAGE_NOTHING = 2;
10818
10819 if (IsClothing() || IsContainer() || IsItemTent())
10820 {
10821 float dmg = damageResult.GetDamage("","Health") * -0.5;
10822 int chances;
10823 int rnd;
10824
10825 if (GetInventory().GetCargo())
10826 {
10827 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10828 rnd = Math.RandomInt(0,chances);
10829
10830 if (rnd < CHANCE_DAMAGE_CARGO)
10831 {
10832 DamageItemInCargo(dmg);
10833 }
10834 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10835 {
10837 }
10838 }
10839 else
10840 {
10841 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10842 rnd = Math.RandomInt(0,chances);
10843
10844 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10845 {
10847 }
10848 }
10849 }
10850 }
10851
10852 bool DamageItemInCargo(float damage)
10853 {
10854 CargoBase cargo = GetInventory().GetCargo();
10855 if (cargo)
10856 {
10857 int item_count = cargo.GetItemCount();
10858 if (item_count > 0)
10859 {
10860 int random_pick = Math.RandomInt(0, item_count);
10861 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
10862 if (!item.IsExplosive())
10863 {
10864 item.AddHealth("","",damage);
10865 return true;
10866 }
10867 }
10868 }
10869 return false;
10870 }
10871
10872 bool DamageItemAttachments(float damage)
10873 {
10874 GameInventory inventory = GetInventory();
10875 int attachment_count = inventory.AttachmentCount();
10876 if (attachment_count > 0)
10877 {
10878 int random_pick = Math.RandomInt(0, attachment_count);
10879 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
10880 if (!attachment.IsExplosive())
10881 {
10882 attachment.AddHealth("","",damage);
10883 return true;
10884 }
10885 }
10886 return false;
10887 }
10888
10889 override bool IsSplitable()
10890 {
10891 return m_CanThisBeSplit;
10892 }
10893 //----------------
10894 override bool CanBeSplit()
10895 {
10896 if (IsSplitable() && (GetQuantity() > 1))
10897 return GetInventory().CanRemoveEntity();
10898
10899 return false;
10900 }
10901
10902 protected bool ShouldSplitQuantity(float quantity)
10903 {
10904 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10905 if (!IsSplitable())
10906 return false;
10907
10908 // nothing to split?
10909 if (GetQuantity() <= 1)
10910 return false;
10911
10912 // check if we should re-use the item instead of creating a new copy?
10913 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10914 int delta = GetQuantity() - quantity;
10915 if (delta == 0)
10916 return false;
10917
10918 // valid to split
10919 return true;
10920 }
10921
10922 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10923 {
10924 if (g_Game.IsClient())
10925 {
10926 if (ScriptInputUserData.CanStoreInputUserData())
10927 {
10928 ScriptInputUserData ctx = new ScriptInputUserData;
10930 ctx.Write(1);
10931 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10932 ctx.Write(i1);
10933 ctx.Write(destination_entity);
10934 ctx.Write(true);
10935 ctx.Write(slot_id);
10936 ctx.Send();
10937 }
10938 }
10939 else if (!g_Game.IsMultiplayer())
10940 {
10941 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
10942 }
10943 }
10944
10945 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10946 {
10947 float split_quantity_new;
10948 ItemBase new_item;
10949 float quantity = GetQuantity();
10950 float stack_max = GetTargetQuantityMax(slot_id);
10951 InventoryLocation loc = new InventoryLocation;
10952
10953 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10954 {
10955 if (stack_max <= GetQuantity())
10956 split_quantity_new = stack_max;
10957 else
10958 split_quantity_new = GetQuantity();
10959
10960 if (ShouldSplitQuantity(split_quantity_new))
10961 {
10962 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10963 if (new_item)
10964 {
10965 new_item.SetResultOfSplit(true);
10966 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10967 AddQuantity(-split_quantity_new, false, true);
10968 new_item.SetQuantity(split_quantity_new, false, true);
10969 }
10970 }
10971 }
10972 else if (destination_entity && slot_id == -1)
10973 {
10974 if (quantity > stack_max)
10975 split_quantity_new = stack_max;
10976 else
10977 split_quantity_new = quantity;
10978
10979 if (ShouldSplitQuantity(split_quantity_new))
10980 {
10981 GameInventory destinationInventory = destination_entity.GetInventory();
10982 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10983 {
10984 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10985 new_item = ItemBase.Cast(o);
10986 }
10987
10988 if (new_item)
10989 {
10990 new_item.SetResultOfSplit(true);
10991 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10992 AddQuantity(-split_quantity_new, false, true);
10993 new_item.SetQuantity(split_quantity_new, false, true);
10994 }
10995 }
10996 }
10997 else
10998 {
10999 if (stack_max != 0)
11000 {
11001 if (stack_max < GetQuantity())
11002 {
11003 split_quantity_new = GetQuantity() - stack_max;
11004 }
11005
11006 if (split_quantity_new == 0)
11007 {
11008 if (!g_Game.IsMultiplayer())
11009 player.PhysicalPredictiveDropItem(this);
11010 else
11011 player.ServerDropEntity(this);
11012 return;
11013 }
11014
11015 if (ShouldSplitQuantity(split_quantity_new))
11016 {
11017 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
11018
11019 if (new_item)
11020 {
11021 new_item.SetResultOfSplit(true);
11022 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11023 SetQuantity(split_quantity_new, false, true);
11024 new_item.SetQuantity(stack_max, false, true);
11025 new_item.PlaceOnSurface();
11026 }
11027 }
11028 }
11029 }
11030 }
11031
11032 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
11033 {
11034 float split_quantity_new;
11035 ItemBase new_item;
11036 float quantity = GetQuantity();
11037 float stack_max = GetTargetQuantityMax(slot_id);
11038 InventoryLocation loc = new InventoryLocation;
11039
11040 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
11041 {
11042 if (stack_max <= GetQuantity())
11043 split_quantity_new = stack_max;
11044 else
11045 split_quantity_new = GetQuantity();
11046
11047 if (ShouldSplitQuantity(split_quantity_new))
11048 {
11049 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
11050 if (new_item)
11051 {
11052 new_item.SetResultOfSplit(true);
11053 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11054 AddQuantity(-split_quantity_new, false, true);
11055 new_item.SetQuantity(split_quantity_new, false, true);
11056 }
11057 }
11058 }
11059 else if (destination_entity && slot_id == -1)
11060 {
11061 if (quantity > stack_max)
11062 split_quantity_new = stack_max;
11063 else
11064 split_quantity_new = quantity;
11065
11066 if (ShouldSplitQuantity(split_quantity_new))
11067 {
11068 GameInventory destinationInventory = destination_entity.GetInventory();
11069 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
11070 {
11071 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
11072 new_item = ItemBase.Cast(o);
11073 }
11074
11075 if (new_item)
11076 {
11077 new_item.SetResultOfSplit(true);
11078 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11079 AddQuantity(-split_quantity_new, false, true);
11080 new_item.SetQuantity(split_quantity_new, false, true);
11081 }
11082 }
11083 }
11084 else
11085 {
11086 if (stack_max != 0)
11087 {
11088 if (stack_max < GetQuantity())
11089 {
11090 split_quantity_new = GetQuantity() - stack_max;
11091 }
11092
11093 if (ShouldSplitQuantity(split_quantity_new))
11094 {
11095 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
11096
11097 if (new_item)
11098 {
11099 new_item.SetResultOfSplit(true);
11100 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11101 SetQuantity(split_quantity_new, false, true);
11102 new_item.SetQuantity(stack_max, false, true);
11103 new_item.PlaceOnSurface();
11104 }
11105 }
11106 }
11107 }
11108 }
11109
11110 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
11111 {
11112 if (g_Game.IsClient())
11113 {
11114 if (ScriptInputUserData.CanStoreInputUserData())
11115 {
11116 ScriptInputUserData ctx = new ScriptInputUserData;
11118 ctx.Write(4);
11119 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11120 ctx.Write(thiz);
11121 dst.WriteToContext(ctx);
11122 ctx.Send();
11123 }
11124 }
11125 else if (!g_Game.IsMultiplayer())
11126 {
11128 }
11129 }
11130
11131 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
11132 {
11133 if (g_Game.IsClient())
11134 {
11135 if (ScriptInputUserData.CanStoreInputUserData())
11136 {
11137 ScriptInputUserData ctx = new ScriptInputUserData;
11139 ctx.Write(2);
11140 ItemBase dummy = this; // @NOTE: workaround for correct serialization
11141 ctx.Write(dummy);
11142 ctx.Write(destination_entity);
11143 ctx.Write(true);
11144 ctx.Write(idx);
11145 ctx.Write(row);
11146 ctx.Write(col);
11147 ctx.Send();
11148 }
11149 }
11150 else if (!g_Game.IsMultiplayer())
11151 {
11152 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
11153 }
11154 }
11155
11156 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
11157 {
11159 }
11160
11161 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
11162 {
11163 float quantity = GetQuantity();
11164 float split_quantity_new;
11165 ItemBase new_item;
11166 if (dst.IsValid())
11167 {
11168 int slot_id = dst.GetSlot();
11169 float stack_max = GetTargetQuantityMax(slot_id);
11170
11171 if (quantity > stack_max)
11172 split_quantity_new = stack_max;
11173 else
11174 split_quantity_new = quantity;
11175
11176 if (ShouldSplitQuantity(split_quantity_new))
11177 {
11178 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11179
11180 if (new_item)
11181 {
11182 new_item.SetResultOfSplit(true);
11183 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11184 AddQuantity(-split_quantity_new, false, true);
11185 new_item.SetQuantity(split_quantity_new, false, true);
11186 }
11187
11188 return new_item;
11189 }
11190 }
11191
11192 return null;
11193 }
11194
11195 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
11196 {
11197 float quantity = GetQuantity();
11198 float split_quantity_new;
11199 ItemBase new_item;
11200 if (destination_entity)
11201 {
11202 float stackable = GetTargetQuantityMax();
11203 if (quantity > stackable)
11204 split_quantity_new = stackable;
11205 else
11206 split_quantity_new = quantity;
11207
11208 if (ShouldSplitQuantity(split_quantity_new))
11209 {
11210 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
11211 if (new_item)
11212 {
11213 new_item.SetResultOfSplit(true);
11214 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11215 AddQuantity(-split_quantity_new, false, true);
11216 new_item.SetQuantity(split_quantity_new, false, true);
11217 }
11218 }
11219 }
11220 }
11221
11222 void SplitIntoStackMaxHandsClient(PlayerBase player)
11223 {
11224 if (g_Game.IsClient())
11225 {
11226 if (ScriptInputUserData.CanStoreInputUserData())
11227 {
11228 ScriptInputUserData ctx = new ScriptInputUserData;
11230 ctx.Write(3);
11231 ItemBase i1 = this; // @NOTE: workaround for correct serialization
11232 ctx.Write(i1);
11233 ItemBase destination_entity = this;
11234 ctx.Write(destination_entity);
11235 ctx.Write(true);
11236 ctx.Write(0);
11237 ctx.Send();
11238 }
11239 }
11240 else if (!g_Game.IsMultiplayer())
11241 {
11242 SplitIntoStackMaxHands(player);
11243 }
11244 }
11245
11246 void SplitIntoStackMaxHands(PlayerBase player)
11247 {
11248 float quantity = GetQuantity();
11249 float split_quantity_new;
11250 ref ItemBase new_item;
11251 if (player)
11252 {
11253 float stackable = GetTargetQuantityMax();
11254 if (quantity > stackable)
11255 split_quantity_new = stackable;
11256 else
11257 split_quantity_new = quantity;
11258
11259 if (ShouldSplitQuantity(split_quantity_new))
11260 {
11261 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
11262 new_item = ItemBase.Cast(in_hands);
11263 if (new_item)
11264 {
11265 new_item.SetResultOfSplit(true);
11266 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11267 AddQuantity(-split_quantity_new, false, true);
11268 new_item.SetQuantity(split_quantity_new, false, true);
11269 }
11270 }
11271 }
11272 }
11273
11274 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
11275 {
11276 float quantity = GetQuantity();
11277 float split_quantity_new = Math.Floor(quantity * 0.5);
11278
11279 if (!ShouldSplitQuantity(split_quantity_new))
11280 return;
11281
11282 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11283
11284 if (new_item)
11285 {
11286 if (new_item.GetQuantityMax() < split_quantity_new)
11287 {
11288 split_quantity_new = new_item.GetQuantityMax();
11289 }
11290
11291 new_item.SetResultOfSplit(true);
11292 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11293
11294 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11295 {
11296 AddQuantity(-1, false, true);
11297 new_item.SetQuantity(1, false, true);
11298 }
11299 else
11300 {
11301 AddQuantity(-split_quantity_new, false, true);
11302 new_item.SetQuantity(split_quantity_new, false, true);
11303 }
11304 }
11305 }
11306
11307 void SplitItem(PlayerBase player)
11308 {
11309 float quantity = GetQuantity();
11310 float split_quantity_new = Math.Floor(quantity / 2);
11311
11312 if (!ShouldSplitQuantity(split_quantity_new))
11313 return;
11314
11315 InventoryLocation invloc = new InventoryLocation;
11316 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
11317
11318 ItemBase new_item;
11319 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
11320
11321 if (new_item)
11322 {
11323 if (new_item.GetQuantityMax() < split_quantity_new)
11324 {
11325 split_quantity_new = new_item.GetQuantityMax();
11326 }
11327 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11328 {
11329 AddQuantity(-1, false, true);
11330 new_item.SetQuantity(1, false, true);
11331 }
11332 else if (split_quantity_new > 1)
11333 {
11334 AddQuantity(-split_quantity_new, false, true);
11335 new_item.SetQuantity(split_quantity_new, false, true);
11336 }
11337 }
11338 }
11339
11341 void OnQuantityChanged(float delta)
11342 {
11343 SetWeightDirty();
11344 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
11345
11346 if (parent)
11347 parent.OnAttachmentQuantityChangedEx(this, delta);
11348
11349 if (IsLiquidContainer())
11350 {
11351 if (GetQuantityNormalized() <= 0.0)
11352 {
11354 }
11355 else if (GetLiquidType() == LIQUID_NONE)
11356 {
11357 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
11359 }
11360 }
11361 }
11362
11365 {
11366 // insert code here
11367 }
11368
11370 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
11371 {
11373 }
11374
11375 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
11376 {
11377 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
11378
11379 if (g_Game.IsServer())
11380 {
11381 if (newLevel == GameConstants.STATE_RUINED)
11382 {
11384 EntityAI parent = GetHierarchyParent();
11385 if (parent && parent.IsFireplace())
11386 {
11387 CargoBase cargo = GetInventory().GetCargo();
11388 if (cargo)
11389 {
11390 for (int i = 0; i < cargo.GetItemCount(); ++i)
11391 {
11392 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
11393 }
11394 }
11395 }
11396 }
11397
11398 if (IsResultOfSplit())
11399 {
11400 // reset the splitting result flag, return to normal item behavior
11401 SetResultOfSplit(false);
11402 return;
11403 }
11404
11405 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
11406 {
11407 SetCleanness(0);//unclean the item upon damage dealt
11408 }
11409 }
11410 }
11411
11412 // just the split? TODO: verify
11413 override void OnRightClick()
11414 {
11415 super.OnRightClick();
11416
11417 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
11418 {
11419 if (g_Game.IsClient())
11420 {
11421 if (ScriptInputUserData.CanStoreInputUserData())
11422 {
11423 EntityAI root = GetHierarchyRoot();
11424 Man playerOwner = GetHierarchyRootPlayer();
11425 InventoryLocation dst = new InventoryLocation;
11426
11427 // 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
11428 if (!playerOwner && root && root == this)
11429 {
11431 }
11432 else
11433 {
11434 // 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
11435 GetInventory().GetCurrentInventoryLocation(dst);
11436 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
11437 {
11438 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
11439 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
11440 {
11442 }
11443 else
11444 {
11445 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
11446 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
11447 this shouldnt cause issues within this scope*/
11448 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
11449 {
11451 }
11452 else
11453 {
11454 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
11455 }
11456 }
11457 }
11458 }
11459
11460 ScriptInputUserData ctx = new ScriptInputUserData;
11462 ctx.Write(4);
11463 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11464 ctx.Write(thiz);
11465 dst.WriteToContext(ctx);
11466 ctx.Write(true); // dummy
11467 ctx.Send();
11468 }
11469 }
11470 else if (!g_Game.IsMultiplayer())
11471 {
11472 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
11473 }
11474 }
11475 }
11476
11477 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11478 {
11479 if (root)
11480 {
11481 vector m4[4];
11482 root.GetTransform(m4);
11483 dst.SetGround(this, m4);
11484 }
11485 else
11486 {
11487 GetInventory().GetCurrentInventoryLocation(dst);
11488 }
11489 }
11490
11491 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11492 {
11493 //TODO: delete check zero quantity check after fix double posts hands fsm events
11494 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11495 return false;
11496
11497 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11498 return false;
11499
11500 //can_this_be_combined = ConfigGetBool("canBeSplit");
11502 return false;
11503
11504
11505 Magazine mag = Magazine.Cast(this);
11506 if (mag)
11507 {
11508 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11509 return false;
11510
11511 if (stack_max_limit)
11512 {
11513 Magazine other_mag = Magazine.Cast(other_item);
11514 if (other_item)
11515 {
11516 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11517 return false;
11518 }
11519
11520 }
11521 }
11522 else
11523 {
11524 //TODO: delete check zero quantity check after fix double posts hands fsm events
11525 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11526 return false;
11527
11528 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11529 return false;
11530 }
11531
11532 PlayerBase player = null;
11533 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11534 {
11535 if (player.GetInventory().HasAttachment(this))
11536 return false;
11537
11538 if (player.IsItemsToDelete())
11539 return false;
11540 }
11541
11542 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11543 return false;
11544
11545 int slotID;
11546 string slotName;
11547 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11548 return false;
11549
11550 return true;
11551 }
11552
11553 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11554 {
11555 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11556 }
11557
11558 bool IsResultOfSplit()
11559 {
11560 return m_IsResultOfSplit;
11561 }
11562
11563 void SetResultOfSplit(bool value)
11564 {
11565 m_IsResultOfSplit = value;
11566 }
11567
11568 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11569 {
11570 return ComputeQuantityUsedEx(other_item, use_stack_max);
11571 }
11572
11573 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11574 {
11575 float other_item_quantity = other_item.GetQuantity();
11576 float this_free_space;
11577
11578 float stack_max = GetQuantityMax();
11579
11580 this_free_space = stack_max - GetQuantity();
11581
11582 if (other_item_quantity > this_free_space)
11583 {
11584 return this_free_space;
11585 }
11586 else
11587 {
11588 return other_item_quantity;
11589 }
11590 }
11591
11592 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11593 {
11594 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11595 }
11596
11597 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11598 {
11599 if (!CanBeCombined(other_item, false))
11600 return;
11601
11602 if (!IsMagazine() && other_item)
11603 {
11604 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11605 if (quantity_used != 0)
11606 {
11607 float hp1 = GetHealth01("","");
11608 float hp2 = other_item.GetHealth01("","");
11609 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11610 hpResult = hpResult / (GetQuantity() + quantity_used);
11611
11612 hpResult *= GetMaxHealth();
11613 Math.Round(hpResult);
11614 SetHealth("", "Health", hpResult);
11615
11616 AddQuantity(quantity_used);
11617 other_item.AddQuantity(-quantity_used);
11618 }
11619 }
11620 OnCombine(other_item);
11621 }
11622
11623 void OnCombine(ItemBase other_item)
11624 {
11625 #ifdef SERVER
11626 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11627 GetHierarchyParent().IncreaseLifetimeUp();
11628 #endif
11629 };
11630
11631 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11632 {
11633 PlayerBase p = PlayerBase.Cast(player);
11634
11635 array<int> recipesIds = p.m_Recipes;
11636 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11637 if (moduleRecipesManager)
11638 {
11639 EntityAI itemInHands = player.GetEntityInHands();
11640 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11641 }
11642
11643 for (int i = 0;i < recipesIds.Count(); i++)
11644 {
11645 int key = recipesIds.Get(i);
11646 string recipeName = moduleRecipesManager.GetRecipeName(key);
11647 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11648 }
11649 }
11650
11651 // -------------------------------------------------------------------------
11652 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11653 {
11654 super.GetDebugActions(outputList);
11655
11656 //quantity
11657 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11658 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11659 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11660 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11661 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11662
11663 //health
11664 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11665 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11666 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11667 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11668 //temperature
11669 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11670 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11671 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11672 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11673
11674 //wet
11675 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11676 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11677 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11678
11679 //liquidtype
11680 if (IsLiquidContainer())
11681 {
11682 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11683 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11684 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11685 }
11686
11687 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11688 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11689
11690 // watch
11691 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11692 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11693 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11694
11695 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11696
11697 InventoryLocation loc = new InventoryLocation();
11698 GetInventory().GetCurrentInventoryLocation(loc);
11699 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11700 {
11701 if (Gizmo_IsSupported())
11702 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11703 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11704 }
11705
11706 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11707 }
11708
11709 // -------------------------------------------------------------------------
11710 // -------------------------------------------------------------------------
11711 // -------------------------------------------------------------------------
11712 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11713 {
11714 super.OnAction(action_id, player, ctx);
11715
11716 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
11717 {
11718 switch (action_id)
11719 {
11720 case EActions.GIZMO_OBJECT:
11721 if (GetGizmoApi())
11722 GetGizmoApi().SelectObject(this);
11723 return true;
11724 case EActions.GIZMO_PHYSICS:
11725 if (GetGizmoApi())
11726 GetGizmoApi().SelectPhysics(GetPhysics());
11727 return true;
11728 }
11729 }
11730
11731 if (g_Game.IsServer())
11732 {
11733 switch (action_id)
11734 {
11735 case EActions.DELETE:
11736 Delete();
11737 return true;
11738 }
11739 }
11740
11741 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11742 {
11743 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11744 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11745 PlayerBase p = PlayerBase.Cast(player);
11746 if (EActions.RECIPES_RANGE_START < 1000)
11747 {
11748 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11749 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11750 }
11751 }
11752 #ifndef SERVER
11753 else if (action_id == EActions.WATCH_PLAYER)
11754 {
11755 PluginDeveloper.SetDeveloperItemClientEx(player);
11756 }
11757 #endif
11758 if (g_Game.IsServer())
11759 {
11760 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11761 {
11762 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11763 OnDebugButtonPressServer(id + 1);
11764 }
11765
11766 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11767 {
11768 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11769 InsertAgent(agent_id,100);
11770 }
11771
11772 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11773 {
11774 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11775 RemoveAgent(agent_id2);
11776 }
11777
11778 else if (action_id == EActions.ADD_QUANTITY)
11779 {
11780 if (IsMagazine())
11781 {
11782 Magazine mag = Magazine.Cast(this);
11783 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11784 }
11785 else
11786 {
11787 AddQuantity(GetQuantityMax() * 0.2);
11788 }
11789
11790 if (m_EM)
11791 {
11792 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11793 }
11794 //PrintVariables();
11795 }
11796
11797 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11798 {
11799 if (IsMagazine())
11800 {
11801 Magazine mag2 = Magazine.Cast(this);
11802 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11803 }
11804 else
11805 {
11806 AddQuantity(- GetQuantityMax() * 0.2);
11807 }
11808 if (m_EM)
11809 {
11810 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11811 }
11812 //PrintVariables();
11813 }
11814
11815 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11816 {
11817 SetQuantity(0);
11818
11819 if (m_EM)
11820 {
11821 m_EM.SetEnergy(0);
11822 }
11823 }
11824
11825 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11826 {
11828
11829 if (m_EM)
11830 {
11831 m_EM.SetEnergy(m_EM.GetEnergyMax());
11832 }
11833 }
11834
11835 else if (action_id == EActions.ADD_HEALTH)
11836 {
11837 AddHealth("","",GetMaxHealth("","Health")/5);
11838 }
11839 else if (action_id == EActions.REMOVE_HEALTH)
11840 {
11841 AddHealth("","",-GetMaxHealth("","Health")/5);
11842 }
11843 else if (action_id == EActions.DESTROY_HEALTH)
11844 {
11845 SetHealth01("","",0);
11846 }
11847 else if (action_id == EActions.WATCH_ITEM)
11848 {
11850 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11851 #ifdef DEVELOPER
11852 SetDebugDeveloper_item(this);
11853 #endif
11854 }
11855
11856 else if (action_id == EActions.ADD_TEMPERATURE)
11857 {
11858 AddTemperature(20);
11859 //PrintVariables();
11860 }
11861
11862 else if (action_id == EActions.REMOVE_TEMPERATURE)
11863 {
11864 AddTemperature(-20);
11865 //PrintVariables();
11866 }
11867
11868 else if (action_id == EActions.FLIP_FROZEN)
11869 {
11870 SetFrozen(!GetIsFrozen());
11871 //PrintVariables();
11872 }
11873
11874 else if (action_id == EActions.ADD_WETNESS)
11875 {
11876 AddWet(GetWetMax()/5);
11877 //PrintVariables();
11878 }
11879
11880 else if (action_id == EActions.REMOVE_WETNESS)
11881 {
11882 AddWet(-GetWetMax()/5);
11883 //PrintVariables();
11884 }
11885
11886 else if (action_id == EActions.LIQUIDTYPE_UP)
11887 {
11888 int curr_type = GetLiquidType();
11889 SetLiquidType(curr_type * 2);
11890 //AddWet(1);
11891 //PrintVariables();
11892 }
11893
11894 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11895 {
11896 int curr_type2 = GetLiquidType();
11897 SetLiquidType(curr_type2 / 2);
11898 }
11899
11900 else if (action_id == EActions.MAKE_SPECIAL)
11901 {
11902 auto debugParams = DebugSpawnParams.WithPlayer(player);
11903 OnDebugSpawnEx(debugParams);
11904 }
11905
11906 }
11907
11908
11909 return false;
11910 }
11911
11912 // -------------------------------------------------------------------------
11913
11914
11917 void OnActivatedByTripWire();
11918
11920 void OnActivatedByItem(notnull ItemBase item);
11921
11922 //----------------------------------------------------------------
11923 //returns true if item is able to explode when put in fire
11924 bool CanExplodeInFire()
11925 {
11926 return false;
11927 }
11928
11929 //----------------------------------------------------------------
11930 bool CanEat()
11931 {
11932 return true;
11933 }
11934
11935 //----------------------------------------------------------------
11936 override bool IsIgnoredByConstruction()
11937 {
11938 return true;
11939 }
11940
11941 //----------------------------------------------------------------
11942 //has FoodStages in config?
11943 bool HasFoodStage()
11944 {
11945 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11946 return g_Game.ConfigIsExisting(config_path);
11947 }
11948
11950 FoodStage GetFoodStage()
11951 {
11952 return null;
11953 }
11954
11955 bool CanBeCooked()
11956 {
11957 return false;
11958 }
11959
11960 bool CanBeCookedOnStick()
11961 {
11962 return false;
11963 }
11964
11966 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11968
11969 //----------------------------------------------------------------
11970 bool CanRepair(ItemBase item_repair_kit)
11971 {
11972 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11973 return module_repairing.CanRepair(this, item_repair_kit);
11974 }
11975
11976 //----------------------------------------------------------------
11977 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11978 {
11979 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11980 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11981 }
11982
11983 //----------------------------------------------------------------
11984 int GetItemSize()
11985 {
11986 /*
11987 vector v_size = this.ConfigGetVector("itemSize");
11988 int v_size_x = v_size[0];
11989 int v_size_y = v_size[1];
11990 int size = v_size_x * v_size_y;
11991 return size;
11992 */
11993
11994 return 1;
11995 }
11996
11997 //----------------------------------------------------------------
11998 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11999 bool CanBeMovedOverride()
12000 {
12001 return m_CanBeMovedOverride;
12002 }
12003
12004 //----------------------------------------------------------------
12005 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
12006 void SetCanBeMovedOverride(bool setting)
12007 {
12008 m_CanBeMovedOverride = setting;
12009 }
12010
12011 //----------------------------------------------------------------
12019 void MessageToOwnerStatus(string text)
12020 {
12021 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12022
12023 if (player)
12024 {
12025 player.MessageStatus(text);
12026 }
12027 }
12028
12029 //----------------------------------------------------------------
12037 void MessageToOwnerAction(string text)
12038 {
12039 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12040
12041 if (player)
12042 {
12043 player.MessageAction(text);
12044 }
12045 }
12046
12047 //----------------------------------------------------------------
12055 void MessageToOwnerFriendly(string text)
12056 {
12057 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12058
12059 if (player)
12060 {
12061 player.MessageFriendly(text);
12062 }
12063 }
12064
12065 //----------------------------------------------------------------
12073 void MessageToOwnerImportant(string text)
12074 {
12075 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12076
12077 if (player)
12078 {
12079 player.MessageImportant(text);
12080 }
12081 }
12082
12083 override bool IsItemBase()
12084 {
12085 return true;
12086 }
12087
12088 // Checks if item is of questioned kind
12089 override bool KindOf(string tag)
12090 {
12091 bool found = false;
12092 string item_name = this.GetType();
12093 ref TStringArray item_tag_array = new TStringArray;
12094 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
12095
12096 int array_size = item_tag_array.Count();
12097 for (int i = 0; i < array_size; i++)
12098 {
12099 if (item_tag_array.Get(i) == tag)
12100 {
12101 found = true;
12102 break;
12103 }
12104 }
12105 return found;
12106 }
12107
12108
12109 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
12110 {
12111 //Debug.Log("OnRPC called");
12112 super.OnRPC(sender, rpc_type,ctx);
12113
12114 //Play soundset for attachment locking (ActionLockAttachment.c)
12115 switch (rpc_type)
12116 {
12117 #ifndef SERVER
12118 case ERPCs.RPC_SOUND_LOCK_ATTACH:
12119 Param2<bool, string> p = new Param2<bool, string>(false, "");
12120
12121 if (!ctx.Read(p))
12122 return;
12123
12124 bool play = p.param1;
12125 string soundSet = p.param2;
12126
12127 if (play)
12128 {
12129 if (m_LockingSound)
12130 {
12132 {
12133 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
12134 }
12135 }
12136 else
12137 {
12138 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
12139 }
12140 }
12141 else
12142 {
12143 SEffectManager.DestroyEffect(m_LockingSound);
12144 }
12145
12146 break;
12147 #endif
12148
12149 }
12150
12151 if (GetWrittenNoteData())
12152 {
12153 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
12154 }
12155 }
12156
12157 //-----------------------------
12158 // VARIABLE MANIPULATION SYSTEM
12159 //-----------------------------
12160 int NameToID(string name)
12161 {
12162 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
12163 return plugin.GetID(name);
12164 }
12165
12166 string IDToName(int id)
12167 {
12168 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
12169 return plugin.GetName(id);
12170 }
12171
12173 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
12174 {
12175 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
12176 //read the flags
12177 int varFlags;
12178 if (!ctx.Read(varFlags))
12179 return;
12180
12181 if (varFlags & ItemVariableFlags.FLOAT)
12182 {
12183 ReadVarsFromCTX(ctx);
12184 }
12185 }
12186
12187 override void SerializeNumericalVars(array<float> floats_out)
12188 {
12189 //some variables handled on EntityAI level already!
12190 super.SerializeNumericalVars(floats_out);
12191
12192 // the order of serialization must be the same as the order of de-serialization
12193 //--------------------------------------------
12194 if (IsVariableSet(VARIABLE_QUANTITY))
12195 {
12196 floats_out.Insert(m_VarQuantity);
12197 }
12198 //--------------------------------------------
12199 if (IsVariableSet(VARIABLE_WET))
12200 {
12201 floats_out.Insert(m_VarWet);
12202 }
12203 //--------------------------------------------
12204 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12205 {
12206 floats_out.Insert(m_VarLiquidType);
12207 }
12208 //--------------------------------------------
12209 if (IsVariableSet(VARIABLE_COLOR))
12210 {
12211 floats_out.Insert(m_ColorComponentR);
12212 floats_out.Insert(m_ColorComponentG);
12213 floats_out.Insert(m_ColorComponentB);
12214 floats_out.Insert(m_ColorComponentA);
12215 }
12216 //--------------------------------------------
12217 if (IsVariableSet(VARIABLE_CLEANNESS))
12218 {
12219 floats_out.Insert(m_Cleanness);
12220 }
12221 }
12222
12223 override void DeSerializeNumericalVars(array<float> floats)
12224 {
12225 //some variables handled on EntityAI level already!
12226 super.DeSerializeNumericalVars(floats);
12227
12228 // the order of serialization must be the same as the order of de-serialization
12229 int index = 0;
12230 int mask = Math.Round(floats.Get(index));
12231
12232 index++;
12233 //--------------------------------------------
12234 if (mask & VARIABLE_QUANTITY)
12235 {
12236 if (m_IsStoreLoad)
12237 {
12238 SetStoreLoadedQuantity(floats.Get(index));
12239 }
12240 else
12241 {
12242 float quantity = floats.Get(index);
12243 SetQuantity(quantity, true, false, false, false);
12244 }
12245 index++;
12246 }
12247 //--------------------------------------------
12248 if (mask & VARIABLE_WET)
12249 {
12250 float wet = floats.Get(index);
12251 SetWet(wet);
12252 index++;
12253 }
12254 //--------------------------------------------
12255 if (mask & VARIABLE_LIQUIDTYPE)
12256 {
12257 int liquidtype = Math.Round(floats.Get(index));
12258 SetLiquidType(liquidtype);
12259 index++;
12260 }
12261 //--------------------------------------------
12262 if (mask & VARIABLE_COLOR)
12263 {
12264 m_ColorComponentR = Math.Round(floats.Get(index));
12265 index++;
12266 m_ColorComponentG = Math.Round(floats.Get(index));
12267 index++;
12268 m_ColorComponentB = Math.Round(floats.Get(index));
12269 index++;
12270 m_ColorComponentA = Math.Round(floats.Get(index));
12271 index++;
12272 }
12273 //--------------------------------------------
12274 if (mask & VARIABLE_CLEANNESS)
12275 {
12276 int cleanness = Math.Round(floats.Get(index));
12277 SetCleanness(cleanness);
12278 index++;
12279 }
12280 }
12281
12282 override void WriteVarsToCTX(ParamsWriteContext ctx)
12283 {
12284 super.WriteVarsToCTX(ctx);
12285
12286 //--------------------------------------------
12287 if (IsVariableSet(VARIABLE_QUANTITY))
12288 {
12289 ctx.Write(GetQuantity());
12290 }
12291 //--------------------------------------------
12292 if (IsVariableSet(VARIABLE_WET))
12293 {
12294 ctx.Write(GetWet());
12295 }
12296 //--------------------------------------------
12297 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12298 {
12299 ctx.Write(GetLiquidType());
12300 }
12301 //--------------------------------------------
12302 if (IsVariableSet(VARIABLE_COLOR))
12303 {
12304 int r,g,b,a;
12305 GetColor(r,g,b,a);
12306 ctx.Write(r);
12307 ctx.Write(g);
12308 ctx.Write(b);
12309 ctx.Write(a);
12310 }
12311 //--------------------------------------------
12312 if (IsVariableSet(VARIABLE_CLEANNESS))
12313 {
12314 ctx.Write(GetCleanness());
12315 }
12316 }
12317
12318 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
12319 {
12320 if (!super.ReadVarsFromCTX(ctx,version))
12321 return false;
12322
12323 int intValue;
12324 float value;
12325
12326 if (version < 140)
12327 {
12328 if (!ctx.Read(intValue))
12329 return false;
12330
12331 m_VariablesMask = intValue;
12332 }
12333
12334 if (m_VariablesMask & VARIABLE_QUANTITY)
12335 {
12336 if (!ctx.Read(value))
12337 return false;
12338
12339 if (IsStoreLoad())
12340 {
12342 }
12343 else
12344 {
12345 SetQuantity(value, true, false, false, false);
12346 }
12347 }
12348 //--------------------------------------------
12349 if (version < 140)
12350 {
12351 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12352 {
12353 if (!ctx.Read(value))
12354 return false;
12355 SetTemperatureDirect(value);
12356 }
12357 }
12358 //--------------------------------------------
12359 if (m_VariablesMask & VARIABLE_WET)
12360 {
12361 if (!ctx.Read(value))
12362 return false;
12363 SetWet(value);
12364 }
12365 //--------------------------------------------
12366 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
12367 {
12368 if (!ctx.Read(intValue))
12369 return false;
12370 SetLiquidType(intValue);
12371 }
12372 //--------------------------------------------
12373 if (m_VariablesMask & VARIABLE_COLOR)
12374 {
12375 int r,g,b,a;
12376 if (!ctx.Read(r))
12377 return false;
12378 if (!ctx.Read(g))
12379 return false;
12380 if (!ctx.Read(b))
12381 return false;
12382 if (!ctx.Read(a))
12383 return false;
12384
12385 SetColor(r,g,b,a);
12386 }
12387 //--------------------------------------------
12388 if (m_VariablesMask & VARIABLE_CLEANNESS)
12389 {
12390 if (!ctx.Read(intValue))
12391 return false;
12392 SetCleanness(intValue);
12393 }
12394 //--------------------------------------------
12395 if (version >= 138 && version < 140)
12396 {
12397 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12398 {
12399 if (!ctx.Read(intValue))
12400 return false;
12401 SetFrozen(intValue);
12402 }
12403 }
12404
12405 return true;
12406 }
12407
12408 //----------------------------------------------------------------
12409 override bool OnStoreLoad(ParamsReadContext ctx, int version)
12410 {
12411 m_IsStoreLoad = true;
12413 {
12414 m_FixDamageSystemInit = true;
12415 }
12416
12417 if (!super.OnStoreLoad(ctx, version))
12418 {
12419 m_IsStoreLoad = false;
12420 return false;
12421 }
12422
12423 if (version >= 114)
12424 {
12425 bool hasQuickBarIndexSaved;
12426
12427 if (!ctx.Read(hasQuickBarIndexSaved))
12428 {
12429 m_IsStoreLoad = false;
12430 return false;
12431 }
12432
12433 if (hasQuickBarIndexSaved)
12434 {
12435 int itmQBIndex;
12436
12437 //Load quickbar item bind
12438 if (!ctx.Read(itmQBIndex))
12439 {
12440 m_IsStoreLoad = false;
12441 return false;
12442 }
12443
12444 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
12445 if (itmQBIndex != -1 && parentPlayer)
12446 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
12447 }
12448 }
12449 else
12450 {
12451 // Backup of how it used to be
12452 PlayerBase player;
12453 int itemQBIndex;
12454 if (version == int.MAX)
12455 {
12456 if (!ctx.Read(itemQBIndex))
12457 {
12458 m_IsStoreLoad = false;
12459 return false;
12460 }
12461 }
12462 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12463 {
12464 //Load quickbar item bind
12465 if (!ctx.Read(itemQBIndex))
12466 {
12467 m_IsStoreLoad = false;
12468 return false;
12469 }
12470 if (itemQBIndex != -1 && player)
12471 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12472 }
12473 }
12474
12475 if (version < 140)
12476 {
12477 // variable management system
12478 if (!LoadVariables(ctx, version))
12479 {
12480 m_IsStoreLoad = false;
12481 return false;
12482 }
12483 }
12484
12485 //agent trasmission system
12486 if (!LoadAgents(ctx, version))
12487 {
12488 m_IsStoreLoad = false;
12489 return false;
12490 }
12491 if (version >= 132)
12492 {
12493 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12494 if (raib)
12495 {
12496 if (!raib.OnStoreLoad(ctx,version))
12497 {
12498 m_IsStoreLoad = false;
12499 return false;
12500 }
12501 }
12502 }
12503
12504 m_IsStoreLoad = false;
12505 return true;
12506 }
12507
12508 //----------------------------------------------------------------
12509
12510 override void OnStoreSave(ParamsWriteContext ctx)
12511 {
12512 super.OnStoreSave(ctx);
12513
12514 PlayerBase player;
12515 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12516 {
12517 ctx.Write(true); // Keep track of if we should actually read this in or not
12518 //Save quickbar item bind
12519 int itemQBIndex = -1;
12520 itemQBIndex = player.FindQuickBarEntityIndex(this);
12521 ctx.Write(itemQBIndex);
12522 }
12523 else
12524 {
12525 ctx.Write(false); // Keep track of if we should actually read this in or not
12526 }
12527
12528 SaveAgents(ctx);//agent trasmission system
12529
12530 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12531 if (raib)
12532 {
12533 raib.OnStoreSave(ctx);
12534 }
12535 }
12536 //----------------------------------------------------------------
12537
12538 override void AfterStoreLoad()
12539 {
12540 super.AfterStoreLoad();
12541
12543 {
12545 }
12546
12547 if (GetStoreLoadedQuantity() != float.LOWEST)
12548 {
12550 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
12551 }
12552 }
12553
12554 override void EEOnAfterLoad()
12555 {
12556 super.EEOnAfterLoad();
12557
12559 {
12560 m_FixDamageSystemInit = false;
12561 }
12562
12565 }
12566
12567 bool CanBeDisinfected()
12568 {
12569 return false;
12570 }
12571
12572
12573 //----------------------------------------------------------------
12574 override void OnVariablesSynchronized()
12575 {
12576 if (m_Initialized)
12577 {
12578 #ifdef PLATFORM_CONSOLE
12579 //bruteforce it is
12580 if (IsSplitable())
12581 {
12582 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
12583 if (menu)
12584 {
12585 menu.Refresh();
12586 }
12587 }
12588 #endif
12589 }
12590
12592 {
12593 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12594 m_WantPlayImpactSound = false;
12595 }
12596
12598 {
12599 SetWeightDirty();
12601 }
12602 if (m_VarWet != m_VarWetPrev)
12603 {
12606 }
12607
12608 if (m_SoundSyncPlay != 0)
12609 {
12612
12613 m_SoundSyncPlay = 0;
12614 m_SoundSyncSlotID = -1;
12615 }
12616 if (m_SoundSyncStop != 0)
12617 {
12619 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12620 m_SoundSyncStop = 0;
12621 }
12622
12623 super.OnVariablesSynchronized();
12624 }
12625
12626 //------------------------- Quantity
12627 //----------------------------------------------------------------
12629 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12630 {
12631 if (!IsServerCheck(allow_client))
12632 return false;
12633
12634 if (!HasQuantity())
12635 return false;
12636
12637 float min = GetQuantityMin();
12638 float max = GetQuantityMax();
12639
12640 if (value <= (min + 0.001))
12641 value = min;
12642
12643 if (value == min)
12644 {
12645 if (destroy_config)
12646 {
12647 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12648 if (dstr)
12649 {
12650 m_VarQuantity = Math.Clamp(value, min, max);
12651 this.Delete();
12652 return true;
12653 }
12654 }
12655 else if (destroy_forced)
12656 {
12657 m_VarQuantity = Math.Clamp(value, min, max);
12658 this.Delete();
12659 return true;
12660 }
12661 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12662 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12663 }
12664
12665 float delta = m_VarQuantity;
12666 m_VarQuantity = Math.Clamp(value, min, max);
12667
12668 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12669 {
12670 EntityAI parent = GetHierarchyRoot();
12671 InventoryLocation iLoc = new InventoryLocation();
12672 GetInventory().GetCurrentInventoryLocation(iLoc);
12673 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
12674 {
12675 int iLocSlot = iLoc.GetSlot();
12676 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
12677 {
12678 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
12679 }
12680 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
12681 {
12682 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
12683 }
12684 }
12685 }
12686
12687 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12688 {
12689 delta = m_VarQuantity - delta;
12690
12691 if (delta)
12692 OnQuantityChanged(delta);
12693 }
12694
12695 SetVariableMask(VARIABLE_QUANTITY);
12696
12697 return false;
12698 }
12699
12700 //----------------------------------------------------------------
12702 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12703 {
12704 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12705 }
12706 //----------------------------------------------------------------
12707 void SetQuantityMax()
12708 {
12709 float max = GetQuantityMax();
12710 SetQuantity(max);
12711 }
12712
12713 override void SetQuantityToMinimum()
12714 {
12715 float min = GetQuantityMin();
12716 SetQuantity(min);
12717 }
12718 //----------------------------------------------------------------
12720 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12721 {
12722 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12723 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12724 SetQuantity(result, destroy_config, destroy_forced);
12725 }
12726
12727 //----------------------------------------------------------------
12729 override float GetQuantityNormalized()
12730 {
12731 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12732 }
12733
12735 {
12736 return GetQuantityNormalized();
12737 }
12738
12739 /*void SetAmmoNormalized(float value)
12740 {
12741 float value_clamped = Math.Clamp(value, 0, 1);
12742 Magazine this_mag = Magazine.Cast(this);
12743 int max_rounds = this_mag.GetAmmoMax();
12744 int result = value * max_rounds;//can the rounded if higher precision is required
12745 this_mag.SetAmmoCount(result);
12746 }*/
12747 //----------------------------------------------------------------
12748 override int GetQuantityMax()
12749 {
12750 int slot = -1;
12751 GameInventory inventory = GetInventory();
12752 if (inventory)
12753 {
12754 InventoryLocation il = new InventoryLocation;
12755 inventory.GetCurrentInventoryLocation(il);
12756 slot = il.GetSlot();
12757 }
12758
12759 return GetTargetQuantityMax(slot);
12760 }
12761
12762 override int GetTargetQuantityMax(int attSlotID = -1)
12763 {
12764 float quantity_max = 0;
12765
12766 if (IsSplitable()) //only stackable/splitable items can check for stack size
12767 {
12768 if (attSlotID != -1)
12769 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12770
12771 if (quantity_max <= 0)
12772 quantity_max = m_VarStackMax;
12773 }
12774
12775 if (quantity_max <= 0)
12776 quantity_max = m_VarQuantityMax;
12777
12778 return quantity_max;
12779 }
12780 //----------------------------------------------------------------
12781 override int GetQuantityMin()
12782 {
12783 return m_VarQuantityMin;
12784 }
12785 //----------------------------------------------------------------
12786 int GetQuantityInit()
12787 {
12788 return m_VarQuantityInit;
12789 }
12790
12791 //----------------------------------------------------------------
12792 override bool HasQuantity()
12793 {
12794 return !(GetQuantityMax() - GetQuantityMin() == 0);
12795 }
12796
12797 override float GetQuantity()
12798 {
12799 return m_VarQuantity;
12800 }
12801
12802 bool IsFullQuantity()
12803 {
12804 return GetQuantity() >= GetQuantityMax();
12805 }
12806
12807 //Calculates weight of single item without attachments and cargo
12808 override float GetSingleInventoryItemWeightEx()
12809 {
12810 //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
12811 float weightEx = GetWeightEx();//overall weight of the item
12812 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12813 return weightEx - special;
12814 }
12815
12816 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12818 {
12820 }
12821
12822 override protected float GetWeightSpecialized(bool forceRecalc = false)
12823 {
12824 if (IsSplitable()) //quantity determines size of the stack
12825 {
12826 #ifdef DEVELOPER
12827 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12828 {
12829 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12830 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12831 }
12832 #endif
12833
12834 return GetQuantity() * GetConfigWeightModified();
12835 }
12836 else if (HasEnergyManager())// items with energy manager
12837 {
12838 #ifdef DEVELOPER
12839 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12840 {
12841 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12842 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12843 }
12844 #endif
12845 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12846 }
12847 else//everything else
12848 {
12849 #ifdef DEVELOPER
12850 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12851 {
12852 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12853 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12854 }
12855 #endif
12856 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12857 }
12858 }
12859
12861 int GetNumberOfItems()
12862 {
12863 int item_count = 0;
12864 ItemBase item;
12865
12866 GameInventory inventory = GetInventory();
12867 CargoBase cargo = inventory.GetCargo();
12868 if (cargo != NULL)
12869 {
12870 item_count = cargo.GetItemCount();
12871 }
12872
12873 int nAttachments = inventory.AttachmentCount();
12874 for (int i = 0; i < nAttachments; ++i)
12875 {
12876 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
12877 if (item)
12878 item_count += item.GetNumberOfItems();
12879 }
12880 return item_count;
12881 }
12882
12884 float GetUnitWeight(bool include_wetness = true)
12885 {
12886 float weight = 0;
12887 float wetness = 1;
12888 if (include_wetness)
12889 wetness += GetWet();
12890 if (IsSplitable()) //quantity determines size of the stack
12891 {
12892 weight = wetness * m_ConfigWeight;
12893 }
12894 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12895 {
12896 weight = 1;
12897 }
12898 return weight;
12899 }
12900
12901 //-----------------------------------------------------------------
12902
12903 override void ClearInventory()
12904 {
12905 GameInventory inventory = GetInventory();
12906 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
12907 {
12908 array<EntityAI> items = new array<EntityAI>;
12909 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
12910 for (int i = 0; i < items.Count(); ++i)
12911 {
12912 ItemBase item = ItemBase.Cast(items.Get(i));
12913 if (item)
12914 {
12915 g_Game.ObjectDelete(item);
12916 }
12917 }
12918 }
12919 }
12920
12921 //------------------------- Energy
12922
12923 //----------------------------------------------------------------
12924 float GetEnergy()
12925 {
12926 float energy = 0;
12927 if (HasEnergyManager())
12928 {
12929 energy = GetCompEM().GetEnergy();
12930 }
12931 return energy;
12932 }
12933
12934
12935 override void OnEnergyConsumed()
12936 {
12937 super.OnEnergyConsumed();
12938
12940 }
12941
12942 override void OnEnergyAdded()
12943 {
12944 super.OnEnergyAdded();
12945
12947 }
12948
12949 // Converts energy (from Energy Manager) to quantity, if enabled.
12951 {
12952 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12953 {
12954 if (HasQuantity())
12955 {
12956 float energy_0to1 = GetCompEM().GetEnergy0To1();
12957 SetQuantityNormalized(energy_0to1);
12958 }
12959 }
12960 }
12961
12962 //----------------------------------------------------------------
12963 float GetHeatIsolationInit()
12964 {
12965 return ConfigGetFloat("heatIsolation");
12966 }
12967
12968 float GetHeatIsolation()
12969 {
12970 return m_HeatIsolation;
12971 }
12972
12973 float GetDryingIncrement(string pIncrementName)
12974 {
12975 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12976 if (g_Game.ConfigIsExisting(paramPath))
12977 return g_Game.ConfigGetFloat(paramPath);
12978
12979 return 0.0;
12980 }
12981
12982 float GetSoakingIncrement(string pIncrementName)
12983 {
12984 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12985 if (g_Game.ConfigIsExisting(paramPath))
12986 return g_Game.ConfigGetFloat(paramPath);
12987
12988 return 0.0;
12989 }
12990 //----------------------------------------------------------------
12991 override void SetWet(float value, bool allow_client = false)
12992 {
12993 if (!IsServerCheck(allow_client))
12994 return;
12995
12996 float min = GetWetMin();
12997 float max = GetWetMax();
12998
12999 float previousValue = m_VarWet;
13000
13001 m_VarWet = Math.Clamp(value, min, max);
13002
13003 if (previousValue != m_VarWet)
13004 {
13005 SetVariableMask(VARIABLE_WET);
13006 OnWetChanged(m_VarWet, previousValue);
13007 }
13008 }
13009 //----------------------------------------------------------------
13010 override void AddWet(float value)
13011 {
13012 SetWet(GetWet() + value);
13013 }
13014 //----------------------------------------------------------------
13015 override void SetWetMax()
13016 {
13018 }
13019 //----------------------------------------------------------------
13020 override float GetWet()
13021 {
13022 return m_VarWet;
13023 }
13024 //----------------------------------------------------------------
13025 override float GetWetMax()
13026 {
13027 return m_VarWetMax;
13028 }
13029 //----------------------------------------------------------------
13030 override float GetWetMin()
13031 {
13032 return m_VarWetMin;
13033 }
13034 //----------------------------------------------------------------
13035 override float GetWetInit()
13036 {
13037 return m_VarWetInit;
13038 }
13039 //----------------------------------------------------------------
13040 override void OnWetChanged(float newVal, float oldVal)
13041 {
13042 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
13043 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
13044 if (newLevel != oldLevel)
13045 {
13046 OnWetLevelChanged(newLevel,oldLevel);
13047 }
13048 }
13049
13050 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
13051 {
13052 SetWeightDirty();
13053 }
13054
13055 override EWetnessLevel GetWetLevel()
13056 {
13057 return GetWetLevelInternal(m_VarWet);
13058 }
13059
13060 //----------------------------------------------------------------
13061
13062 override void SetStoreLoad(bool value)
13063 {
13064 m_IsStoreLoad = value;
13065 }
13066
13067 override bool IsStoreLoad()
13068 {
13069 return m_IsStoreLoad;
13070 }
13071
13072 override void SetStoreLoadedQuantity(float value)
13073 {
13074 m_StoreLoadedQuantity = value;
13075 }
13076
13077 override float GetStoreLoadedQuantity()
13078 {
13079 return m_StoreLoadedQuantity;
13080 }
13081
13082 //----------------------------------------------------------------
13083
13084 float GetItemModelLength()
13085 {
13086 if (ConfigIsExisting("itemModelLength"))
13087 {
13088 return ConfigGetFloat("itemModelLength");
13089 }
13090 return 0;
13091 }
13092
13093 float GetItemAttachOffset()
13094 {
13095 if (ConfigIsExisting("itemAttachOffset"))
13096 {
13097 return ConfigGetFloat("itemAttachOffset");
13098 }
13099 return 0;
13100 }
13101
13102 override void SetCleanness(int value, bool allow_client = false)
13103 {
13104 if (!IsServerCheck(allow_client))
13105 return;
13106
13107 int previousValue = m_Cleanness;
13108
13109 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
13110
13111 if (previousValue != m_Cleanness)
13112 SetVariableMask(VARIABLE_CLEANNESS);
13113 }
13114
13115 override int GetCleanness()
13116 {
13117 return m_Cleanness;
13118 }
13119
13121 {
13122 return true;
13123 }
13124
13125 //----------------------------------------------------------------
13126 // ATTACHMENT LOCKING
13127 // Getters relevant to generic ActionLockAttachment
13128 int GetLockType()
13129 {
13130 return m_LockType;
13131 }
13132
13133 string GetLockSoundSet()
13134 {
13135 return m_LockSoundSet;
13136 }
13137
13138 //----------------------------------------------------------------
13139 //------------------------- Color
13140 // sets items color variable given color components
13141 override void SetColor(int r, int g, int b, int a)
13142 {
13147 SetVariableMask(VARIABLE_COLOR);
13148 }
13150 override void GetColor(out int r,out int g,out int b,out int a)
13151 {
13156 }
13157
13158 bool IsColorSet()
13159 {
13160 return IsVariableSet(VARIABLE_COLOR);
13161 }
13162
13164 string GetColorString()
13165 {
13166 int r,g,b,a;
13167 GetColor(r,g,b,a);
13168 r = r/255;
13169 g = g/255;
13170 b = b/255;
13171 a = a/255;
13172 return MiscGameplayFunctions.GetColorString(r, g, b, a);
13173 }
13174 //----------------------------------------------------------------
13175 //------------------------- LiquidType
13176
13177 override void SetLiquidType(int value, bool allow_client = false)
13178 {
13179 if (!IsServerCheck(allow_client))
13180 return;
13181
13182 int old = m_VarLiquidType;
13183 m_VarLiquidType = value;
13184 OnLiquidTypeChanged(old,value);
13185 SetVariableMask(VARIABLE_LIQUIDTYPE);
13186 }
13187
13188 int GetLiquidTypeInit()
13189 {
13190 return ConfigGetInt("varLiquidTypeInit");
13191 }
13192
13193 override int GetLiquidType()
13194 {
13195 return m_VarLiquidType;
13196 }
13197
13198 protected void OnLiquidTypeChanged(int oldType, int newType)
13199 {
13200 if (newType == LIQUID_NONE && GetIsFrozen())
13201 SetFrozen(false);
13202 }
13203
13205 void UpdateQuickbarShortcutVisibility(PlayerBase player)
13206 {
13207 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13208 }
13209
13210 // -------------------------------------------------------------------------
13212 void OnInventoryEnter(Man player)
13213 {
13214 PlayerBase nplayer;
13215 if (PlayerBase.CastTo(nplayer, player))
13216 {
13217 m_CanPlayImpactSound = true;
13218 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13219 }
13220 }
13221
13222 // -------------------------------------------------------------------------
13224 void OnInventoryExit(Man player)
13225 {
13226 PlayerBase nplayer;
13227 if (PlayerBase.CastTo(nplayer,player))
13228 {
13229 nplayer.SetEnableQuickBarEntityShortcut(this, false);
13230 }
13231
13232 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
13233
13234 if (HasEnergyManager())
13235 {
13236 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
13237 }
13238 }
13239
13240 // ADVANCED PLACEMENT EVENTS
13241 override void OnPlacementStarted(Man player)
13242 {
13243 super.OnPlacementStarted(player);
13244
13245 SetTakeable(false);
13246 }
13247
13248 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
13249 {
13250 if (m_AdminLog)
13251 {
13252 m_AdminLog.OnPlacementComplete(player, this);
13253 }
13254
13255 super.OnPlacementComplete(player, position, orientation);
13256 }
13257
13258 //-----------------------------
13259 // AGENT SYSTEM
13260 //-----------------------------
13261 //--------------------------------------------------------------------------
13262 bool ContainsAgent(int agent_id)
13263 {
13264 if (agent_id & m_AttachedAgents)
13265 {
13266 return true;
13267 }
13268 else
13269 {
13270 return false;
13271 }
13272 }
13273
13274 //--------------------------------------------------------------------------
13275 override void RemoveAgent(int agent_id)
13276 {
13277 if (ContainsAgent(agent_id))
13278 {
13279 m_AttachedAgents = ~agent_id & m_AttachedAgents;
13280 }
13281 }
13282
13283 //--------------------------------------------------------------------------
13284 override void RemoveAllAgents()
13285 {
13286 m_AttachedAgents = 0;
13287 }
13288 //--------------------------------------------------------------------------
13289 override void RemoveAllAgentsExcept(int agent_to_keep)
13290 {
13291 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
13292 }
13293 // -------------------------------------------------------------------------
13294 override void InsertAgent(int agent, float count = 1)
13295 {
13296 if (count < 1)
13297 return;
13298 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
13300 }
13301
13303 void TransferAgents(int agents)
13304 {
13306 }
13307
13308 // -------------------------------------------------------------------------
13309 override int GetAgents()
13310 {
13311 return m_AttachedAgents;
13312 }
13313 //----------------------------------------------------------------------
13314
13315 /*int GetContaminationType()
13316 {
13317 int contamination_type;
13318
13319 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
13320 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
13321 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
13322 const int DIRTY_MASK = eAgents.WOUND_AGENT;
13323
13324 Edible_Base edible = Edible_Base.Cast(this);
13325 int agents = GetAgents();
13326 if (edible)
13327 {
13328 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
13329 if (profile)
13330 {
13331 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
13332 }
13333 }
13334 if (agents & CONTAMINATED_MASK)
13335 {
13336 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
13337 }
13338 if (agents & POISONED_MASK)
13339 {
13340 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
13341 }
13342 if (agents & NERVE_GAS_MASK)
13343 {
13344 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
13345 }
13346 if (agents & DIRTY_MASK)
13347 {
13348 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
13349 }
13350
13351 return agents;
13352 }*/
13353
13354 // -------------------------------------------------------------------------
13355 bool LoadAgents(ParamsReadContext ctx, int version)
13356 {
13357 if (!ctx.Read(m_AttachedAgents))
13358 return false;
13359 return true;
13360 }
13361 // -------------------------------------------------------------------------
13363 {
13364
13366 }
13367 // -------------------------------------------------------------------------
13368
13370 override void CheckForRoofLimited(float timeTresholdMS = 3000)
13371 {
13372 super.CheckForRoofLimited(timeTresholdMS);
13373
13374 float time = g_Game.GetTime();
13375 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
13376 {
13377 m_PreviousRoofTestTime = time;
13378 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
13379 }
13380 }
13381
13382 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
13383 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
13384 {
13385 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
13386 {
13387 return 0;
13388 }
13389
13390 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
13391 {
13392 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
13393 if (filter)
13394 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
13395 else
13396 return 0;//otherwise return 0 when no filter attached
13397 }
13398
13399 string subclassPath, entryName;
13400
13401 switch (type)
13402 {
13403 case DEF_BIOLOGICAL:
13404 entryName = "biological";
13405 break;
13406 case DEF_CHEMICAL:
13407 entryName = "chemical";
13408 break;
13409 default:
13410 entryName = "biological";
13411 break;
13412 }
13413
13414 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
13415
13416 return g_Game.ConfigGetFloat(subclassPath + entryName);
13417 }
13418
13419
13420
13422 override void EEOnCECreate()
13423 {
13424 if (!IsMagazine())
13426
13428 }
13429
13430
13431 //-------------------------
13432 // OPEN/CLOSE USER ACTIONS
13433 //-------------------------
13435 void Open();
13436 void Close();
13437 bool IsOpen()
13438 {
13439 return true;
13440 }
13441
13442 override bool CanDisplayCargo()
13443 {
13444 return IsOpen();
13445 }
13446
13447
13448 // ------------------------------------------------------------
13449 // CONDITIONS
13450 // ------------------------------------------------------------
13451 override bool CanPutInCargo(EntityAI parent)
13452 {
13453 if (parent)
13454 {
13455 if (parent.IsInherited(DayZInfected))
13456 return true;
13457
13458 if (!parent.IsRuined())
13459 return true;
13460 }
13461
13462 return true;
13463 }
13464
13465 override bool CanPutAsAttachment(EntityAI parent)
13466 {
13467 if (!super.CanPutAsAttachment(parent))
13468 {
13469 return false;
13470 }
13471
13472 if (!IsRuined() && !parent.IsRuined())
13473 {
13474 return true;
13475 }
13476
13477 return false;
13478 }
13479
13480 override bool CanReceiveItemIntoCargo(EntityAI item)
13481 {
13482 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13483 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13484 // return false;
13485
13486 return super.CanReceiveItemIntoCargo(item);
13487 }
13488
13489 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13490 {
13491 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13492 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13493 // return false;
13494
13495 GameInventory attachmentInv = attachment.GetInventory();
13496 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13497 {
13498 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13499 return false;
13500 }
13501
13502 InventoryLocation loc = new InventoryLocation();
13503 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13504 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13505 return false;
13506
13507 return super.CanReceiveAttachment(attachment, slotId);
13508 }
13509
13510 override bool CanReleaseAttachment(EntityAI attachment)
13511 {
13512 if (!super.CanReleaseAttachment(attachment))
13513 return false;
13514
13515 return GetInventory().AreChildrenAccessible();
13516 }
13517
13518 /*override bool CanLoadAttachment(EntityAI attachment)
13519 {
13520 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13521 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13522 // return false;
13523
13524 GameInventory attachmentInv = attachment.GetInventory();
13525 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13526 {
13527 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13528 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13529
13530 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13531 return false;
13532 }
13533
13534 return super.CanLoadAttachment(attachment);
13535 }*/
13536
13537 // Plays muzzle flash particle effects
13538 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13539 {
13540 int id = muzzle_owner.GetMuzzleID();
13541 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13542
13543 if (WPOF_array)
13544 {
13545 for (int i = 0; i < WPOF_array.Count(); i++)
13546 {
13547 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13548
13549 if (WPOF)
13550 {
13551 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13552 }
13553 }
13554 }
13555 }
13556
13557 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13558 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13559 {
13560 int id = muzzle_owner.GetMuzzleID();
13561 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13562
13563 if (WPOBE_array)
13564 {
13565 for (int i = 0; i < WPOBE_array.Count(); i++)
13566 {
13567 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13568
13569 if (WPOBE)
13570 {
13571 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13572 }
13573 }
13574 }
13575 }
13576
13577 // Plays all weapon overheating particles
13578 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13579 {
13580 int id = muzzle_owner.GetMuzzleID();
13581 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13582
13583 if (WPOOH_array)
13584 {
13585 for (int i = 0; i < WPOOH_array.Count(); i++)
13586 {
13587 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13588
13589 if (WPOOH)
13590 {
13591 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13592 }
13593 }
13594 }
13595 }
13596
13597 // Updates all weapon overheating particles
13598 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13599 {
13600 int id = muzzle_owner.GetMuzzleID();
13601 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13602
13603 if (WPOOH_array)
13604 {
13605 for (int i = 0; i < WPOOH_array.Count(); i++)
13606 {
13607 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13608
13609 if (WPOOH)
13610 {
13611 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13612 }
13613 }
13614 }
13615 }
13616
13617 // Stops overheating particles
13618 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13619 {
13620 int id = muzzle_owner.GetMuzzleID();
13621 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13622
13623 if (WPOOH_array)
13624 {
13625 for (int i = 0; i < WPOOH_array.Count(); i++)
13626 {
13627 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13628
13629 if (WPOOH)
13630 {
13631 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13632 }
13633 }
13634 }
13635 }
13636
13637 //----------------------------------------------------------------
13638 //Item Behaviour - unified approach
13639 override bool IsHeavyBehaviour()
13640 {
13641 if (m_ItemBehaviour == 0)
13642 {
13643 return true;
13644 }
13645
13646 return false;
13647 }
13648
13649 override bool IsOneHandedBehaviour()
13650 {
13651 if (m_ItemBehaviour == 1)
13652 {
13653 return true;
13654 }
13655
13656 return false;
13657 }
13658
13659 override bool IsTwoHandedBehaviour()
13660 {
13661 if (m_ItemBehaviour == 2)
13662 {
13663 return true;
13664 }
13665
13666 return false;
13667 }
13668
13669 bool IsDeployable()
13670 {
13671 return false;
13672 }
13673
13675 float GetDeployTime()
13676 {
13677 return UATimeSpent.DEFAULT_DEPLOY;
13678 }
13679
13680
13681 //----------------------------------------------------------------
13682 // Item Targeting (User Actions)
13683 override void SetTakeable(bool pState)
13684 {
13685 m_IsTakeable = pState;
13686 SetSynchDirty();
13687 }
13688
13689 override bool IsTakeable()
13690 {
13691 return m_IsTakeable;
13692 }
13693
13694 // For cases where we want to show object widget which cant be taken to hands
13696 {
13697 return false;
13698 }
13699
13701 protected void PreLoadSoundAttachmentType()
13702 {
13703 string att_type = "None";
13704
13705 if (ConfigIsExisting("soundAttType"))
13706 {
13707 att_type = ConfigGetString("soundAttType");
13708 }
13709
13710 m_SoundAttType = att_type;
13711 }
13712
13713 override string GetAttachmentSoundType()
13714 {
13715 return m_SoundAttType;
13716 }
13717
13718 //----------------------------------------------------------------
13719 //SOUNDS - ItemSoundHandler
13720 //----------------------------------------------------------------
13721
13722 string GetPlaceSoundset(); // played when deploy starts
13723 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13724 string GetDeploySoundset(); // played when deploy sucessfully finishes
13725 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13726 string GetFoldSoundset(); // played when fold sucessfully finishes
13727
13729 {
13730 if (!m_ItemSoundHandler)
13732
13733 return m_ItemSoundHandler;
13734 }
13735
13736 // override to initialize sounds
13737 protected void InitItemSounds()
13738 {
13739 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
13740 return;
13741
13743
13744 if (GetPlaceSoundset() != string.Empty)
13745 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13746
13747 if (GetDeploySoundset() != string.Empty)
13748 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13749
13750 SoundParameters params = new SoundParameters();
13751 params.m_Loop = true;
13752 if (GetLoopDeploySoundset() != string.Empty)
13753 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13754 }
13755
13756 // Start sound using ItemSoundHandler
13757 void StartItemSoundServer(int id, int slotId)
13758 {
13759 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
13760 {
13761 m_SoundSyncSlotID = slotId;
13762 m_SoundSyncPlay = id;
13763
13764 SetSynchDirty();
13765
13766 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13767 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
13768 }
13769 }
13770
13771 void StartItemSoundServer(int id)
13772 {
13773 StartItemSoundServer(id, InventorySlots.INVALID);
13774 }
13775
13776 // Stop sound using ItemSoundHandler
13777 void StopItemSoundServer(int id)
13778 {
13779 if (!g_Game.IsServer())
13780 return;
13781
13782 m_SoundSyncStop = id;
13783 SetSynchDirty();
13784
13785 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13786 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
13787 }
13788
13789 protected void ClearStartItemSoundServer()
13790 {
13791 m_SoundSyncPlay = 0;
13792 m_SoundSyncSlotID = InventorySlots.INVALID;
13793 }
13794
13795 protected void ClearStopItemSoundServer()
13796 {
13797 m_SoundSyncStop = 0;
13798 }
13799
13800 void OnApply(PlayerBase player);
13801
13803 {
13804 return 1.0;
13805 };
13806 //returns applicable selection
13807 array<string> GetHeadHidingSelection()
13808 {
13810 }
13811
13813 {
13815 }
13816
13817 WrittenNoteData GetWrittenNoteData() {};
13818
13820 {
13821 SetDynamicPhysicsLifeTime(0.01);
13822 m_ItemBeingDroppedPhys = false;
13823 }
13824
13826 {
13827 array<string> zone_names = new array<string>;
13828 GetDamageZones(zone_names);
13829 for (int i = 0; i < zone_names.Count(); i++)
13830 {
13831 SetHealthMax(zone_names.Get(i),"Health");
13832 }
13833 SetHealthMax("","Health");
13834 }
13835
13837 void SetZoneDamageCEInit()
13838 {
13839 float global_health = GetHealth01("","Health");
13840 array<string> zones = new array<string>;
13841 GetDamageZones(zones);
13842 //set damage of all zones to match global health level
13843 for (int i = 0; i < zones.Count(); i++)
13844 {
13845 SetHealth01(zones.Get(i),"Health",global_health);
13846 }
13847 }
13848
13850 bool IsCoverFaceForShave(string slot_name)
13851 {
13852 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13853 }
13854
13855 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13856 {
13857 if (!hasRootAsPlayer)
13858 {
13859 if (refParentIB)
13860 {
13861 // parent is wet
13862 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13863 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13864 // parent has liquid inside
13865 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13866 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13867 // drying
13868 else if (m_VarWet > m_VarWetMin)
13869 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13870 }
13871 else
13872 {
13873 // drying on ground or inside non-itembase (car, ...)
13874 if (m_VarWet > m_VarWetMin)
13875 AddWet(-1 * delta * GetDryingIncrement("ground"));
13876 }
13877 }
13878 }
13879
13880 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13881 {
13883 {
13884 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13885 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13886 {
13887 float heatPermCoef = 1.0;
13888 EntityAI ent = this;
13889 while (ent)
13890 {
13891 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13892 ent = ent.GetHierarchyParent();
13893 }
13894
13895 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13896 }
13897 }
13898 }
13899
13900 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13901 {
13902 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13903 EntityAI parent = GetHierarchyParent();
13904 if (!parent)
13905 {
13906 hasParent = false;
13907 hasRootAsPlayer = false;
13908 }
13909 else
13910 {
13911 hasParent = true;
13912 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13913 refParentIB = ItemBase.Cast(parent);
13914 }
13915 }
13916
13917 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13918 {
13919 // this is stub, implemented on Edible_Base
13920 }
13921
13922 bool CanDecay()
13923 {
13924 // return true used on selected food clases so they can decay
13925 return false;
13926 }
13927
13928 protected bool CanProcessDecay()
13929 {
13930 // this is stub, implemented on Edible_Base class
13931 // used to determine whether it is still necessary for the food to decay
13932 return false;
13933 }
13934
13935 protected bool CanHaveWetness()
13936 {
13937 // return true used on selected items that have a wetness effect
13938 return false;
13939 }
13940
13942 bool CanBeConsumed(ConsumeConditionData data = null)
13943 {
13944 return !GetIsFrozen() && IsOpen();
13945 }
13946
13947 override void ProcessVariables()
13948 {
13949 bool hasParent = false, hasRootAsPlayer = false;
13950 ItemBase refParentIB;
13951
13952 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13953 bool foodDecay = g_Game.IsFoodDecayEnabled();
13954
13955 if (wwtu || foodDecay)
13956 {
13957 bool processWetness = wwtu && CanHaveWetness();
13958 bool processTemperature = wwtu && CanHaveTemperature();
13959 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13960
13961 if (processWetness || processTemperature || processDecay)
13962 {
13963 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13964
13965 if (processWetness)
13966 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13967
13968 if (processTemperature)
13969 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13970
13971 if (processDecay)
13972 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13973 }
13974 }
13975 }
13976
13979 {
13980 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13981 }
13982
13983 override float GetTemperatureFreezeThreshold()
13984 {
13986 return Liquid.GetFreezeThreshold(GetLiquidType());
13987
13988 return super.GetTemperatureFreezeThreshold();
13989 }
13990
13991 override float GetTemperatureThawThreshold()
13992 {
13994 return Liquid.GetThawThreshold(GetLiquidType());
13995
13996 return super.GetTemperatureThawThreshold();
13997 }
13998
13999 override float GetItemOverheatThreshold()
14000 {
14002 return Liquid.GetBoilThreshold(GetLiquidType());
14003
14004 return super.GetItemOverheatThreshold();
14005 }
14006
14007 override float GetTemperatureFreezeTime()
14008 {
14009 if (HasQuantity())
14010 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
14011
14012 return super.GetTemperatureFreezeTime();
14013 }
14014
14015 override float GetTemperatureThawTime()
14016 {
14017 if (HasQuantity())
14018 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
14019
14020 return super.GetTemperatureThawTime();
14021 }
14022
14024 void AffectLiquidContainerOnFill(int liquid_type, float amount);
14026 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
14027
14028 bool IsCargoException4x3(EntityAI item)
14029 {
14030 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
14031 }
14032
14034 {
14035 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
14036 }
14037
14039 void AddLightSourceItem(ItemBase lightsource)
14040 {
14041 m_LightSourceItem = lightsource;
14042 }
14043
14045 {
14046 m_LightSourceItem = null;
14047 }
14048
14050 {
14051 return m_LightSourceItem;
14052 }
14053
14055 array<int> GetValidFinishers()
14056 {
14057 return null;
14058 }
14059
14061 bool GetActionWidgetOverride(out typename name)
14062 {
14063 return false;
14064 }
14065
14066 bool PairWithDevice(notnull ItemBase otherDevice)
14067 {
14068 if (g_Game.IsServer())
14069 {
14070 ItemBase explosive = otherDevice;
14072 if (!trg)
14073 {
14074 trg = RemoteDetonatorTrigger.Cast(otherDevice);
14075 explosive = this;
14076 }
14077
14078 explosive.PairRemote(trg);
14079 trg.SetControlledDevice(explosive);
14080
14081 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
14082 trg.SetPersistentPairID(persistentID);
14083 explosive.SetPersistentPairID(persistentID);
14084
14085 return true;
14086 }
14087 return false;
14088 }
14089
14091 float GetBaitEffectivity()
14092 {
14093 float ret = 1.0;
14094 if (HasQuantity())
14095 ret *= GetQuantityNormalized();
14096 ret *= GetHealth01();
14097
14098 return ret;
14099 }
14100
14101 #ifdef DEVELOPER
14102 override void SetDebugItem()
14103 {
14104 super.SetDebugItem();
14105 _itemBase = this;
14106 }
14107
14108 override string GetDebugText()
14109 {
14110 string text = super.GetDebugText();
14111
14112 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
14113 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
14114
14115 return text;
14116 }
14117 #endif
14118
14119 bool CanBeUsedForSuicide()
14120 {
14121 return true;
14122 }
14123
14125 //DEPRECATED BELOW
14127 // Backwards compatibility
14128 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
14129 {
14130 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
14131 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
14132 }
14133
14134 // replaced by ItemSoundHandler
14135 protected EffectSound m_SoundDeployFinish;
14136 protected EffectSound m_SoundPlace;
14137 protected EffectSound m_DeployLoopSoundEx;
14138 protected EffectSound m_SoundDeploy;
14139 bool m_IsPlaceSound;
14140 bool m_IsDeploySound;
14142
14143 string GetDeployFinishSoundset();
14144 void PlayDeploySound();
14145 void PlayDeployFinishSound();
14146 void PlayPlaceSound();
14147 void PlayDeployLoopSoundEx();
14148 void StopDeployLoopSoundEx();
14149 void SoundSynchRemoteReset();
14150 void SoundSynchRemote();
14151 bool UsesGlobalDeploy(){return false;}
14152 bool CanPlayDeployLoopSound(){return false;}
14154 bool IsPlaceSound(){return m_IsPlaceSound;}
14155 bool IsDeploySound(){return m_IsDeploySound;}
14156 void SetIsPlaceSound(bool is_place_sound);
14157 void SetIsDeploySound(bool is_deploy_sound);
14158
14159 [Obsolete("Use ItemSoundHandler instead")]
14161 void PlayAttachSound(string slot_type)
14162 {
14163 if (!g_Game.IsDedicatedServer())
14164 {
14165 if (ConfigIsExisting("attachSoundSet"))
14166 {
14167 string cfg_path = "";
14168 string soundset = "";
14169 string type_name = GetType();
14170
14171 TStringArray cfg_soundset_array = new TStringArray;
14172 TStringArray cfg_slot_array = new TStringArray;
14173 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
14174 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
14175
14176 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
14177 {
14178 for (int i = 0; i < cfg_soundset_array.Count(); i++)
14179 {
14180 if (cfg_slot_array[i] == slot_type)
14181 {
14182 soundset = cfg_soundset_array[i];
14183 break;
14184 }
14185 }
14186 }
14187
14188 if (soundset != "")
14189 {
14190 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
14191 sound.SetAutodestroy(true);
14192 }
14193 }
14194 }
14195 }
14196
14197 void PlayDetachSound(string slot_type) {}
14198}
14199
14200EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
14201{
14202 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
14203 if (entity)
14204 {
14205 bool is_item = entity.IsInherited(ItemBase);
14206 if (is_item && full_quantity)
14207 {
14208 ItemBase item = ItemBase.Cast(entity);
14209 item.SetQuantity(item.GetQuantityInit());
14210 }
14211 }
14212 else
14213 {
14214 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
14215 return NULL;
14216 }
14217 return entity;
14218}
14219
14220void SetupSpawnedItem(ItemBase item, float health, float quantity)
14221{
14222 if (item)
14223 {
14224 if (health > 0)
14225 item.SetHealth("", "", health);
14226
14227 if (item.CanHaveTemperature())
14228 {
14229 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
14230 if (item.CanFreeze())
14231 item.SetFrozen(false);
14232 }
14233
14234 if (item.HasEnergyManager())
14235 {
14236 if (quantity >= 0)
14237 {
14238 item.GetCompEM().SetEnergy0To1(quantity);
14239 }
14240 else
14241 {
14242 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
14243 }
14244 }
14245 else if (item.IsMagazine())
14246 {
14247 Magazine mag = Magazine.Cast(item);
14248 if (quantity >= 0)
14249 {
14250 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
14251 }
14252 else
14253 {
14254 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
14255 }
14256
14257 }
14258 else
14259 {
14260 if (quantity >= 0)
14261 {
14262 item.SetQuantityNormalized(quantity, false);
14263 }
14264 else
14265 {
14266 item.SetQuantity(Math.AbsFloat(quantity));
14267 }
14268
14269 }
14270 }
14271}
14272
14273#ifdef DEVELOPER
14274ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
14275#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()