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

◆ IsOneHandedBehaviour()

override bool SpawnItemOnLocation::IsOneHandedBehaviour ( )
protected

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

9154{
9155 override bool CanPutAsAttachment(EntityAI parent)
9156 {
9157 return true;
9158 }
9159};
9160
9161//const bool QUANTITY_DEBUG_REMOVE_ME = false;
9162
9163class ItemBase extends InventoryItem
9164{
9168
9170
9171 static int m_DebugActionsMask;
9173 // ============================================
9174 // Variable Manipulation System
9175 // ============================================
9176 // Quantity
9177
9178 float m_VarQuantity;
9179 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
9181 int m_VarQuantityMin;
9182 int m_VarQuantityMax;
9183 int m_Count;
9184 float m_VarStackMax;
9185 float m_StoreLoadedQuantity = float.LOWEST;
9186 // Wet
9187 float m_VarWet;
9188 float m_VarWetPrev;//for client to know wetness changed during synchronization
9189 float m_VarWetInit;
9190 float m_VarWetMin;
9191 float m_VarWetMax;
9192 // Cleanness
9193 int m_Cleanness;
9194 int m_CleannessInit;
9195 int m_CleannessMin;
9196 int m_CleannessMax;
9197 // impact sounds
9199 bool m_CanPlayImpactSound = true;
9200 float m_ImpactSpeed;
9202 //
9203 float m_HeatIsolation;
9204 float m_ItemModelLength;
9205 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
9207 int m_VarLiquidType;
9208 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
9209 int m_QuickBarBonus;
9210 bool m_IsBeingPlaced;
9211 bool m_IsHologram;
9212 bool m_IsTakeable;
9213 bool m_ThrowItemOnDrop;
9216 bool m_FixDamageSystemInit = false; //can be changed on storage version check
9217 bool can_this_be_combined; //Check if item can be combined
9218 bool m_CanThisBeSplit; //Check if item can be split
9219 bool m_IsStoreLoad = false;
9220 bool m_CanShowQuantity;
9221 bool m_HasQuantityBar;
9222 protected bool m_CanBeDigged;
9223 protected bool m_IsResultOfSplit
9224
9225 string m_SoundAttType;
9226 // items color variables
9231 //-------------------------------------------------------
9232
9233 // light source managing
9235
9239
9240 //==============================================
9241 // agent system
9242 private int m_AttachedAgents;
9243
9245 void TransferModifiers(PlayerBase reciever);
9246
9247
9248 // Weapons & suppressors particle effects
9253 static int m_LastRegisteredWeaponID = 0;
9254
9255 // Overheating effects
9257 float m_OverheatingShots;
9258 ref Timer m_CheckOverheating;
9259 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
9260 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
9261 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
9262 ref array <ref OverheatingParticle> m_OverheatingParticles;
9263
9265 protected bool m_HideSelectionsBySlot;
9266
9267 // Admin Log
9268 PluginAdminLog m_AdminLog;
9269
9270 // misc
9271 ref Timer m_PhysDropTimer;
9272
9273 // Attachment Locking variables
9274 ref array<int> m_CompatibleLocks;
9275 protected int m_LockType;
9276 protected ref EffectSound m_LockingSound;
9277 protected string m_LockSoundSet;
9278
9279 // ItemSoundHandler
9280 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
9281 protected int m_SoundSyncPlay; // id for sound to play
9282 protected int m_SoundSyncStop; // id for sound to stop
9284
9285 //temperature
9286 private float m_TemperaturePerQuantityWeight;
9287
9288 // -------------------------------------------------------------------------
9289 void ItemBase()
9290 {
9291 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9295
9296 if (!GetGame().IsDedicatedServer())
9297 {
9298 if (HasMuzzle())
9299 {
9301
9303 {
9305 }
9306 }
9307
9309 m_ActionsInitialize = false;
9310 }
9311
9312 m_OldLocation = null;
9313
9314 if (GetGame().IsServer())
9315 {
9316 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9317 }
9318
9319 if (ConfigIsExisting("headSelectionsToHide"))
9320 {
9322 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9323 }
9324
9325 m_HideSelectionsBySlot = false;
9326 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9327 {
9328 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9329 }
9330
9331 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9332
9333 m_IsResultOfSplit = false;
9334
9336 }
9337
9338 override void InitItemVariables()
9339 {
9340 super.InitItemVariables();
9341
9342 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9343 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9344 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9345 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9346 m_VarStackMax = ConfigGetFloat("varStackMax");
9347 m_Count = ConfigGetInt("count");
9348
9349 m_CanShowQuantity = ConfigGetBool("quantityShow");
9350 m_HasQuantityBar = ConfigGetBool("quantityBar");
9351
9352 m_CleannessInit = ConfigGetInt("varCleannessInit");
9354 m_CleannessMin = ConfigGetInt("varCleannessMin");
9355 m_CleannessMax = ConfigGetInt("varCleannessMax");
9356
9357 m_WantPlayImpactSound = false;
9358 m_ImpactSpeed = 0.0;
9359
9360 m_VarWetInit = ConfigGetFloat("varWetInit");
9362 m_VarWetMin = ConfigGetFloat("varWetMin");
9363 m_VarWetMax = ConfigGetFloat("varWetMax");
9364
9365 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9366 if (IsLiquidContainer() && GetQuantity() != 0)
9368 m_IsBeingPlaced = false;
9369 m_IsHologram = false;
9370 m_IsTakeable = true;
9371 m_CanBeMovedOverride = false;
9375 m_CanBeDigged = ConfigGetBool("canBeDigged");
9376
9377 m_CompatibleLocks = new array<int>();
9378 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9379 m_LockType = ConfigGetInt("lockType");
9380
9381 //Define if item can be split and set ability to be combined accordingly
9382 m_CanThisBeSplit = false;
9383 can_this_be_combined = false;
9384 if (ConfigIsExisting("canBeSplit"))
9385 {
9386 can_this_be_combined = ConfigGetBool("canBeSplit");
9388 }
9389
9390 m_ItemBehaviour = -1;
9391 if (ConfigIsExisting("itemBehaviour"))
9392 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9393
9394 //RegisterNetSyncVariableInt("m_VariablesMask");
9395 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9396 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9397 RegisterNetSyncVariableInt("m_VarLiquidType");
9398 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9399
9400 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9401 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9402 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9403
9404 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9405 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9406 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9407 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9408
9409 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9410 RegisterNetSyncVariableBool("m_IsTakeable");
9411 RegisterNetSyncVariableBool("m_IsHologram");
9412
9413 InitItemSounds();
9415 {
9416 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9417 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9418 }
9419
9420 m_LockSoundSet = ConfigGetString("lockSoundSet");
9421
9423 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9424 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9425
9426 }
9427
9428 override int GetQuickBarBonus()
9429 {
9430 return m_QuickBarBonus;
9431 }
9432
9433 void InitializeActions()
9434 {
9436 if (!m_InputActionMap)
9437 {
9439 m_InputActionMap = iam;
9440 SetActions();
9442 }
9443 }
9444
9445 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9446 {
9448 {
9449 m_ActionsInitialize = true;
9451 }
9452
9453 actions = m_InputActionMap.Get(action_input_type);
9454 }
9455
9456 void SetActions()
9457 {
9458 AddAction(ActionTakeItem);
9459 AddAction(ActionTakeItemToHands);
9460 AddAction(ActionWorldCraft);
9462 AddAction(ActionAttachWithSwitch);
9463 }
9464
9465 void SetActionAnimOverrides(); // Override action animation for specific item
9466
9467 void AddAction(typename actionName)
9468 {
9469 ActionBase action = ActionManagerBase.GetAction(actionName);
9470
9471 if (!action)
9472 {
9473 Debug.LogError("Action " + actionName + " dosn't exist!");
9474 return;
9475 }
9476
9477 typename ai = action.GetInputType();
9478 if (!ai)
9479 {
9480 m_ActionsInitialize = false;
9481 return;
9482 }
9483
9484 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9485 if (!action_array)
9486 {
9487 action_array = new array<ActionBase_Basic>;
9488 m_InputActionMap.Insert(ai, action_array);
9489 }
9490 if (LogManager.IsActionLogEnable())
9491 {
9492 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9493 }
9494
9495 if (action_array.Find(action) != -1)
9496 {
9497 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9498 }
9499 else
9500 {
9501 action_array.Insert(action);
9502 }
9503 }
9504
9505 void RemoveAction(typename actionName)
9506 {
9507 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9508 ActionBase action = player.GetActionManager().GetAction(actionName);
9509 typename ai = action.GetInputType();
9510 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9511
9512 if (action_array)
9513 {
9514 action_array.RemoveItem(action);
9515 }
9516 }
9517
9518 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9519 // Set -1 for params which should stay in default state
9520 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9521 {
9522 ActionOverrideData overrideData = new ActionOverrideData();
9523 overrideData.m_CommandUID = commandUID;
9524 overrideData.m_CommandUIDProne = commandUIDProne;
9525 overrideData.m_StanceMask = stanceMask;
9526
9527 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9528 if (!actionMap) // create new map of action > overidables map
9529 {
9530 actionMap = new TActionAnimOverrideMap();
9531 m_ItemActionOverrides.Insert(action, actionMap);
9532 }
9533
9534 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9535
9536 }
9537
9538 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9539
9540 ScriptedLightBase GetLight();
9541
9542 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9543 void LoadParticleConfigOnFire(int id)
9544 {
9545 if (!m_OnFireEffect)
9547
9550
9551 string config_to_search = "CfgVehicles";
9552 string muzzle_owner_config;
9553
9554 if (!m_OnFireEffect.Contains(id))
9555 {
9556 if (IsInherited(Weapon))
9557 config_to_search = "CfgWeapons";
9558
9559 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9560
9561 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9562
9563 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
9564
9565 if (config_OnFire_subclass_count > 0)
9566 {
9567 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9568
9569 for (int i = 0; i < config_OnFire_subclass_count; i++)
9570 {
9571 string particle_class = "";
9572 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
9573 string config_OnFire_entry = config_OnFire_class + particle_class;
9574 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9575 WPOF_array.Insert(WPOF);
9576 }
9577
9578
9579 m_OnFireEffect.Insert(id, WPOF_array);
9580 }
9581 }
9582
9583 if (!m_OnBulletCasingEjectEffect.Contains(id))
9584 {
9585 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9586 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9587
9588 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9589
9590 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9591
9592 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9593 {
9594 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9595
9596 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9597 {
9598 string particle_class2 = "";
9599 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9600 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9601 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9602 WPOBE_array.Insert(WPOBE);
9603 }
9604
9605
9606 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9607 }
9608 }
9609 }
9610
9611 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9613 {
9616
9617 if (!m_OnOverheatingEffect.Contains(id))
9618 {
9619 string config_to_search = "CfgVehicles";
9620
9621 if (IsInherited(Weapon))
9622 config_to_search = "CfgWeapons";
9623
9624 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9625 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9626
9627 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
9628 {
9629
9630 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9631
9633 {
9634 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9635 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9636 Error(error);
9637 return;
9638 }
9639
9640 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9641 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9642
9643
9644
9645 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
9646 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9647
9648 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9649 {
9650 string particle_class = "";
9651 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9652 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9653 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
9654
9655 if (entry_type == CT_CLASS)
9656 {
9657 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9658 WPOOH_array.Insert(WPOF);
9659 }
9660 }
9661
9662
9663 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9664 }
9665 }
9666 }
9667
9668 float GetOverheatingValue()
9669 {
9670 return m_OverheatingShots;
9671 }
9672
9673 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9674 {
9675 if (m_MaxOverheatingValue > 0)
9676 {
9678
9679 if (!m_CheckOverheating)
9681
9683 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9684
9685 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9686 }
9687 }
9688
9689 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9690 {
9692 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9693
9695 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9696
9698 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9699
9701 {
9703 }
9704 }
9705
9707 {
9709 }
9710
9711 void OnOverheatingDecay()
9712 {
9713 if (m_MaxOverheatingValue > 0)
9714 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9715 else
9717
9718 if (m_OverheatingShots <= 0)
9719 {
9722 }
9723 else
9724 {
9725 if (!m_CheckOverheating)
9727
9729 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9730 }
9731
9732 CheckOverheating(this, "", this);
9733 }
9734
9735 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9736 {
9738 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9739 }
9740
9741 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9742 {
9744 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9746 }
9747
9748 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9749 {
9751 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9752 }
9753
9754 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9755 {
9757 m_OverheatingParticles = new array<ref OverheatingParticle>;
9758
9759 OverheatingParticle OP = new OverheatingParticle();
9760 OP.RegisterParticle(p);
9761 OP.SetOverheatingLimitMin(min_heat_coef);
9762 OP.SetOverheatingLimitMax(max_heat_coef);
9763 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9764
9765 m_OverheatingParticles.Insert(OP);
9766 }
9767
9768 float GetOverheatingCoef()
9769 {
9770 if (m_MaxOverheatingValue > 0)
9772
9773 return -1;
9774 }
9775
9777 {
9779 {
9780 float overheat_coef = GetOverheatingCoef();
9781 int count = m_OverheatingParticles.Count();
9782
9783 for (int i = count; i > 0; --i)
9784 {
9785 int id = i - 1;
9786 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9787 Particle p = OP.GetParticle();
9788
9789 float overheat_min = OP.GetOverheatingLimitMin();
9790 float overheat_max = OP.GetOverheatingLimitMax();
9791
9792 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9793 {
9794 if (p)
9795 {
9796 p.Stop();
9797 OP.RegisterParticle(null);
9798 }
9799 }
9800 }
9801 }
9802 }
9803
9805 {
9807 {
9808 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9809 {
9810 int id = i - 1;
9811 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9812
9813 if (OP)
9814 {
9815 Particle p = OP.GetParticle();
9816
9817 if (p)
9818 {
9819 p.Stop();
9820 }
9821
9822 delete OP;
9823 }
9824 }
9825
9826 m_OverheatingParticles.Clear();
9828 }
9829 }
9830
9832 float GetInfectionChance(int system = 0, Param param = null)
9833 {
9834 return 0.0;
9835 }
9836
9837
9838 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9839 {
9840 return 250;//default value
9841 }
9842
9843 float GetFilterDamageRatio()
9844 {
9845 return 0;
9846 }
9847
9849 bool HasMuzzle()
9850 {
9851 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9852 return true;
9853
9854 return false;
9855 }
9856
9858 int GetMuzzleID()
9859 {
9860 if (!m_WeaponTypeToID)
9862
9863 if (m_WeaponTypeToID.Contains(GetType()))
9864 {
9865 return m_WeaponTypeToID.Get(GetType());
9866 }
9867 else
9868 {
9869 // Register new weapon ID
9871 }
9872
9874 }
9875
9882 {
9883 return -1;
9884 }
9885
9886
9887
9888 // -------------------------------------------------------------------------
9889 void ~ItemBase()
9890 {
9891 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
9892 {
9893 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9894 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9895
9896 if (r_index >= 0)
9897 {
9898 InventoryLocation r_il = new InventoryLocation;
9899 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9900
9901 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9902 int r_type = r_il.GetType();
9903 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9904 {
9905 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9906 }
9907 else if (r_type == InventoryLocationType.ATTACHMENT)
9908 {
9909 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9910 }
9911
9912 }
9913
9914 player.GetHumanInventory().ClearUserReservedLocation(this);
9915 }
9916
9917 if (m_LockingSound)
9918 SEffectManager.DestroyEffect(m_LockingSound);
9919 }
9920
9921
9922
9923 // -------------------------------------------------------------------------
9924 static int GetDebugActionsMask()
9925 {
9926 return ItemBase.m_DebugActionsMask;
9927 }
9928
9929 static bool HasDebugActionsMask(int mask)
9930 {
9931 return ItemBase.m_DebugActionsMask & mask;
9932 }
9933
9934 static void SetDebugActionsMask(int mask)
9935 {
9936 ItemBase.m_DebugActionsMask = mask;
9937 }
9938
9939 static void AddDebugActionsMask(int mask)
9940 {
9941 ItemBase.m_DebugActionsMask |= mask;
9942 }
9943
9944 static void RemoveDebugActionsMask(int mask)
9945 {
9946 ItemBase.m_DebugActionsMask &= ~mask;
9947 }
9948
9949 static void ToggleDebugActionsMask(int mask)
9950 {
9951 if (HasDebugActionsMask(mask))
9952 {
9954 }
9955 else
9956 {
9957 AddDebugActionsMask(mask);
9958 }
9959 }
9960
9961 // -------------------------------------------------------------------------
9962 void SetCEBasedQuantity()
9963 {
9964 if (GetEconomyProfile())
9965 {
9966 float q_max = GetEconomyProfile().GetQuantityMax();
9967 if (q_max > 0)
9968 {
9969 float q_min = GetEconomyProfile().GetQuantityMin();
9970 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9971
9972 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9973 {
9974 ComponentEnergyManager comp = GetCompEM();
9975 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
9976 {
9977 comp.SetEnergy0To1(quantity_randomized);
9978 }
9979 }
9980 else if (HasQuantity())
9981 {
9982 SetQuantityNormalized(quantity_randomized, false);
9983 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9984 }
9985
9986 }
9987 }
9988 }
9989
9991 void LockToParent()
9992 {
9993 EntityAI parent = GetHierarchyParent();
9994
9995 if (parent)
9996 {
9997 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9998 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9999 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
10000 }
10001 }
10002
10004 void UnlockFromParent()
10005 {
10006 EntityAI parent = GetHierarchyParent();
10007
10008 if (parent)
10009 {
10010 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
10011 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
10012 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
10013 }
10014 }
10015
10016 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
10017 {
10018 /*
10019 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
10020 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
10021 */
10022 ItemBase item2 = ItemBase.Cast(entity2);
10023
10024 if (GetGame().IsClient())
10025 {
10026 if (ScriptInputUserData.CanStoreInputUserData())
10027 {
10028 ScriptInputUserData ctx = new ScriptInputUserData;
10030 ctx.Write(-1);
10031 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10032 ctx.Write(i1);
10033 ctx.Write(item2);
10034 ctx.Write(use_stack_max);
10035 ctx.Write(-1);
10036 ctx.Send();
10037
10038 if (IsCombineAll(item2, use_stack_max))
10039 {
10040 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
10041 }
10042 }
10043 }
10044 else if (!GetGame().IsMultiplayer())
10045 {
10046 CombineItems(item2, use_stack_max);
10047 }
10048 }
10049
10050 bool IsLiquidPresent()
10051 {
10052 return (GetLiquidType() != 0 && HasQuantity());
10053 }
10054
10055 bool IsLiquidContainer()
10056 {
10057 return m_LiquidContainerMask != 0;
10058 }
10059
10061 {
10062 return m_LiquidContainerMask;
10063 }
10064
10065 bool IsBloodContainer()
10066 {
10067 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
10068 return false;
10069 }
10070
10071 bool IsNVG()
10072 {
10073 return false;
10074 }
10075
10078 bool IsExplosive()
10079 {
10080 return false;
10081 }
10082
10084 {
10085 return "";
10086 }
10087
10089
10090 bool IsLightSource()
10091 {
10092 return false;
10093 }
10094
10096 {
10097 return true;
10098 }
10099
10100 //--- ACTION CONDITIONS
10101 //direction
10102 bool IsFacingPlayer(PlayerBase player, string selection)
10103 {
10104 return true;
10105 }
10106
10107 bool IsPlayerInside(PlayerBase player, string selection)
10108 {
10109 return true;
10110 }
10111
10112 override bool CanObstruct()
10113 {
10114 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10115 return !player || !IsPlayerInside(player, "");
10116 }
10117
10118 override bool IsBeingPlaced()
10119 {
10120 return m_IsBeingPlaced;
10121 }
10122
10123 void SetIsBeingPlaced(bool is_being_placed)
10124 {
10125 m_IsBeingPlaced = is_being_placed;
10126 if (!is_being_placed)
10128 SetSynchDirty();
10129 }
10130
10131 //server-side
10132 void OnEndPlacement() {}
10133
10134 override bool IsHologram()
10135 {
10136 return m_IsHologram;
10137 }
10138
10139 bool CanBeDigged()
10140 {
10141 return m_CanBeDigged;
10142 }
10143
10145 {
10146 return 1;
10147 }
10148
10149 bool CanMakeGardenplot()
10150 {
10151 return false;
10152 }
10153
10154 void SetIsHologram(bool is_hologram)
10155 {
10156 m_IsHologram = is_hologram;
10157 SetSynchDirty();
10158 }
10159 /*
10160 protected float GetNutritionalEnergy()
10161 {
10162 Edible_Base edible = Edible_Base.Cast(this);
10163 return edible.GetFoodEnergy();
10164 }
10165
10166 protected float GetNutritionalWaterContent()
10167 {
10168 Edible_Base edible = Edible_Base.Cast(this);
10169 return edible.GetFoodWater();
10170 }
10171
10172 protected float GetNutritionalIndex()
10173 {
10174 Edible_Base edible = Edible_Base.Cast(this);
10175 return edible.GetFoodNutritionalIndex();
10176 }
10177
10178 protected float GetNutritionalFullnessIndex()
10179 {
10180 Edible_Base edible = Edible_Base.Cast(this);
10181 return edible.GetFoodTotalVolume();
10182 }
10183
10184 protected float GetNutritionalToxicity()
10185 {
10186 Edible_Base edible = Edible_Base.Cast(this);
10187 return edible.GetFoodToxicity();
10188
10189 }
10190 */
10191
10192
10193 // -------------------------------------------------------------------------
10194 override void OnMovedInsideCargo(EntityAI container)
10195 {
10196 super.OnMovedInsideCargo(container);
10197
10198 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10199 }
10200
10201 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10202 {
10203 super.EEItemLocationChanged(oldLoc,newLoc);
10204
10205 PlayerBase new_player = null;
10206 PlayerBase old_player = null;
10207
10208 if (newLoc.GetParent())
10209 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
10210
10211 if (oldLoc.GetParent())
10212 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
10213
10214 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
10215 {
10216 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
10217
10218 if (r_index >= 0)
10219 {
10220 InventoryLocation r_il = new InventoryLocation;
10221 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10222
10223 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10224 int r_type = r_il.GetType();
10225 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10226 {
10227 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10228 }
10229 else if (r_type == InventoryLocationType.ATTACHMENT)
10230 {
10231 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10232 }
10233
10234 }
10235 }
10236
10237 if (newLoc.GetType() == InventoryLocationType.HANDS)
10238 {
10239 if (new_player)
10240 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
10241
10242 if (new_player == old_player)
10243 {
10244
10245 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
10246 {
10247 if (oldLoc.GetType() == InventoryLocationType.CARGO)
10248 {
10249 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
10250 {
10251 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10252 }
10253 }
10254 else
10255 {
10256 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10257 }
10258 }
10259
10260 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
10261 {
10262 int type = oldLoc.GetType();
10263 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
10264 {
10265 oldLoc.GetParent().GetOnSetLock().Invoke(this);
10266 }
10267 else if (type == InventoryLocationType.ATTACHMENT)
10268 {
10269 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
10270 }
10271 }
10272 if (!m_OldLocation)
10273 {
10274 m_OldLocation = new InventoryLocation;
10275 }
10276 m_OldLocation.Copy(oldLoc);
10277 }
10278 else
10279 {
10280 if (m_OldLocation)
10281 {
10282 m_OldLocation.Reset();
10283 }
10284 }
10285
10287 }
10288 else
10289 {
10290 if (new_player)
10291 {
10292 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
10293 if (res_index >= 0)
10294 {
10295 InventoryLocation il = new InventoryLocation;
10296 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
10297 ItemBase it = ItemBase.Cast(il.GetItem());
10298 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
10299 int rel_type = il.GetType();
10300 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10301 {
10302 il.GetParent().GetOnReleaseLock().Invoke(it);
10303 }
10304 else if (rel_type == InventoryLocationType.ATTACHMENT)
10305 {
10306 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10307 }
10308 //it.GetOnReleaseLock().Invoke(it);
10309 }
10310 }
10311 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10312 {
10313 //ThrowPhysically(old_player, vector.Zero);
10314 m_ThrowItemOnDrop = false;
10315 }
10316
10317 if (m_OldLocation)
10318 {
10319 m_OldLocation.Reset();
10320 }
10321 }
10322 }
10323
10324 override void EOnContact(IEntity other, Contact extra)
10325 {
10327 {
10328 int liquidType = -1;
10329 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10330 if (impactSpeed > 0.0)
10331 {
10332 m_ImpactSpeed = impactSpeed;
10333 #ifndef SERVER
10334 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10335 #else
10336 m_WantPlayImpactSound = true;
10337 SetSynchDirty();
10338 #endif
10339 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10340 }
10341 }
10342
10343 #ifdef SERVER
10344 if (GetCompEM() && GetCompEM().IsPlugged())
10345 {
10346 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10347 GetCompEM().UnplugThis();
10348 }
10349 #endif
10350 }
10351
10352 void RefreshPhysics();
10353
10354 override void OnCreatePhysics()
10355 {
10357 }
10358
10359 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10360 {
10361
10362 }
10363 // -------------------------------------------------------------------------
10364 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10365 {
10366 super.OnItemLocationChanged(old_owner, new_owner);
10367
10368 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10369 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10370
10371 if (!relatedPlayer && playerNew)
10372 relatedPlayer = playerNew;
10373
10374 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10375 {
10376 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10377 if (actionMgr)
10378 {
10379 ActionBase currentAction = actionMgr.GetRunningAction();
10380 if (currentAction)
10381 currentAction.OnItemLocationChanged(this);
10382 }
10383 }
10384
10385 Man ownerPlayerOld = null;
10386 Man ownerPlayerNew = null;
10387
10388 if (old_owner)
10389 {
10390 if (old_owner.IsMan())
10391 {
10392 ownerPlayerOld = Man.Cast(old_owner);
10393 }
10394 else
10395 {
10396 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10397 }
10398 }
10399 else
10400 {
10401 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10402 {
10403 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10404
10405 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10406 {
10407 GetCompEM().UnplugThis();
10408 }
10409 }
10410 }
10411
10412 if (new_owner)
10413 {
10414 if (new_owner.IsMan())
10415 {
10416 ownerPlayerNew = Man.Cast(new_owner);
10417 }
10418 else
10419 {
10420 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10421 }
10422 }
10423
10424 if (ownerPlayerOld != ownerPlayerNew)
10425 {
10426 if (ownerPlayerOld)
10427 {
10428 array<EntityAI> subItemsExit = new array<EntityAI>;
10429 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10430 for (int i = 0; i < subItemsExit.Count(); i++)
10431 {
10432 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10433 itemExit.OnInventoryExit(ownerPlayerOld);
10434 }
10435 }
10436
10437 if (ownerPlayerNew)
10438 {
10439 array<EntityAI> subItemsEnter = new array<EntityAI>;
10440 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10441 for (int j = 0; j < subItemsEnter.Count(); j++)
10442 {
10443 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10444 itemEnter.OnInventoryEnter(ownerPlayerNew);
10445 }
10446 }
10447 }
10448 else if (ownerPlayerNew != null)
10449 {
10450 PlayerBase nplayer;
10451 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10452 {
10453 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10454 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10455 for (int k = 0; k < subItemsUpdate.Count(); k++)
10456 {
10457 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10458 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10459 }
10460 }
10461 }
10462
10463 if (old_owner)
10464 old_owner.OnChildItemRemoved(this);
10465 if (new_owner)
10466 new_owner.OnChildItemReceived(this);
10467 }
10468
10469 // -------------------------------------------------------------------------------
10470 override void EEDelete(EntityAI parent)
10471 {
10472 super.EEDelete(parent);
10473 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10474 if (player)
10475 {
10476 OnInventoryExit(player);
10477
10478 if (player.IsAlive())
10479 {
10480 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10481 if (r_index >= 0)
10482 {
10483 InventoryLocation r_il = new InventoryLocation;
10484 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10485
10486 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10487 int r_type = r_il.GetType();
10488 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10489 {
10490 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10491 }
10492 else if (r_type == InventoryLocationType.ATTACHMENT)
10493 {
10494 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10495 }
10496
10497 }
10498
10499 player.RemoveQuickBarEntityShortcut(this);
10500 }
10501 }
10502 }
10503 // -------------------------------------------------------------------------------
10504 override void EEKilled(Object killer)
10505 {
10506 super.EEKilled(killer);
10507
10509 if (killer && killer.IsFireplace() && CanExplodeInFire())
10510 {
10511 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10512 {
10513 if (IsMagazine())
10514 {
10515 if (Magazine.Cast(this).GetAmmoCount() > 0)
10516 {
10517 ExplodeAmmo();
10518 }
10519 }
10520 else
10521 {
10522 Explode(DamageType.EXPLOSION);
10523 }
10524 }
10525 }
10526 }
10527
10528 override void OnWasAttached(EntityAI parent, int slot_id)
10529 {
10530 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10531
10532 super.OnWasAttached(parent, slot_id);
10533
10534 if (HasQuantity())
10535 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10536
10537 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
10538 }
10539
10540 override void OnWasDetached(EntityAI parent, int slot_id)
10541 {
10542 super.OnWasDetached(parent, slot_id);
10543
10544 if (HasQuantity())
10545 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10546 }
10547
10548 override string ChangeIntoOnAttach(string slot)
10549 {
10550 int idx;
10551 TStringArray inventory_slots = new TStringArray;
10552 TStringArray attach_types = new TStringArray;
10553
10554 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10555 if (inventory_slots.Count() < 1) //is string
10556 {
10557 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10558 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10559 }
10560 else //is array
10561 {
10562 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10563 }
10564
10565 idx = inventory_slots.Find(slot);
10566 if (idx < 0)
10567 return "";
10568
10569 return attach_types.Get(idx);
10570 }
10571
10572 override string ChangeIntoOnDetach()
10573 {
10574 int idx = -1;
10575 string slot;
10576
10577 TStringArray inventory_slots = new TStringArray;
10578 TStringArray detach_types = new TStringArray;
10579
10580 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10581 if (inventory_slots.Count() < 1) //is string
10582 {
10583 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10584 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10585 }
10586 else //is array
10587 {
10588 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10589 if (detach_types.Count() < 1)
10590 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10591 }
10592
10593 for (int i = 0; i < inventory_slots.Count(); i++)
10594 {
10595 slot = inventory_slots.Get(i);
10596 }
10597
10598 if (slot != "")
10599 {
10600 if (detach_types.Count() == 1)
10601 idx = 0;
10602 else
10603 idx = inventory_slots.Find(slot);
10604 }
10605 if (idx < 0)
10606 return "";
10607
10608 return detach_types.Get(idx);
10609 }
10610
10611 void ExplodeAmmo()
10612 {
10613 //timer
10614 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10615
10616 //min/max time
10617 float min_time = 1;
10618 float max_time = 3;
10619 float delay = Math.RandomFloat(min_time, max_time);
10620
10621 explode_timer.Run(delay, this, "DoAmmoExplosion");
10622 }
10623
10624 void DoAmmoExplosion()
10625 {
10626 Magazine magazine = Magazine.Cast(this);
10627 int pop_sounds_count = 6;
10628 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10629
10630 //play sound
10631 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10632 string sound_name = pop_sounds[ sound_idx ];
10633 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
10634
10635 //remove ammo count
10636 magazine.ServerAddAmmoCount(-1);
10637
10638 //if condition then repeat -> ExplodeAmmo
10639 float min_temp_to_explode = 100; //min temperature for item to explode
10640
10641 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10642 {
10643 ExplodeAmmo();
10644 }
10645 }
10646
10647 // -------------------------------------------------------------------------------
10648 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10649 {
10650 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10651
10652 const int CHANCE_DAMAGE_CARGO = 4;
10653 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10654 const int CHANCE_DAMAGE_NOTHING = 2;
10655
10656 if (IsClothing() || IsContainer() || IsItemTent())
10657 {
10658 float dmg = damageResult.GetDamage("","Health") * -0.5;
10659 int chances;
10660 int rnd;
10661
10662 if (GetInventory().GetCargo())
10663 {
10664 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10665 rnd = Math.RandomInt(0,chances);
10666
10667 if (rnd < CHANCE_DAMAGE_CARGO)
10668 {
10669 DamageItemInCargo(dmg);
10670 }
10671 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10672 {
10674 }
10675 }
10676 else
10677 {
10678 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10679 rnd = Math.RandomInt(0,chances);
10680
10681 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10682 {
10684 }
10685 }
10686 }
10687 }
10688
10689 bool DamageItemInCargo(float damage)
10690 {
10691 if (GetInventory().GetCargo())
10692 {
10693 int item_count = GetInventory().GetCargo().GetItemCount();
10694 if (item_count > 0)
10695 {
10696 int random_pick = Math.RandomInt(0, item_count);
10697 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
10698 if (!item.IsExplosive())
10699 {
10700 item.AddHealth("","",damage);
10701 return true;
10702 }
10703 }
10704 }
10705 return false;
10706 }
10707
10708 bool DamageItemAttachments(float damage)
10709 {
10710 int attachment_count = GetInventory().AttachmentCount();
10711 if (attachment_count > 0)
10712 {
10713 int random_pick = Math.RandomInt(0, attachment_count);
10714 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
10715 if (!attachment.IsExplosive())
10716 {
10717 attachment.AddHealth("","",damage);
10718 return true;
10719 }
10720 }
10721 return false;
10722 }
10723
10724 override bool IsSplitable()
10725 {
10726 return m_CanThisBeSplit;
10727 }
10728 //----------------
10729 override bool CanBeSplit()
10730 {
10731 if (IsSplitable() && (GetQuantity() > 1))
10732 return GetInventory().CanRemoveEntity();
10733
10734 return false;
10735 }
10736
10737 protected bool ShouldSplitQuantity(float quantity)
10738 {
10739 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10740 if (!IsSplitable())
10741 return false;
10742
10743 // nothing to split?
10744 if (GetQuantity() <= 1)
10745 return false;
10746
10747 // check if we should re-use the item instead of creating a new copy?
10748 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10749 int delta = GetQuantity() - quantity;
10750 if (delta == 0)
10751 return false;
10752
10753 // valid to split
10754 return true;
10755 }
10756
10757 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10758 {
10759 if (GetGame().IsClient())
10760 {
10761 if (ScriptInputUserData.CanStoreInputUserData())
10762 {
10763 ScriptInputUserData ctx = new ScriptInputUserData;
10765 ctx.Write(1);
10766 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10767 ctx.Write(i1);
10768 ctx.Write(destination_entity);
10769 ctx.Write(true);
10770 ctx.Write(slot_id);
10771 ctx.Send();
10772 }
10773 }
10774 else if (!GetGame().IsMultiplayer())
10775 {
10776 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
10777 }
10778 }
10779
10780 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10781 {
10782 float split_quantity_new;
10783 ItemBase new_item;
10784 float quantity = GetQuantity();
10785 float stack_max = GetTargetQuantityMax(slot_id);
10786 InventoryLocation loc = new InventoryLocation;
10787
10788 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10789 {
10790 if (stack_max <= GetQuantity())
10791 split_quantity_new = stack_max;
10792 else
10793 split_quantity_new = GetQuantity();
10794
10795 if (ShouldSplitQuantity(split_quantity_new))
10796 {
10797 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10798 if (new_item)
10799 {
10800 new_item.SetResultOfSplit(true);
10801 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10802 AddQuantity(-split_quantity_new, false, true);
10803 new_item.SetQuantity(split_quantity_new, false, true);
10804 }
10805 }
10806 }
10807 else if (destination_entity && slot_id == -1)
10808 {
10809 if (quantity > stack_max)
10810 split_quantity_new = stack_max;
10811 else
10812 split_quantity_new = quantity;
10813
10814 if (ShouldSplitQuantity(split_quantity_new))
10815 {
10816 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10817 {
10818 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10819 new_item = ItemBase.Cast(o);
10820 }
10821
10822 if (new_item)
10823 {
10824 new_item.SetResultOfSplit(true);
10825 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10826 AddQuantity(-split_quantity_new, false, true);
10827 new_item.SetQuantity(split_quantity_new, false, true);
10828 }
10829 }
10830 }
10831 else
10832 {
10833 if (stack_max != 0)
10834 {
10835 if (stack_max < GetQuantity())
10836 {
10837 split_quantity_new = GetQuantity() - stack_max;
10838 }
10839
10840 if (split_quantity_new == 0)
10841 {
10842 if (!GetGame().IsMultiplayer())
10843 player.PhysicalPredictiveDropItem(this);
10844 else
10845 player.ServerDropEntity(this);
10846 return;
10847 }
10848
10849 if (ShouldSplitQuantity(split_quantity_new))
10850 {
10851 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10852
10853 if (new_item)
10854 {
10855 new_item.SetResultOfSplit(true);
10856 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10857 SetQuantity(split_quantity_new, false, true);
10858 new_item.SetQuantity(stack_max, false, true);
10859 new_item.PlaceOnSurface();
10860 }
10861 }
10862 }
10863 }
10864 }
10865
10866 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10867 {
10868 float split_quantity_new;
10869 ItemBase new_item;
10870 float quantity = GetQuantity();
10871 float stack_max = GetTargetQuantityMax(slot_id);
10872 InventoryLocation loc = new InventoryLocation;
10873
10874 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10875 {
10876 if (stack_max <= GetQuantity())
10877 split_quantity_new = stack_max;
10878 else
10879 split_quantity_new = GetQuantity();
10880
10881 if (ShouldSplitQuantity(split_quantity_new))
10882 {
10883 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10884 if (new_item)
10885 {
10886 new_item.SetResultOfSplit(true);
10887 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10888 AddQuantity(-split_quantity_new, false, true);
10889 new_item.SetQuantity(split_quantity_new, false, true);
10890 }
10891 }
10892 }
10893 else if (destination_entity && slot_id == -1)
10894 {
10895 if (quantity > stack_max)
10896 split_quantity_new = stack_max;
10897 else
10898 split_quantity_new = quantity;
10899
10900 if (ShouldSplitQuantity(split_quantity_new))
10901 {
10902 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10903 {
10904 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10905 new_item = ItemBase.Cast(o);
10906 }
10907
10908 if (new_item)
10909 {
10910 new_item.SetResultOfSplit(true);
10911 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10912 AddQuantity(-split_quantity_new, false, true);
10913 new_item.SetQuantity(split_quantity_new, false, true);
10914 }
10915 }
10916 }
10917 else
10918 {
10919 if (stack_max != 0)
10920 {
10921 if (stack_max < GetQuantity())
10922 {
10923 split_quantity_new = GetQuantity() - stack_max;
10924 }
10925
10926 if (ShouldSplitQuantity(split_quantity_new))
10927 {
10928 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10929
10930 if (new_item)
10931 {
10932 new_item.SetResultOfSplit(true);
10933 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10934 SetQuantity(split_quantity_new, false, true);
10935 new_item.SetQuantity(stack_max, false, true);
10936 new_item.PlaceOnSurface();
10937 }
10938 }
10939 }
10940 }
10941 }
10942
10943 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10944 {
10945 if (GetGame().IsClient())
10946 {
10947 if (ScriptInputUserData.CanStoreInputUserData())
10948 {
10949 ScriptInputUserData ctx = new ScriptInputUserData;
10951 ctx.Write(4);
10952 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10953 ctx.Write(thiz);
10954 dst.WriteToContext(ctx);
10955 ctx.Send();
10956 }
10957 }
10958 else if (!GetGame().IsMultiplayer())
10959 {
10961 }
10962 }
10963
10964 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10965 {
10966 if (GetGame().IsClient())
10967 {
10968 if (ScriptInputUserData.CanStoreInputUserData())
10969 {
10970 ScriptInputUserData ctx = new ScriptInputUserData;
10972 ctx.Write(2);
10973 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10974 ctx.Write(dummy);
10975 ctx.Write(destination_entity);
10976 ctx.Write(true);
10977 ctx.Write(idx);
10978 ctx.Write(row);
10979 ctx.Write(col);
10980 ctx.Send();
10981 }
10982 }
10983 else if (!GetGame().IsMultiplayer())
10984 {
10985 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10986 }
10987 }
10988
10989 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10990 {
10992 }
10993
10994 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10995 {
10996 float quantity = GetQuantity();
10997 float split_quantity_new;
10998 ItemBase new_item;
10999 if (dst.IsValid())
11000 {
11001 int slot_id = dst.GetSlot();
11002 float stack_max = GetTargetQuantityMax(slot_id);
11003
11004 if (quantity > stack_max)
11005 split_quantity_new = stack_max;
11006 else
11007 split_quantity_new = quantity;
11008
11009 if (ShouldSplitQuantity(split_quantity_new))
11010 {
11011 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11012
11013 if (new_item)
11014 {
11015 new_item.SetResultOfSplit(true);
11016 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11017 AddQuantity(-split_quantity_new, false, true);
11018 new_item.SetQuantity(split_quantity_new, false, true);
11019 }
11020
11021 return new_item;
11022 }
11023 }
11024
11025 return null;
11026 }
11027
11028 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
11029 {
11030 float quantity = GetQuantity();
11031 float split_quantity_new;
11032 ItemBase new_item;
11033 if (destination_entity)
11034 {
11035 float stackable = GetTargetQuantityMax();
11036 if (quantity > stackable)
11037 split_quantity_new = stackable;
11038 else
11039 split_quantity_new = quantity;
11040
11041 if (ShouldSplitQuantity(split_quantity_new))
11042 {
11043 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
11044 if (new_item)
11045 {
11046 new_item.SetResultOfSplit(true);
11047 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11048 AddQuantity(-split_quantity_new, false, true);
11049 new_item.SetQuantity(split_quantity_new, false, true);
11050 }
11051 }
11052 }
11053 }
11054
11055 void SplitIntoStackMaxHandsClient(PlayerBase player)
11056 {
11057 if (GetGame().IsClient())
11058 {
11059 if (ScriptInputUserData.CanStoreInputUserData())
11060 {
11061 ScriptInputUserData ctx = new ScriptInputUserData;
11063 ctx.Write(3);
11064 ItemBase i1 = this; // @NOTE: workaround for correct serialization
11065 ctx.Write(i1);
11066 ItemBase destination_entity = this;
11067 ctx.Write(destination_entity);
11068 ctx.Write(true);
11069 ctx.Write(0);
11070 ctx.Send();
11071 }
11072 }
11073 else if (!GetGame().IsMultiplayer())
11074 {
11075 SplitIntoStackMaxHands(player);
11076 }
11077 }
11078
11079 void SplitIntoStackMaxHands(PlayerBase player)
11080 {
11081 float quantity = GetQuantity();
11082 float split_quantity_new;
11083 ref ItemBase new_item;
11084 if (player)
11085 {
11086 float stackable = GetTargetQuantityMax();
11087 if (quantity > stackable)
11088 split_quantity_new = stackable;
11089 else
11090 split_quantity_new = quantity;
11091
11092 if (ShouldSplitQuantity(split_quantity_new))
11093 {
11094 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
11095 new_item = ItemBase.Cast(in_hands);
11096 if (new_item)
11097 {
11098 new_item.SetResultOfSplit(true);
11099 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11100 AddQuantity(-split_quantity_new, false, true);
11101 new_item.SetQuantity(split_quantity_new, false, true);
11102 }
11103 }
11104 }
11105 }
11106
11107 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
11108 {
11109 float quantity = GetQuantity();
11110 float split_quantity_new = Math.Floor(quantity * 0.5);
11111
11112 if (!ShouldSplitQuantity(split_quantity_new))
11113 return;
11114
11115 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11116
11117 if (new_item)
11118 {
11119 if (new_item.GetQuantityMax() < split_quantity_new)
11120 {
11121 split_quantity_new = new_item.GetQuantityMax();
11122 }
11123
11124 new_item.SetResultOfSplit(true);
11125 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11126
11127 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11128 {
11129 AddQuantity(-1, false, true);
11130 new_item.SetQuantity(1, false, true);
11131 }
11132 else
11133 {
11134 AddQuantity(-split_quantity_new, false, true);
11135 new_item.SetQuantity(split_quantity_new, false, true);
11136 }
11137 }
11138 }
11139
11140 void SplitItem(PlayerBase player)
11141 {
11142 float quantity = GetQuantity();
11143 float split_quantity_new = Math.Floor(quantity / 2);
11144
11145 if (!ShouldSplitQuantity(split_quantity_new))
11146 return;
11147
11148 InventoryLocation invloc = new InventoryLocation;
11149 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
11150
11151 ItemBase new_item;
11152 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
11153
11154 if (new_item)
11155 {
11156 if (new_item.GetQuantityMax() < split_quantity_new)
11157 {
11158 split_quantity_new = new_item.GetQuantityMax();
11159 }
11160 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11161 {
11162 AddQuantity(-1, false, true);
11163 new_item.SetQuantity(1, false, true);
11164 }
11165 else if (split_quantity_new > 1)
11166 {
11167 AddQuantity(-split_quantity_new, false, true);
11168 new_item.SetQuantity(split_quantity_new, false, true);
11169 }
11170 }
11171 }
11172
11174 void OnQuantityChanged(float delta)
11175 {
11176 SetWeightDirty();
11177 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
11178
11179 if (parent)
11180 parent.OnAttachmentQuantityChangedEx(this, delta);
11181
11182 if (IsLiquidContainer())
11183 {
11184 if (GetQuantityNormalized() <= 0.0)
11185 {
11187 }
11188 else if (GetLiquidType() == LIQUID_NONE)
11189 {
11190 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
11192 }
11193 }
11194
11195 }
11196
11199 {
11200 // insert code here
11201 }
11202
11204 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
11205 {
11207 }
11208
11209 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
11210 {
11211 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
11212
11213 if (GetGame().IsServer())
11214 {
11215 if (newLevel == GameConstants.STATE_RUINED)
11216 {
11218 EntityAI parent = GetHierarchyParent();
11219 if (parent && parent.IsFireplace())
11220 {
11221 CargoBase cargo = GetInventory().GetCargo();
11222 if (cargo)
11223 {
11224 for (int i = 0; i < cargo.GetItemCount(); ++i)
11225 {
11226 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
11227 }
11228 }
11229 }
11230 }
11231
11232 if (IsResultOfSplit())
11233 {
11234 // reset the splitting result flag, return to normal item behavior
11235 SetResultOfSplit(false);
11236 return;
11237 }
11238
11239 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
11240 {
11241 SetCleanness(0);//unclean the item upon damage dealt
11242 }
11243 }
11244 }
11245
11246 // just the split? TODO: verify
11247 override void OnRightClick()
11248 {
11249 super.OnRightClick();
11250
11251 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
11252 {
11253 if (GetGame().IsClient())
11254 {
11255 if (ScriptInputUserData.CanStoreInputUserData())
11256 {
11257 EntityAI root = GetHierarchyRoot();
11258 Man playerOwner = GetHierarchyRootPlayer();
11259 InventoryLocation dst = new InventoryLocation;
11260
11261 // 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
11262 if (!playerOwner && root && root == this)
11263 {
11265 }
11266 else
11267 {
11268 // 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
11269 GetInventory().GetCurrentInventoryLocation(dst);
11270 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
11271 {
11272 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
11273 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
11274 {
11276 }
11277 else
11278 {
11279 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
11280 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
11281 this shouldnt cause issues within this scope*/
11282 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
11283 {
11285 }
11286 else
11287 {
11288 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
11289 }
11290 }
11291 }
11292 }
11293
11294 ScriptInputUserData ctx = new ScriptInputUserData;
11296 ctx.Write(4);
11297 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11298 ctx.Write(thiz);
11299 dst.WriteToContext(ctx);
11300 ctx.Write(true); // dummy
11301 ctx.Send();
11302 }
11303 }
11304 else if (!GetGame().IsMultiplayer())
11305 {
11306 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
11307 }
11308 }
11309 }
11310
11311 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11312 {
11313 if (root)
11314 {
11315 vector m4[4];
11316 root.GetTransform(m4);
11317 dst.SetGround(this, m4);
11318 }
11319 else
11320 {
11321 GetInventory().GetCurrentInventoryLocation(dst);
11322 }
11323 }
11324
11325 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11326 {
11327 //TODO: delete check zero quantity check after fix double posts hands fsm events
11328 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11329 return false;
11330
11331 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11332 return false;
11333
11334 //can_this_be_combined = ConfigGetBool("canBeSplit");
11336 return false;
11337
11338
11339 Magazine mag = Magazine.Cast(this);
11340 if (mag)
11341 {
11342 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11343 return false;
11344
11345 if (stack_max_limit)
11346 {
11347 Magazine other_mag = Magazine.Cast(other_item);
11348 if (other_item)
11349 {
11350 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11351 return false;
11352 }
11353
11354 }
11355 }
11356 else
11357 {
11358 //TODO: delete check zero quantity check after fix double posts hands fsm events
11359 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11360 return false;
11361
11362 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11363 return false;
11364 }
11365
11366 PlayerBase player = null;
11367 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11368 {
11369 if (player.GetInventory().HasAttachment(this))
11370 return false;
11371
11372 if (player.IsItemsToDelete())
11373 return false;
11374 }
11375
11376 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11377 return false;
11378
11379 int slotID;
11380 string slotName;
11381 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11382 return false;
11383
11384 return true;
11385 }
11386
11387 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11388 {
11389 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11390 }
11391
11392 bool IsResultOfSplit()
11393 {
11394 return m_IsResultOfSplit;
11395 }
11396
11397 void SetResultOfSplit(bool value)
11398 {
11399 m_IsResultOfSplit = value;
11400 }
11401
11402 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11403 {
11404 return ComputeQuantityUsedEx(other_item, use_stack_max);
11405 }
11406
11407 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11408 {
11409 float other_item_quantity = other_item.GetQuantity();
11410 float this_free_space;
11411
11412 float stack_max = GetQuantityMax();
11413
11414 this_free_space = stack_max - GetQuantity();
11415
11416 if (other_item_quantity > this_free_space)
11417 {
11418 return this_free_space;
11419 }
11420 else
11421 {
11422 return other_item_quantity;
11423 }
11424 }
11425
11426 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11427 {
11428 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11429 }
11430
11431 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11432 {
11433 if (!CanBeCombined(other_item, false))
11434 return;
11435
11436 if (!IsMagazine() && other_item)
11437 {
11438 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11439 if (quantity_used != 0)
11440 {
11441 float hp1 = GetHealth01("","");
11442 float hp2 = other_item.GetHealth01("","");
11443 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11444 hpResult = hpResult / (GetQuantity() + quantity_used);
11445
11446 hpResult *= GetMaxHealth();
11447 Math.Round(hpResult);
11448 SetHealth("", "Health", hpResult);
11449
11450 AddQuantity(quantity_used);
11451 other_item.AddQuantity(-quantity_used);
11452 }
11453 }
11454 OnCombine(other_item);
11455 }
11456
11457 void OnCombine(ItemBase other_item)
11458 {
11459 #ifdef SERVER
11460 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11461 GetHierarchyParent().IncreaseLifetimeUp();
11462 #endif
11463 };
11464
11465 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11466 {
11467 PlayerBase p = PlayerBase.Cast(player);
11468
11469 array<int> recipesIds = p.m_Recipes;
11470 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11471 if (moduleRecipesManager)
11472 {
11473 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
11474 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11475 }
11476
11477 for (int i = 0;i < recipesIds.Count(); i++)
11478 {
11479 int key = recipesIds.Get(i);
11480 string recipeName = moduleRecipesManager.GetRecipeName(key);
11481 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11482 }
11483 }
11484
11485 // -------------------------------------------------------------------------
11486 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11487 {
11488 super.GetDebugActions(outputList);
11489
11490 //quantity
11491 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11492 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11493 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11494 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11495 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11496
11497 //health
11498 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11499 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11500 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11501 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11502 //temperature
11503 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11504 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11505 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11506 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11507
11508 //wet
11509 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11510 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11511 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11512
11513 //liquidtype
11514 if (IsLiquidContainer())
11515 {
11516 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11517 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11518 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11519 }
11520
11521 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11522 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11523
11524 // watch
11525 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11526 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11527 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11528
11529 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11530
11531 InventoryLocation loc = new InventoryLocation();
11532 GetInventory().GetCurrentInventoryLocation(loc);
11533 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11534 {
11535 if (Gizmo_IsSupported())
11536 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11537 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11538 }
11539
11540 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11541 }
11542
11543 // -------------------------------------------------------------------------
11544 // -------------------------------------------------------------------------
11545 // -------------------------------------------------------------------------
11546 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11547 {
11548 super.OnAction(action_id, player, ctx);
11549
11550 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
11551 {
11552 switch (action_id)
11553 {
11554 case EActions.GIZMO_OBJECT:
11555 GetGame().GizmoSelectObject(this);
11556 return true;
11557 case EActions.GIZMO_PHYSICS:
11558 GetGame().GizmoSelectPhysics(GetPhysics());
11559 return true;
11560 }
11561 }
11562
11563 if (GetGame().IsServer())
11564 {
11565 switch (action_id)
11566 {
11567 case EActions.DELETE:
11568 Delete();
11569 return true;
11570 }
11571 }
11572
11573 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11574 {
11575 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11576 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11577 PlayerBase p = PlayerBase.Cast(player);
11578 if (EActions.RECIPES_RANGE_START < 1000)
11579 {
11580 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11581 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11582 }
11583 }
11584 #ifndef SERVER
11585 else if (action_id == EActions.WATCH_PLAYER)
11586 {
11587 PluginDeveloper.SetDeveloperItemClientEx(player);
11588 }
11589 #endif
11590 if (GetGame().IsServer())
11591 {
11592 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11593 {
11594 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11595 OnDebugButtonPressServer(id + 1);
11596 }
11597
11598 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11599 {
11600 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11601 InsertAgent(agent_id,100);
11602 }
11603
11604 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11605 {
11606 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11607 RemoveAgent(agent_id2);
11608 }
11609
11610 else if (action_id == EActions.ADD_QUANTITY)
11611 {
11612 if (IsMagazine())
11613 {
11614 Magazine mag = Magazine.Cast(this);
11615 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11616 }
11617 else
11618 {
11619 AddQuantity(GetQuantityMax() * 0.2);
11620 }
11621
11622 if (m_EM)
11623 {
11624 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11625 }
11626 //PrintVariables();
11627 }
11628
11629 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11630 {
11631 if (IsMagazine())
11632 {
11633 Magazine mag2 = Magazine.Cast(this);
11634 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11635 }
11636 else
11637 {
11638 AddQuantity(- GetQuantityMax() * 0.2);
11639 }
11640 if (m_EM)
11641 {
11642 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11643 }
11644 //PrintVariables();
11645 }
11646
11647 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11648 {
11649 SetQuantity(0);
11650
11651 if (m_EM)
11652 {
11653 m_EM.SetEnergy(0);
11654 }
11655 }
11656
11657 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11658 {
11660
11661 if (m_EM)
11662 {
11663 m_EM.SetEnergy(m_EM.GetEnergyMax());
11664 }
11665 }
11666
11667 else if (action_id == EActions.ADD_HEALTH)
11668 {
11669 AddHealth("","",GetMaxHealth("","Health")/5);
11670 }
11671 else if (action_id == EActions.REMOVE_HEALTH)
11672 {
11673 AddHealth("","",-GetMaxHealth("","Health")/5);
11674 }
11675 else if (action_id == EActions.DESTROY_HEALTH)
11676 {
11677 SetHealth01("","",0);
11678 }
11679 else if (action_id == EActions.WATCH_ITEM)
11680 {
11682 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11683 #ifdef DEVELOPER
11684 SetDebugDeveloper_item(this);
11685 #endif
11686 }
11687
11688 else if (action_id == EActions.ADD_TEMPERATURE)
11689 {
11690 AddTemperature(20);
11691 //PrintVariables();
11692 }
11693
11694 else if (action_id == EActions.REMOVE_TEMPERATURE)
11695 {
11696 AddTemperature(-20);
11697 //PrintVariables();
11698 }
11699
11700 else if (action_id == EActions.FLIP_FROZEN)
11701 {
11702 SetFrozen(!GetIsFrozen());
11703 //PrintVariables();
11704 }
11705
11706 else if (action_id == EActions.ADD_WETNESS)
11707 {
11708 AddWet(GetWetMax()/5);
11709 //PrintVariables();
11710 }
11711
11712 else if (action_id == EActions.REMOVE_WETNESS)
11713 {
11714 AddWet(-GetWetMax()/5);
11715 //PrintVariables();
11716 }
11717
11718 else if (action_id == EActions.LIQUIDTYPE_UP)
11719 {
11720 int curr_type = GetLiquidType();
11721 SetLiquidType(curr_type * 2);
11722 //AddWet(1);
11723 //PrintVariables();
11724 }
11725
11726 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11727 {
11728 int curr_type2 = GetLiquidType();
11729 SetLiquidType(curr_type2 / 2);
11730 }
11731
11732 else if (action_id == EActions.MAKE_SPECIAL)
11733 {
11734 auto debugParams = DebugSpawnParams.WithPlayer(player);
11735 OnDebugSpawnEx(debugParams);
11736 }
11737
11738 }
11739
11740
11741 return false;
11742 }
11743
11744 // -------------------------------------------------------------------------
11745
11746
11749 void OnActivatedByTripWire();
11750
11752 void OnActivatedByItem(notnull ItemBase item);
11753
11754 //----------------------------------------------------------------
11755 //returns true if item is able to explode when put in fire
11756 bool CanExplodeInFire()
11757 {
11758 return false;
11759 }
11760
11761 //----------------------------------------------------------------
11762 bool CanEat()
11763 {
11764 return true;
11765 }
11766
11767 //----------------------------------------------------------------
11768 override bool IsIgnoredByConstruction()
11769 {
11770 return true;
11771 }
11772
11773 //----------------------------------------------------------------
11774 //has FoodStages in config?
11775 bool HasFoodStage()
11776 {
11777 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11778 return GetGame().ConfigIsExisting(config_path);
11779 }
11780
11782 FoodStage GetFoodStage()
11783 {
11784 return null;
11785 }
11786
11787 bool CanBeCooked()
11788 {
11789 return false;
11790 }
11791
11792 bool CanBeCookedOnStick()
11793 {
11794 return false;
11795 }
11796
11798 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11800
11801 //----------------------------------------------------------------
11802 bool CanRepair(ItemBase item_repair_kit)
11803 {
11804 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11805 return module_repairing.CanRepair(this, item_repair_kit);
11806 }
11807
11808 //----------------------------------------------------------------
11809 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11810 {
11811 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11812 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11813 }
11814
11815 //----------------------------------------------------------------
11816 int GetItemSize()
11817 {
11818 /*
11819 vector v_size = this.ConfigGetVector("itemSize");
11820 int v_size_x = v_size[0];
11821 int v_size_y = v_size[1];
11822 int size = v_size_x * v_size_y;
11823 return size;
11824 */
11825
11826 return 1;
11827 }
11828
11829 //----------------------------------------------------------------
11830 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11831 bool CanBeMovedOverride()
11832 {
11833 return m_CanBeMovedOverride;
11834 }
11835
11836 //----------------------------------------------------------------
11837 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11838 void SetCanBeMovedOverride(bool setting)
11839 {
11840 m_CanBeMovedOverride = setting;
11841 }
11842
11843 //----------------------------------------------------------------
11851 void MessageToOwnerStatus(string text)
11852 {
11853 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11854
11855 if (player)
11856 {
11857 player.MessageStatus(text);
11858 }
11859 }
11860
11861 //----------------------------------------------------------------
11869 void MessageToOwnerAction(string text)
11870 {
11871 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11872
11873 if (player)
11874 {
11875 player.MessageAction(text);
11876 }
11877 }
11878
11879 //----------------------------------------------------------------
11887 void MessageToOwnerFriendly(string text)
11888 {
11889 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11890
11891 if (player)
11892 {
11893 player.MessageFriendly(text);
11894 }
11895 }
11896
11897 //----------------------------------------------------------------
11905 void MessageToOwnerImportant(string text)
11906 {
11907 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11908
11909 if (player)
11910 {
11911 player.MessageImportant(text);
11912 }
11913 }
11914
11915 override bool IsItemBase()
11916 {
11917 return true;
11918 }
11919
11920 // Checks if item is of questioned kind
11921 override bool KindOf(string tag)
11922 {
11923 bool found = false;
11924 string item_name = this.GetType();
11925 ref TStringArray item_tag_array = new TStringArray;
11926 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11927
11928 int array_size = item_tag_array.Count();
11929 for (int i = 0; i < array_size; i++)
11930 {
11931 if (item_tag_array.Get(i) == tag)
11932 {
11933 found = true;
11934 break;
11935 }
11936 }
11937 return found;
11938 }
11939
11940
11941 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11942 {
11943 //Debug.Log("OnRPC called");
11944 super.OnRPC(sender, rpc_type,ctx);
11945
11946 //Play soundset for attachment locking (ActionLockAttachment.c)
11947 switch (rpc_type)
11948 {
11949 #ifndef SERVER
11950 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11951 Param2<bool, string> p = new Param2<bool, string>(false, "");
11952
11953 if (!ctx.Read(p))
11954 return;
11955
11956 bool play = p.param1;
11957 string soundSet = p.param2;
11958
11959 if (play)
11960 {
11961 if (m_LockingSound)
11962 {
11964 {
11965 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11966 }
11967 }
11968 else
11969 {
11970 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11971 }
11972 }
11973 else
11974 {
11975 SEffectManager.DestroyEffect(m_LockingSound);
11976 }
11977
11978 break;
11979 #endif
11980
11981 }
11982
11983 if (GetWrittenNoteData())
11984 {
11985 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11986 }
11987 }
11988
11989 //-----------------------------
11990 // VARIABLE MANIPULATION SYSTEM
11991 //-----------------------------
11992 int NameToID(string name)
11993 {
11994 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11995 return plugin.GetID(name);
11996 }
11997
11998 string IDToName(int id)
11999 {
12000 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
12001 return plugin.GetName(id);
12002 }
12003
12005 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
12006 {
12007 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
12008 //read the flags
12009 int varFlags;
12010 if (!ctx.Read(varFlags))
12011 return;
12012
12013 if (varFlags & ItemVariableFlags.FLOAT)
12014 {
12015 ReadVarsFromCTX(ctx);
12016 }
12017 }
12018
12019 override void SerializeNumericalVars(array<float> floats_out)
12020 {
12021 //some variables handled on EntityAI level already!
12022 super.SerializeNumericalVars(floats_out);
12023
12024 // the order of serialization must be the same as the order of de-serialization
12025 //--------------------------------------------
12026 if (IsVariableSet(VARIABLE_QUANTITY))
12027 {
12028 floats_out.Insert(m_VarQuantity);
12029 }
12030 //--------------------------------------------
12031 if (IsVariableSet(VARIABLE_WET))
12032 {
12033 floats_out.Insert(m_VarWet);
12034 }
12035 //--------------------------------------------
12036 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12037 {
12038 floats_out.Insert(m_VarLiquidType);
12039 }
12040 //--------------------------------------------
12041 if (IsVariableSet(VARIABLE_COLOR))
12042 {
12043 floats_out.Insert(m_ColorComponentR);
12044 floats_out.Insert(m_ColorComponentG);
12045 floats_out.Insert(m_ColorComponentB);
12046 floats_out.Insert(m_ColorComponentA);
12047 }
12048 //--------------------------------------------
12049 if (IsVariableSet(VARIABLE_CLEANNESS))
12050 {
12051 floats_out.Insert(m_Cleanness);
12052 }
12053 }
12054
12055 override void DeSerializeNumericalVars(array<float> floats)
12056 {
12057 //some variables handled on EntityAI level already!
12058 super.DeSerializeNumericalVars(floats);
12059
12060 // the order of serialization must be the same as the order of de-serialization
12061 int index = 0;
12062 int mask = Math.Round(floats.Get(index));
12063
12064 index++;
12065 //--------------------------------------------
12066 if (mask & VARIABLE_QUANTITY)
12067 {
12068 if (m_IsStoreLoad)
12069 {
12070 SetStoreLoadedQuantity(floats.Get(index));
12071 }
12072 else
12073 {
12074 float quantity = floats.Get(index);
12075 SetQuantity(quantity, true, false, false, false);
12076 }
12077 index++;
12078 }
12079 //--------------------------------------------
12080 if (mask & VARIABLE_WET)
12081 {
12082 float wet = floats.Get(index);
12083 SetWet(wet);
12084 index++;
12085 }
12086 //--------------------------------------------
12087 if (mask & VARIABLE_LIQUIDTYPE)
12088 {
12089 int liquidtype = Math.Round(floats.Get(index));
12090 SetLiquidType(liquidtype);
12091 index++;
12092 }
12093 //--------------------------------------------
12094 if (mask & VARIABLE_COLOR)
12095 {
12096 m_ColorComponentR = Math.Round(floats.Get(index));
12097 index++;
12098 m_ColorComponentG = Math.Round(floats.Get(index));
12099 index++;
12100 m_ColorComponentB = Math.Round(floats.Get(index));
12101 index++;
12102 m_ColorComponentA = Math.Round(floats.Get(index));
12103 index++;
12104 }
12105 //--------------------------------------------
12106 if (mask & VARIABLE_CLEANNESS)
12107 {
12108 int cleanness = Math.Round(floats.Get(index));
12109 SetCleanness(cleanness);
12110 index++;
12111 }
12112 }
12113
12114 override void WriteVarsToCTX(ParamsWriteContext ctx)
12115 {
12116 super.WriteVarsToCTX(ctx);
12117
12118 //--------------------------------------------
12119 if (IsVariableSet(VARIABLE_QUANTITY))
12120 {
12121 ctx.Write(GetQuantity());
12122 }
12123 //--------------------------------------------
12124 if (IsVariableSet(VARIABLE_WET))
12125 {
12126 ctx.Write(GetWet());
12127 }
12128 //--------------------------------------------
12129 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12130 {
12131 ctx.Write(GetLiquidType());
12132 }
12133 //--------------------------------------------
12134 if (IsVariableSet(VARIABLE_COLOR))
12135 {
12136 int r,g,b,a;
12137 GetColor(r,g,b,a);
12138 ctx.Write(r);
12139 ctx.Write(g);
12140 ctx.Write(b);
12141 ctx.Write(a);
12142 }
12143 //--------------------------------------------
12144 if (IsVariableSet(VARIABLE_CLEANNESS))
12145 {
12146 ctx.Write(GetCleanness());
12147 }
12148 }
12149
12150 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
12151 {
12152 if (!super.ReadVarsFromCTX(ctx,version))
12153 return false;
12154
12155 int intValue;
12156 float value;
12157
12158 if (version < 140)
12159 {
12160 if (!ctx.Read(intValue))
12161 return false;
12162
12163 m_VariablesMask = intValue;
12164 }
12165
12166 if (m_VariablesMask & VARIABLE_QUANTITY)
12167 {
12168 if (!ctx.Read(value))
12169 return false;
12170
12171 if (IsStoreLoad())
12172 {
12174 }
12175 else
12176 {
12177 SetQuantity(value, true, false, false, false);
12178 }
12179 }
12180 //--------------------------------------------
12181 if (version < 140)
12182 {
12183 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12184 {
12185 if (!ctx.Read(value))
12186 return false;
12187 SetTemperatureDirect(value);
12188 }
12189 }
12190 //--------------------------------------------
12191 if (m_VariablesMask & VARIABLE_WET)
12192 {
12193 if (!ctx.Read(value))
12194 return false;
12195 SetWet(value);
12196 }
12197 //--------------------------------------------
12198 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
12199 {
12200 if (!ctx.Read(intValue))
12201 return false;
12202 SetLiquidType(intValue);
12203 }
12204 //--------------------------------------------
12205 if (m_VariablesMask & VARIABLE_COLOR)
12206 {
12207 int r,g,b,a;
12208 if (!ctx.Read(r))
12209 return false;
12210 if (!ctx.Read(g))
12211 return false;
12212 if (!ctx.Read(b))
12213 return false;
12214 if (!ctx.Read(a))
12215 return false;
12216
12217 SetColor(r,g,b,a);
12218 }
12219 //--------------------------------------------
12220 if (m_VariablesMask & VARIABLE_CLEANNESS)
12221 {
12222 if (!ctx.Read(intValue))
12223 return false;
12224 SetCleanness(intValue);
12225 }
12226 //--------------------------------------------
12227 if (version >= 138 && version < 140)
12228 {
12229 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12230 {
12231 if (!ctx.Read(intValue))
12232 return false;
12233 SetFrozen(intValue);
12234 }
12235 }
12236
12237 return true;
12238 }
12239
12240 //----------------------------------------------------------------
12241 override bool OnStoreLoad(ParamsReadContext ctx, int version)
12242 {
12243 m_IsStoreLoad = true;
12245 {
12246 m_FixDamageSystemInit = true;
12247 }
12248
12249 if (!super.OnStoreLoad(ctx, version))
12250 {
12251 m_IsStoreLoad = false;
12252 return false;
12253 }
12254
12255 if (version >= 114)
12256 {
12257 bool hasQuickBarIndexSaved;
12258
12259 if (!ctx.Read(hasQuickBarIndexSaved))
12260 {
12261 m_IsStoreLoad = false;
12262 return false;
12263 }
12264
12265 if (hasQuickBarIndexSaved)
12266 {
12267 int itmQBIndex;
12268
12269 //Load quickbar item bind
12270 if (!ctx.Read(itmQBIndex))
12271 {
12272 m_IsStoreLoad = false;
12273 return false;
12274 }
12275
12276 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
12277 if (itmQBIndex != -1 && parentPlayer)
12278 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
12279 }
12280 }
12281 else
12282 {
12283 // Backup of how it used to be
12284 PlayerBase player;
12285 int itemQBIndex;
12286 if (version == int.MAX)
12287 {
12288 if (!ctx.Read(itemQBIndex))
12289 {
12290 m_IsStoreLoad = false;
12291 return false;
12292 }
12293 }
12294 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12295 {
12296 //Load quickbar item bind
12297 if (!ctx.Read(itemQBIndex))
12298 {
12299 m_IsStoreLoad = false;
12300 return false;
12301 }
12302 if (itemQBIndex != -1 && player)
12303 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12304 }
12305 }
12306
12307 if (version < 140)
12308 {
12309 // variable management system
12310 if (!LoadVariables(ctx, version))
12311 {
12312 m_IsStoreLoad = false;
12313 return false;
12314 }
12315 }
12316
12317 //agent trasmission system
12318 if (!LoadAgents(ctx, version))
12319 {
12320 m_IsStoreLoad = false;
12321 return false;
12322 }
12323 if (version >= 132)
12324 {
12325 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12326 if (raib)
12327 {
12328 if (!raib.OnStoreLoad(ctx,version))
12329 {
12330 m_IsStoreLoad = false;
12331 return false;
12332 }
12333 }
12334 }
12335
12336 m_IsStoreLoad = false;
12337 return true;
12338 }
12339
12340 //----------------------------------------------------------------
12341
12342 override void OnStoreSave(ParamsWriteContext ctx)
12343 {
12344 super.OnStoreSave(ctx);
12345
12346 PlayerBase player;
12347 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12348 {
12349 ctx.Write(true); // Keep track of if we should actually read this in or not
12350 //Save quickbar item bind
12351 int itemQBIndex = -1;
12352 itemQBIndex = player.FindQuickBarEntityIndex(this);
12353 ctx.Write(itemQBIndex);
12354 }
12355 else
12356 {
12357 ctx.Write(false); // Keep track of if we should actually read this in or not
12358 }
12359
12360 SaveAgents(ctx);//agent trasmission system
12361
12362 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12363 if (raib)
12364 {
12365 raib.OnStoreSave(ctx);
12366 }
12367 }
12368 //----------------------------------------------------------------
12369
12370 override void AfterStoreLoad()
12371 {
12372 super.AfterStoreLoad();
12373
12375 {
12377 }
12378
12379 if (GetStoreLoadedQuantity() != float.LOWEST)
12380 {
12382 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
12383 }
12384 }
12385
12386 override void EEOnAfterLoad()
12387 {
12388 super.EEOnAfterLoad();
12389
12391 {
12392 m_FixDamageSystemInit = false;
12393 }
12394
12397 }
12398
12399 bool CanBeDisinfected()
12400 {
12401 return false;
12402 }
12403
12404
12405 //----------------------------------------------------------------
12406 override void OnVariablesSynchronized()
12407 {
12408 if (m_Initialized)
12409 {
12410 #ifdef PLATFORM_CONSOLE
12411 //bruteforce it is
12412 if (IsSplitable())
12413 {
12414 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
12415 if (menu)
12416 {
12417 menu.Refresh();
12418 }
12419 }
12420 #endif
12421 }
12422
12424 {
12425 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12426 m_WantPlayImpactSound = false;
12427 }
12428
12430 {
12431 SetWeightDirty();
12433 }
12434 if (m_VarWet != m_VarWetPrev)
12435 {
12438 }
12439
12440 if (m_SoundSyncPlay != 0)
12441 {
12442 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
12443 m_SoundSyncPlay = 0;
12444 }
12445 if (m_SoundSyncStop != 0)
12446 {
12447 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12448 m_SoundSyncStop = 0;
12449 }
12450
12451 super.OnVariablesSynchronized();
12452 }
12453
12454 //------------------------- Quantity
12455 //----------------------------------------------------------------
12457 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12458 {
12459 if (!IsServerCheck(allow_client))
12460 return false;
12461
12462 if (!HasQuantity())
12463 return false;
12464
12465 float min = GetQuantityMin();
12466 float max = GetQuantityMax();
12467
12468 if (value <= (min + 0.001))
12469 value = min;
12470
12471 if (value == min)
12472 {
12473 if (destroy_config)
12474 {
12475 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12476 if (dstr)
12477 {
12478 m_VarQuantity = Math.Clamp(value, min, max);
12479 this.Delete();
12480 return true;
12481 }
12482 }
12483 else if (destroy_forced)
12484 {
12485 m_VarQuantity = Math.Clamp(value, min, max);
12486 this.Delete();
12487 return true;
12488 }
12489 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12490 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12491 }
12492
12493 float delta = m_VarQuantity;
12494 m_VarQuantity = Math.Clamp(value, min, max);
12495
12496 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12497 {
12498 delta = m_VarQuantity - delta;
12499
12500 if (delta)
12501 OnQuantityChanged(delta);
12502 }
12503
12504 SetVariableMask(VARIABLE_QUANTITY);
12505
12506 return false;
12507 }
12508
12509 //----------------------------------------------------------------
12511 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12512 {
12513 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12514 }
12515 //----------------------------------------------------------------
12516 void SetQuantityMax()
12517 {
12518 float max = GetQuantityMax();
12519 SetQuantity(max);
12520 }
12521
12522 override void SetQuantityToMinimum()
12523 {
12524 float min = GetQuantityMin();
12525 SetQuantity(min);
12526 }
12527 //----------------------------------------------------------------
12529 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12530 {
12531 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12532 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12533 SetQuantity(result, destroy_config, destroy_forced);
12534 }
12535
12536 //----------------------------------------------------------------
12538 override float GetQuantityNormalized()
12539 {
12540 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12541 }
12542
12544 {
12545 return GetQuantityNormalized();
12546 }
12547
12548 /*void SetAmmoNormalized(float value)
12549 {
12550 float value_clamped = Math.Clamp(value, 0, 1);
12551 Magazine this_mag = Magazine.Cast(this);
12552 int max_rounds = this_mag.GetAmmoMax();
12553 int result = value * max_rounds;//can the rounded if higher precision is required
12554 this_mag.SetAmmoCount(result);
12555 }*/
12556 //----------------------------------------------------------------
12557 override int GetQuantityMax()
12558 {
12559 int slot = -1;
12560 if (GetInventory())
12561 {
12562 InventoryLocation il = new InventoryLocation;
12563 GetInventory().GetCurrentInventoryLocation(il);
12564 slot = il.GetSlot();
12565 }
12566
12567 return GetTargetQuantityMax(slot);
12568 }
12569
12570 override int GetTargetQuantityMax(int attSlotID = -1)
12571 {
12572 float quantity_max = 0;
12573
12574 if (IsSplitable()) //only stackable/splitable items can check for stack size
12575 {
12576 if (attSlotID != -1)
12577 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12578
12579 if (quantity_max <= 0)
12580 quantity_max = m_VarStackMax;
12581 }
12582
12583 if (quantity_max <= 0)
12584 quantity_max = m_VarQuantityMax;
12585
12586 return quantity_max;
12587 }
12588 //----------------------------------------------------------------
12589 override int GetQuantityMin()
12590 {
12591 return m_VarQuantityMin;
12592 }
12593 //----------------------------------------------------------------
12594 int GetQuantityInit()
12595 {
12596 return m_VarQuantityInit;
12597 }
12598
12599 //----------------------------------------------------------------
12600 override bool HasQuantity()
12601 {
12602 return !(GetQuantityMax() - GetQuantityMin() == 0);
12603 }
12604
12605 override float GetQuantity()
12606 {
12607 return m_VarQuantity;
12608 }
12609
12610 bool IsFullQuantity()
12611 {
12612 return GetQuantity() >= GetQuantityMax();
12613 }
12614
12615 //Calculates weight of single item without attachments and cargo
12616 override float GetSingleInventoryItemWeightEx()
12617 {
12618 //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
12619 float weightEx = GetWeightEx();//overall weight of the item
12620 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12621 return weightEx - special;
12622 }
12623
12624 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12626 {
12628 }
12629
12630 override protected float GetWeightSpecialized(bool forceRecalc = false)
12631 {
12632 if (IsSplitable()) //quantity determines size of the stack
12633 {
12634 #ifdef DEVELOPER
12635 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12636 {
12637 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12638 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12639 }
12640 #endif
12641
12642 return GetQuantity() * GetConfigWeightModified();
12643 }
12644 else if (HasEnergyManager())// items with energy manager
12645 {
12646 #ifdef DEVELOPER
12647 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12648 {
12649 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12650 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12651 }
12652 #endif
12653 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12654 }
12655 else//everything else
12656 {
12657 #ifdef DEVELOPER
12658 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12659 {
12660 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12661 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12662 }
12663 #endif
12664 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12665 }
12666 }
12667
12669 int GetNumberOfItems()
12670 {
12671 int item_count = 0;
12672 ItemBase item;
12673
12674 if (GetInventory().GetCargo() != NULL)
12675 {
12676 item_count = GetInventory().GetCargo().GetItemCount();
12677 }
12678
12679 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
12680 {
12681 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
12682 if (item)
12683 item_count += item.GetNumberOfItems();
12684 }
12685 return item_count;
12686 }
12687
12689 float GetUnitWeight(bool include_wetness = true)
12690 {
12691 float weight = 0;
12692 float wetness = 1;
12693 if (include_wetness)
12694 wetness += GetWet();
12695 if (IsSplitable()) //quantity determines size of the stack
12696 {
12697 weight = wetness * m_ConfigWeight;
12698 }
12699 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12700 {
12701 weight = 1;
12702 }
12703 return weight;
12704 }
12705
12706 //-----------------------------------------------------------------
12707
12708 override void ClearInventory()
12709 {
12710 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
12711 {
12712 GameInventory inv = GetInventory();
12713 array<EntityAI> items = new array<EntityAI>;
12714 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
12715 for (int i = 0; i < items.Count(); i++)
12716 {
12717 ItemBase item = ItemBase.Cast(items.Get(i));
12718 if (item)
12719 {
12720 GetGame().ObjectDelete(item);
12721 }
12722 }
12723 }
12724 }
12725
12726 //------------------------- Energy
12727
12728 //----------------------------------------------------------------
12729 float GetEnergy()
12730 {
12731 float energy = 0;
12732 if (HasEnergyManager())
12733 {
12734 energy = GetCompEM().GetEnergy();
12735 }
12736 return energy;
12737 }
12738
12739
12740 override void OnEnergyConsumed()
12741 {
12742 super.OnEnergyConsumed();
12743
12745 }
12746
12747 override void OnEnergyAdded()
12748 {
12749 super.OnEnergyAdded();
12750
12752 }
12753
12754 // Converts energy (from Energy Manager) to quantity, if enabled.
12756 {
12757 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12758 {
12759 if (HasQuantity())
12760 {
12761 float energy_0to1 = GetCompEM().GetEnergy0To1();
12762 SetQuantityNormalized(energy_0to1);
12763 }
12764 }
12765 }
12766
12767 //----------------------------------------------------------------
12768 float GetHeatIsolationInit()
12769 {
12770 return ConfigGetFloat("heatIsolation");
12771 }
12772
12773 float GetHeatIsolation()
12774 {
12775 return m_HeatIsolation;
12776 }
12777
12778 float GetDryingIncrement(string pIncrementName)
12779 {
12780 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12781 if (GetGame().ConfigIsExisting(paramPath))
12782 return GetGame().ConfigGetFloat(paramPath);
12783
12784 return 0.0;
12785 }
12786
12787 float GetSoakingIncrement(string pIncrementName)
12788 {
12789 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12790 if (GetGame().ConfigIsExisting(paramPath))
12791 return GetGame().ConfigGetFloat(paramPath);
12792
12793 return 0.0;
12794 }
12795 //----------------------------------------------------------------
12796 override void SetWet(float value, bool allow_client = false)
12797 {
12798 if (!IsServerCheck(allow_client))
12799 return;
12800
12801 float min = GetWetMin();
12802 float max = GetWetMax();
12803
12804 float previousValue = m_VarWet;
12805
12806 m_VarWet = Math.Clamp(value, min, max);
12807
12808 if (previousValue != m_VarWet)
12809 {
12810 SetVariableMask(VARIABLE_WET);
12811 OnWetChanged(m_VarWet, previousValue);
12812 }
12813 }
12814 //----------------------------------------------------------------
12815 override void AddWet(float value)
12816 {
12817 SetWet(GetWet() + value);
12818 }
12819 //----------------------------------------------------------------
12820 override void SetWetMax()
12821 {
12823 }
12824 //----------------------------------------------------------------
12825 override float GetWet()
12826 {
12827 return m_VarWet;
12828 }
12829 //----------------------------------------------------------------
12830 override float GetWetMax()
12831 {
12832 return m_VarWetMax;
12833 }
12834 //----------------------------------------------------------------
12835 override float GetWetMin()
12836 {
12837 return m_VarWetMin;
12838 }
12839 //----------------------------------------------------------------
12840 override float GetWetInit()
12841 {
12842 return m_VarWetInit;
12843 }
12844 //----------------------------------------------------------------
12845 override void OnWetChanged(float newVal, float oldVal)
12846 {
12847 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12848 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12849 if (newLevel != oldLevel)
12850 {
12851 OnWetLevelChanged(newLevel,oldLevel);
12852 }
12853 }
12854
12855 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12856 {
12857 SetWeightDirty();
12858 }
12859
12860 override EWetnessLevel GetWetLevel()
12861 {
12862 return GetWetLevelInternal(m_VarWet);
12863 }
12864
12865 //----------------------------------------------------------------
12866
12867 override void SetStoreLoad(bool value)
12868 {
12869 m_IsStoreLoad = value;
12870 }
12871
12872 override bool IsStoreLoad()
12873 {
12874 return m_IsStoreLoad;
12875 }
12876
12877 override void SetStoreLoadedQuantity(float value)
12878 {
12879 m_StoreLoadedQuantity = value;
12880 }
12881
12882 override float GetStoreLoadedQuantity()
12883 {
12884 return m_StoreLoadedQuantity;
12885 }
12886
12887 //----------------------------------------------------------------
12888
12889 float GetItemModelLength()
12890 {
12891 if (ConfigIsExisting("itemModelLength"))
12892 {
12893 return ConfigGetFloat("itemModelLength");
12894 }
12895 return 0;
12896 }
12897
12898 float GetItemAttachOffset()
12899 {
12900 if (ConfigIsExisting("itemAttachOffset"))
12901 {
12902 return ConfigGetFloat("itemAttachOffset");
12903 }
12904 return 0;
12905 }
12906
12907 override void SetCleanness(int value, bool allow_client = false)
12908 {
12909 if (!IsServerCheck(allow_client))
12910 return;
12911
12912 int previousValue = m_Cleanness;
12913
12914 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12915
12916 if (previousValue != m_Cleanness)
12917 SetVariableMask(VARIABLE_CLEANNESS);
12918 }
12919
12920 override int GetCleanness()
12921 {
12922 return m_Cleanness;
12923 }
12924
12926 {
12927 return true;
12928 }
12929
12930 //----------------------------------------------------------------
12931 // ATTACHMENT LOCKING
12932 // Getters relevant to generic ActionLockAttachment
12933 int GetLockType()
12934 {
12935 return m_LockType;
12936 }
12937
12938 string GetLockSoundSet()
12939 {
12940 return m_LockSoundSet;
12941 }
12942
12943 //----------------------------------------------------------------
12944 //------------------------- Color
12945 // sets items color variable given color components
12946 override void SetColor(int r, int g, int b, int a)
12947 {
12952 SetVariableMask(VARIABLE_COLOR);
12953 }
12955 override void GetColor(out int r,out int g,out int b,out int a)
12956 {
12961 }
12962
12963 bool IsColorSet()
12964 {
12965 return IsVariableSet(VARIABLE_COLOR);
12966 }
12967
12969 string GetColorString()
12970 {
12971 int r,g,b,a;
12972 GetColor(r,g,b,a);
12973 r = r/255;
12974 g = g/255;
12975 b = b/255;
12976 a = a/255;
12977 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12978 }
12979 //----------------------------------------------------------------
12980 //------------------------- LiquidType
12981
12982 override void SetLiquidType(int value, bool allow_client = false)
12983 {
12984 if (!IsServerCheck(allow_client))
12985 return;
12986
12987 int old = m_VarLiquidType;
12988 m_VarLiquidType = value;
12989 OnLiquidTypeChanged(old,value);
12990 SetVariableMask(VARIABLE_LIQUIDTYPE);
12991 }
12992
12993 int GetLiquidTypeInit()
12994 {
12995 return ConfigGetInt("varLiquidTypeInit");
12996 }
12997
12998 override int GetLiquidType()
12999 {
13000 return m_VarLiquidType;
13001 }
13002
13003 protected void OnLiquidTypeChanged(int oldType, int newType)
13004 {
13005 if (newType == LIQUID_NONE && GetIsFrozen())
13006 SetFrozen(false);
13007 }
13008
13010 void UpdateQuickbarShortcutVisibility(PlayerBase player)
13011 {
13012 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13013 }
13014
13015 // -------------------------------------------------------------------------
13017 void OnInventoryEnter(Man player)
13018 {
13019 PlayerBase nplayer;
13020 if (PlayerBase.CastTo(nplayer, player))
13021 {
13022 m_CanPlayImpactSound = true;
13023 //nplayer.OnItemInventoryEnter(this);
13024 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13025 }
13026 }
13027
13028 // -------------------------------------------------------------------------
13030 void OnInventoryExit(Man player)
13031 {
13032 PlayerBase nplayer;
13033 if (PlayerBase.CastTo(nplayer,player))
13034 {
13035 //nplayer.OnItemInventoryExit(this);
13036 nplayer.SetEnableQuickBarEntityShortcut(this,false);
13037
13038 }
13039
13040 //if (!GetGame().IsDedicatedServer())
13041 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
13042
13043
13044 if (HasEnergyManager())
13045 {
13046 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
13047 }
13048 }
13049
13050 // ADVANCED PLACEMENT EVENTS
13051 override void OnPlacementStarted(Man player)
13052 {
13053 super.OnPlacementStarted(player);
13054
13055 SetTakeable(false);
13056 }
13057
13058 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
13059 {
13060 if (m_AdminLog)
13061 {
13062 m_AdminLog.OnPlacementComplete(player, this);
13063 }
13064
13065 super.OnPlacementComplete(player, position, orientation);
13066 }
13067
13068 //-----------------------------
13069 // AGENT SYSTEM
13070 //-----------------------------
13071 //--------------------------------------------------------------------------
13072 bool ContainsAgent(int agent_id)
13073 {
13074 if (agent_id & m_AttachedAgents)
13075 {
13076 return true;
13077 }
13078 else
13079 {
13080 return false;
13081 }
13082 }
13083
13084 //--------------------------------------------------------------------------
13085 override void RemoveAgent(int agent_id)
13086 {
13087 if (ContainsAgent(agent_id))
13088 {
13089 m_AttachedAgents = ~agent_id & m_AttachedAgents;
13090 }
13091 }
13092
13093 //--------------------------------------------------------------------------
13094 override void RemoveAllAgents()
13095 {
13096 m_AttachedAgents = 0;
13097 }
13098 //--------------------------------------------------------------------------
13099 override void RemoveAllAgentsExcept(int agent_to_keep)
13100 {
13101 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
13102 }
13103 // -------------------------------------------------------------------------
13104 override void InsertAgent(int agent, float count = 1)
13105 {
13106 if (count < 1)
13107 return;
13108 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
13110 }
13111
13113 void TransferAgents(int agents)
13114 {
13116 }
13117
13118 // -------------------------------------------------------------------------
13119 override int GetAgents()
13120 {
13121 return m_AttachedAgents;
13122 }
13123 //----------------------------------------------------------------------
13124
13125 /*int GetContaminationType()
13126 {
13127 int contamination_type;
13128
13129 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
13130 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
13131 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
13132 const int DIRTY_MASK = eAgents.WOUND_AGENT;
13133
13134 Edible_Base edible = Edible_Base.Cast(this);
13135 int agents = GetAgents();
13136 if (edible)
13137 {
13138 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
13139 if (profile)
13140 {
13141 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
13142 }
13143 }
13144 if (agents & CONTAMINATED_MASK)
13145 {
13146 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
13147 }
13148 if (agents & POISONED_MASK)
13149 {
13150 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
13151 }
13152 if (agents & NERVE_GAS_MASK)
13153 {
13154 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
13155 }
13156 if (agents & DIRTY_MASK)
13157 {
13158 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
13159 }
13160
13161 return agents;
13162 }*/
13163
13164 // -------------------------------------------------------------------------
13165 bool LoadAgents(ParamsReadContext ctx, int version)
13166 {
13167 if (!ctx.Read(m_AttachedAgents))
13168 return false;
13169 return true;
13170 }
13171 // -------------------------------------------------------------------------
13173 {
13174
13176 }
13177 // -------------------------------------------------------------------------
13178
13180 override void CheckForRoofLimited(float timeTresholdMS = 3000)
13181 {
13182 super.CheckForRoofLimited(timeTresholdMS);
13183
13184 float time = GetGame().GetTime();
13185 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
13186 {
13187 m_PreviousRoofTestTime = time;
13188 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
13189 }
13190 }
13191
13192 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
13193 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
13194 {
13195 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
13196 {
13197 return 0;
13198 }
13199
13200 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
13201 {
13202 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
13203 if (filter)
13204 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
13205 else
13206 return 0;//otherwise return 0 when no filter attached
13207 }
13208
13209 string subclassPath, entryName;
13210
13211 switch (type)
13212 {
13213 case DEF_BIOLOGICAL:
13214 entryName = "biological";
13215 break;
13216 case DEF_CHEMICAL:
13217 entryName = "chemical";
13218 break;
13219 default:
13220 entryName = "biological";
13221 break;
13222 }
13223
13224 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
13225
13226 return GetGame().ConfigGetFloat(subclassPath + entryName);
13227 }
13228
13229
13230
13232 override void EEOnCECreate()
13233 {
13234 if (!IsMagazine())
13236
13238 }
13239
13240
13241 //-------------------------
13242 // OPEN/CLOSE USER ACTIONS
13243 //-------------------------
13245 void Open();
13246 void Close();
13247 bool IsOpen()
13248 {
13249 return true;
13250 }
13251
13252 override bool CanDisplayCargo()
13253 {
13254 return IsOpen();
13255 }
13256
13257
13258 // ------------------------------------------------------------
13259 // CONDITIONS
13260 // ------------------------------------------------------------
13261 override bool CanPutInCargo(EntityAI parent)
13262 {
13263 if (parent)
13264 {
13265 if (parent.IsInherited(DayZInfected))
13266 return true;
13267
13268 if (!parent.IsRuined())
13269 return true;
13270 }
13271
13272 return true;
13273 }
13274
13275 override bool CanPutAsAttachment(EntityAI parent)
13276 {
13277 if (!super.CanPutAsAttachment(parent))
13278 {
13279 return false;
13280 }
13281
13282 if (!IsRuined() && !parent.IsRuined())
13283 {
13284 return true;
13285 }
13286
13287 return false;
13288 }
13289
13290 override bool CanReceiveItemIntoCargo(EntityAI item)
13291 {
13292 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13293 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13294 // return false;
13295
13296 return super.CanReceiveItemIntoCargo(item);
13297 }
13298
13299 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13300 {
13301 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13302 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13303 // return false;
13304
13305 GameInventory attachmentInv = attachment.GetInventory();
13306 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13307 {
13308 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13309 return false;
13310 }
13311
13312 InventoryLocation loc = new InventoryLocation();
13313 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13314 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13315 return false;
13316
13317 return super.CanReceiveAttachment(attachment, slotId);
13318 }
13319
13320 override bool CanReleaseAttachment(EntityAI attachment)
13321 {
13322 if (!super.CanReleaseAttachment(attachment))
13323 return false;
13324
13325 return GetInventory().AreChildrenAccessible();
13326 }
13327
13328 /*override bool CanLoadAttachment(EntityAI attachment)
13329 {
13330 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13331 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13332 // return false;
13333
13334 GameInventory attachmentInv = attachment.GetInventory();
13335 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13336 {
13337 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13338 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13339
13340 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13341 return false;
13342 }
13343
13344 return super.CanLoadAttachment(attachment);
13345 }*/
13346
13347 // Plays muzzle flash particle effects
13348 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13349 {
13350 int id = muzzle_owner.GetMuzzleID();
13351 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13352
13353 if (WPOF_array)
13354 {
13355 for (int i = 0; i < WPOF_array.Count(); i++)
13356 {
13357 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13358
13359 if (WPOF)
13360 {
13361 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13362 }
13363 }
13364 }
13365 }
13366
13367 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13368 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13369 {
13370 int id = muzzle_owner.GetMuzzleID();
13371 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13372
13373 if (WPOBE_array)
13374 {
13375 for (int i = 0; i < WPOBE_array.Count(); i++)
13376 {
13377 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13378
13379 if (WPOBE)
13380 {
13381 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13382 }
13383 }
13384 }
13385 }
13386
13387 // Plays all weapon overheating particles
13388 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13389 {
13390 int id = muzzle_owner.GetMuzzleID();
13391 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13392
13393 if (WPOOH_array)
13394 {
13395 for (int i = 0; i < WPOOH_array.Count(); i++)
13396 {
13397 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13398
13399 if (WPOOH)
13400 {
13401 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13402 }
13403 }
13404 }
13405 }
13406
13407 // Updates all weapon overheating particles
13408 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13409 {
13410 int id = muzzle_owner.GetMuzzleID();
13411 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13412
13413 if (WPOOH_array)
13414 {
13415 for (int i = 0; i < WPOOH_array.Count(); i++)
13416 {
13417 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13418
13419 if (WPOOH)
13420 {
13421 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13422 }
13423 }
13424 }
13425 }
13426
13427 // Stops overheating particles
13428 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13429 {
13430 int id = muzzle_owner.GetMuzzleID();
13431 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13432
13433 if (WPOOH_array)
13434 {
13435 for (int i = 0; i < WPOOH_array.Count(); i++)
13436 {
13437 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13438
13439 if (WPOOH)
13440 {
13441 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13442 }
13443 }
13444 }
13445 }
13446
13447 //----------------------------------------------------------------
13448 //Item Behaviour - unified approach
13449 override bool IsHeavyBehaviour()
13450 {
13451 if (m_ItemBehaviour == 0)
13452 {
13453 return true;
13454 }
13455
13456 return false;
13457 }
13458
13459 override bool IsOneHandedBehaviour()
13460 {
13461 if (m_ItemBehaviour == 1)
13462 {
13463 return true;
13464 }
13465
13466 return false;
13467 }
13468
13469 override bool IsTwoHandedBehaviour()
13470 {
13471 if (m_ItemBehaviour == 2)
13472 {
13473 return true;
13474 }
13475
13476 return false;
13477 }
13478
13479 bool IsDeployable()
13480 {
13481 return false;
13482 }
13483
13485 float GetDeployTime()
13486 {
13487 return UATimeSpent.DEFAULT_DEPLOY;
13488 }
13489
13490
13491 //----------------------------------------------------------------
13492 // Item Targeting (User Actions)
13493 override void SetTakeable(bool pState)
13494 {
13495 m_IsTakeable = pState;
13496 SetSynchDirty();
13497 }
13498
13499 override bool IsTakeable()
13500 {
13501 return m_IsTakeable;
13502 }
13503
13504 // For cases where we want to show object widget which cant be taken to hands
13506 {
13507 return false;
13508 }
13509
13511 protected void PreLoadSoundAttachmentType()
13512 {
13513 string att_type = "None";
13514
13515 if (ConfigIsExisting("soundAttType"))
13516 {
13517 att_type = ConfigGetString("soundAttType");
13518 }
13519
13520 m_SoundAttType = att_type;
13521 }
13522
13523 override string GetAttachmentSoundType()
13524 {
13525 return m_SoundAttType;
13526 }
13527
13528 //----------------------------------------------------------------
13529 //SOUNDS - ItemSoundHandler
13530 //----------------------------------------------------------------
13531
13532 string GetPlaceSoundset(); // played when deploy starts
13533 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13534 string GetDeploySoundset(); // played when deploy sucessfully finishes
13535 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13536 string GetFoldSoundset(); // played when fold sucessfully finishes
13537
13539 {
13540 if (!m_ItemSoundHandler)
13542
13543 return m_ItemSoundHandler;
13544 }
13545
13546 // override to initialize sounds
13547 protected void InitItemSounds()
13548 {
13549 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
13550 return;
13551
13553
13554 if (GetPlaceSoundset() != string.Empty)
13555 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13556
13557 if (GetDeploySoundset() != string.Empty)
13558 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13559
13560 SoundParameters params = new SoundParameters();
13561 params.m_Loop = true;
13562 if (GetLoopDeploySoundset() != string.Empty)
13563 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13564 }
13565
13566 // Start sound using ItemSoundHandler
13567 void StartItemSoundServer(int id)
13568 {
13569 if (!GetGame().IsServer())
13570 return;
13571
13572 m_SoundSyncPlay = id;
13573 SetSynchDirty();
13574
13575 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13577 }
13578
13579 // Stop sound using ItemSoundHandler
13580 void StopItemSoundServer(int id)
13581 {
13582 if (!GetGame().IsServer())
13583 return;
13584
13585 m_SoundSyncStop = id;
13586 SetSynchDirty();
13587
13588 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13590 }
13591
13592 protected void ClearStartItemSoundServer()
13593 {
13594 m_SoundSyncPlay = 0;
13595 }
13596
13597 protected void ClearStopItemSoundServer()
13598 {
13599 m_SoundSyncStop = 0;
13600 }
13601
13603 void PlayAttachSound(string slot_type)
13604 {
13605 if (!GetGame().IsDedicatedServer())
13606 {
13607 if (ConfigIsExisting("attachSoundSet"))
13608 {
13609 string cfg_path = "";
13610 string soundset = "";
13611 string type_name = GetType();
13612
13613 TStringArray cfg_soundset_array = new TStringArray;
13614 TStringArray cfg_slot_array = new TStringArray;
13615 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13616 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13617
13618 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13619 {
13620 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13621 {
13622 if (cfg_slot_array[i] == slot_type)
13623 {
13624 soundset = cfg_soundset_array[i];
13625 break;
13626 }
13627 }
13628 }
13629
13630 if (soundset != "")
13631 {
13632 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13633 sound.SetAutodestroy(true);
13634 }
13635 }
13636 }
13637 }
13638
13639 void PlayDetachSound(string slot_type)
13640 {
13641 //TODO - evaluate if needed and devise universal config structure if so
13642 }
13643
13644 void OnApply(PlayerBase player);
13645
13647 {
13648 return 1.0;
13649 };
13650 //returns applicable selection
13651 array<string> GetHeadHidingSelection()
13652 {
13654 }
13655
13657 {
13659 }
13660
13661 WrittenNoteData GetWrittenNoteData() {};
13662
13664 {
13665 SetDynamicPhysicsLifeTime(0.01);
13666 m_ItemBeingDroppedPhys = false;
13667 }
13668
13670 {
13671 array<string> zone_names = new array<string>;
13672 GetDamageZones(zone_names);
13673 for (int i = 0; i < zone_names.Count(); i++)
13674 {
13675 SetHealthMax(zone_names.Get(i),"Health");
13676 }
13677 SetHealthMax("","Health");
13678 }
13679
13681 void SetZoneDamageCEInit()
13682 {
13683 float global_health = GetHealth01("","Health");
13684 array<string> zones = new array<string>;
13685 GetDamageZones(zones);
13686 //set damage of all zones to match global health level
13687 for (int i = 0; i < zones.Count(); i++)
13688 {
13689 SetHealth01(zones.Get(i),"Health",global_health);
13690 }
13691 }
13692
13694 bool IsCoverFaceForShave(string slot_name)
13695 {
13696 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13697 }
13698
13699 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13700 {
13701 if (!hasRootAsPlayer)
13702 {
13703 if (refParentIB)
13704 {
13705 // parent is wet
13706 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13707 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13708 // parent has liquid inside
13709 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13710 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13711 // drying
13712 else if (m_VarWet > m_VarWetMin)
13713 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13714 }
13715 else
13716 {
13717 // drying on ground or inside non-itembase (car, ...)
13718 if (m_VarWet > m_VarWetMin)
13719 AddWet(-1 * delta * GetDryingIncrement("ground"));
13720 }
13721 }
13722 }
13723
13724 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13725 {
13727 {
13728 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13729 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13730 {
13731 float heatPermCoef = 1.0;
13732 EntityAI ent = this;
13733 while (ent)
13734 {
13735 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13736 ent = ent.GetHierarchyParent();
13737 }
13738
13739 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13740 }
13741 }
13742 }
13743
13744 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13745 {
13746 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13747 EntityAI parent = GetHierarchyParent();
13748 if (!parent)
13749 {
13750 hasParent = false;
13751 hasRootAsPlayer = false;
13752 }
13753 else
13754 {
13755 hasParent = true;
13756 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13757 refParentIB = ItemBase.Cast(parent);
13758 }
13759 }
13760
13761 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13762 {
13763 // this is stub, implemented on Edible_Base
13764 }
13765
13766 bool CanDecay()
13767 {
13768 // return true used on selected food clases so they can decay
13769 return false;
13770 }
13771
13772 protected bool CanProcessDecay()
13773 {
13774 // this is stub, implemented on Edible_Base class
13775 // used to determine whether it is still necessary for the food to decay
13776 return false;
13777 }
13778
13779 protected bool CanHaveWetness()
13780 {
13781 // return true used on selected items that have a wetness effect
13782 return false;
13783 }
13784
13786 bool CanBeConsumed(ConsumeConditionData data = null)
13787 {
13788 return !GetIsFrozen() && IsOpen();
13789 }
13790
13791 override void ProcessVariables()
13792 {
13793 bool hasParent = false, hasRootAsPlayer = false;
13794 ItemBase refParentIB;
13795
13796 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13797 bool foodDecay = g_Game.IsFoodDecayEnabled();
13798
13799 if (wwtu || foodDecay)
13800 {
13801 bool processWetness = wwtu && CanHaveWetness();
13802 bool processTemperature = wwtu && CanHaveTemperature();
13803 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13804
13805 if (processWetness || processTemperature || processDecay)
13806 {
13807 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13808
13809 if (processWetness)
13810 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13811
13812 if (processTemperature)
13813 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13814
13815 if (processDecay)
13816 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13817 }
13818 }
13819 }
13820
13823 {
13824 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13825 }
13826
13827 override float GetTemperatureFreezeThreshold()
13828 {
13830 return Liquid.GetFreezeThreshold(GetLiquidType());
13831
13832 return super.GetTemperatureFreezeThreshold();
13833 }
13834
13835 override float GetTemperatureThawThreshold()
13836 {
13838 return Liquid.GetThawThreshold(GetLiquidType());
13839
13840 return super.GetTemperatureThawThreshold();
13841 }
13842
13843 override float GetItemOverheatThreshold()
13844 {
13846 return Liquid.GetBoilThreshold(GetLiquidType());
13847
13848 return super.GetItemOverheatThreshold();
13849 }
13850
13851 override float GetTemperatureFreezeTime()
13852 {
13853 if (HasQuantity())
13854 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13855
13856 return super.GetTemperatureFreezeTime();
13857 }
13858
13859 override float GetTemperatureThawTime()
13860 {
13861 if (HasQuantity())
13862 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13863
13864 return super.GetTemperatureThawTime();
13865 }
13866
13868 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13870 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13871
13872 bool IsCargoException4x3(EntityAI item)
13873 {
13874 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13875 }
13876
13878 {
13879 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13880 }
13881
13883 void AddLightSourceItem(ItemBase lightsource)
13884 {
13885 m_LightSourceItem = lightsource;
13886 }
13887
13889 {
13890 m_LightSourceItem = null;
13891 }
13892
13894 {
13895 return m_LightSourceItem;
13896 }
13897
13899 array<int> GetValidFinishers()
13900 {
13901 return null;
13902 }
13903
13905 bool GetActionWidgetOverride(out typename name)
13906 {
13907 return false;
13908 }
13909
13910 bool PairWithDevice(notnull ItemBase otherDevice)
13911 {
13912 if (GetGame().IsServer())
13913 {
13914 ItemBase explosive = otherDevice;
13916 if (!trg)
13917 {
13918 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13919 explosive = this;
13920 }
13921
13922 explosive.PairRemote(trg);
13923 trg.SetControlledDevice(explosive);
13924
13925 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13926 trg.SetPersistentPairID(persistentID);
13927 explosive.SetPersistentPairID(persistentID);
13928
13929 return true;
13930 }
13931 return false;
13932 }
13933
13935 float GetBaitEffectivity()
13936 {
13937 float ret = 1.0;
13938 if (HasQuantity())
13939 ret *= GetQuantityNormalized();
13940 ret *= GetHealth01();
13941
13942 return ret;
13943 }
13944
13945 #ifdef DEVELOPER
13946 override void SetDebugItem()
13947 {
13948 super.SetDebugItem();
13949 _itemBase = this;
13950 }
13951
13952 override string GetDebugText()
13953 {
13954 string text = super.GetDebugText();
13955
13956 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13957 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13958
13959 return text;
13960 }
13961 #endif
13962
13963 bool CanBeUsedForSuicide()
13964 {
13965 return true;
13966 }
13967
13969 //DEPRECATED BELOW
13971 // Backwards compatibility
13972 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13973 {
13974 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13975 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13976 }
13977
13978 // replaced by ItemSoundHandler
13979 protected EffectSound m_SoundDeployFinish;
13980 protected EffectSound m_SoundPlace;
13981 protected EffectSound m_DeployLoopSoundEx;
13982 protected EffectSound m_SoundDeploy;
13983 bool m_IsPlaceSound;
13984 bool m_IsDeploySound;
13986
13987 string GetDeployFinishSoundset();
13988 void PlayDeploySound();
13989 void PlayDeployFinishSound();
13990 void PlayPlaceSound();
13991 void PlayDeployLoopSoundEx();
13992 void StopDeployLoopSoundEx();
13993 void SoundSynchRemoteReset();
13994 void SoundSynchRemote();
13995 bool UsesGlobalDeploy(){return false;}
13996 bool CanPlayDeployLoopSound(){return false;}
13998 bool IsPlaceSound(){return m_IsPlaceSound;}
13999 bool IsDeploySound(){return m_IsDeploySound;}
14000 void SetIsPlaceSound(bool is_place_sound);
14001 void SetIsDeploySound(bool is_deploy_sound);
14002}
14003
14004EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
14005{
14006 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
14007 if (entity)
14008 {
14009 bool is_item = entity.IsInherited(ItemBase);
14010 if (is_item && full_quantity)
14011 {
14012 ItemBase item = ItemBase.Cast(entity);
14013 item.SetQuantity(item.GetQuantityInit());
14014 }
14015 }
14016 else
14017 {
14018 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
14019 return NULL;
14020 }
14021 return entity;
14022}
14023
14024void SetupSpawnedItem(ItemBase item, float health, float quantity)
14025{
14026 if (item)
14027 {
14028 if (health > 0)
14029 item.SetHealth("", "", health);
14030
14031 if (item.CanHaveTemperature())
14032 {
14033 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
14034 if (item.CanFreeze())
14035 item.SetFrozen(false);
14036 }
14037
14038 if (item.HasEnergyManager())
14039 {
14040 if (quantity >= 0)
14041 {
14042 item.GetCompEM().SetEnergy0To1(quantity);
14043 }
14044 else
14045 {
14046 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
14047 }
14048 }
14049 else if (item.IsMagazine())
14050 {
14051 Magazine mag = Magazine.Cast(item);
14052 if (quantity >= 0)
14053 {
14054 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
14055 }
14056 else
14057 {
14058 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
14059 }
14060
14061 }
14062 else
14063 {
14064 if (quantity >= 0)
14065 {
14066 item.SetQuantityNormalized(quantity, false);
14067 }
14068 else
14069 {
14070 item.SetQuantity(Math.AbsFloat(quantity));
14071 }
14072
14073 }
14074 }
14075}
14076
14077#ifdef DEVELOPER
14078ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
14079#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
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:14
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
int GetLiquidType()
Определения CCTWaterSurface.c:129
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:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
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:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
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:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
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:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
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:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
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:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
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:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
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
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
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/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
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:469
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:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
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 void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
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:424
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 IsClothing()
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
Определения 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 void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, 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)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
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:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
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
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
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:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
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/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()