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

◆ GetTemperatureThawTime()

override float SpawnItemOnLocation::GetTemperatureThawTime ( )
protected

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

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