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

◆ ProcessDecay()

void SpawnItemOnLocation::ProcessDecay ( float delta,
bool hasRootAsPlayer )
protected

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

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