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

◆ StopItemDynamicPhysics()

void SpawnItemOnLocation::StopItemDynamicPhysics ( )
protected

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

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