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

◆ SetZoneDamageCEInit()

void SpawnItemOnLocation::SetZoneDamageCEInit ( )
protected

Sets zone damages to match randomized global health set by CE (CE spawn only)

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

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

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