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

◆ AllowFoodConsumption()

bool SpawnItemOnLocation::AllowFoodConsumption ( )
protected

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

8726{
8727 override bool CanPutAsAttachment(EntityAI parent)
8728 {
8729 return true;
8730 }
8731};
8732
8734{
8735
8736};
8737
8738//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8739
8740class ItemBase extends InventoryItem
8741{
8745
8747
8748 static int m_DebugActionsMask;
8750 // ============================================
8751 // Variable Manipulation System
8752 // ============================================
8753 // Quantity
8754
8755 float m_VarQuantity;
8756 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8758 int m_VarQuantityMin;
8759 int m_VarQuantityMax;
8760 int m_Count;
8761 float m_VarStackMax;
8762 float m_StoreLoadedQuantity = float.LOWEST;
8763 // Wet
8764 float m_VarWet;
8765 float m_VarWetPrev;//for client to know wetness changed during synchronization
8766 float m_VarWetInit;
8767 float m_VarWetMin;
8768 float m_VarWetMax;
8769 // Cleanness
8770 int m_Cleanness;
8771 int m_CleannessInit;
8772 int m_CleannessMin;
8773 int m_CleannessMax;
8774 // impact sounds
8776 bool m_CanPlayImpactSound = true;
8777 float m_ImpactSpeed;
8779 //
8780 float m_HeatIsolation;
8781 float m_ItemModelLength;
8782 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8784 int m_VarLiquidType;
8785 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8786 int m_QuickBarBonus;
8787 bool m_IsBeingPlaced;
8788 bool m_IsHologram;
8789 bool m_IsTakeable;
8790 bool m_ThrowItemOnDrop;
8793 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8794 bool can_this_be_combined; //Check if item can be combined
8795 bool m_CanThisBeSplit; //Check if item can be split
8796 bool m_IsStoreLoad = false;
8797 bool m_CanShowQuantity;
8798 bool m_HasQuantityBar;
8799 protected bool m_CanBeDigged;
8800 protected bool m_IsResultOfSplit
8801
8802 string m_SoundAttType;
8803 // items color variables
8808 //-------------------------------------------------------
8809
8810 // light source managing
8812
8816
8817 //==============================================
8818 // agent system
8819 private int m_AttachedAgents;
8820
8822 void TransferModifiers(PlayerBase reciever);
8823
8824
8825 // Weapons & suppressors particle effects
8829 ref static map<string, int> m_WeaponTypeToID;
8830 static int m_LastRegisteredWeaponID = 0;
8831
8832 // Overheating effects
8834 float m_OverheatingShots;
8835 ref Timer m_CheckOverheating;
8836 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8837 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8838 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8839 ref array <ref OverheatingParticle> m_OverheatingParticles;
8840
8842 protected bool m_HideSelectionsBySlot;
8843
8844 // Admin Log
8845 PluginAdminLog m_AdminLog;
8846
8847 // misc
8848 ref Timer m_PhysDropTimer;
8849
8850 // Attachment Locking variables
8851 ref array<int> m_CompatibleLocks;
8852 protected int m_LockType;
8853 protected ref EffectSound m_LockingSound;
8854 protected string m_LockSoundSet;
8855
8856 // ItemSoundHandler variables
8857 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8858 protected int m_SoundSyncPlay; // id for sound to play
8859 protected int m_SoundSyncStop; // id for sound to stop
8860 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8861
8863
8864 //temperature
8865 private float m_TemperaturePerQuantityWeight;
8866
8867 // -------------------------------------------------------------------------
8868 void ItemBase()
8869 {
8870 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8874
8875 if (!g_Game.IsDedicatedServer())
8876 {
8877 if (HasMuzzle())
8878 {
8880
8882 {
8884 }
8885 }
8886
8888 m_ActionsInitialize = false;
8889 }
8890
8891 m_OldLocation = null;
8892
8893 if (g_Game.IsServer())
8894 {
8895 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8896 }
8897
8898 if (ConfigIsExisting("headSelectionsToHide"))
8899 {
8901 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8902 }
8903
8904 m_HideSelectionsBySlot = false;
8905 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8906 {
8907 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8908 }
8909
8910 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8911
8912 m_IsResultOfSplit = false;
8913
8915 }
8916
8917 override void InitItemVariables()
8918 {
8919 super.InitItemVariables();
8920
8921 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8922 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8923 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8924 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8925 m_VarStackMax = ConfigGetFloat("varStackMax");
8926 m_Count = ConfigGetInt("count");
8927
8928 m_CanShowQuantity = ConfigGetBool("quantityShow");
8929 m_HasQuantityBar = ConfigGetBool("quantityBar");
8930
8931 m_CleannessInit = ConfigGetInt("varCleannessInit");
8933 m_CleannessMin = ConfigGetInt("varCleannessMin");
8934 m_CleannessMax = ConfigGetInt("varCleannessMax");
8935
8936 m_WantPlayImpactSound = false;
8937 m_ImpactSpeed = 0.0;
8938
8939 m_VarWetInit = ConfigGetFloat("varWetInit");
8941 m_VarWetMin = ConfigGetFloat("varWetMin");
8942 m_VarWetMax = ConfigGetFloat("varWetMax");
8943
8944 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8945 if (IsLiquidContainer() && GetQuantity() != 0)
8947 m_IsBeingPlaced = false;
8948 m_IsHologram = false;
8949 m_IsTakeable = true;
8950 m_CanBeMovedOverride = false;
8954 m_CanBeDigged = ConfigGetBool("canBeDigged");
8955
8956 m_CompatibleLocks = new array<int>();
8957 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8958 m_LockType = ConfigGetInt("lockType");
8959
8960 //Define if item can be split and set ability to be combined accordingly
8961 m_CanThisBeSplit = false;
8962 can_this_be_combined = false;
8963 if (ConfigIsExisting("canBeSplit"))
8964 {
8965 can_this_be_combined = ConfigGetBool("canBeSplit");
8967 }
8968
8969 m_ItemBehaviour = -1;
8970 if (ConfigIsExisting("itemBehaviour"))
8971 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8972
8973 //RegisterNetSyncVariableInt("m_VariablesMask");
8974 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8975 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8976 RegisterNetSyncVariableInt("m_VarLiquidType");
8977 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8978
8979 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8980 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8981 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8982
8983 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8984 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8985 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8986 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8987
8988 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8989 RegisterNetSyncVariableBool("m_IsTakeable");
8990 RegisterNetSyncVariableBool("m_IsHologram");
8991
8994 {
8995 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8996 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8997 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8998 }
8999
9000 m_LockSoundSet = ConfigGetString("lockSoundSet");
9001
9003 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9004 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9005
9006 m_SoundSyncSlotID = -1;
9007 }
9008
9009 override int GetQuickBarBonus()
9010 {
9011 return m_QuickBarBonus;
9012 }
9013
9014 void InitializeActions()
9015 {
9017 if (!m_InputActionMap)
9018 {
9020 m_InputActionMap = iam;
9021 SetActions();
9023 }
9024 }
9025
9026 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9027 {
9029 {
9030 m_ActionsInitialize = true;
9032 }
9033
9034 actions = m_InputActionMap.Get(action_input_type);
9035 }
9036
9037 void SetActions()
9038 {
9039 AddAction(ActionTakeItem);
9040 AddAction(ActionTakeItemToHands);
9041 AddAction(ActionWorldCraft);
9043 AddAction(ActionAttachWithSwitch);
9044 }
9045
9046 void SetActionAnimOverrides(); // Override action animation for specific item
9047
9048 void AddAction(typename actionName)
9049 {
9050 ActionBase action = ActionManagerBase.GetAction(actionName);
9051
9052 if (!action)
9053 {
9054 Debug.LogError("Action " + actionName + " dosn't exist!");
9055 return;
9056 }
9057
9058 typename ai = action.GetInputType();
9059 if (!ai)
9060 {
9061 m_ActionsInitialize = false;
9062 return;
9063 }
9064
9065 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9066 if (!action_array)
9067 {
9068 action_array = new array<ActionBase_Basic>;
9069 m_InputActionMap.Insert(ai, action_array);
9070 }
9071 if (LogManager.IsActionLogEnable())
9072 {
9073 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9074 }
9075
9076 if (action_array.Find(action) != -1)
9077 {
9078 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9079 }
9080 else
9081 {
9082 action_array.Insert(action);
9083 }
9084 }
9085
9086 void RemoveAction(typename actionName)
9087 {
9088 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9089 ActionBase action = player.GetActionManager().GetAction(actionName);
9090 typename ai = action.GetInputType();
9091 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9092
9093 if (action_array)
9094 {
9095 action_array.RemoveItem(action);
9096 }
9097 }
9098
9099 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9100 // Set -1 for params which should stay in default state
9101 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9102 {
9103 ActionOverrideData overrideData = new ActionOverrideData();
9104 overrideData.m_CommandUID = commandUID;
9105 overrideData.m_CommandUIDProne = commandUIDProne;
9106 overrideData.m_StanceMask = stanceMask;
9107
9108 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9109 if (!actionMap) // create new map of action > overidables map
9110 {
9111 actionMap = new TActionAnimOverrideMap();
9112 m_ItemActionOverrides.Insert(action, actionMap);
9113 }
9114
9115 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9116
9117 }
9118
9119 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9120
9121 ScriptedLightBase GetLight();
9122
9123 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9124 void LoadParticleConfigOnFire(int id)
9125 {
9126 if (!m_OnFireEffect)
9128
9131
9132 string config_to_search = "CfgVehicles";
9133 string muzzle_owner_config;
9134
9135 if (!m_OnFireEffect.Contains(id))
9136 {
9137 if (IsInherited(Weapon))
9138 config_to_search = "CfgWeapons";
9139
9140 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9141
9142 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9143
9144 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
9145
9146 if (config_OnFire_subclass_count > 0)
9147 {
9148 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9149
9150 for (int i = 0; i < config_OnFire_subclass_count; i++)
9151 {
9152 string particle_class = "";
9153 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
9154 string config_OnFire_entry = config_OnFire_class + particle_class;
9155 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9156 WPOF_array.Insert(WPOF);
9157 }
9158
9159
9160 m_OnFireEffect.Insert(id, WPOF_array);
9161 }
9162 }
9163
9164 if (!m_OnBulletCasingEjectEffect.Contains(id))
9165 {
9166 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9167 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9168
9169 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9170
9171 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9172
9173 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9174 {
9175 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9176
9177 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9178 {
9179 string particle_class2 = "";
9180 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9181 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9182 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9183 WPOBE_array.Insert(WPOBE);
9184 }
9185
9186
9187 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9188 }
9189 }
9190 }
9191
9192 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9194 {
9197
9198 if (!m_OnOverheatingEffect.Contains(id))
9199 {
9200 string config_to_search = "CfgVehicles";
9201
9202 if (IsInherited(Weapon))
9203 config_to_search = "CfgWeapons";
9204
9205 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9206 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9207
9208 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
9209 {
9210
9211 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9212
9214 {
9215 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9216 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9217 Error(error);
9218 return;
9219 }
9220
9221 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9222 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9223
9224
9225
9226 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
9227 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9228
9229 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9230 {
9231 string particle_class = "";
9232 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9233 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9234 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
9235
9236 if (entry_type == CT_CLASS)
9237 {
9238 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9239 WPOOH_array.Insert(WPOF);
9240 }
9241 }
9242
9243
9244 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9245 }
9246 }
9247 }
9248
9249 float GetOverheatingValue()
9250 {
9251 return m_OverheatingShots;
9252 }
9253
9254 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9255 {
9256 if (m_MaxOverheatingValue > 0)
9257 {
9259
9260 if (!m_CheckOverheating)
9262
9264 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9265
9266 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9267 }
9268 }
9269
9270 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9271 {
9273 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9274
9276 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9277
9279 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9280
9282 {
9284 }
9285 }
9286
9288 {
9290 }
9291
9292 void OnOverheatingDecay()
9293 {
9294 if (m_MaxOverheatingValue > 0)
9295 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9296 else
9298
9299 if (m_OverheatingShots <= 0)
9300 {
9303 }
9304 else
9305 {
9306 if (!m_CheckOverheating)
9308
9310 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9311 }
9312
9313 CheckOverheating(this, "", this);
9314 }
9315
9316 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9317 {
9319 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9320 }
9321
9322 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9323 {
9325 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9327 }
9328
9329 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9330 {
9332 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9333 }
9334
9335 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9336 {
9338 m_OverheatingParticles = new array<ref OverheatingParticle>;
9339
9340 OverheatingParticle OP = new OverheatingParticle();
9341 OP.RegisterParticle(p);
9342 OP.SetOverheatingLimitMin(min_heat_coef);
9343 OP.SetOverheatingLimitMax(max_heat_coef);
9344 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9345
9346 m_OverheatingParticles.Insert(OP);
9347 }
9348
9349 float GetOverheatingCoef()
9350 {
9351 if (m_MaxOverheatingValue > 0)
9353
9354 return -1;
9355 }
9356
9358 {
9360 {
9361 float overheat_coef = GetOverheatingCoef();
9362 int count = m_OverheatingParticles.Count();
9363
9364 for (int i = count; i > 0; --i)
9365 {
9366 int id = i - 1;
9367 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9368 Particle p = OP.GetParticle();
9369
9370 float overheat_min = OP.GetOverheatingLimitMin();
9371 float overheat_max = OP.GetOverheatingLimitMax();
9372
9373 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9374 {
9375 if (p)
9376 {
9377 p.Stop();
9378 OP.RegisterParticle(null);
9379 }
9380 }
9381 }
9382 }
9383 }
9384
9386 {
9388 {
9389 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9390 {
9391 int id = i - 1;
9392 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9393
9394 if (OP)
9395 {
9396 Particle p = OP.GetParticle();
9397
9398 if (p)
9399 {
9400 p.Stop();
9401 }
9402
9403 delete OP;
9404 }
9405 }
9406
9407 m_OverheatingParticles.Clear();
9409 }
9410 }
9411
9413 float GetInfectionChance(int system = 0, Param param = null)
9414 {
9415 return 0.0;
9416 }
9417
9418
9419 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9420 {
9421 return 250;//default value
9422 }
9423
9424 float GetFilterDamageRatio()
9425 {
9426 return 0;
9427 }
9428
9430 bool HasMuzzle()
9431 {
9432 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9433 return true;
9434
9435 return false;
9436 }
9437
9439 int GetMuzzleID()
9440 {
9441 if (!m_WeaponTypeToID)
9442 m_WeaponTypeToID = new map<string, int>;
9443
9444 if (m_WeaponTypeToID.Contains(GetType()))
9445 {
9446 return m_WeaponTypeToID.Get(GetType());
9447 }
9448 else
9449 {
9450 // Register new weapon ID
9452 }
9453
9455 }
9456
9463 {
9464 return -1;
9465 }
9466
9467
9468
9469 // -------------------------------------------------------------------------
9470 void ~ItemBase()
9471 {
9472 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
9473 {
9474 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9475 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9476
9477 if (r_index >= 0)
9478 {
9479 InventoryLocation r_il = new InventoryLocation;
9480 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9481
9482 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9483 int r_type = r_il.GetType();
9484 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9485 {
9486 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9487 }
9488 else if (r_type == InventoryLocationType.ATTACHMENT)
9489 {
9490 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9491 }
9492
9493 }
9494
9495 player.GetHumanInventory().ClearUserReservedLocation(this);
9496 }
9497
9498 if (m_LockingSound)
9499 SEffectManager.DestroyEffect(m_LockingSound);
9500 }
9501
9502
9503
9504 // -------------------------------------------------------------------------
9505 static int GetDebugActionsMask()
9506 {
9507 return ItemBase.m_DebugActionsMask;
9508 }
9509
9510 static bool HasDebugActionsMask(int mask)
9511 {
9512 return ItemBase.m_DebugActionsMask & mask;
9513 }
9514
9515 static void SetDebugActionsMask(int mask)
9516 {
9517 ItemBase.m_DebugActionsMask = mask;
9518 }
9519
9520 static void AddDebugActionsMask(int mask)
9521 {
9522 ItemBase.m_DebugActionsMask |= mask;
9523 }
9524
9525 static void RemoveDebugActionsMask(int mask)
9526 {
9527 ItemBase.m_DebugActionsMask &= ~mask;
9528 }
9529
9530 static void ToggleDebugActionsMask(int mask)
9531 {
9532 if (HasDebugActionsMask(mask))
9533 {
9535 }
9536 else
9537 {
9538 AddDebugActionsMask(mask);
9539 }
9540 }
9541
9542 // -------------------------------------------------------------------------
9543 void SetCEBasedQuantity()
9544 {
9545 if (GetEconomyProfile())
9546 {
9547 float q_max = GetEconomyProfile().GetQuantityMax();
9548 if (q_max > 0)
9549 {
9550 float q_min = GetEconomyProfile().GetQuantityMin();
9551 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9552
9553 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9554 {
9555 ComponentEnergyManager comp = GetCompEM();
9556 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
9557 {
9558 comp.SetEnergy0To1(quantity_randomized);
9559 }
9560 }
9561 else if (HasQuantity())
9562 {
9563 SetQuantityNormalized(quantity_randomized, false);
9564 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9565 }
9566
9567 }
9568 }
9569 }
9570
9572 void LockToParent()
9573 {
9574 EntityAI parent = GetHierarchyParent();
9575
9576 if (parent)
9577 {
9578 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9579 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9580 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9581 }
9582 }
9583
9585 void UnlockFromParent()
9586 {
9587 EntityAI parent = GetHierarchyParent();
9588
9589 if (parent)
9590 {
9591 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9592 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9593 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9594 }
9595 }
9596
9597 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9598 {
9599 /*
9600 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9601 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9602 */
9603 ItemBase item2 = ItemBase.Cast(entity2);
9604
9605 if (g_Game.IsClient())
9606 {
9607 if (ScriptInputUserData.CanStoreInputUserData())
9608 {
9609 ScriptInputUserData ctx = new ScriptInputUserData;
9611 ctx.Write(-1);
9612 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9613 ctx.Write(i1);
9614 ctx.Write(item2);
9615 ctx.Write(use_stack_max);
9616 ctx.Write(-1);
9617 ctx.Send();
9618
9619 if (IsCombineAll(item2, use_stack_max))
9620 {
9621 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9622 }
9623 }
9624 }
9625 else if (!g_Game.IsMultiplayer())
9626 {
9627 CombineItems(item2, use_stack_max);
9628 }
9629 }
9630
9631 bool IsLiquidPresent()
9632 {
9633 return (GetLiquidType() != 0 && HasQuantity());
9634 }
9635
9636 bool IsLiquidContainer()
9637 {
9638 return m_LiquidContainerMask != 0;
9639 }
9640
9642 {
9643 return m_LiquidContainerMask;
9644 }
9645
9646 bool IsBloodContainer()
9647 {
9648 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9649 return false;
9650 }
9651
9652 bool IsNVG()
9653 {
9654 return false;
9655 }
9656
9659 bool IsExplosive()
9660 {
9661 return false;
9662 }
9663
9665 {
9666 return "";
9667 }
9668
9670
9671 bool IsLightSource()
9672 {
9673 return false;
9674 }
9675
9677 {
9678 return true;
9679 }
9680
9681 //--- ACTION CONDITIONS
9682 //direction
9683 bool IsFacingPlayer(PlayerBase player, string selection)
9684 {
9685 return true;
9686 }
9687
9688 bool IsPlayerInside(PlayerBase player, string selection)
9689 {
9690 return true;
9691 }
9692
9693 override bool CanObstruct()
9694 {
9695 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9696 return !player || !IsPlayerInside(player, "");
9697 }
9698
9699 override bool IsBeingPlaced()
9700 {
9701 return m_IsBeingPlaced;
9702 }
9703
9704 void SetIsBeingPlaced(bool is_being_placed)
9705 {
9706 m_IsBeingPlaced = is_being_placed;
9707 if (!is_being_placed)
9709 SetSynchDirty();
9710 }
9711
9712 //server-side
9713 void OnEndPlacement() {}
9714
9715 override bool IsHologram()
9716 {
9717 return m_IsHologram;
9718 }
9719
9720 bool CanBeDigged()
9721 {
9722 return m_CanBeDigged;
9723 }
9724
9726 {
9727 return 1;
9728 }
9729
9730 bool CanMakeGardenplot()
9731 {
9732 return false;
9733 }
9734
9735 void SetIsHologram(bool is_hologram)
9736 {
9737 m_IsHologram = is_hologram;
9738 SetSynchDirty();
9739 }
9740 /*
9741 protected float GetNutritionalEnergy()
9742 {
9743 Edible_Base edible = Edible_Base.Cast(this);
9744 return edible.GetFoodEnergy();
9745 }
9746
9747 protected float GetNutritionalWaterContent()
9748 {
9749 Edible_Base edible = Edible_Base.Cast(this);
9750 return edible.GetFoodWater();
9751 }
9752
9753 protected float GetNutritionalIndex()
9754 {
9755 Edible_Base edible = Edible_Base.Cast(this);
9756 return edible.GetFoodNutritionalIndex();
9757 }
9758
9759 protected float GetNutritionalFullnessIndex()
9760 {
9761 Edible_Base edible = Edible_Base.Cast(this);
9762 return edible.GetFoodTotalVolume();
9763 }
9764
9765 protected float GetNutritionalToxicity()
9766 {
9767 Edible_Base edible = Edible_Base.Cast(this);
9768 return edible.GetFoodToxicity();
9769
9770 }
9771 */
9772
9773
9774 // -------------------------------------------------------------------------
9775 override void OnMovedInsideCargo(EntityAI container)
9776 {
9777 super.OnMovedInsideCargo(container);
9778
9779 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9780 }
9781
9782 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9783 {
9784 super.EEItemLocationChanged(oldLoc, newLoc);
9785
9786 PlayerBase newPlayer = null;
9787 PlayerBase oldPlayer = null;
9788
9789 if (newLoc.GetParent())
9790 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9791
9792 if (oldLoc.GetParent())
9793 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9794
9795 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9796 {
9797 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9798
9799 if (rIndex >= 0)
9800 {
9801 InventoryLocation rIl = new InventoryLocation;
9802 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9803
9804 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9805 int rType = rIl.GetType();
9806 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9807 {
9808 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9809 }
9810 else if (rType == InventoryLocationType.ATTACHMENT)
9811 {
9812 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9813 }
9814
9815 }
9816 }
9817
9818 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9819 {
9820 if (newPlayer)
9821 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9822
9823 if (newPlayer == oldPlayer)
9824 {
9825 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9826 {
9827 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9828 {
9829 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9830 {
9831 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9832 }
9833 }
9834 else
9835 {
9836 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9837 }
9838 }
9839
9840 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9841 {
9842 int type = oldLoc.GetType();
9843 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9844 {
9845 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9846 }
9847 else if (type == InventoryLocationType.ATTACHMENT)
9848 {
9849 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9850 }
9851 }
9852 if (!m_OldLocation)
9853 {
9854 m_OldLocation = new InventoryLocation;
9855 }
9856 m_OldLocation.Copy(oldLoc);
9857 }
9858 else
9859 {
9860 if (m_OldLocation)
9861 {
9862 m_OldLocation.Reset();
9863 }
9864 }
9865
9866 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9867 }
9868 else
9869 {
9870 if (newPlayer)
9871 {
9872 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9873 if (resIndex >= 0)
9874 {
9875 InventoryLocation il = new InventoryLocation;
9876 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9877 ItemBase it = ItemBase.Cast(il.GetItem());
9878 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9879 int rel_type = il.GetType();
9880 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9881 {
9882 il.GetParent().GetOnReleaseLock().Invoke(it);
9883 }
9884 else if (rel_type == InventoryLocationType.ATTACHMENT)
9885 {
9886 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9887 }
9888 //it.GetOnReleaseLock().Invoke(it);
9889 }
9890 }
9891 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9892 {
9893 //ThrowPhysically(oldPlayer, vector.Zero);
9894 m_ThrowItemOnDrop = false;
9895 }
9896
9897 if (m_OldLocation)
9898 {
9899 m_OldLocation.Reset();
9900 }
9901 }
9902
9903 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9904 {
9905 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9906 }
9907
9908 if (newLoc.GetType() == InventoryLocationType.TEMP)
9909 {
9910 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9911 }
9912 }
9913
9914 override void EOnContact(IEntity other, Contact extra)
9915 {
9917 {
9918 int liquidType = -1;
9919 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9920 if (impactSpeed > 0.0)
9921 {
9922 m_ImpactSpeed = impactSpeed;
9923 #ifndef SERVER
9924 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9925 #else
9926 m_WantPlayImpactSound = true;
9927 SetSynchDirty();
9928 #endif
9929 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9930 }
9931 }
9932
9933 #ifdef SERVER
9934 if (GetCompEM() && GetCompEM().IsPlugged())
9935 {
9936 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9937 GetCompEM().UnplugThis();
9938 }
9939 #endif
9940 }
9941
9942 void RefreshPhysics();
9943
9944 override void OnCreatePhysics()
9945 {
9947 }
9948
9949 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9950 {
9951
9952 }
9953 // -------------------------------------------------------------------------
9954 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9955 {
9956 super.OnItemLocationChanged(old_owner, new_owner);
9957
9958 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9959 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9960
9961 if (!relatedPlayer && playerNew)
9962 relatedPlayer = playerNew;
9963
9964 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9965 {
9966 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9967 if (actionMgr)
9968 {
9969 ActionBase currentAction = actionMgr.GetRunningAction();
9970 if (currentAction)
9971 currentAction.OnItemLocationChanged(this);
9972 }
9973 }
9974
9975 Man ownerPlayerOld = null;
9976 Man ownerPlayerNew = null;
9977
9978 if (old_owner)
9979 {
9980 if (old_owner.IsMan())
9981 {
9982 ownerPlayerOld = Man.Cast(old_owner);
9983 }
9984 else
9985 {
9986 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9987 }
9988 }
9989 else
9990 {
9991 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9992 {
9993 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9994
9995 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9996 {
9997 GetCompEM().UnplugThis();
9998 }
9999 }
10000 }
10001
10002 if (new_owner)
10003 {
10004 if (new_owner.IsMan())
10005 {
10006 ownerPlayerNew = Man.Cast(new_owner);
10007 }
10008 else
10009 {
10010 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10011 }
10012 }
10013
10014 if (ownerPlayerOld != ownerPlayerNew)
10015 {
10016 if (ownerPlayerOld)
10017 {
10018 array<EntityAI> subItemsExit = new array<EntityAI>;
10019 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10020 for (int i = 0; i < subItemsExit.Count(); i++)
10021 {
10022 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10023 itemExit.OnInventoryExit(ownerPlayerOld);
10024 }
10025 }
10026
10027 if (ownerPlayerNew)
10028 {
10029 array<EntityAI> subItemsEnter = new array<EntityAI>;
10030 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10031 for (int j = 0; j < subItemsEnter.Count(); j++)
10032 {
10033 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10034 itemEnter.OnInventoryEnter(ownerPlayerNew);
10035 }
10036 }
10037 }
10038 else if (ownerPlayerNew != null)
10039 {
10040 PlayerBase nplayer;
10041 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10042 {
10043 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10044 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10045 for (int k = 0; k < subItemsUpdate.Count(); k++)
10046 {
10047 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10048 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10049 }
10050 }
10051 }
10052
10053 if (old_owner)
10054 old_owner.OnChildItemRemoved(this);
10055 if (new_owner)
10056 new_owner.OnChildItemReceived(this);
10057 }
10058
10059 // -------------------------------------------------------------------------------
10060 override void EEDelete(EntityAI parent)
10061 {
10062 super.EEDelete(parent);
10063 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10064 if (player)
10065 {
10066 OnInventoryExit(player);
10067
10068 if (player.IsAlive())
10069 {
10070 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10071 if (r_index >= 0)
10072 {
10073 InventoryLocation r_il = new InventoryLocation;
10074 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10075
10076 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10077 int r_type = r_il.GetType();
10078 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10079 {
10080 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10081 }
10082 else if (r_type == InventoryLocationType.ATTACHMENT)
10083 {
10084 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10085 }
10086
10087 }
10088
10089 player.RemoveQuickBarEntityShortcut(this);
10090 }
10091 }
10092 }
10093 // -------------------------------------------------------------------------------
10094 override void EEKilled(Object killer)
10095 {
10096 super.EEKilled(killer);
10097
10099 if (killer && killer.IsFireplace() && CanExplodeInFire())
10100 {
10101 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10102 {
10103 if (IsMagazine())
10104 {
10105 if (Magazine.Cast(this).GetAmmoCount() > 0)
10106 {
10107 ExplodeAmmo();
10108 }
10109 }
10110 else
10111 {
10112 Explode(DamageType.EXPLOSION);
10113 }
10114 }
10115 }
10116 }
10117
10118 override void OnWasAttached(EntityAI parent, int slot_id)
10119 {
10120 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10121
10122 super.OnWasAttached(parent, slot_id);
10123
10124 if (HasQuantity())
10125 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10126
10127 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10128 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
10129 }
10130
10131 override void OnWasDetached(EntityAI parent, int slot_id)
10132 {
10133 super.OnWasDetached(parent, slot_id);
10134
10135 if (HasQuantity())
10136 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10137
10138 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10139 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
10140 }
10141
10142 override string ChangeIntoOnAttach(string slot)
10143 {
10144 int idx;
10145 TStringArray inventory_slots = new TStringArray;
10146 TStringArray attach_types = new TStringArray;
10147
10148 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10149 if (inventory_slots.Count() < 1) //is string
10150 {
10151 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10152 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10153 }
10154 else //is array
10155 {
10156 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10157 }
10158
10159 idx = inventory_slots.Find(slot);
10160 if (idx < 0)
10161 return "";
10162
10163 return attach_types.Get(idx);
10164 }
10165
10166 override string ChangeIntoOnDetach()
10167 {
10168 int idx = -1;
10169 string slot;
10170
10171 TStringArray inventory_slots = new TStringArray;
10172 TStringArray detach_types = new TStringArray;
10173
10174 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10175 if (inventory_slots.Count() < 1) //is string
10176 {
10177 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10178 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10179 }
10180 else //is array
10181 {
10182 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10183 if (detach_types.Count() < 1)
10184 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10185 }
10186
10187 for (int i = 0; i < inventory_slots.Count(); i++)
10188 {
10189 slot = inventory_slots.Get(i);
10190 }
10191
10192 if (slot != "")
10193 {
10194 if (detach_types.Count() == 1)
10195 idx = 0;
10196 else
10197 idx = inventory_slots.Find(slot);
10198 }
10199 if (idx < 0)
10200 return "";
10201
10202 return detach_types.Get(idx);
10203 }
10204
10205 void ExplodeAmmo()
10206 {
10207 //timer
10208 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10209
10210 //min/max time
10211 float min_time = 1;
10212 float max_time = 3;
10213 float delay = Math.RandomFloat(min_time, max_time);
10214
10215 explode_timer.Run(delay, this, "DoAmmoExplosion");
10216 }
10217
10218 void DoAmmoExplosion()
10219 {
10220 Magazine magazine = Magazine.Cast(this);
10221 int pop_sounds_count = 6;
10222 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10223
10224 //play sound
10225 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10226 string sound_name = pop_sounds[ sound_idx ];
10227 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
10228
10229 //remove ammo count
10230 magazine.ServerAddAmmoCount(-1);
10231
10232 //if condition then repeat -> ExplodeAmmo
10233 float min_temp_to_explode = 100; //min temperature for item to explode
10234
10235 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10236 {
10237 ExplodeAmmo();
10238 }
10239 }
10240
10241 // -------------------------------------------------------------------------------
10242 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10243 {
10244 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10245
10246 const int CHANCE_DAMAGE_CARGO = 4;
10247 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10248 const int CHANCE_DAMAGE_NOTHING = 2;
10249
10250 if (IsClothing() || IsContainer() || IsItemTent())
10251 {
10252 float dmg = damageResult.GetDamage("","Health") * -0.5;
10253 int chances;
10254 int rnd;
10255
10256 if (GetInventory().GetCargo())
10257 {
10258 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10259 rnd = Math.RandomInt(0,chances);
10260
10261 if (rnd < CHANCE_DAMAGE_CARGO)
10262 {
10263 DamageItemInCargo(dmg);
10264 }
10265 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10266 {
10268 }
10269 }
10270 else
10271 {
10272 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10273 rnd = Math.RandomInt(0,chances);
10274
10275 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10276 {
10278 }
10279 }
10280 }
10281 }
10282
10283 bool DamageItemInCargo(float damage)
10284 {
10285 CargoBase cargo = GetInventory().GetCargo();
10286 if (cargo)
10287 {
10288 int item_count = cargo.GetItemCount();
10289 if (item_count > 0)
10290 {
10291 int random_pick = Math.RandomInt(0, item_count);
10292 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
10293 if (!item.IsExplosive())
10294 {
10295 item.AddHealth("","",damage);
10296 return true;
10297 }
10298 }
10299 }
10300 return false;
10301 }
10302
10303 bool DamageItemAttachments(float damage)
10304 {
10305 GameInventory inventory = GetInventory();
10306 int attachment_count = inventory.AttachmentCount();
10307 if (attachment_count > 0)
10308 {
10309 int random_pick = Math.RandomInt(0, attachment_count);
10310 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
10311 if (!attachment.IsExplosive())
10312 {
10313 attachment.AddHealth("","",damage);
10314 return true;
10315 }
10316 }
10317 return false;
10318 }
10319
10320 override bool IsSplitable()
10321 {
10322 return m_CanThisBeSplit;
10323 }
10324 //----------------
10325 override bool CanBeSplit()
10326 {
10327 if (IsSplitable() && (GetQuantity() > 1))
10328 return GetInventory().CanRemoveEntity();
10329
10330 return false;
10331 }
10332
10333 protected bool ShouldSplitQuantity(float quantity)
10334 {
10335 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10336 if (!IsSplitable())
10337 return false;
10338
10339 // nothing to split?
10340 if (GetQuantity() <= 1)
10341 return false;
10342
10343 // check if we should re-use the item instead of creating a new copy?
10344 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10345 int delta = GetQuantity() - quantity;
10346 if (delta == 0)
10347 return false;
10348
10349 // valid to split
10350 return true;
10351 }
10352
10353 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10354 {
10355 if (g_Game.IsClient())
10356 {
10357 if (ScriptInputUserData.CanStoreInputUserData())
10358 {
10359 ScriptInputUserData ctx = new ScriptInputUserData;
10361 ctx.Write(1);
10362 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10363 ctx.Write(i1);
10364 ctx.Write(destination_entity);
10365 ctx.Write(true);
10366 ctx.Write(slot_id);
10367 ctx.Send();
10368 }
10369 }
10370 else if (!g_Game.IsMultiplayer())
10371 {
10372 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
10373 }
10374 }
10375
10376 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10377 {
10378 float split_quantity_new;
10379 ItemBase new_item;
10380 float quantity = GetQuantity();
10381 float stack_max = GetTargetQuantityMax(slot_id);
10382 InventoryLocation loc = new InventoryLocation;
10383
10384 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10385 {
10386 if (stack_max <= GetQuantity())
10387 split_quantity_new = stack_max;
10388 else
10389 split_quantity_new = GetQuantity();
10390
10391 if (ShouldSplitQuantity(split_quantity_new))
10392 {
10393 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10394 if (new_item)
10395 {
10396 new_item.SetResultOfSplit(true);
10397 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10398 AddQuantity(-split_quantity_new, false, true);
10399 new_item.SetQuantity(split_quantity_new, false, true);
10400 }
10401 }
10402 }
10403 else if (destination_entity && slot_id == -1)
10404 {
10405 if (quantity > stack_max)
10406 split_quantity_new = stack_max;
10407 else
10408 split_quantity_new = quantity;
10409
10410 if (ShouldSplitQuantity(split_quantity_new))
10411 {
10412 GameInventory destinationInventory = destination_entity.GetInventory();
10413 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10414 {
10415 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10416 new_item = ItemBase.Cast(o);
10417 }
10418
10419 if (new_item)
10420 {
10421 new_item.SetResultOfSplit(true);
10422 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10423 AddQuantity(-split_quantity_new, false, true);
10424 new_item.SetQuantity(split_quantity_new, false, true);
10425 }
10426 }
10427 }
10428 else
10429 {
10430 if (stack_max != 0)
10431 {
10432 if (stack_max < GetQuantity())
10433 {
10434 split_quantity_new = GetQuantity() - stack_max;
10435 }
10436
10437 if (split_quantity_new == 0)
10438 {
10439 if (!g_Game.IsMultiplayer())
10440 player.PhysicalPredictiveDropItem(this);
10441 else
10442 player.ServerDropEntity(this);
10443 return;
10444 }
10445
10446 if (ShouldSplitQuantity(split_quantity_new))
10447 {
10448 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10449
10450 if (new_item)
10451 {
10452 new_item.SetResultOfSplit(true);
10453 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10454 SetQuantity(split_quantity_new, false, true);
10455 new_item.SetQuantity(stack_max, false, true);
10456 new_item.PlaceOnSurface();
10457 }
10458 }
10459 }
10460 }
10461 }
10462
10463 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10464 {
10465 float split_quantity_new;
10466 ItemBase new_item;
10467 float quantity = GetQuantity();
10468 float stack_max = GetTargetQuantityMax(slot_id);
10469 InventoryLocation loc = new InventoryLocation;
10470
10471 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10472 {
10473 if (stack_max <= GetQuantity())
10474 split_quantity_new = stack_max;
10475 else
10476 split_quantity_new = GetQuantity();
10477
10478 if (ShouldSplitQuantity(split_quantity_new))
10479 {
10480 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10481 if (new_item)
10482 {
10483 new_item.SetResultOfSplit(true);
10484 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10485 AddQuantity(-split_quantity_new, false, true);
10486 new_item.SetQuantity(split_quantity_new, false, true);
10487 }
10488 }
10489 }
10490 else if (destination_entity && slot_id == -1)
10491 {
10492 if (quantity > stack_max)
10493 split_quantity_new = stack_max;
10494 else
10495 split_quantity_new = quantity;
10496
10497 if (ShouldSplitQuantity(split_quantity_new))
10498 {
10499 GameInventory destinationInventory = destination_entity.GetInventory();
10500 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10501 {
10502 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10503 new_item = ItemBase.Cast(o);
10504 }
10505
10506 if (new_item)
10507 {
10508 new_item.SetResultOfSplit(true);
10509 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10510 AddQuantity(-split_quantity_new, false, true);
10511 new_item.SetQuantity(split_quantity_new, false, true);
10512 }
10513 }
10514 }
10515 else
10516 {
10517 if (stack_max != 0)
10518 {
10519 if (stack_max < GetQuantity())
10520 {
10521 split_quantity_new = GetQuantity() - stack_max;
10522 }
10523
10524 if (ShouldSplitQuantity(split_quantity_new))
10525 {
10526 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10527
10528 if (new_item)
10529 {
10530 new_item.SetResultOfSplit(true);
10531 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10532 SetQuantity(split_quantity_new, false, true);
10533 new_item.SetQuantity(stack_max, false, true);
10534 new_item.PlaceOnSurface();
10535 }
10536 }
10537 }
10538 }
10539 }
10540
10541 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10542 {
10543 if (g_Game.IsClient())
10544 {
10545 if (ScriptInputUserData.CanStoreInputUserData())
10546 {
10547 ScriptInputUserData ctx = new ScriptInputUserData;
10549 ctx.Write(4);
10550 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10551 ctx.Write(thiz);
10552 dst.WriteToContext(ctx);
10553 ctx.Send();
10554 }
10555 }
10556 else if (!g_Game.IsMultiplayer())
10557 {
10559 }
10560 }
10561
10562 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10563 {
10564 if (g_Game.IsClient())
10565 {
10566 if (ScriptInputUserData.CanStoreInputUserData())
10567 {
10568 ScriptInputUserData ctx = new ScriptInputUserData;
10570 ctx.Write(2);
10571 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10572 ctx.Write(dummy);
10573 ctx.Write(destination_entity);
10574 ctx.Write(true);
10575 ctx.Write(idx);
10576 ctx.Write(row);
10577 ctx.Write(col);
10578 ctx.Send();
10579 }
10580 }
10581 else if (!g_Game.IsMultiplayer())
10582 {
10583 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10584 }
10585 }
10586
10587 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10588 {
10590 }
10591
10592 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10593 {
10594 float quantity = GetQuantity();
10595 float split_quantity_new;
10596 ItemBase new_item;
10597 if (dst.IsValid())
10598 {
10599 int slot_id = dst.GetSlot();
10600 float stack_max = GetTargetQuantityMax(slot_id);
10601
10602 if (quantity > stack_max)
10603 split_quantity_new = stack_max;
10604 else
10605 split_quantity_new = quantity;
10606
10607 if (ShouldSplitQuantity(split_quantity_new))
10608 {
10609 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10610
10611 if (new_item)
10612 {
10613 new_item.SetResultOfSplit(true);
10614 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10615 AddQuantity(-split_quantity_new, false, true);
10616 new_item.SetQuantity(split_quantity_new, false, true);
10617 }
10618
10619 return new_item;
10620 }
10621 }
10622
10623 return null;
10624 }
10625
10626 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10627 {
10628 float quantity = GetQuantity();
10629 float split_quantity_new;
10630 ItemBase new_item;
10631 if (destination_entity)
10632 {
10633 float stackable = GetTargetQuantityMax();
10634 if (quantity > stackable)
10635 split_quantity_new = stackable;
10636 else
10637 split_quantity_new = quantity;
10638
10639 if (ShouldSplitQuantity(split_quantity_new))
10640 {
10641 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10642 if (new_item)
10643 {
10644 new_item.SetResultOfSplit(true);
10645 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10646 AddQuantity(-split_quantity_new, false, true);
10647 new_item.SetQuantity(split_quantity_new, false, true);
10648 }
10649 }
10650 }
10651 }
10652
10653 void SplitIntoStackMaxHandsClient(PlayerBase player)
10654 {
10655 if (g_Game.IsClient())
10656 {
10657 if (ScriptInputUserData.CanStoreInputUserData())
10658 {
10659 ScriptInputUserData ctx = new ScriptInputUserData;
10661 ctx.Write(3);
10662 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10663 ctx.Write(i1);
10664 ItemBase destination_entity = this;
10665 ctx.Write(destination_entity);
10666 ctx.Write(true);
10667 ctx.Write(0);
10668 ctx.Send();
10669 }
10670 }
10671 else if (!g_Game.IsMultiplayer())
10672 {
10673 SplitIntoStackMaxHands(player);
10674 }
10675 }
10676
10677 void SplitIntoStackMaxHands(PlayerBase player)
10678 {
10679 float quantity = GetQuantity();
10680 float split_quantity_new;
10681 ref ItemBase new_item;
10682 if (player)
10683 {
10684 float stackable = GetTargetQuantityMax();
10685 if (quantity > stackable)
10686 split_quantity_new = stackable;
10687 else
10688 split_quantity_new = quantity;
10689
10690 if (ShouldSplitQuantity(split_quantity_new))
10691 {
10692 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10693 new_item = ItemBase.Cast(in_hands);
10694 if (new_item)
10695 {
10696 new_item.SetResultOfSplit(true);
10697 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10698 AddQuantity(-split_quantity_new, false, true);
10699 new_item.SetQuantity(split_quantity_new, false, true);
10700 }
10701 }
10702 }
10703 }
10704
10705 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10706 {
10707 float quantity = GetQuantity();
10708 float split_quantity_new = Math.Floor(quantity * 0.5);
10709
10710 if (!ShouldSplitQuantity(split_quantity_new))
10711 return;
10712
10713 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10714
10715 if (new_item)
10716 {
10717 if (new_item.GetQuantityMax() < split_quantity_new)
10718 {
10719 split_quantity_new = new_item.GetQuantityMax();
10720 }
10721
10722 new_item.SetResultOfSplit(true);
10723 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10724
10725 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10726 {
10727 AddQuantity(-1, false, true);
10728 new_item.SetQuantity(1, false, true);
10729 }
10730 else
10731 {
10732 AddQuantity(-split_quantity_new, false, true);
10733 new_item.SetQuantity(split_quantity_new, false, true);
10734 }
10735 }
10736 }
10737
10738 void SplitItem(PlayerBase player)
10739 {
10740 float quantity = GetQuantity();
10741 float split_quantity_new = Math.Floor(quantity / 2);
10742
10743 if (!ShouldSplitQuantity(split_quantity_new))
10744 return;
10745
10746 InventoryLocation invloc = new InventoryLocation;
10747 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10748
10749 ItemBase new_item;
10750 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10751
10752 if (new_item)
10753 {
10754 if (new_item.GetQuantityMax() < split_quantity_new)
10755 {
10756 split_quantity_new = new_item.GetQuantityMax();
10757 }
10758 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10759 {
10760 AddQuantity(-1, false, true);
10761 new_item.SetQuantity(1, false, true);
10762 }
10763 else if (split_quantity_new > 1)
10764 {
10765 AddQuantity(-split_quantity_new, false, true);
10766 new_item.SetQuantity(split_quantity_new, false, true);
10767 }
10768 }
10769 }
10770
10772 void OnQuantityChanged(float delta)
10773 {
10774 SetWeightDirty();
10775 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10776
10777 if (parent)
10778 parent.OnAttachmentQuantityChangedEx(this, delta);
10779
10780 if (IsLiquidContainer())
10781 {
10782 if (GetQuantityNormalized() <= 0.0)
10783 {
10785 }
10786 else if (GetLiquidType() == LIQUID_NONE)
10787 {
10788 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10790 }
10791 }
10792 }
10793
10796 {
10797 // insert code here
10798 }
10799
10801 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10802 {
10804 }
10805
10806 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10807 {
10808 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10809
10810 if (g_Game.IsServer())
10811 {
10812 if (newLevel == GameConstants.STATE_RUINED)
10813 {
10815 EntityAI parent = GetHierarchyParent();
10816 if (parent && parent.IsFireplace())
10817 {
10818 CargoBase cargo = GetInventory().GetCargo();
10819 if (cargo)
10820 {
10821 for (int i = 0; i < cargo.GetItemCount(); ++i)
10822 {
10823 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10824 }
10825 }
10826 }
10827 }
10828
10829 if (IsResultOfSplit())
10830 {
10831 // reset the splitting result flag, return to normal item behavior
10832 SetResultOfSplit(false);
10833 return;
10834 }
10835
10836 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10837 {
10838 SetCleanness(0);//unclean the item upon damage dealt
10839 }
10840 }
10841 }
10842
10843 // just the split? TODO: verify
10844 override void OnRightClick()
10845 {
10846 super.OnRightClick();
10847
10848 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10849 {
10850 if (g_Game.IsClient())
10851 {
10852 if (ScriptInputUserData.CanStoreInputUserData())
10853 {
10854 EntityAI root = GetHierarchyRoot();
10855 Man playerOwner = GetHierarchyRootPlayer();
10856 InventoryLocation dst = new InventoryLocation;
10857
10858 // 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
10859 if (!playerOwner && root && root == this)
10860 {
10862 }
10863 else
10864 {
10865 // 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
10866 GetInventory().GetCurrentInventoryLocation(dst);
10867 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10868 {
10869 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10870 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10871 {
10873 }
10874 else
10875 {
10876 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10877 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10878 this shouldnt cause issues within this scope*/
10879 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10880 {
10882 }
10883 else
10884 {
10885 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10886 }
10887 }
10888 }
10889 }
10890
10891 ScriptInputUserData ctx = new ScriptInputUserData;
10893 ctx.Write(4);
10894 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10895 ctx.Write(thiz);
10896 dst.WriteToContext(ctx);
10897 ctx.Write(true); // dummy
10898 ctx.Send();
10899 }
10900 }
10901 else if (!g_Game.IsMultiplayer())
10902 {
10903 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10904 }
10905 }
10906 }
10907
10908 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10909 {
10910 if (root)
10911 {
10912 vector m4[4];
10913 root.GetTransform(m4);
10914 dst.SetGround(this, m4);
10915 }
10916 else
10917 {
10918 GetInventory().GetCurrentInventoryLocation(dst);
10919 }
10920 }
10921
10922 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10923 {
10924 //TODO: delete check zero quantity check after fix double posts hands fsm events
10925 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10926 return false;
10927
10928 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10929 return false;
10930
10931 //can_this_be_combined = ConfigGetBool("canBeSplit");
10933 return false;
10934
10935
10936 Magazine mag = Magazine.Cast(this);
10937 if (mag)
10938 {
10939 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10940 return false;
10941
10942 if (stack_max_limit)
10943 {
10944 Magazine other_mag = Magazine.Cast(other_item);
10945 if (other_item)
10946 {
10947 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10948 return false;
10949 }
10950
10951 }
10952 }
10953 else
10954 {
10955 //TODO: delete check zero quantity check after fix double posts hands fsm events
10956 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10957 return false;
10958
10959 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10960 return false;
10961 }
10962
10963 PlayerBase player = null;
10964 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10965 {
10966 if (player.GetInventory().HasAttachment(this))
10967 return false;
10968
10969 if (player.IsItemsToDelete())
10970 return false;
10971 }
10972
10973 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10974 return false;
10975
10976 int slotID;
10977 string slotName;
10978 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10979 return false;
10980
10981 return true;
10982 }
10983
10984 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10985 {
10986 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10987 }
10988
10989 bool IsResultOfSplit()
10990 {
10991 return m_IsResultOfSplit;
10992 }
10993
10994 void SetResultOfSplit(bool value)
10995 {
10996 m_IsResultOfSplit = value;
10997 }
10998
10999 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11000 {
11001 return ComputeQuantityUsedEx(other_item, use_stack_max);
11002 }
11003
11004 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11005 {
11006 float other_item_quantity = other_item.GetQuantity();
11007 float this_free_space;
11008
11009 float stack_max = GetQuantityMax();
11010
11011 this_free_space = stack_max - GetQuantity();
11012
11013 if (other_item_quantity > this_free_space)
11014 {
11015 return this_free_space;
11016 }
11017 else
11018 {
11019 return other_item_quantity;
11020 }
11021 }
11022
11023 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11024 {
11025 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11026 }
11027
11028 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11029 {
11030 if (!CanBeCombined(other_item, false))
11031 return;
11032
11033 if (!IsMagazine() && other_item)
11034 {
11035 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11036 if (quantity_used != 0)
11037 {
11038 float hp1 = GetHealth01("","");
11039 float hp2 = other_item.GetHealth01("","");
11040 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11041 hpResult = hpResult / (GetQuantity() + quantity_used);
11042
11043 hpResult *= GetMaxHealth();
11044 Math.Round(hpResult);
11045 SetHealth("", "Health", hpResult);
11046
11047 AddQuantity(quantity_used);
11048 other_item.AddQuantity(-quantity_used);
11049 }
11050 }
11051 OnCombine(other_item);
11052 }
11053
11054 void OnCombine(ItemBase other_item)
11055 {
11056 #ifdef SERVER
11057 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11058 GetHierarchyParent().IncreaseLifetimeUp();
11059 #endif
11060 };
11061
11062 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11063 {
11064 PlayerBase p = PlayerBase.Cast(player);
11065
11066 array<int> recipesIds = p.m_Recipes;
11067 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11068 if (moduleRecipesManager)
11069 {
11070 EntityAI itemInHands = player.GetEntityInHands();
11071 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11072 }
11073
11074 for (int i = 0;i < recipesIds.Count(); i++)
11075 {
11076 int key = recipesIds.Get(i);
11077 string recipeName = moduleRecipesManager.GetRecipeName(key);
11078 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11079 }
11080 }
11081
11082 // -------------------------------------------------------------------------
11083 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11084 {
11085 super.GetDebugActions(outputList);
11086
11087 //quantity
11088 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11089 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11090 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11091 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11092 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11093
11094 //health
11095 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11096 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11097 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11098 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11099 //temperature
11100 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11101 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11102 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11103 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11104
11105 //wet
11106 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11107 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11108 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11109
11110 //liquidtype
11111 if (IsLiquidContainer())
11112 {
11113 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11114 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11115 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11116 }
11117
11118 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11119 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11120
11121 // watch
11122 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11123 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11124 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11125
11126 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11127
11128 InventoryLocation loc = new InventoryLocation();
11129 GetInventory().GetCurrentInventoryLocation(loc);
11130 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11131 {
11132 if (Gizmo_IsSupported())
11133 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11134 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11135 }
11136
11137 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11138 }
11139
11140 // -------------------------------------------------------------------------
11141 // -------------------------------------------------------------------------
11142 // -------------------------------------------------------------------------
11143 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11144 {
11145 super.OnAction(action_id, player, ctx);
11146
11147 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
11148 {
11149 switch (action_id)
11150 {
11151 case EActions.GIZMO_OBJECT:
11152 if (GetGizmoApi())
11153 GetGizmoApi().SelectObject(this);
11154 return true;
11155 case EActions.GIZMO_PHYSICS:
11156 if (GetGizmoApi())
11157 GetGizmoApi().SelectPhysics(GetPhysics());
11158 return true;
11159 }
11160 }
11161
11162 if (g_Game.IsServer())
11163 {
11164 switch (action_id)
11165 {
11166 case EActions.DELETE:
11167 Delete();
11168 return true;
11169 }
11170 }
11171
11172 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11173 {
11174 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11175 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11176 PlayerBase p = PlayerBase.Cast(player);
11177 if (EActions.RECIPES_RANGE_START < 1000)
11178 {
11179 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11180 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11181 }
11182 }
11183 #ifndef SERVER
11184 else if (action_id == EActions.WATCH_PLAYER)
11185 {
11186 PluginDeveloper.SetDeveloperItemClientEx(player);
11187 }
11188 #endif
11189 if (g_Game.IsServer())
11190 {
11191 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11192 {
11193 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11194 OnDebugButtonPressServer(id + 1);
11195 }
11196
11197 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11198 {
11199 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11200 InsertAgent(agent_id,100);
11201 }
11202
11203 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11204 {
11205 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11206 RemoveAgent(agent_id2);
11207 }
11208
11209 else if (action_id == EActions.ADD_QUANTITY)
11210 {
11211 if (IsMagazine())
11212 {
11213 Magazine mag = Magazine.Cast(this);
11214 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11215 }
11216 else
11217 {
11218 AddQuantity(GetQuantityMax() * 0.2);
11219 }
11220
11221 if (m_EM)
11222 {
11223 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11224 }
11225 //PrintVariables();
11226 }
11227
11228 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11229 {
11230 if (IsMagazine())
11231 {
11232 Magazine mag2 = Magazine.Cast(this);
11233 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11234 }
11235 else
11236 {
11237 AddQuantity(- GetQuantityMax() * 0.2);
11238 }
11239 if (m_EM)
11240 {
11241 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11242 }
11243 //PrintVariables();
11244 }
11245
11246 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11247 {
11248 SetQuantity(0);
11249
11250 if (m_EM)
11251 {
11252 m_EM.SetEnergy(0);
11253 }
11254 }
11255
11256 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11257 {
11259
11260 if (m_EM)
11261 {
11262 m_EM.SetEnergy(m_EM.GetEnergyMax());
11263 }
11264 }
11265
11266 else if (action_id == EActions.ADD_HEALTH)
11267 {
11268 AddHealth("","",GetMaxHealth("","Health")/5);
11269 }
11270 else if (action_id == EActions.REMOVE_HEALTH)
11271 {
11272 AddHealth("","",-GetMaxHealth("","Health")/5);
11273 }
11274 else if (action_id == EActions.DESTROY_HEALTH)
11275 {
11276 SetHealth01("","",0);
11277 }
11278 else if (action_id == EActions.WATCH_ITEM)
11279 {
11281 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11282 #ifdef DEVELOPER
11283 SetDebugDeveloper_item(this);
11284 #endif
11285 }
11286
11287 else if (action_id == EActions.ADD_TEMPERATURE)
11288 {
11289 AddTemperature(20);
11290 //PrintVariables();
11291 }
11292
11293 else if (action_id == EActions.REMOVE_TEMPERATURE)
11294 {
11295 AddTemperature(-20);
11296 //PrintVariables();
11297 }
11298
11299 else if (action_id == EActions.FLIP_FROZEN)
11300 {
11301 SetFrozen(!GetIsFrozen());
11302 //PrintVariables();
11303 }
11304
11305 else if (action_id == EActions.ADD_WETNESS)
11306 {
11307 AddWet(GetWetMax()/5);
11308 //PrintVariables();
11309 }
11310
11311 else if (action_id == EActions.REMOVE_WETNESS)
11312 {
11313 AddWet(-GetWetMax()/5);
11314 //PrintVariables();
11315 }
11316
11317 else if (action_id == EActions.LIQUIDTYPE_UP)
11318 {
11319 int curr_type = GetLiquidType();
11320 SetLiquidType(curr_type * 2);
11321 //AddWet(1);
11322 //PrintVariables();
11323 }
11324
11325 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11326 {
11327 int curr_type2 = GetLiquidType();
11328 SetLiquidType(curr_type2 / 2);
11329 }
11330
11331 else if (action_id == EActions.MAKE_SPECIAL)
11332 {
11333 auto debugParams = DebugSpawnParams.WithPlayer(player);
11334 OnDebugSpawnEx(debugParams);
11335 }
11336
11337 }
11338
11339
11340 return false;
11341 }
11342
11343 // -------------------------------------------------------------------------
11344
11345
11348 void OnActivatedByTripWire();
11349
11351 void OnActivatedByItem(notnull ItemBase item);
11352
11353 //----------------------------------------------------------------
11354 //returns true if item is able to explode when put in fire
11355 bool CanExplodeInFire()
11356 {
11357 return false;
11358 }
11359
11360 //----------------------------------------------------------------
11361 bool CanEat()
11362 {
11363 return true;
11364 }
11365
11366 //----------------------------------------------------------------
11367 override bool IsIgnoredByConstruction()
11368 {
11369 return true;
11370 }
11371
11372 //----------------------------------------------------------------
11373 //has FoodStages in config?
11374 bool HasFoodStage()
11375 {
11376 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11377 return g_Game.ConfigIsExisting(config_path);
11378 }
11379
11381 FoodStage GetFoodStage()
11382 {
11383 return null;
11384 }
11385
11386 bool CanBeCooked()
11387 {
11388 return false;
11389 }
11390
11391 bool CanBeCookedOnStick()
11392 {
11393 return false;
11394 }
11395
11397 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11399
11400 //----------------------------------------------------------------
11401 bool CanRepair(ItemBase item_repair_kit)
11402 {
11403 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11404 return module_repairing.CanRepair(this, item_repair_kit);
11405 }
11406
11407 //----------------------------------------------------------------
11408 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11409 {
11410 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11411 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11412 }
11413
11414 //----------------------------------------------------------------
11415 int GetItemSize()
11416 {
11417 /*
11418 vector v_size = this.ConfigGetVector("itemSize");
11419 int v_size_x = v_size[0];
11420 int v_size_y = v_size[1];
11421 int size = v_size_x * v_size_y;
11422 return size;
11423 */
11424
11425 return 1;
11426 }
11427
11428 //----------------------------------------------------------------
11429 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11430 bool CanBeMovedOverride()
11431 {
11432 return m_CanBeMovedOverride;
11433 }
11434
11435 //----------------------------------------------------------------
11436 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11437 void SetCanBeMovedOverride(bool setting)
11438 {
11439 m_CanBeMovedOverride = setting;
11440 }
11441
11442 //----------------------------------------------------------------
11450 void MessageToOwnerStatus(string text)
11451 {
11452 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11453
11454 if (player)
11455 {
11456 player.MessageStatus(text);
11457 }
11458 }
11459
11460 //----------------------------------------------------------------
11468 void MessageToOwnerAction(string text)
11469 {
11470 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11471
11472 if (player)
11473 {
11474 player.MessageAction(text);
11475 }
11476 }
11477
11478 //----------------------------------------------------------------
11486 void MessageToOwnerFriendly(string text)
11487 {
11488 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11489
11490 if (player)
11491 {
11492 player.MessageFriendly(text);
11493 }
11494 }
11495
11496 //----------------------------------------------------------------
11504 void MessageToOwnerImportant(string text)
11505 {
11506 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11507
11508 if (player)
11509 {
11510 player.MessageImportant(text);
11511 }
11512 }
11513
11514 override bool IsItemBase()
11515 {
11516 return true;
11517 }
11518
11519 // Checks if item is of questioned kind
11520 override bool KindOf(string tag)
11521 {
11522 bool found = false;
11523 string item_name = this.GetType();
11524 ref TStringArray item_tag_array = new TStringArray;
11525 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11526
11527 int array_size = item_tag_array.Count();
11528 for (int i = 0; i < array_size; i++)
11529 {
11530 if (item_tag_array.Get(i) == tag)
11531 {
11532 found = true;
11533 break;
11534 }
11535 }
11536 return found;
11537 }
11538
11539
11540 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11541 {
11542 //Debug.Log("OnRPC called");
11543 super.OnRPC(sender, rpc_type,ctx);
11544
11545 //Play soundset for attachment locking (ActionLockAttachment.c)
11546 switch (rpc_type)
11547 {
11548 #ifndef SERVER
11549 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11550 Param2<bool, string> p = new Param2<bool, string>(false, "");
11551
11552 if (!ctx.Read(p))
11553 return;
11554
11555 bool play = p.param1;
11556 string soundSet = p.param2;
11557
11558 if (play)
11559 {
11560 if (m_LockingSound)
11561 {
11563 {
11564 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11565 }
11566 }
11567 else
11568 {
11569 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11570 }
11571 }
11572 else
11573 {
11574 SEffectManager.DestroyEffect(m_LockingSound);
11575 }
11576
11577 break;
11578 #endif
11579
11580 }
11581
11582 if (GetWrittenNoteData())
11583 {
11584 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11585 }
11586 }
11587
11588 //-----------------------------
11589 // VARIABLE MANIPULATION SYSTEM
11590 //-----------------------------
11591 int NameToID(string name)
11592 {
11593 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11594 return plugin.GetID(name);
11595 }
11596
11597 string IDToName(int id)
11598 {
11599 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11600 return plugin.GetName(id);
11601 }
11602
11604 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11605 {
11606 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11607 //read the flags
11608 int varFlags;
11609 if (!ctx.Read(varFlags))
11610 return;
11611
11612 if (varFlags & ItemVariableFlags.FLOAT)
11613 {
11614 ReadVarsFromCTX(ctx);
11615 }
11616 }
11617
11618 override void SerializeNumericalVars(array<float> floats_out)
11619 {
11620 //some variables handled on EntityAI level already!
11621 super.SerializeNumericalVars(floats_out);
11622
11623 // the order of serialization must be the same as the order of de-serialization
11624 //--------------------------------------------
11625 if (IsVariableSet(VARIABLE_QUANTITY))
11626 {
11627 floats_out.Insert(m_VarQuantity);
11628 }
11629 //--------------------------------------------
11630 if (IsVariableSet(VARIABLE_WET))
11631 {
11632 floats_out.Insert(m_VarWet);
11633 }
11634 //--------------------------------------------
11635 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11636 {
11637 floats_out.Insert(m_VarLiquidType);
11638 }
11639 //--------------------------------------------
11640 if (IsVariableSet(VARIABLE_COLOR))
11641 {
11642 floats_out.Insert(m_ColorComponentR);
11643 floats_out.Insert(m_ColorComponentG);
11644 floats_out.Insert(m_ColorComponentB);
11645 floats_out.Insert(m_ColorComponentA);
11646 }
11647 //--------------------------------------------
11648 if (IsVariableSet(VARIABLE_CLEANNESS))
11649 {
11650 floats_out.Insert(m_Cleanness);
11651 }
11652 }
11653
11654 override void DeSerializeNumericalVars(array<float> floats)
11655 {
11656 //some variables handled on EntityAI level already!
11657 super.DeSerializeNumericalVars(floats);
11658
11659 // the order of serialization must be the same as the order of de-serialization
11660 int index = 0;
11661 int mask = Math.Round(floats.Get(index));
11662
11663 index++;
11664 //--------------------------------------------
11665 if (mask & VARIABLE_QUANTITY)
11666 {
11667 if (m_IsStoreLoad)
11668 {
11669 SetStoreLoadedQuantity(floats.Get(index));
11670 }
11671 else
11672 {
11673 float quantity = floats.Get(index);
11674 SetQuantity(quantity, true, false, false, false);
11675 }
11676 index++;
11677 }
11678 //--------------------------------------------
11679 if (mask & VARIABLE_WET)
11680 {
11681 float wet = floats.Get(index);
11682 SetWet(wet);
11683 index++;
11684 }
11685 //--------------------------------------------
11686 if (mask & VARIABLE_LIQUIDTYPE)
11687 {
11688 int liquidtype = Math.Round(floats.Get(index));
11689 SetLiquidType(liquidtype);
11690 index++;
11691 }
11692 //--------------------------------------------
11693 if (mask & VARIABLE_COLOR)
11694 {
11695 m_ColorComponentR = Math.Round(floats.Get(index));
11696 index++;
11697 m_ColorComponentG = Math.Round(floats.Get(index));
11698 index++;
11699 m_ColorComponentB = Math.Round(floats.Get(index));
11700 index++;
11701 m_ColorComponentA = Math.Round(floats.Get(index));
11702 index++;
11703 }
11704 //--------------------------------------------
11705 if (mask & VARIABLE_CLEANNESS)
11706 {
11707 int cleanness = Math.Round(floats.Get(index));
11708 SetCleanness(cleanness);
11709 index++;
11710 }
11711 }
11712
11713 override void WriteVarsToCTX(ParamsWriteContext ctx)
11714 {
11715 super.WriteVarsToCTX(ctx);
11716
11717 //--------------------------------------------
11718 if (IsVariableSet(VARIABLE_QUANTITY))
11719 {
11720 ctx.Write(GetQuantity());
11721 }
11722 //--------------------------------------------
11723 if (IsVariableSet(VARIABLE_WET))
11724 {
11725 ctx.Write(GetWet());
11726 }
11727 //--------------------------------------------
11728 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11729 {
11730 ctx.Write(GetLiquidType());
11731 }
11732 //--------------------------------------------
11733 if (IsVariableSet(VARIABLE_COLOR))
11734 {
11735 int r,g,b,a;
11736 GetColor(r,g,b,a);
11737 ctx.Write(r);
11738 ctx.Write(g);
11739 ctx.Write(b);
11740 ctx.Write(a);
11741 }
11742 //--------------------------------------------
11743 if (IsVariableSet(VARIABLE_CLEANNESS))
11744 {
11745 ctx.Write(GetCleanness());
11746 }
11747 }
11748
11749 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11750 {
11751 if (!super.ReadVarsFromCTX(ctx,version))
11752 return false;
11753
11754 int intValue;
11755 float value;
11756
11757 if (version < 140)
11758 {
11759 if (!ctx.Read(intValue))
11760 return false;
11761
11762 m_VariablesMask = intValue;
11763 }
11764
11765 if (m_VariablesMask & VARIABLE_QUANTITY)
11766 {
11767 if (!ctx.Read(value))
11768 return false;
11769
11770 if (IsStoreLoad())
11771 {
11773 }
11774 else
11775 {
11776 SetQuantity(value, true, false, false, false);
11777 }
11778 }
11779 //--------------------------------------------
11780 if (version < 140)
11781 {
11782 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11783 {
11784 if (!ctx.Read(value))
11785 return false;
11786 SetTemperatureDirect(value);
11787 }
11788 }
11789 //--------------------------------------------
11790 if (m_VariablesMask & VARIABLE_WET)
11791 {
11792 if (!ctx.Read(value))
11793 return false;
11794 SetWet(value);
11795 }
11796 //--------------------------------------------
11797 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11798 {
11799 if (!ctx.Read(intValue))
11800 return false;
11801 SetLiquidType(intValue);
11802 }
11803 //--------------------------------------------
11804 if (m_VariablesMask & VARIABLE_COLOR)
11805 {
11806 int r,g,b,a;
11807 if (!ctx.Read(r))
11808 return false;
11809 if (!ctx.Read(g))
11810 return false;
11811 if (!ctx.Read(b))
11812 return false;
11813 if (!ctx.Read(a))
11814 return false;
11815
11816 SetColor(r,g,b,a);
11817 }
11818 //--------------------------------------------
11819 if (m_VariablesMask & VARIABLE_CLEANNESS)
11820 {
11821 if (!ctx.Read(intValue))
11822 return false;
11823 SetCleanness(intValue);
11824 }
11825 //--------------------------------------------
11826 if (version >= 138 && version < 140)
11827 {
11828 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11829 {
11830 if (!ctx.Read(intValue))
11831 return false;
11832 SetFrozen(intValue);
11833 }
11834 }
11835
11836 return true;
11837 }
11838
11839 //----------------------------------------------------------------
11840 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11841 {
11842 m_IsStoreLoad = true;
11844 {
11845 m_FixDamageSystemInit = true;
11846 }
11847
11848 if (!super.OnStoreLoad(ctx, version))
11849 {
11850 m_IsStoreLoad = false;
11851 return false;
11852 }
11853
11854 if (version >= 114)
11855 {
11856 bool hasQuickBarIndexSaved;
11857
11858 if (!ctx.Read(hasQuickBarIndexSaved))
11859 {
11860 m_IsStoreLoad = false;
11861 return false;
11862 }
11863
11864 if (hasQuickBarIndexSaved)
11865 {
11866 int itmQBIndex;
11867
11868 //Load quickbar item bind
11869 if (!ctx.Read(itmQBIndex))
11870 {
11871 m_IsStoreLoad = false;
11872 return false;
11873 }
11874
11875 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11876 if (itmQBIndex != -1 && parentPlayer)
11877 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11878 }
11879 }
11880 else
11881 {
11882 // Backup of how it used to be
11883 PlayerBase player;
11884 int itemQBIndex;
11885 if (version == int.MAX)
11886 {
11887 if (!ctx.Read(itemQBIndex))
11888 {
11889 m_IsStoreLoad = false;
11890 return false;
11891 }
11892 }
11893 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11894 {
11895 //Load quickbar item bind
11896 if (!ctx.Read(itemQBIndex))
11897 {
11898 m_IsStoreLoad = false;
11899 return false;
11900 }
11901 if (itemQBIndex != -1 && player)
11902 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11903 }
11904 }
11905
11906 if (version < 140)
11907 {
11908 // variable management system
11909 if (!LoadVariables(ctx, version))
11910 {
11911 m_IsStoreLoad = false;
11912 return false;
11913 }
11914 }
11915
11916 //agent trasmission system
11917 if (!LoadAgents(ctx, version))
11918 {
11919 m_IsStoreLoad = false;
11920 return false;
11921 }
11922 if (version >= 132)
11923 {
11924 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11925 if (raib)
11926 {
11927 if (!raib.OnStoreLoad(ctx,version))
11928 {
11929 m_IsStoreLoad = false;
11930 return false;
11931 }
11932 }
11933 }
11934
11935 m_IsStoreLoad = false;
11936 return true;
11937 }
11938
11939 //----------------------------------------------------------------
11940
11941 override void OnStoreSave(ParamsWriteContext ctx)
11942 {
11943 super.OnStoreSave(ctx);
11944
11945 PlayerBase player;
11946 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11947 {
11948 ctx.Write(true); // Keep track of if we should actually read this in or not
11949 //Save quickbar item bind
11950 int itemQBIndex = -1;
11951 itemQBIndex = player.FindQuickBarEntityIndex(this);
11952 ctx.Write(itemQBIndex);
11953 }
11954 else
11955 {
11956 ctx.Write(false); // Keep track of if we should actually read this in or not
11957 }
11958
11959 SaveAgents(ctx);//agent trasmission system
11960
11961 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11962 if (raib)
11963 {
11964 raib.OnStoreSave(ctx);
11965 }
11966 }
11967 //----------------------------------------------------------------
11968
11969 override void AfterStoreLoad()
11970 {
11971 super.AfterStoreLoad();
11972
11974 {
11976 }
11977
11978 if (GetStoreLoadedQuantity() != float.LOWEST)
11979 {
11981 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
11982 }
11983 }
11984
11985 override void EEOnAfterLoad()
11986 {
11987 super.EEOnAfterLoad();
11988
11990 {
11991 m_FixDamageSystemInit = false;
11992 }
11993
11996 }
11997
11998 bool CanBeDisinfected()
11999 {
12000 return false;
12001 }
12002
12003
12004 //----------------------------------------------------------------
12005 override void OnVariablesSynchronized()
12006 {
12007 if (m_Initialized)
12008 {
12009 #ifdef PLATFORM_CONSOLE
12010 //bruteforce it is
12011 if (IsSplitable())
12012 {
12013 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
12014 if (menu)
12015 {
12016 menu.Refresh();
12017 }
12018 }
12019 #endif
12020 }
12021
12023 {
12024 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12025 m_WantPlayImpactSound = false;
12026 }
12027
12029 {
12030 SetWeightDirty();
12032 }
12033 if (m_VarWet != m_VarWetPrev)
12034 {
12037 }
12038
12039 if (m_SoundSyncPlay != 0)
12040 {
12043
12044 m_SoundSyncPlay = 0;
12045 m_SoundSyncSlotID = -1;
12046 }
12047 if (m_SoundSyncStop != 0)
12048 {
12050 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12051 m_SoundSyncStop = 0;
12052 }
12053
12054 super.OnVariablesSynchronized();
12055 }
12056
12057 //------------------------- Quantity
12058 //----------------------------------------------------------------
12060 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12061 {
12062 if (!IsServerCheck(allow_client))
12063 return false;
12064
12065 if (!HasQuantity())
12066 return false;
12067
12068 float min = GetQuantityMin();
12069 float max = GetQuantityMax();
12070
12071 if (value <= (min + 0.001))
12072 value = min;
12073
12074 if (value == min)
12075 {
12076 if (destroy_config)
12077 {
12078 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12079 if (dstr)
12080 {
12081 m_VarQuantity = Math.Clamp(value, min, max);
12082 this.Delete();
12083 return true;
12084 }
12085 }
12086 else if (destroy_forced)
12087 {
12088 m_VarQuantity = Math.Clamp(value, min, max);
12089 this.Delete();
12090 return true;
12091 }
12092 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12093 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12094 }
12095
12096 float delta = m_VarQuantity;
12097 m_VarQuantity = Math.Clamp(value, min, max);
12098
12099 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12100 {
12101 EntityAI parent = GetHierarchyRoot();
12102 InventoryLocation iLoc = new InventoryLocation();
12103 GetInventory().GetCurrentInventoryLocation(iLoc);
12104 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
12105 {
12106 int iLocSlot = iLoc.GetSlot();
12107 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
12108 {
12109 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
12110 }
12111 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
12112 {
12113 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
12114 }
12115 }
12116 }
12117
12118 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12119 {
12120 delta = m_VarQuantity - delta;
12121
12122 if (delta)
12123 OnQuantityChanged(delta);
12124 }
12125
12126 SetVariableMask(VARIABLE_QUANTITY);
12127
12128 return false;
12129 }
12130
12131 //----------------------------------------------------------------
12133 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12134 {
12135 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12136 }
12137 //----------------------------------------------------------------
12138 void SetQuantityMax()
12139 {
12140 float max = GetQuantityMax();
12141 SetQuantity(max);
12142 }
12143
12144 override void SetQuantityToMinimum()
12145 {
12146 float min = GetQuantityMin();
12147 SetQuantity(min);
12148 }
12149 //----------------------------------------------------------------
12151 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12152 {
12153 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12154 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12155 SetQuantity(result, destroy_config, destroy_forced);
12156 }
12157
12158 //----------------------------------------------------------------
12160 override float GetQuantityNormalized()
12161 {
12162 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12163 }
12164
12166 {
12167 return GetQuantityNormalized();
12168 }
12169
12170 /*void SetAmmoNormalized(float value)
12171 {
12172 float value_clamped = Math.Clamp(value, 0, 1);
12173 Magazine this_mag = Magazine.Cast(this);
12174 int max_rounds = this_mag.GetAmmoMax();
12175 int result = value * max_rounds;//can the rounded if higher precision is required
12176 this_mag.SetAmmoCount(result);
12177 }*/
12178 //----------------------------------------------------------------
12179 override int GetQuantityMax()
12180 {
12181 int slot = -1;
12182 GameInventory inventory = GetInventory();
12183 if (inventory)
12184 {
12185 InventoryLocation il = new InventoryLocation;
12186 inventory.GetCurrentInventoryLocation(il);
12187 slot = il.GetSlot();
12188 }
12189
12190 return GetTargetQuantityMax(slot);
12191 }
12192
12193 override int GetTargetQuantityMax(int attSlotID = -1)
12194 {
12195 float quantity_max = 0;
12196
12197 if (IsSplitable()) //only stackable/splitable items can check for stack size
12198 {
12199 if (attSlotID != -1)
12200 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12201
12202 if (quantity_max <= 0)
12203 quantity_max = m_VarStackMax;
12204 }
12205
12206 if (quantity_max <= 0)
12207 quantity_max = m_VarQuantityMax;
12208
12209 return quantity_max;
12210 }
12211 //----------------------------------------------------------------
12212 override int GetQuantityMin()
12213 {
12214 return m_VarQuantityMin;
12215 }
12216 //----------------------------------------------------------------
12217 int GetQuantityInit()
12218 {
12219 return m_VarQuantityInit;
12220 }
12221
12222 //----------------------------------------------------------------
12223 override bool HasQuantity()
12224 {
12225 return !(GetQuantityMax() - GetQuantityMin() == 0);
12226 }
12227
12228 override float GetQuantity()
12229 {
12230 return m_VarQuantity;
12231 }
12232
12233 bool IsFullQuantity()
12234 {
12235 return GetQuantity() >= GetQuantityMax();
12236 }
12237
12238 //Calculates weight of single item without attachments and cargo
12239 override float GetSingleInventoryItemWeightEx()
12240 {
12241 //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
12242 float weightEx = GetWeightEx();//overall weight of the item
12243 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12244 return weightEx - special;
12245 }
12246
12247 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12249 {
12251 }
12252
12253 override protected float GetWeightSpecialized(bool forceRecalc = false)
12254 {
12255 if (IsSplitable()) //quantity determines size of the stack
12256 {
12257 #ifdef DEVELOPER
12258 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12259 {
12260 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12261 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12262 }
12263 #endif
12264
12265 return GetQuantity() * GetConfigWeightModified();
12266 }
12267 else if (HasEnergyManager())// items with energy manager
12268 {
12269 #ifdef DEVELOPER
12270 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12271 {
12272 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12273 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12274 }
12275 #endif
12276 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12277 }
12278 else//everything else
12279 {
12280 #ifdef DEVELOPER
12281 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12282 {
12283 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12284 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12285 }
12286 #endif
12287 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12288 }
12289 }
12290
12292 int GetNumberOfItems()
12293 {
12294 int item_count = 0;
12295 ItemBase item;
12296
12297 GameInventory inventory = GetInventory();
12298 CargoBase cargo = inventory.GetCargo();
12299 if (cargo != NULL)
12300 {
12301 item_count = cargo.GetItemCount();
12302 }
12303
12304 int nAttachments = inventory.AttachmentCount();
12305 for (int i = 0; i < nAttachments; ++i)
12306 {
12307 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
12308 if (item)
12309 item_count += item.GetNumberOfItems();
12310 }
12311 return item_count;
12312 }
12313
12315 float GetUnitWeight(bool include_wetness = true)
12316 {
12317 float weight = 0;
12318 float wetness = 1;
12319 if (include_wetness)
12320 wetness += GetWet();
12321 if (IsSplitable()) //quantity determines size of the stack
12322 {
12323 weight = wetness * m_ConfigWeight;
12324 }
12325 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12326 {
12327 weight = 1;
12328 }
12329 return weight;
12330 }
12331
12332 //-----------------------------------------------------------------
12333
12334 override void ClearInventory()
12335 {
12336 GameInventory inventory = GetInventory();
12337 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
12338 {
12339 array<EntityAI> items = new array<EntityAI>;
12340 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
12341 for (int i = 0; i < items.Count(); ++i)
12342 {
12343 ItemBase item = ItemBase.Cast(items.Get(i));
12344 if (item)
12345 {
12346 g_Game.ObjectDelete(item);
12347 }
12348 }
12349 }
12350 }
12351
12352 //------------------------- Energy
12353
12354 //----------------------------------------------------------------
12355 float GetEnergy()
12356 {
12357 float energy = 0;
12358 if (HasEnergyManager())
12359 {
12360 energy = GetCompEM().GetEnergy();
12361 }
12362 return energy;
12363 }
12364
12365
12366 override void OnEnergyConsumed()
12367 {
12368 super.OnEnergyConsumed();
12369
12371 }
12372
12373 override void OnEnergyAdded()
12374 {
12375 super.OnEnergyAdded();
12376
12378 }
12379
12380 // Converts energy (from Energy Manager) to quantity, if enabled.
12382 {
12383 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12384 {
12385 if (HasQuantity())
12386 {
12387 float energy_0to1 = GetCompEM().GetEnergy0To1();
12388 SetQuantityNormalized(energy_0to1);
12389 }
12390 }
12391 }
12392
12393 //----------------------------------------------------------------
12394 float GetHeatIsolationInit()
12395 {
12396 return ConfigGetFloat("heatIsolation");
12397 }
12398
12399 float GetHeatIsolation()
12400 {
12401 return m_HeatIsolation;
12402 }
12403
12404 float GetDryingIncrement(string pIncrementName)
12405 {
12406 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12407 if (g_Game.ConfigIsExisting(paramPath))
12408 return g_Game.ConfigGetFloat(paramPath);
12409
12410 return 0.0;
12411 }
12412
12413 float GetSoakingIncrement(string pIncrementName)
12414 {
12415 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12416 if (g_Game.ConfigIsExisting(paramPath))
12417 return g_Game.ConfigGetFloat(paramPath);
12418
12419 return 0.0;
12420 }
12421 //----------------------------------------------------------------
12422 override void SetWet(float value, bool allow_client = false)
12423 {
12424 if (!IsServerCheck(allow_client))
12425 return;
12426
12427 float min = GetWetMin();
12428 float max = GetWetMax();
12429
12430 float previousValue = m_VarWet;
12431
12432 m_VarWet = Math.Clamp(value, min, max);
12433
12434 if (previousValue != m_VarWet)
12435 {
12436 SetVariableMask(VARIABLE_WET);
12437 OnWetChanged(m_VarWet, previousValue);
12438 }
12439 }
12440 //----------------------------------------------------------------
12441 override void AddWet(float value)
12442 {
12443 SetWet(GetWet() + value);
12444 }
12445 //----------------------------------------------------------------
12446 override void SetWetMax()
12447 {
12449 }
12450 //----------------------------------------------------------------
12451 override float GetWet()
12452 {
12453 return m_VarWet;
12454 }
12455 //----------------------------------------------------------------
12456 override float GetWetMax()
12457 {
12458 return m_VarWetMax;
12459 }
12460 //----------------------------------------------------------------
12461 override float GetWetMin()
12462 {
12463 return m_VarWetMin;
12464 }
12465 //----------------------------------------------------------------
12466 override float GetWetInit()
12467 {
12468 return m_VarWetInit;
12469 }
12470 //----------------------------------------------------------------
12471 override void OnWetChanged(float newVal, float oldVal)
12472 {
12473 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12474 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12475 if (newLevel != oldLevel)
12476 {
12477 OnWetLevelChanged(newLevel,oldLevel);
12478 }
12479 }
12480
12481 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12482 {
12483 SetWeightDirty();
12484 }
12485
12486 override EWetnessLevel GetWetLevel()
12487 {
12488 return GetWetLevelInternal(m_VarWet);
12489 }
12490
12491 //----------------------------------------------------------------
12492
12493 override void SetStoreLoad(bool value)
12494 {
12495 m_IsStoreLoad = value;
12496 }
12497
12498 override bool IsStoreLoad()
12499 {
12500 return m_IsStoreLoad;
12501 }
12502
12503 override void SetStoreLoadedQuantity(float value)
12504 {
12505 m_StoreLoadedQuantity = value;
12506 }
12507
12508 override float GetStoreLoadedQuantity()
12509 {
12510 return m_StoreLoadedQuantity;
12511 }
12512
12513 //----------------------------------------------------------------
12514
12515 float GetItemModelLength()
12516 {
12517 if (ConfigIsExisting("itemModelLength"))
12518 {
12519 return ConfigGetFloat("itemModelLength");
12520 }
12521 return 0;
12522 }
12523
12524 float GetItemAttachOffset()
12525 {
12526 if (ConfigIsExisting("itemAttachOffset"))
12527 {
12528 return ConfigGetFloat("itemAttachOffset");
12529 }
12530 return 0;
12531 }
12532
12533 override void SetCleanness(int value, bool allow_client = false)
12534 {
12535 if (!IsServerCheck(allow_client))
12536 return;
12537
12538 int previousValue = m_Cleanness;
12539
12540 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12541
12542 if (previousValue != m_Cleanness)
12543 SetVariableMask(VARIABLE_CLEANNESS);
12544 }
12545
12546 override int GetCleanness()
12547 {
12548 return m_Cleanness;
12549 }
12550
12552 {
12553 return true;
12554 }
12555
12556 //----------------------------------------------------------------
12557 // ATTACHMENT LOCKING
12558 // Getters relevant to generic ActionLockAttachment
12559 int GetLockType()
12560 {
12561 return m_LockType;
12562 }
12563
12564 string GetLockSoundSet()
12565 {
12566 return m_LockSoundSet;
12567 }
12568
12569 //----------------------------------------------------------------
12570 //------------------------- Color
12571 // sets items color variable given color components
12572 override void SetColor(int r, int g, int b, int a)
12573 {
12578 SetVariableMask(VARIABLE_COLOR);
12579 }
12581 override void GetColor(out int r,out int g,out int b,out int a)
12582 {
12587 }
12588
12589 bool IsColorSet()
12590 {
12591 return IsVariableSet(VARIABLE_COLOR);
12592 }
12593
12595 string GetColorString()
12596 {
12597 int r,g,b,a;
12598 GetColor(r,g,b,a);
12599 r = r/255;
12600 g = g/255;
12601 b = b/255;
12602 a = a/255;
12603 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12604 }
12605 //----------------------------------------------------------------
12606 //------------------------- LiquidType
12607
12608 override void SetLiquidType(int value, bool allow_client = false)
12609 {
12610 if (!IsServerCheck(allow_client))
12611 return;
12612
12613 int old = m_VarLiquidType;
12614 m_VarLiquidType = value;
12615 OnLiquidTypeChanged(old,value);
12616 SetVariableMask(VARIABLE_LIQUIDTYPE);
12617 }
12618
12619 int GetLiquidTypeInit()
12620 {
12621 return ConfigGetInt("varLiquidTypeInit");
12622 }
12623
12624 override int GetLiquidType()
12625 {
12626 return m_VarLiquidType;
12627 }
12628
12629 protected void OnLiquidTypeChanged(int oldType, int newType)
12630 {
12631 if (newType == LIQUID_NONE && GetIsFrozen())
12632 SetFrozen(false);
12633 }
12634
12636 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12637 {
12638 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12639 }
12640
12641 // -------------------------------------------------------------------------
12643 void OnInventoryEnter(Man player)
12644 {
12645 PlayerBase nplayer;
12646 if (PlayerBase.CastTo(nplayer, player))
12647 {
12648 m_CanPlayImpactSound = true;
12649 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12650 }
12651 }
12652
12653 // -------------------------------------------------------------------------
12655 void OnInventoryExit(Man player)
12656 {
12657 PlayerBase nplayer;
12658 if (PlayerBase.CastTo(nplayer,player))
12659 {
12660 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12661 }
12662
12663 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12664
12665 if (HasEnergyManager())
12666 {
12667 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12668 }
12669 }
12670
12671 // ADVANCED PLACEMENT EVENTS
12672 override void OnPlacementStarted(Man player)
12673 {
12674 super.OnPlacementStarted(player);
12675
12676 SetTakeable(false);
12677 }
12678
12679 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12680 {
12681 if (m_AdminLog)
12682 {
12683 m_AdminLog.OnPlacementComplete(player, this);
12684 }
12685
12686 super.OnPlacementComplete(player, position, orientation);
12687 }
12688
12689 //-----------------------------
12690 // AGENT SYSTEM
12691 //-----------------------------
12692 //--------------------------------------------------------------------------
12693 bool ContainsAgent(int agent_id)
12694 {
12695 if (agent_id & m_AttachedAgents)
12696 {
12697 return true;
12698 }
12699 else
12700 {
12701 return false;
12702 }
12703 }
12704
12705 //--------------------------------------------------------------------------
12706 override void RemoveAgent(int agent_id)
12707 {
12708 if (ContainsAgent(agent_id))
12709 {
12710 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12711 }
12712 }
12713
12714 //--------------------------------------------------------------------------
12715 override void RemoveAllAgents()
12716 {
12717 m_AttachedAgents = 0;
12718 }
12719 //--------------------------------------------------------------------------
12720 override void RemoveAllAgentsExcept(int agent_to_keep)
12721 {
12722 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12723 }
12724 // -------------------------------------------------------------------------
12725 override void InsertAgent(int agent, float count = 1)
12726 {
12727 if (count < 1)
12728 return;
12729 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12731 }
12732
12734 void TransferAgents(int agents)
12735 {
12737 }
12738
12739 // -------------------------------------------------------------------------
12740 override int GetAgents()
12741 {
12742 return m_AttachedAgents;
12743 }
12744 //----------------------------------------------------------------------
12745
12746 /*int GetContaminationType()
12747 {
12748 int contamination_type;
12749
12750 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12751 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12752 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12753 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12754
12755 Edible_Base edible = Edible_Base.Cast(this);
12756 int agents = GetAgents();
12757 if (edible)
12758 {
12759 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12760 if (profile)
12761 {
12762 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12763 }
12764 }
12765 if (agents & CONTAMINATED_MASK)
12766 {
12767 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12768 }
12769 if (agents & POISONED_MASK)
12770 {
12771 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12772 }
12773 if (agents & NERVE_GAS_MASK)
12774 {
12775 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12776 }
12777 if (agents & DIRTY_MASK)
12778 {
12779 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12780 }
12781
12782 return agents;
12783 }*/
12784
12785 // -------------------------------------------------------------------------
12786 bool LoadAgents(ParamsReadContext ctx, int version)
12787 {
12788 if (!ctx.Read(m_AttachedAgents))
12789 return false;
12790 return true;
12791 }
12792 // -------------------------------------------------------------------------
12794 {
12795
12797 }
12798 // -------------------------------------------------------------------------
12799
12801 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12802 {
12803 super.CheckForRoofLimited(timeTresholdMS);
12804
12805 float time = g_Game.GetTime();
12806 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12807 {
12808 m_PreviousRoofTestTime = time;
12809 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12810 }
12811 }
12812
12813 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12814 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12815 {
12816 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12817 {
12818 return 0;
12819 }
12820
12821 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12822 {
12823 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12824 if (filter)
12825 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12826 else
12827 return 0;//otherwise return 0 when no filter attached
12828 }
12829
12830 string subclassPath, entryName;
12831
12832 switch (type)
12833 {
12834 case DEF_BIOLOGICAL:
12835 entryName = "biological";
12836 break;
12837 case DEF_CHEMICAL:
12838 entryName = "chemical";
12839 break;
12840 default:
12841 entryName = "biological";
12842 break;
12843 }
12844
12845 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12846
12847 return g_Game.ConfigGetFloat(subclassPath + entryName);
12848 }
12849
12850
12851
12853 override void EEOnCECreate()
12854 {
12855 if (!IsMagazine())
12857
12859 }
12860
12861
12862 //-------------------------
12863 // OPEN/CLOSE USER ACTIONS
12864 //-------------------------
12866 void Open();
12867 void Close();
12868 bool IsOpen()
12869 {
12870 return true;
12871 }
12872
12873 override bool CanDisplayCargo()
12874 {
12875 return IsOpen();
12876 }
12877
12878
12879 // ------------------------------------------------------------
12880 // CONDITIONS
12881 // ------------------------------------------------------------
12882 override bool CanPutInCargo(EntityAI parent)
12883 {
12884 if (parent)
12885 {
12886 if (parent.IsInherited(DayZInfected))
12887 return true;
12888
12889 if (!parent.IsRuined())
12890 return true;
12891 }
12892
12893 return true;
12894 }
12895
12896 override bool CanPutAsAttachment(EntityAI parent)
12897 {
12898 if (!super.CanPutAsAttachment(parent))
12899 {
12900 return false;
12901 }
12902
12903 if (!IsRuined() && !parent.IsRuined())
12904 {
12905 return true;
12906 }
12907
12908 return false;
12909 }
12910
12911 override bool CanReceiveItemIntoCargo(EntityAI item)
12912 {
12913 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12914 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12915 // return false;
12916
12917 return super.CanReceiveItemIntoCargo(item);
12918 }
12919
12920 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12921 {
12922 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12923 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12924 // return false;
12925
12926 GameInventory attachmentInv = attachment.GetInventory();
12927 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12928 {
12929 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12930 return false;
12931 }
12932
12933 InventoryLocation loc = new InventoryLocation();
12934 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12935 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12936 return false;
12937
12938 return super.CanReceiveAttachment(attachment, slotId);
12939 }
12940
12941 override bool CanReleaseAttachment(EntityAI attachment)
12942 {
12943 if (!super.CanReleaseAttachment(attachment))
12944 return false;
12945
12946 return GetInventory().AreChildrenAccessible();
12947 }
12948
12949 /*override bool CanLoadAttachment(EntityAI attachment)
12950 {
12951 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12952 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12953 // return false;
12954
12955 GameInventory attachmentInv = attachment.GetInventory();
12956 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12957 {
12958 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12959 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12960
12961 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12962 return false;
12963 }
12964
12965 return super.CanLoadAttachment(attachment);
12966 }*/
12967
12968 // Plays muzzle flash particle effects
12969 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12970 {
12971 int id = muzzle_owner.GetMuzzleID();
12972 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12973
12974 if (WPOF_array)
12975 {
12976 for (int i = 0; i < WPOF_array.Count(); i++)
12977 {
12978 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12979
12980 if (WPOF)
12981 {
12982 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12983 }
12984 }
12985 }
12986 }
12987
12988 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12989 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12990 {
12991 int id = muzzle_owner.GetMuzzleID();
12992 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12993
12994 if (WPOBE_array)
12995 {
12996 for (int i = 0; i < WPOBE_array.Count(); i++)
12997 {
12998 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12999
13000 if (WPOBE)
13001 {
13002 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13003 }
13004 }
13005 }
13006 }
13007
13008 // Plays all weapon overheating particles
13009 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13010 {
13011 int id = muzzle_owner.GetMuzzleID();
13012 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13013
13014 if (WPOOH_array)
13015 {
13016 for (int i = 0; i < WPOOH_array.Count(); i++)
13017 {
13018 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13019
13020 if (WPOOH)
13021 {
13022 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13023 }
13024 }
13025 }
13026 }
13027
13028 // Updates all weapon overheating particles
13029 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13030 {
13031 int id = muzzle_owner.GetMuzzleID();
13032 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13033
13034 if (WPOOH_array)
13035 {
13036 for (int i = 0; i < WPOOH_array.Count(); i++)
13037 {
13038 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13039
13040 if (WPOOH)
13041 {
13042 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13043 }
13044 }
13045 }
13046 }
13047
13048 // Stops overheating particles
13049 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13050 {
13051 int id = muzzle_owner.GetMuzzleID();
13052 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13053
13054 if (WPOOH_array)
13055 {
13056 for (int i = 0; i < WPOOH_array.Count(); i++)
13057 {
13058 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13059
13060 if (WPOOH)
13061 {
13062 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13063 }
13064 }
13065 }
13066 }
13067
13068 //----------------------------------------------------------------
13069 //Item Behaviour - unified approach
13070 override bool IsHeavyBehaviour()
13071 {
13072 if (m_ItemBehaviour == 0)
13073 {
13074 return true;
13075 }
13076
13077 return false;
13078 }
13079
13080 override bool IsOneHandedBehaviour()
13081 {
13082 if (m_ItemBehaviour == 1)
13083 {
13084 return true;
13085 }
13086
13087 return false;
13088 }
13089
13090 override bool IsTwoHandedBehaviour()
13091 {
13092 if (m_ItemBehaviour == 2)
13093 {
13094 return true;
13095 }
13096
13097 return false;
13098 }
13099
13100 bool IsDeployable()
13101 {
13102 return false;
13103 }
13104
13106 float GetDeployTime()
13107 {
13108 return UATimeSpent.DEFAULT_DEPLOY;
13109 }
13110
13111
13112 //----------------------------------------------------------------
13113 // Item Targeting (User Actions)
13114 override void SetTakeable(bool pState)
13115 {
13116 m_IsTakeable = pState;
13117 SetSynchDirty();
13118 }
13119
13120 override bool IsTakeable()
13121 {
13122 return m_IsTakeable;
13123 }
13124
13125 // For cases where we want to show object widget which cant be taken to hands
13127 {
13128 return false;
13129 }
13130
13132 protected void PreLoadSoundAttachmentType()
13133 {
13134 string att_type = "None";
13135
13136 if (ConfigIsExisting("soundAttType"))
13137 {
13138 att_type = ConfigGetString("soundAttType");
13139 }
13140
13141 m_SoundAttType = att_type;
13142 }
13143
13144 override string GetAttachmentSoundType()
13145 {
13146 return m_SoundAttType;
13147 }
13148
13149 //----------------------------------------------------------------
13150 //SOUNDS - ItemSoundHandler
13151 //----------------------------------------------------------------
13152
13153 string GetPlaceSoundset(); // played when deploy starts
13154 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13155 string GetDeploySoundset(); // played when deploy sucessfully finishes
13156 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13157 string GetFoldSoundset(); // played when fold sucessfully finishes
13158
13160 {
13161 if (!m_ItemSoundHandler)
13163
13164 return m_ItemSoundHandler;
13165 }
13166
13167 // override to initialize sounds
13168 protected void InitItemSounds()
13169 {
13170 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
13171 return;
13172
13174
13175 if (GetPlaceSoundset() != string.Empty)
13176 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13177
13178 if (GetDeploySoundset() != string.Empty)
13179 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13180
13181 SoundParameters params = new SoundParameters();
13182 params.m_Loop = true;
13183 if (GetLoopDeploySoundset() != string.Empty)
13184 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13185 }
13186
13187 // Start sound using ItemSoundHandler
13188 void StartItemSoundServer(int id, int slotId)
13189 {
13190 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
13191 {
13192 m_SoundSyncSlotID = slotId;
13193 m_SoundSyncPlay = id;
13194
13195 SetSynchDirty();
13196
13197 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13198 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
13199 }
13200 }
13201
13202 void StartItemSoundServer(int id)
13203 {
13204 StartItemSoundServer(id, InventorySlots.INVALID);
13205 }
13206
13207 // Stop sound using ItemSoundHandler
13208 void StopItemSoundServer(int id)
13209 {
13210 if (!g_Game.IsServer())
13211 return;
13212
13213 m_SoundSyncStop = id;
13214 SetSynchDirty();
13215
13216 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13217 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
13218 }
13219
13220 protected void ClearStartItemSoundServer()
13221 {
13222 m_SoundSyncPlay = 0;
13223 m_SoundSyncSlotID = InventorySlots.INVALID;
13224 }
13225
13226 protected void ClearStopItemSoundServer()
13227 {
13228 m_SoundSyncStop = 0;
13229 }
13230
13231 void OnApply(PlayerBase player);
13232
13234 {
13235 return 1.0;
13236 };
13237 //returns applicable selection
13238 array<string> GetHeadHidingSelection()
13239 {
13241 }
13242
13244 {
13246 }
13247
13248 WrittenNoteData GetWrittenNoteData() {};
13249
13251 {
13252 SetDynamicPhysicsLifeTime(0.01);
13253 m_ItemBeingDroppedPhys = false;
13254 }
13255
13257 {
13258 array<string> zone_names = new array<string>;
13259 GetDamageZones(zone_names);
13260 for (int i = 0; i < zone_names.Count(); i++)
13261 {
13262 SetHealthMax(zone_names.Get(i),"Health");
13263 }
13264 SetHealthMax("","Health");
13265 }
13266
13268 void SetZoneDamageCEInit()
13269 {
13270 float global_health = GetHealth01("","Health");
13271 array<string> zones = new array<string>;
13272 GetDamageZones(zones);
13273 //set damage of all zones to match global health level
13274 for (int i = 0; i < zones.Count(); i++)
13275 {
13276 SetHealth01(zones.Get(i),"Health",global_health);
13277 }
13278 }
13279
13281 bool IsCoverFaceForShave(string slot_name)
13282 {
13283 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13284 }
13285
13286 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13287 {
13288 if (!hasRootAsPlayer)
13289 {
13290 if (refParentIB)
13291 {
13292 // parent is wet
13293 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13294 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13295 // parent has liquid inside
13296 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13297 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13298 // drying
13299 else if (m_VarWet > m_VarWetMin)
13300 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13301 }
13302 else
13303 {
13304 // drying on ground or inside non-itembase (car, ...)
13305 if (m_VarWet > m_VarWetMin)
13306 AddWet(-1 * delta * GetDryingIncrement("ground"));
13307 }
13308 }
13309 }
13310
13311 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13312 {
13314 {
13315 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13316 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13317 {
13318 float heatPermCoef = 1.0;
13319 EntityAI ent = this;
13320 while (ent)
13321 {
13322 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13323 ent = ent.GetHierarchyParent();
13324 }
13325
13326 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13327 }
13328 }
13329 }
13330
13331 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13332 {
13333 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13334 EntityAI parent = GetHierarchyParent();
13335 if (!parent)
13336 {
13337 hasParent = false;
13338 hasRootAsPlayer = false;
13339 }
13340 else
13341 {
13342 hasParent = true;
13343 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13344 refParentIB = ItemBase.Cast(parent);
13345 }
13346 }
13347
13348 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13349 {
13350 // this is stub, implemented on Edible_Base
13351 }
13352
13353 bool CanDecay()
13354 {
13355 // return true used on selected food clases so they can decay
13356 return false;
13357 }
13358
13359 protected bool CanProcessDecay()
13360 {
13361 // this is stub, implemented on Edible_Base class
13362 // used to determine whether it is still necessary for the food to decay
13363 return false;
13364 }
13365
13366 protected bool CanHaveWetness()
13367 {
13368 // return true used on selected items that have a wetness effect
13369 return false;
13370 }
13371
13373 bool CanBeConsumed(ConsumeConditionData data = null)
13374 {
13375 return !GetIsFrozen() && IsOpen();
13376 }
13377
13378 override void ProcessVariables()
13379 {
13380 bool hasParent = false, hasRootAsPlayer = false;
13381 ItemBase refParentIB;
13382
13383 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13384 bool foodDecay = g_Game.IsFoodDecayEnabled();
13385
13386 if (wwtu || foodDecay)
13387 {
13388 bool processWetness = wwtu && CanHaveWetness();
13389 bool processTemperature = wwtu && CanHaveTemperature();
13390 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13391
13392 if (processWetness || processTemperature || processDecay)
13393 {
13394 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13395
13396 if (processWetness)
13397 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13398
13399 if (processTemperature)
13400 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13401
13402 if (processDecay)
13403 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13404 }
13405 }
13406 }
13407
13410 {
13411 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13412 }
13413
13414 override float GetTemperatureFreezeThreshold()
13415 {
13417 return Liquid.GetFreezeThreshold(GetLiquidType());
13418
13419 return super.GetTemperatureFreezeThreshold();
13420 }
13421
13422 override float GetTemperatureThawThreshold()
13423 {
13425 return Liquid.GetThawThreshold(GetLiquidType());
13426
13427 return super.GetTemperatureThawThreshold();
13428 }
13429
13430 override float GetItemOverheatThreshold()
13431 {
13433 return Liquid.GetBoilThreshold(GetLiquidType());
13434
13435 return super.GetItemOverheatThreshold();
13436 }
13437
13438 override float GetTemperatureFreezeTime()
13439 {
13440 if (HasQuantity())
13441 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13442
13443 return super.GetTemperatureFreezeTime();
13444 }
13445
13446 override float GetTemperatureThawTime()
13447 {
13448 if (HasQuantity())
13449 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13450
13451 return super.GetTemperatureThawTime();
13452 }
13453
13455 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13457 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13458
13459 bool IsCargoException4x3(EntityAI item)
13460 {
13461 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13462 }
13463
13465 {
13466 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13467 }
13468
13470 void AddLightSourceItem(ItemBase lightsource)
13471 {
13472 m_LightSourceItem = lightsource;
13473 }
13474
13476 {
13477 m_LightSourceItem = null;
13478 }
13479
13481 {
13482 return m_LightSourceItem;
13483 }
13484
13486 array<int> GetValidFinishers()
13487 {
13488 return null;
13489 }
13490
13492 bool GetActionWidgetOverride(out typename name)
13493 {
13494 return false;
13495 }
13496
13497 bool PairWithDevice(notnull ItemBase otherDevice)
13498 {
13499 if (g_Game.IsServer())
13500 {
13501 ItemBase explosive = otherDevice;
13503 if (!trg)
13504 {
13505 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13506 explosive = this;
13507 }
13508
13509 explosive.PairRemote(trg);
13510 trg.SetControlledDevice(explosive);
13511
13512 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13513 trg.SetPersistentPairID(persistentID);
13514 explosive.SetPersistentPairID(persistentID);
13515
13516 return true;
13517 }
13518 return false;
13519 }
13520
13522 float GetBaitEffectivity()
13523 {
13524 float ret = 1.0;
13525 if (HasQuantity())
13526 ret *= GetQuantityNormalized();
13527 ret *= GetHealth01();
13528
13529 return ret;
13530 }
13531
13532 #ifdef DEVELOPER
13533 override void SetDebugItem()
13534 {
13535 super.SetDebugItem();
13536 _itemBase = this;
13537 }
13538
13539 override string GetDebugText()
13540 {
13541 string text = super.GetDebugText();
13542
13543 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13544 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13545
13546 return text;
13547 }
13548 #endif
13549
13550 bool CanBeUsedForSuicide()
13551 {
13552 return true;
13553 }
13554
13556 //DEPRECATED BELOW
13558 // Backwards compatibility
13559 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13560 {
13561 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13562 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13563 }
13564
13565 // replaced by ItemSoundHandler
13566 protected EffectSound m_SoundDeployFinish;
13567 protected EffectSound m_SoundPlace;
13568 protected EffectSound m_DeployLoopSoundEx;
13569 protected EffectSound m_SoundDeploy;
13570 bool m_IsPlaceSound;
13571 bool m_IsDeploySound;
13573
13574 string GetDeployFinishSoundset();
13575 void PlayDeploySound();
13576 void PlayDeployFinishSound();
13577 void PlayPlaceSound();
13578 void PlayDeployLoopSoundEx();
13579 void StopDeployLoopSoundEx();
13580 void SoundSynchRemoteReset();
13581 void SoundSynchRemote();
13582 bool UsesGlobalDeploy(){return false;}
13583 bool CanPlayDeployLoopSound(){return false;}
13585 bool IsPlaceSound(){return m_IsPlaceSound;}
13586 bool IsDeploySound(){return m_IsDeploySound;}
13587 void SetIsPlaceSound(bool is_place_sound);
13588 void SetIsDeploySound(bool is_deploy_sound);
13589
13590 [Obsolete("Use ItemSoundHandler instead")]
13592 void PlayAttachSound(string slot_type)
13593 {
13594 if (!g_Game.IsDedicatedServer())
13595 {
13596 if (ConfigIsExisting("attachSoundSet"))
13597 {
13598 string cfg_path = "";
13599 string soundset = "";
13600 string type_name = GetType();
13601
13602 TStringArray cfg_soundset_array = new TStringArray;
13603 TStringArray cfg_slot_array = new TStringArray;
13604 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13605 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13606
13607 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13608 {
13609 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13610 {
13611 if (cfg_slot_array[i] == slot_type)
13612 {
13613 soundset = cfg_soundset_array[i];
13614 break;
13615 }
13616 }
13617 }
13618
13619 if (soundset != "")
13620 {
13621 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13622 sound.SetAutodestroy(true);
13623 }
13624 }
13625 }
13626 }
13627
13628 void PlayDetachSound(string slot_type) {}
13629}
13630
13631EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13632{
13633 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13634 if (entity)
13635 {
13636 bool is_item = entity.IsInherited(ItemBase);
13637 if (is_item && full_quantity)
13638 {
13639 ItemBase item = ItemBase.Cast(entity);
13640 item.SetQuantity(item.GetQuantityInit());
13641 }
13642 }
13643 else
13644 {
13645 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13646 return NULL;
13647 }
13648 return entity;
13649}
13650
13651void SetupSpawnedItem(ItemBase item, float health, float quantity)
13652{
13653 if (item)
13654 {
13655 if (health > 0)
13656 item.SetHealth("", "", health);
13657
13658 if (item.CanHaveTemperature())
13659 {
13660 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13661 if (item.CanFreeze())
13662 item.SetFrozen(false);
13663 }
13664
13665 if (item.HasEnergyManager())
13666 {
13667 if (quantity >= 0)
13668 {
13669 item.GetCompEM().SetEnergy0To1(quantity);
13670 }
13671 else
13672 {
13673 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13674 }
13675 }
13676 else if (item.IsMagazine())
13677 {
13678 Magazine mag = Magazine.Cast(item);
13679 if (quantity >= 0)
13680 {
13681 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13682 }
13683 else
13684 {
13685 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13686 }
13687
13688 }
13689 else
13690 {
13691 if (quantity >= 0)
13692 {
13693 item.SetQuantityNormalized(quantity, false);
13694 }
13695 else
13696 {
13697 item.SetQuantity(Math.AbsFloat(quantity));
13698 }
13699
13700 }
13701 }
13702}
13703
13704#ifdef DEVELOPER
13705ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13706#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()