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

◆ PerformDamageSystemReinit()

void SpawnItemOnLocation::PerformDamageSystemReinit ( )
protected

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

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

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