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

◆ PerformDamageSystemReinit()

void SpawnItemOnLocation::PerformDamageSystemReinit ( )
protected

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

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

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