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

◆ ProcessVariables()

override void SpawnItemOnLocation::ProcessVariables ( )
protected

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

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

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