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

◆ CanBeCooked()

bool SpawnItemOnLocation::CanBeCooked ( )
protected

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

7482{
7483 override bool CanPutAsAttachment(EntityAI parent)
7484 {
7485 return true;
7486 }
7487};
7488
7489//const bool QUANTITY_DEBUG_REMOVE_ME = false;
7490
7491class ItemBase extends InventoryItem
7492{
7496
7498
7499 static int m_DebugActionsMask;
7501 // ============================================
7502 // Variable Manipulation System
7503 // ============================================
7504 // Quantity
7505
7506 float m_VarQuantity;
7507 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7509 int m_VarQuantityMin;
7510 int m_VarQuantityMax;
7511 int m_Count;
7512 float m_VarStackMax;
7513 float m_StoreLoadedQuantity = float.LOWEST;
7514 // Wet
7515 float m_VarWet;
7516 float m_VarWetPrev;//for client to know wetness changed during synchronization
7517 float m_VarWetInit;
7518 float m_VarWetMin;
7519 float m_VarWetMax;
7520 // Cleanness
7521 int m_Cleanness;
7522 int m_CleannessInit;
7523 int m_CleannessMin;
7524 int m_CleannessMax;
7525 // impact sounds
7527 bool m_CanPlayImpactSound = true;
7528 float m_ImpactSpeed;
7530 //
7531 float m_HeatIsolation;
7532 float m_ItemModelLength;
7533 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7535 int m_VarLiquidType;
7536 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7537 int m_QuickBarBonus;
7538 bool m_IsBeingPlaced;
7539 bool m_IsHologram;
7540 bool m_IsTakeable;
7541 bool m_ThrowItemOnDrop;
7544 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7545 bool can_this_be_combined; //Check if item can be combined
7546 bool m_CanThisBeSplit; //Check if item can be split
7547 bool m_IsStoreLoad = false;
7548 bool m_CanShowQuantity;
7549 bool m_HasQuantityBar;
7550 protected bool m_CanBeDigged;
7551 protected bool m_IsResultOfSplit
7552
7553 string m_SoundAttType;
7554 // items color variables
7559 //-------------------------------------------------------
7560
7561 // light source managing
7563
7567
7568 //==============================================
7569 // agent system
7570 private int m_AttachedAgents;
7571
7573 void TransferModifiers(PlayerBase reciever);
7574
7575
7576 // Weapons & suppressors particle effects
7581 static int m_LastRegisteredWeaponID = 0;
7582
7583 // Overheating effects
7585 float m_OverheatingShots;
7586 ref Timer m_CheckOverheating;
7587 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7588 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
7589 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
7590 ref array <ref OverheatingParticle> m_OverheatingParticles;
7591
7593 protected bool m_HideSelectionsBySlot;
7594
7595 // Admin Log
7596 PluginAdminLog m_AdminLog;
7597
7598 // misc
7599 ref Timer m_PhysDropTimer;
7600
7601 // Attachment Locking variables
7602 ref array<int> m_CompatibleLocks;
7603 protected int m_LockType;
7604 protected ref EffectSound m_LockingSound;
7605 protected string m_LockSoundSet;
7606
7607 // ItemSoundHandler
7608 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
7609 protected int m_SoundSyncPlay; // id for sound to play
7610 protected int m_SoundSyncStop; // id for sound to stop
7612
7613 //temperature
7614 private float m_TemperaturePerQuantityWeight;
7615
7616 // -------------------------------------------------------------------------
7617 void ItemBase()
7618 {
7619 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7623
7624 if (!GetGame().IsDedicatedServer())
7625 {
7626 if (HasMuzzle())
7627 {
7629
7631 {
7633 }
7634 }
7635
7637 m_ActionsInitialize = false;
7638 }
7639
7640 m_OldLocation = null;
7641
7642 if (GetGame().IsServer())
7643 {
7644 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7645 }
7646
7647 if (ConfigIsExisting("headSelectionsToHide"))
7648 {
7650 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7651 }
7652
7653 m_HideSelectionsBySlot = false;
7654 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7655 {
7656 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7657 }
7658
7659 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7660
7661 m_IsResultOfSplit = false;
7662
7664 }
7665
7666 override void InitItemVariables()
7667 {
7668 super.InitItemVariables();
7669
7670 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7671 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7672 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7673 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7674 m_VarStackMax = ConfigGetFloat("varStackMax");
7675 m_Count = ConfigGetInt("count");
7676
7677 m_CanShowQuantity = ConfigGetBool("quantityShow");
7678 m_HasQuantityBar = ConfigGetBool("quantityBar");
7679
7680 m_CleannessInit = ConfigGetInt("varCleannessInit");
7682 m_CleannessMin = ConfigGetInt("varCleannessMin");
7683 m_CleannessMax = ConfigGetInt("varCleannessMax");
7684
7685 m_WantPlayImpactSound = false;
7686 m_ImpactSpeed = 0.0;
7687
7688 m_VarWetInit = ConfigGetFloat("varWetInit");
7690 m_VarWetMin = ConfigGetFloat("varWetMin");
7691 m_VarWetMax = ConfigGetFloat("varWetMax");
7692
7693 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7694 if (IsLiquidContainer() && GetQuantity() != 0)
7696 m_IsBeingPlaced = false;
7697 m_IsHologram = false;
7698 m_IsTakeable = true;
7699 m_CanBeMovedOverride = false;
7703 m_CanBeDigged = ConfigGetBool("canBeDigged");
7704
7705 m_CompatibleLocks = new array<int>();
7706 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7707 m_LockType = ConfigGetInt("lockType");
7708
7709 //Define if item can be split and set ability to be combined accordingly
7710 m_CanThisBeSplit = false;
7711 can_this_be_combined = false;
7712 if (ConfigIsExisting("canBeSplit"))
7713 {
7714 can_this_be_combined = ConfigGetBool("canBeSplit");
7716 }
7717
7718 m_ItemBehaviour = -1;
7719 if (ConfigIsExisting("itemBehaviour"))
7720 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7721
7722 //RegisterNetSyncVariableInt("m_VariablesMask");
7723 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7724 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7725 RegisterNetSyncVariableInt("m_VarLiquidType");
7726 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7727
7728 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7729 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7730 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7731
7732 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7733 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7734 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7735 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7736
7737 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7738 RegisterNetSyncVariableBool("m_IsTakeable");
7739 RegisterNetSyncVariableBool("m_IsHologram");
7740
7741 InitItemSounds();
7743 {
7744 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7745 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7746 }
7747
7748 m_LockSoundSet = ConfigGetString("lockSoundSet");
7749
7751 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7752 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7753
7754 }
7755
7756 override int GetQuickBarBonus()
7757 {
7758 return m_QuickBarBonus;
7759 }
7760
7761 void InitializeActions()
7762 {
7764 if (!m_InputActionMap)
7765 {
7767 m_InputActionMap = iam;
7768 SetActions();
7770 }
7771 }
7772
7773 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7774 {
7776 {
7777 m_ActionsInitialize = true;
7779 }
7780
7781 actions = m_InputActionMap.Get(action_input_type);
7782 }
7783
7784 void SetActions()
7785 {
7786 AddAction(ActionTakeItem);
7787 AddAction(ActionTakeItemToHands);
7788 AddAction(ActionWorldCraft);
7790 AddAction(ActionAttachWithSwitch);
7791 }
7792
7793 void SetActionAnimOverrides(); // Override action animation for specific item
7794
7795 void AddAction(typename actionName)
7796 {
7797 ActionBase action = ActionManagerBase.GetAction(actionName);
7798
7799 if (!action)
7800 {
7801 Debug.LogError("Action " + actionName + " dosn't exist!");
7802 return;
7803 }
7804
7805 typename ai = action.GetInputType();
7806 if (!ai)
7807 {
7808 m_ActionsInitialize = false;
7809 return;
7810 }
7811
7812 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7813 if (!action_array)
7814 {
7815 action_array = new array<ActionBase_Basic>;
7816 m_InputActionMap.Insert(ai, action_array);
7817 }
7818 if (LogManager.IsActionLogEnable())
7819 {
7820 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7821 }
7822
7823 if (action_array.Find(action) != -1)
7824 {
7825 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7826 }
7827 else
7828 {
7829 action_array.Insert(action);
7830 }
7831 }
7832
7833 void RemoveAction(typename actionName)
7834 {
7835 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7836 ActionBase action = player.GetActionManager().GetAction(actionName);
7837 typename ai = action.GetInputType();
7838 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7839
7840 if (action_array)
7841 {
7842 action_array.RemoveItem(action);
7843 }
7844 }
7845
7846 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7847 // Set -1 for params which should stay in default state
7848 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7849 {
7850 ActionOverrideData overrideData = new ActionOverrideData();
7851 overrideData.m_CommandUID = commandUID;
7852 overrideData.m_CommandUIDProne = commandUIDProne;
7853 overrideData.m_StanceMask = stanceMask;
7854
7855 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7856 if (!actionMap) // create new map of action > overidables map
7857 {
7858 actionMap = new TActionAnimOverrideMap();
7859 m_ItemActionOverrides.Insert(action, actionMap);
7860 }
7861
7862 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7863
7864 }
7865
7866 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7867
7868 ScriptedLightBase GetLight();
7869
7870 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7871 void LoadParticleConfigOnFire(int id)
7872 {
7873 if (!m_OnFireEffect)
7875
7878
7879 string config_to_search = "CfgVehicles";
7880 string muzzle_owner_config;
7881
7882 if (!m_OnFireEffect.Contains(id))
7883 {
7884 if (IsInherited(Weapon))
7885 config_to_search = "CfgWeapons";
7886
7887 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7888
7889 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7890
7891 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
7892
7893 if (config_OnFire_subclass_count > 0)
7894 {
7895 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7896
7897 for (int i = 0; i < config_OnFire_subclass_count; i++)
7898 {
7899 string particle_class = "";
7900 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
7901 string config_OnFire_entry = config_OnFire_class + particle_class;
7902 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7903 WPOF_array.Insert(WPOF);
7904 }
7905
7906
7907 m_OnFireEffect.Insert(id, WPOF_array);
7908 }
7909 }
7910
7911 if (!m_OnBulletCasingEjectEffect.Contains(id))
7912 {
7913 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7914 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7915
7916 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7917
7918 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7919
7920 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7921 {
7922 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7923
7924 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7925 {
7926 string particle_class2 = "";
7927 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7928 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7929 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7930 WPOBE_array.Insert(WPOBE);
7931 }
7932
7933
7934 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7935 }
7936 }
7937 }
7938
7939 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7941 {
7944
7945 if (!m_OnOverheatingEffect.Contains(id))
7946 {
7947 string config_to_search = "CfgVehicles";
7948
7949 if (IsInherited(Weapon))
7950 config_to_search = "CfgWeapons";
7951
7952 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
7953 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
7954
7955 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
7956 {
7957
7958 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
7959
7961 {
7962 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
7963 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
7964 Error(error);
7965 return;
7966 }
7967
7968 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
7969 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
7970
7971
7972
7973 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
7974 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
7975
7976 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
7977 {
7978 string particle_class = "";
7979 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
7980 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
7981 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
7982
7983 if (entry_type == CT_CLASS)
7984 {
7985 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
7986 WPOOH_array.Insert(WPOF);
7987 }
7988 }
7989
7990
7991 m_OnOverheatingEffect.Insert(id, WPOOH_array);
7992 }
7993 }
7994 }
7995
7996 float GetOverheatingValue()
7997 {
7998 return m_OverheatingShots;
7999 }
8000
8001 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8002 {
8003 if (m_MaxOverheatingValue > 0)
8004 {
8006
8007 if (!m_CheckOverheating)
8009
8011 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8012
8013 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8014 }
8015 }
8016
8017 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8018 {
8020 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8021
8023 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8024
8026 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8027
8029 {
8031 }
8032 }
8033
8035 {
8037 }
8038
8039 void OnOverheatingDecay()
8040 {
8041 if (m_MaxOverheatingValue > 0)
8042 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8043 else
8045
8046 if (m_OverheatingShots <= 0)
8047 {
8050 }
8051 else
8052 {
8053 if (!m_CheckOverheating)
8055
8057 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8058 }
8059
8060 CheckOverheating(this, "", this);
8061 }
8062
8063 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8064 {
8066 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8067 }
8068
8069 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8070 {
8072 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8074 }
8075
8076 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8077 {
8079 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8080 }
8081
8082 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8083 {
8085 m_OverheatingParticles = new array<ref OverheatingParticle>;
8086
8087 OverheatingParticle OP = new OverheatingParticle();
8088 OP.RegisterParticle(p);
8089 OP.SetOverheatingLimitMin(min_heat_coef);
8090 OP.SetOverheatingLimitMax(max_heat_coef);
8091 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8092
8093 m_OverheatingParticles.Insert(OP);
8094 }
8095
8096 float GetOverheatingCoef()
8097 {
8098 if (m_MaxOverheatingValue > 0)
8100
8101 return -1;
8102 }
8103
8105 {
8107 {
8108 float overheat_coef = GetOverheatingCoef();
8109 int count = m_OverheatingParticles.Count();
8110
8111 for (int i = count; i > 0; --i)
8112 {
8113 int id = i - 1;
8114 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8115 Particle p = OP.GetParticle();
8116
8117 float overheat_min = OP.GetOverheatingLimitMin();
8118 float overheat_max = OP.GetOverheatingLimitMax();
8119
8120 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8121 {
8122 if (p)
8123 {
8124 p.Stop();
8125 OP.RegisterParticle(null);
8126 }
8127 }
8128 }
8129 }
8130 }
8131
8133 {
8135 {
8136 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8137 {
8138 int id = i - 1;
8139 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8140
8141 if (OP)
8142 {
8143 Particle p = OP.GetParticle();
8144
8145 if (p)
8146 {
8147 p.Stop();
8148 }
8149
8150 delete OP;
8151 }
8152 }
8153
8154 m_OverheatingParticles.Clear();
8156 }
8157 }
8158
8160 float GetInfectionChance(int system = 0, Param param = null)
8161 {
8162 return 0.0;
8163 }
8164
8165
8166 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8167 {
8168 return 250;//default value
8169 }
8170
8171 float GetFilterDamageRatio()
8172 {
8173 return 0;
8174 }
8175
8177 bool HasMuzzle()
8178 {
8179 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8180 return true;
8181
8182 return false;
8183 }
8184
8186 int GetMuzzleID()
8187 {
8188 if (!m_WeaponTypeToID)
8190
8191 if (m_WeaponTypeToID.Contains(GetType()))
8192 {
8193 return m_WeaponTypeToID.Get(GetType());
8194 }
8195 else
8196 {
8197 // Register new weapon ID
8199 }
8200
8202 }
8203
8210 {
8211 return -1;
8212 }
8213
8214
8215
8216 // -------------------------------------------------------------------------
8217 void ~ItemBase()
8218 {
8219 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
8220 {
8221 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8222 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8223
8224 if (r_index >= 0)
8225 {
8226 InventoryLocation r_il = new InventoryLocation;
8227 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8228
8229 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8230 int r_type = r_il.GetType();
8231 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8232 {
8233 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8234 }
8235 else if (r_type == InventoryLocationType.ATTACHMENT)
8236 {
8237 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8238 }
8239
8240 }
8241
8242 player.GetHumanInventory().ClearUserReservedLocation(this);
8243 }
8244
8245 if (m_LockingSound)
8246 SEffectManager.DestroyEffect(m_LockingSound);
8247 }
8248
8249
8250
8251 // -------------------------------------------------------------------------
8252 static int GetDebugActionsMask()
8253 {
8254 return ItemBase.m_DebugActionsMask;
8255 }
8256
8257 static bool HasDebugActionsMask(int mask)
8258 {
8259 return ItemBase.m_DebugActionsMask & mask;
8260 }
8261
8262 static void SetDebugActionsMask(int mask)
8263 {
8264 ItemBase.m_DebugActionsMask = mask;
8265 }
8266
8267 static void AddDebugActionsMask(int mask)
8268 {
8269 ItemBase.m_DebugActionsMask |= mask;
8270 }
8271
8272 static void RemoveDebugActionsMask(int mask)
8273 {
8274 ItemBase.m_DebugActionsMask &= ~mask;
8275 }
8276
8277 static void ToggleDebugActionsMask(int mask)
8278 {
8279 if (HasDebugActionsMask(mask))
8280 {
8282 }
8283 else
8284 {
8285 AddDebugActionsMask(mask);
8286 }
8287 }
8288
8289 // -------------------------------------------------------------------------
8290 void SetCEBasedQuantity()
8291 {
8292 if (GetEconomyProfile())
8293 {
8294 float q_max = GetEconomyProfile().GetQuantityMax();
8295 if (q_max > 0)
8296 {
8297 float q_min = GetEconomyProfile().GetQuantityMin();
8298 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8299
8300 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8301 {
8302 ComponentEnergyManager comp = GetCompEM();
8303 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
8304 {
8305 comp.SetEnergy0To1(quantity_randomized);
8306 }
8307 }
8308 else if (HasQuantity())
8309 {
8310 SetQuantityNormalized(quantity_randomized, false);
8311 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8312 }
8313
8314 }
8315 }
8316 }
8317
8319 void LockToParent()
8320 {
8321 EntityAI parent = GetHierarchyParent();
8322
8323 if (parent)
8324 {
8325 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8326 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8327 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8328 }
8329 }
8330
8332 void UnlockFromParent()
8333 {
8334 EntityAI parent = GetHierarchyParent();
8335
8336 if (parent)
8337 {
8338 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
8339 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
8340 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
8341 }
8342 }
8343
8344 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
8345 {
8346 /*
8347 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
8348 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
8349 */
8350 ItemBase item2 = ItemBase.Cast(entity2);
8351
8352 if (GetGame().IsClient())
8353 {
8354 if (ScriptInputUserData.CanStoreInputUserData())
8355 {
8356 ScriptInputUserData ctx = new ScriptInputUserData;
8358 ctx.Write(-1);
8359 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8360 ctx.Write(i1);
8361 ctx.Write(item2);
8362 ctx.Write(use_stack_max);
8363 ctx.Write(-1);
8364 ctx.Send();
8365
8366 if (IsCombineAll(item2, use_stack_max))
8367 {
8368 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8369 }
8370 }
8371 }
8372 else if (!GetGame().IsMultiplayer())
8373 {
8374 CombineItems(item2, use_stack_max);
8375 }
8376 }
8377
8378 bool IsLiquidPresent()
8379 {
8380 return (GetLiquidType() != 0 && HasQuantity());
8381 }
8382
8383 bool IsLiquidContainer()
8384 {
8385 return m_LiquidContainerMask != 0;
8386 }
8387
8389 {
8390 return m_LiquidContainerMask;
8391 }
8392
8393 bool IsBloodContainer()
8394 {
8395 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8396 return false;
8397 }
8398
8399 bool IsNVG()
8400 {
8401 return false;
8402 }
8403
8406 bool IsExplosive()
8407 {
8408 return false;
8409 }
8410
8412 {
8413 return "";
8414 }
8415
8417
8418 bool IsLightSource()
8419 {
8420 return false;
8421 }
8422
8424 {
8425 return true;
8426 }
8427
8428 //--- ACTION CONDITIONS
8429 //direction
8430 bool IsFacingPlayer(PlayerBase player, string selection)
8431 {
8432 return true;
8433 }
8434
8435 bool IsPlayerInside(PlayerBase player, string selection)
8436 {
8437 return true;
8438 }
8439
8440 override bool CanObstruct()
8441 {
8442 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8443 return !player || !IsPlayerInside(player, "");
8444 }
8445
8446 override bool IsBeingPlaced()
8447 {
8448 return m_IsBeingPlaced;
8449 }
8450
8451 void SetIsBeingPlaced(bool is_being_placed)
8452 {
8453 m_IsBeingPlaced = is_being_placed;
8454 if (!is_being_placed)
8456 SetSynchDirty();
8457 }
8458
8459 //server-side
8460 void OnEndPlacement() {}
8461
8462 override bool IsHologram()
8463 {
8464 return m_IsHologram;
8465 }
8466
8467 bool CanBeDigged()
8468 {
8469 return m_CanBeDigged;
8470 }
8471
8473 {
8474 return 1;
8475 }
8476
8477 bool CanMakeGardenplot()
8478 {
8479 return false;
8480 }
8481
8482 void SetIsHologram(bool is_hologram)
8483 {
8484 m_IsHologram = is_hologram;
8485 SetSynchDirty();
8486 }
8487 /*
8488 protected float GetNutritionalEnergy()
8489 {
8490 Edible_Base edible = Edible_Base.Cast(this);
8491 return edible.GetFoodEnergy();
8492 }
8493
8494 protected float GetNutritionalWaterContent()
8495 {
8496 Edible_Base edible = Edible_Base.Cast(this);
8497 return edible.GetFoodWater();
8498 }
8499
8500 protected float GetNutritionalIndex()
8501 {
8502 Edible_Base edible = Edible_Base.Cast(this);
8503 return edible.GetFoodNutritionalIndex();
8504 }
8505
8506 protected float GetNutritionalFullnessIndex()
8507 {
8508 Edible_Base edible = Edible_Base.Cast(this);
8509 return edible.GetFoodTotalVolume();
8510 }
8511
8512 protected float GetNutritionalToxicity()
8513 {
8514 Edible_Base edible = Edible_Base.Cast(this);
8515 return edible.GetFoodToxicity();
8516
8517 }
8518 */
8519
8520
8521 // -------------------------------------------------------------------------
8522 override void OnMovedInsideCargo(EntityAI container)
8523 {
8524 super.OnMovedInsideCargo(container);
8525
8526 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8527 }
8528
8529 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8530 {
8531 super.EEItemLocationChanged(oldLoc,newLoc);
8532
8533 PlayerBase new_player = null;
8534 PlayerBase old_player = null;
8535
8536 if (newLoc.GetParent())
8537 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8538
8539 if (oldLoc.GetParent())
8540 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8541
8542 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
8543 {
8544 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
8545
8546 if (r_index >= 0)
8547 {
8548 InventoryLocation r_il = new InventoryLocation;
8549 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8550
8551 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8552 int r_type = r_il.GetType();
8553 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8554 {
8555 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8556 }
8557 else if (r_type == InventoryLocationType.ATTACHMENT)
8558 {
8559 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8560 }
8561
8562 }
8563 }
8564
8565 if (newLoc.GetType() == InventoryLocationType.HANDS)
8566 {
8567 if (new_player)
8568 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
8569
8570 if (new_player == old_player)
8571 {
8572
8573 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8574 {
8575 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8576 {
8577 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8578 {
8579 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8580 }
8581 }
8582 else
8583 {
8584 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8585 }
8586 }
8587
8588 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
8589 {
8590 int type = oldLoc.GetType();
8591 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
8592 {
8593 oldLoc.GetParent().GetOnSetLock().Invoke(this);
8594 }
8595 else if (type == InventoryLocationType.ATTACHMENT)
8596 {
8597 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
8598 }
8599 }
8600 if (!m_OldLocation)
8601 {
8602 m_OldLocation = new InventoryLocation;
8603 }
8604 m_OldLocation.Copy(oldLoc);
8605 }
8606 else
8607 {
8608 if (m_OldLocation)
8609 {
8610 m_OldLocation.Reset();
8611 }
8612 }
8613
8615 }
8616 else
8617 {
8618 if (new_player)
8619 {
8620 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8621 if (res_index >= 0)
8622 {
8623 InventoryLocation il = new InventoryLocation;
8624 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
8625 ItemBase it = ItemBase.Cast(il.GetItem());
8626 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
8627 int rel_type = il.GetType();
8628 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8629 {
8630 il.GetParent().GetOnReleaseLock().Invoke(it);
8631 }
8632 else if (rel_type == InventoryLocationType.ATTACHMENT)
8633 {
8634 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8635 }
8636 //it.GetOnReleaseLock().Invoke(it);
8637 }
8638 }
8639 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8640 {
8641 //ThrowPhysically(old_player, vector.Zero);
8642 m_ThrowItemOnDrop = false;
8643 }
8644
8645 if (m_OldLocation)
8646 {
8647 m_OldLocation.Reset();
8648 }
8649 }
8650 }
8651
8652 override void EOnContact(IEntity other, Contact extra)
8653 {
8655 {
8656 int liquidType = -1;
8657 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8658 if (impactSpeed > 0.0)
8659 {
8660 m_ImpactSpeed = impactSpeed;
8661 #ifndef SERVER
8662 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8663 #else
8664 m_WantPlayImpactSound = true;
8665 SetSynchDirty();
8666 #endif
8667 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8668 }
8669 }
8670
8671 #ifdef SERVER
8672 if (GetCompEM() && GetCompEM().IsPlugged())
8673 {
8674 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8675 GetCompEM().UnplugThis();
8676 }
8677 #endif
8678 }
8679
8680 void RefreshPhysics();
8681
8682 override void OnCreatePhysics()
8683 {
8685 }
8686
8687 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8688 {
8689
8690 }
8691 // -------------------------------------------------------------------------
8692 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8693 {
8694 super.OnItemLocationChanged(old_owner, new_owner);
8695
8696 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8697 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8698
8699 if (!relatedPlayer && playerNew)
8700 relatedPlayer = playerNew;
8701
8702 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8703 {
8704 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8705 if (actionMgr)
8706 {
8707 ActionBase currentAction = actionMgr.GetRunningAction();
8708 if (currentAction)
8709 currentAction.OnItemLocationChanged(this);
8710 }
8711 }
8712
8713 Man ownerPlayerOld = null;
8714 Man ownerPlayerNew = null;
8715
8716 if (old_owner)
8717 {
8718 if (old_owner.IsMan())
8719 {
8720 ownerPlayerOld = Man.Cast(old_owner);
8721 }
8722 else
8723 {
8724 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8725 }
8726 }
8727 else
8728 {
8729 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8730 {
8731 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8732
8733 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8734 {
8735 GetCompEM().UnplugThis();
8736 }
8737 }
8738 }
8739
8740 if (new_owner)
8741 {
8742 if (new_owner.IsMan())
8743 {
8744 ownerPlayerNew = Man.Cast(new_owner);
8745 }
8746 else
8747 {
8748 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8749 }
8750 }
8751
8752 if (ownerPlayerOld != ownerPlayerNew)
8753 {
8754 if (ownerPlayerOld)
8755 {
8756 array<EntityAI> subItemsExit = new array<EntityAI>;
8757 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8758 for (int i = 0; i < subItemsExit.Count(); i++)
8759 {
8760 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8761 itemExit.OnInventoryExit(ownerPlayerOld);
8762 }
8763 }
8764
8765 if (ownerPlayerNew)
8766 {
8767 array<EntityAI> subItemsEnter = new array<EntityAI>;
8768 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8769 for (int j = 0; j < subItemsEnter.Count(); j++)
8770 {
8771 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8772 itemEnter.OnInventoryEnter(ownerPlayerNew);
8773 }
8774 }
8775 }
8776 else if (ownerPlayerNew != null)
8777 {
8778 PlayerBase nplayer;
8779 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8780 {
8781 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8782 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8783 for (int k = 0; k < subItemsUpdate.Count(); k++)
8784 {
8785 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8786 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8787 }
8788 }
8789 }
8790
8791 if (old_owner)
8792 old_owner.OnChildItemRemoved(this);
8793 if (new_owner)
8794 new_owner.OnChildItemReceived(this);
8795 }
8796
8797 // -------------------------------------------------------------------------------
8798 override void EEDelete(EntityAI parent)
8799 {
8800 super.EEDelete(parent);
8801 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8802 if (player)
8803 {
8804 OnInventoryExit(player);
8805
8806 if (player.IsAlive())
8807 {
8808 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8809 if (r_index >= 0)
8810 {
8811 InventoryLocation r_il = new InventoryLocation;
8812 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8813
8814 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8815 int r_type = r_il.GetType();
8816 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8817 {
8818 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8819 }
8820 else if (r_type == InventoryLocationType.ATTACHMENT)
8821 {
8822 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8823 }
8824
8825 }
8826
8827 player.RemoveQuickBarEntityShortcut(this);
8828 }
8829 }
8830 }
8831 // -------------------------------------------------------------------------------
8832 override void EEKilled(Object killer)
8833 {
8834 super.EEKilled(killer);
8835
8837 if (killer && killer.IsFireplace() && CanExplodeInFire())
8838 {
8839 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8840 {
8841 if (IsMagazine())
8842 {
8843 if (Magazine.Cast(this).GetAmmoCount() > 0)
8844 {
8845 ExplodeAmmo();
8846 }
8847 }
8848 else
8849 {
8850 Explode(DamageType.EXPLOSION);
8851 }
8852 }
8853 }
8854 }
8855
8856 override void OnWasAttached(EntityAI parent, int slot_id)
8857 {
8858 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8859
8860 super.OnWasAttached(parent, slot_id);
8861
8862 if (HasQuantity())
8863 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8864
8865 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
8866 }
8867
8868 override void OnWasDetached(EntityAI parent, int slot_id)
8869 {
8870 super.OnWasDetached(parent, slot_id);
8871
8872 if (HasQuantity())
8873 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8874 }
8875
8876 override string ChangeIntoOnAttach(string slot)
8877 {
8878 int idx;
8879 TStringArray inventory_slots = new TStringArray;
8880 TStringArray attach_types = new TStringArray;
8881
8882 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8883 if (inventory_slots.Count() < 1) //is string
8884 {
8885 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8886 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8887 }
8888 else //is array
8889 {
8890 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8891 }
8892
8893 idx = inventory_slots.Find(slot);
8894 if (idx < 0)
8895 return "";
8896
8897 return attach_types.Get(idx);
8898 }
8899
8900 override string ChangeIntoOnDetach()
8901 {
8902 int idx = -1;
8903 string slot;
8904
8905 TStringArray inventory_slots = new TStringArray;
8906 TStringArray detach_types = new TStringArray;
8907
8908 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8909 if (inventory_slots.Count() < 1) //is string
8910 {
8911 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8912 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8913 }
8914 else //is array
8915 {
8916 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8917 if (detach_types.Count() < 1)
8918 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8919 }
8920
8921 for (int i = 0; i < inventory_slots.Count(); i++)
8922 {
8923 slot = inventory_slots.Get(i);
8924 }
8925
8926 if (slot != "")
8927 {
8928 if (detach_types.Count() == 1)
8929 idx = 0;
8930 else
8931 idx = inventory_slots.Find(slot);
8932 }
8933 if (idx < 0)
8934 return "";
8935
8936 return detach_types.Get(idx);
8937 }
8938
8939 void ExplodeAmmo()
8940 {
8941 //timer
8942 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
8943
8944 //min/max time
8945 float min_time = 1;
8946 float max_time = 3;
8947 float delay = Math.RandomFloat(min_time, max_time);
8948
8949 explode_timer.Run(delay, this, "DoAmmoExplosion");
8950 }
8951
8952 void DoAmmoExplosion()
8953 {
8954 Magazine magazine = Magazine.Cast(this);
8955 int pop_sounds_count = 6;
8956 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
8957
8958 //play sound
8959 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
8960 string sound_name = pop_sounds[ sound_idx ];
8961 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
8962
8963 //remove ammo count
8964 magazine.ServerAddAmmoCount(-1);
8965
8966 //if condition then repeat -> ExplodeAmmo
8967 float min_temp_to_explode = 100; //min temperature for item to explode
8968
8969 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
8970 {
8971 ExplodeAmmo();
8972 }
8973 }
8974
8975 // -------------------------------------------------------------------------------
8976 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
8977 {
8978 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
8979
8980 const int CHANCE_DAMAGE_CARGO = 4;
8981 const int CHANCE_DAMAGE_ATTACHMENT = 1;
8982 const int CHANCE_DAMAGE_NOTHING = 2;
8983
8984 if (IsClothing() || IsContainer() || IsItemTent())
8985 {
8986 float dmg = damageResult.GetDamage("","Health") * -0.5;
8987 int chances;
8988 int rnd;
8989
8990 if (GetInventory().GetCargo())
8991 {
8992 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8993 rnd = Math.RandomInt(0,chances);
8994
8995 if (rnd < CHANCE_DAMAGE_CARGO)
8996 {
8997 DamageItemInCargo(dmg);
8998 }
8999 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9000 {
9002 }
9003 }
9004 else
9005 {
9006 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9007 rnd = Math.RandomInt(0,chances);
9008
9009 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9010 {
9012 }
9013 }
9014 }
9015 }
9016
9017 bool DamageItemInCargo(float damage)
9018 {
9019 if (GetInventory().GetCargo())
9020 {
9021 int item_count = GetInventory().GetCargo().GetItemCount();
9022 if (item_count > 0)
9023 {
9024 int random_pick = Math.RandomInt(0, item_count);
9025 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
9026 if (!item.IsExplosive())
9027 {
9028 item.AddHealth("","",damage);
9029 return true;
9030 }
9031 }
9032 }
9033 return false;
9034 }
9035
9036 bool DamageItemAttachments(float damage)
9037 {
9038 int attachment_count = GetInventory().AttachmentCount();
9039 if (attachment_count > 0)
9040 {
9041 int random_pick = Math.RandomInt(0, attachment_count);
9042 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
9043 if (!attachment.IsExplosive())
9044 {
9045 attachment.AddHealth("","",damage);
9046 return true;
9047 }
9048 }
9049 return false;
9050 }
9051
9052 override bool IsSplitable()
9053 {
9054 return m_CanThisBeSplit;
9055 }
9056 //----------------
9057 override bool CanBeSplit()
9058 {
9059 if (IsSplitable() && (GetQuantity() > 1))
9060 return GetInventory().CanRemoveEntity();
9061
9062 return false;
9063 }
9064
9065 protected bool ShouldSplitQuantity(float quantity)
9066 {
9067 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9068 if (!IsSplitable())
9069 return false;
9070
9071 // nothing to split?
9072 if (GetQuantity() <= 1)
9073 return false;
9074
9075 // check if we should re-use the item instead of creating a new copy?
9076 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9077 int delta = GetQuantity() - quantity;
9078 if (delta == 0)
9079 return false;
9080
9081 // valid to split
9082 return true;
9083 }
9084
9085 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9086 {
9087 if (GetGame().IsClient())
9088 {
9089 if (ScriptInputUserData.CanStoreInputUserData())
9090 {
9091 ScriptInputUserData ctx = new ScriptInputUserData;
9093 ctx.Write(1);
9094 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9095 ctx.Write(i1);
9096 ctx.Write(destination_entity);
9097 ctx.Write(true);
9098 ctx.Write(slot_id);
9099 ctx.Send();
9100 }
9101 }
9102 else if (!GetGame().IsMultiplayer())
9103 {
9104 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
9105 }
9106 }
9107
9108 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9109 {
9110 float split_quantity_new;
9111 ItemBase new_item;
9112 float quantity = GetQuantity();
9113 float stack_max = GetTargetQuantityMax(slot_id);
9114 InventoryLocation loc = new InventoryLocation;
9115
9116 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9117 {
9118 if (stack_max <= GetQuantity())
9119 split_quantity_new = stack_max;
9120 else
9121 split_quantity_new = GetQuantity();
9122
9123 if (ShouldSplitQuantity(split_quantity_new))
9124 {
9125 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9126 if (new_item)
9127 {
9128 new_item.SetResultOfSplit(true);
9129 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9130 AddQuantity(-split_quantity_new, false, true);
9131 new_item.SetQuantity(split_quantity_new, false, true);
9132 }
9133 }
9134 }
9135 else if (destination_entity && slot_id == -1)
9136 {
9137 if (quantity > stack_max)
9138 split_quantity_new = stack_max;
9139 else
9140 split_quantity_new = quantity;
9141
9142 if (ShouldSplitQuantity(split_quantity_new))
9143 {
9144 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9145 {
9146 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9147 new_item = ItemBase.Cast(o);
9148 }
9149
9150 if (new_item)
9151 {
9152 new_item.SetResultOfSplit(true);
9153 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9154 AddQuantity(-split_quantity_new, false, true);
9155 new_item.SetQuantity(split_quantity_new, false, true);
9156 }
9157 }
9158 }
9159 else
9160 {
9161 if (stack_max != 0)
9162 {
9163 if (stack_max < GetQuantity())
9164 {
9165 split_quantity_new = GetQuantity() - stack_max;
9166 }
9167
9168 if (split_quantity_new == 0)
9169 {
9170 if (!GetGame().IsMultiplayer())
9171 player.PhysicalPredictiveDropItem(this);
9172 else
9173 player.ServerDropEntity(this);
9174 return;
9175 }
9176
9177 if (ShouldSplitQuantity(split_quantity_new))
9178 {
9179 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9180
9181 if (new_item)
9182 {
9183 new_item.SetResultOfSplit(true);
9184 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9185 SetQuantity(split_quantity_new, false, true);
9186 new_item.SetQuantity(stack_max, false, true);
9187 new_item.PlaceOnSurface();
9188 }
9189 }
9190 }
9191 }
9192 }
9193
9194 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9195 {
9196 float split_quantity_new;
9197 ItemBase new_item;
9198 float quantity = GetQuantity();
9199 float stack_max = GetTargetQuantityMax(slot_id);
9200 InventoryLocation loc = new InventoryLocation;
9201
9202 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9203 {
9204 if (stack_max <= GetQuantity())
9205 split_quantity_new = stack_max;
9206 else
9207 split_quantity_new = GetQuantity();
9208
9209 if (ShouldSplitQuantity(split_quantity_new))
9210 {
9211 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9212 if (new_item)
9213 {
9214 new_item.SetResultOfSplit(true);
9215 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9216 AddQuantity(-split_quantity_new, false, true);
9217 new_item.SetQuantity(split_quantity_new, false, true);
9218 }
9219 }
9220 }
9221 else if (destination_entity && slot_id == -1)
9222 {
9223 if (quantity > stack_max)
9224 split_quantity_new = stack_max;
9225 else
9226 split_quantity_new = quantity;
9227
9228 if (ShouldSplitQuantity(split_quantity_new))
9229 {
9230 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9231 {
9232 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9233 new_item = ItemBase.Cast(o);
9234 }
9235
9236 if (new_item)
9237 {
9238 new_item.SetResultOfSplit(true);
9239 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9240 AddQuantity(-split_quantity_new, false, true);
9241 new_item.SetQuantity(split_quantity_new, false, true);
9242 }
9243 }
9244 }
9245 else
9246 {
9247 if (stack_max != 0)
9248 {
9249 if (stack_max < GetQuantity())
9250 {
9251 split_quantity_new = GetQuantity() - stack_max;
9252 }
9253
9254 if (ShouldSplitQuantity(split_quantity_new))
9255 {
9256 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9257
9258 if (new_item)
9259 {
9260 new_item.SetResultOfSplit(true);
9261 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9262 SetQuantity(split_quantity_new, false, true);
9263 new_item.SetQuantity(stack_max, false, true);
9264 new_item.PlaceOnSurface();
9265 }
9266 }
9267 }
9268 }
9269 }
9270
9271 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9272 {
9273 if (GetGame().IsClient())
9274 {
9275 if (ScriptInputUserData.CanStoreInputUserData())
9276 {
9277 ScriptInputUserData ctx = new ScriptInputUserData;
9279 ctx.Write(4);
9280 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9281 ctx.Write(thiz);
9282 dst.WriteToContext(ctx);
9283 ctx.Send();
9284 }
9285 }
9286 else if (!GetGame().IsMultiplayer())
9287 {
9289 }
9290 }
9291
9292 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9293 {
9294 if (GetGame().IsClient())
9295 {
9296 if (ScriptInputUserData.CanStoreInputUserData())
9297 {
9298 ScriptInputUserData ctx = new ScriptInputUserData;
9300 ctx.Write(2);
9301 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9302 ctx.Write(dummy);
9303 ctx.Write(destination_entity);
9304 ctx.Write(true);
9305 ctx.Write(idx);
9306 ctx.Write(row);
9307 ctx.Write(col);
9308 ctx.Send();
9309 }
9310 }
9311 else if (!GetGame().IsMultiplayer())
9312 {
9313 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
9314 }
9315 }
9316
9317 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
9318 {
9320 }
9321
9322 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
9323 {
9324 float quantity = GetQuantity();
9325 float split_quantity_new;
9326 ItemBase new_item;
9327 if (dst.IsValid())
9328 {
9329 int slot_id = dst.GetSlot();
9330 float stack_max = GetTargetQuantityMax(slot_id);
9331
9332 if (quantity > stack_max)
9333 split_quantity_new = stack_max;
9334 else
9335 split_quantity_new = quantity;
9336
9337 if (ShouldSplitQuantity(split_quantity_new))
9338 {
9339 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9340
9341 if (new_item)
9342 {
9343 new_item.SetResultOfSplit(true);
9344 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9345 AddQuantity(-split_quantity_new, false, true);
9346 new_item.SetQuantity(split_quantity_new, false, true);
9347 }
9348
9349 return new_item;
9350 }
9351 }
9352
9353 return null;
9354 }
9355
9356 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9357 {
9358 float quantity = GetQuantity();
9359 float split_quantity_new;
9360 ItemBase new_item;
9361 if (destination_entity)
9362 {
9363 float stackable = GetTargetQuantityMax();
9364 if (quantity > stackable)
9365 split_quantity_new = stackable;
9366 else
9367 split_quantity_new = quantity;
9368
9369 if (ShouldSplitQuantity(split_quantity_new))
9370 {
9371 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9372 if (new_item)
9373 {
9374 new_item.SetResultOfSplit(true);
9375 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9376 AddQuantity(-split_quantity_new, false, true);
9377 new_item.SetQuantity(split_quantity_new, false, true);
9378 }
9379 }
9380 }
9381 }
9382
9383 void SplitIntoStackMaxHandsClient(PlayerBase player)
9384 {
9385 if (GetGame().IsClient())
9386 {
9387 if (ScriptInputUserData.CanStoreInputUserData())
9388 {
9389 ScriptInputUserData ctx = new ScriptInputUserData;
9391 ctx.Write(3);
9392 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9393 ctx.Write(i1);
9394 ItemBase destination_entity = this;
9395 ctx.Write(destination_entity);
9396 ctx.Write(true);
9397 ctx.Write(0);
9398 ctx.Send();
9399 }
9400 }
9401 else if (!GetGame().IsMultiplayer())
9402 {
9403 SplitIntoStackMaxHands(player);
9404 }
9405 }
9406
9407 void SplitIntoStackMaxHands(PlayerBase player)
9408 {
9409 float quantity = GetQuantity();
9410 float split_quantity_new;
9411 ref ItemBase new_item;
9412 if (player)
9413 {
9414 float stackable = GetTargetQuantityMax();
9415 if (quantity > stackable)
9416 split_quantity_new = stackable;
9417 else
9418 split_quantity_new = quantity;
9419
9420 if (ShouldSplitQuantity(split_quantity_new))
9421 {
9422 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
9423 new_item = ItemBase.Cast(in_hands);
9424 if (new_item)
9425 {
9426 new_item.SetResultOfSplit(true);
9427 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9428 AddQuantity(-split_quantity_new, false, true);
9429 new_item.SetQuantity(split_quantity_new, false, true);
9430 }
9431 }
9432 }
9433 }
9434
9435 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
9436 {
9437 float quantity = GetQuantity();
9438 float split_quantity_new = Math.Floor(quantity * 0.5);
9439
9440 if (!ShouldSplitQuantity(split_quantity_new))
9441 return;
9442
9443 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9444
9445 if (new_item)
9446 {
9447 if (new_item.GetQuantityMax() < split_quantity_new)
9448 {
9449 split_quantity_new = new_item.GetQuantityMax();
9450 }
9451
9452 new_item.SetResultOfSplit(true);
9453 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9454
9455 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9456 {
9457 AddQuantity(-1, false, true);
9458 new_item.SetQuantity(1, false, true);
9459 }
9460 else
9461 {
9462 AddQuantity(-split_quantity_new, false, true);
9463 new_item.SetQuantity(split_quantity_new, false, true);
9464 }
9465 }
9466 }
9467
9468 void SplitItem(PlayerBase player)
9469 {
9470 float quantity = GetQuantity();
9471 float split_quantity_new = Math.Floor(quantity / 2);
9472
9473 if (!ShouldSplitQuantity(split_quantity_new))
9474 return;
9475
9476 InventoryLocation invloc = new InventoryLocation;
9477 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
9478
9479 ItemBase new_item;
9480 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
9481
9482 if (new_item)
9483 {
9484 if (new_item.GetQuantityMax() < split_quantity_new)
9485 {
9486 split_quantity_new = new_item.GetQuantityMax();
9487 }
9488 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9489 {
9490 AddQuantity(-1, false, true);
9491 new_item.SetQuantity(1, false, true);
9492 }
9493 else if (split_quantity_new > 1)
9494 {
9495 AddQuantity(-split_quantity_new, false, true);
9496 new_item.SetQuantity(split_quantity_new, false, true);
9497 }
9498 }
9499 }
9500
9502 void OnQuantityChanged(float delta)
9503 {
9504 SetWeightDirty();
9505 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9506
9507 if (parent)
9508 parent.OnAttachmentQuantityChangedEx(this, delta);
9509
9510 if (IsLiquidContainer())
9511 {
9512 if (GetQuantityNormalized() <= 0.0)
9513 {
9515 }
9516 else if (GetLiquidType() == LIQUID_NONE)
9517 {
9518 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
9520 }
9521 }
9522
9523 }
9524
9527 {
9528 // insert code here
9529 }
9530
9532 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
9533 {
9535 }
9536
9537 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
9538 {
9539 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
9540
9541 if (GetGame().IsServer())
9542 {
9543 if (newLevel == GameConstants.STATE_RUINED)
9544 {
9546 EntityAI parent = GetHierarchyParent();
9547 if (parent && parent.IsFireplace())
9548 {
9549 CargoBase cargo = GetInventory().GetCargo();
9550 if (cargo)
9551 {
9552 for (int i = 0; i < cargo.GetItemCount(); ++i)
9553 {
9554 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
9555 }
9556 }
9557 }
9558 }
9559
9560 if (IsResultOfSplit())
9561 {
9562 // reset the splitting result flag, return to normal item behavior
9563 SetResultOfSplit(false);
9564 return;
9565 }
9566
9567 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
9568 {
9569 SetCleanness(0);//unclean the item upon damage dealt
9570 }
9571 }
9572 }
9573
9574 // just the split? TODO: verify
9575 override void OnRightClick()
9576 {
9577 super.OnRightClick();
9578
9579 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
9580 {
9581 if (GetGame().IsClient())
9582 {
9583 if (ScriptInputUserData.CanStoreInputUserData())
9584 {
9585 EntityAI root = GetHierarchyRoot();
9586 Man playerOwner = GetHierarchyRootPlayer();
9587 InventoryLocation dst = new InventoryLocation;
9588
9589 // 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
9590 if (!playerOwner && root && root == this)
9591 {
9593 }
9594 else
9595 {
9596 // 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
9597 GetInventory().GetCurrentInventoryLocation(dst);
9598 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
9599 {
9600 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9601 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
9602 {
9604 }
9605 else
9606 {
9607 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
9608 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
9609 this shouldnt cause issues within this scope*/
9610 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
9611 {
9613 }
9614 else
9615 {
9616 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
9617 }
9618 }
9619 }
9620 }
9621
9622 ScriptInputUserData ctx = new ScriptInputUserData;
9624 ctx.Write(4);
9625 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9626 ctx.Write(thiz);
9627 dst.WriteToContext(ctx);
9628 ctx.Write(true); // dummy
9629 ctx.Send();
9630 }
9631 }
9632 else if (!GetGame().IsMultiplayer())
9633 {
9634 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
9635 }
9636 }
9637 }
9638
9639 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
9640 {
9641 if (root)
9642 {
9643 vector m4[4];
9644 root.GetTransform(m4);
9645 dst.SetGround(this, m4);
9646 }
9647 else
9648 {
9649 GetInventory().GetCurrentInventoryLocation(dst);
9650 }
9651 }
9652
9653 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
9654 {
9655 //TODO: delete check zero quantity check after fix double posts hands fsm events
9656 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
9657 return false;
9658
9659 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
9660 return false;
9661
9662 //can_this_be_combined = ConfigGetBool("canBeSplit");
9664 return false;
9665
9666
9667 Magazine mag = Magazine.Cast(this);
9668 if (mag)
9669 {
9670 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
9671 return false;
9672
9673 if (stack_max_limit)
9674 {
9675 Magazine other_mag = Magazine.Cast(other_item);
9676 if (other_item)
9677 {
9678 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
9679 return false;
9680 }
9681
9682 }
9683 }
9684 else
9685 {
9686 //TODO: delete check zero quantity check after fix double posts hands fsm events
9687 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
9688 return false;
9689
9690 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
9691 return false;
9692 }
9693
9694 PlayerBase player = null;
9695 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
9696 {
9697 if (player.GetInventory().HasAttachment(this))
9698 return false;
9699
9700 if (player.IsItemsToDelete())
9701 return false;
9702 }
9703
9704 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
9705 return false;
9706
9707 int slotID;
9708 string slotName;
9709 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
9710 return false;
9711
9712 return true;
9713 }
9714
9715 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
9716 {
9717 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
9718 }
9719
9720 bool IsResultOfSplit()
9721 {
9722 return m_IsResultOfSplit;
9723 }
9724
9725 void SetResultOfSplit(bool value)
9726 {
9727 m_IsResultOfSplit = value;
9728 }
9729
9730 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
9731 {
9732 return ComputeQuantityUsedEx(other_item, use_stack_max);
9733 }
9734
9735 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
9736 {
9737 float other_item_quantity = other_item.GetQuantity();
9738 float this_free_space;
9739
9740 float stack_max = GetQuantityMax();
9741
9742 this_free_space = stack_max - GetQuantity();
9743
9744 if (other_item_quantity > this_free_space)
9745 {
9746 return this_free_space;
9747 }
9748 else
9749 {
9750 return other_item_quantity;
9751 }
9752 }
9753
9754 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
9755 {
9756 CombineItems(ItemBase.Cast(entity2),use_stack_max);
9757 }
9758
9759 void CombineItems(ItemBase other_item, bool use_stack_max = true)
9760 {
9761 if (!CanBeCombined(other_item, false))
9762 return;
9763
9764 if (!IsMagazine() && other_item)
9765 {
9766 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
9767 if (quantity_used != 0)
9768 {
9769 float hp1 = GetHealth01("","");
9770 float hp2 = other_item.GetHealth01("","");
9771 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
9772 hpResult = hpResult / (GetQuantity() + quantity_used);
9773
9774 hpResult *= GetMaxHealth();
9775 Math.Round(hpResult);
9776 SetHealth("", "Health", hpResult);
9777
9778 AddQuantity(quantity_used);
9779 other_item.AddQuantity(-quantity_used);
9780 }
9781 }
9782 OnCombine(other_item);
9783 }
9784
9785 void OnCombine(ItemBase other_item)
9786 {
9787 #ifdef SERVER
9788 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
9789 GetHierarchyParent().IncreaseLifetimeUp();
9790 #endif
9791 };
9792
9793 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9794 {
9795 PlayerBase p = PlayerBase.Cast(player);
9796
9797 array<int> recipesIds = p.m_Recipes;
9798 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9799 if (moduleRecipesManager)
9800 {
9801 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
9802 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9803 }
9804
9805 for (int i = 0;i < recipesIds.Count(); i++)
9806 {
9807 int key = recipesIds.Get(i);
9808 string recipeName = moduleRecipesManager.GetRecipeName(key);
9809 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9810 }
9811 }
9812
9813 // -------------------------------------------------------------------------
9814 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9815 {
9816 super.GetDebugActions(outputList);
9817
9818 //quantity
9819 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9820 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9821 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9822 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9823 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9824
9825 //health
9826 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9827 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9828 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9829 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9830 //temperature
9831 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9832 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9833 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9834 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9835
9836 //wet
9837 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9838 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9839 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9840
9841 //liquidtype
9842 if (IsLiquidContainer())
9843 {
9844 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9845 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9846 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9847 }
9848
9849 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9850 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9851
9852 // watch
9853 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9854 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9855 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9856
9857 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
9858
9859 InventoryLocation loc = new InventoryLocation();
9860 GetInventory().GetCurrentInventoryLocation(loc);
9861 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
9862 {
9863 if (Gizmo_IsSupported())
9864 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
9865 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
9866 }
9867
9868 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
9869 }
9870
9871 // -------------------------------------------------------------------------
9872 // -------------------------------------------------------------------------
9873 // -------------------------------------------------------------------------
9874 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
9875 {
9876 super.OnAction(action_id, player, ctx);
9877
9878 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
9879 {
9880 switch (action_id)
9881 {
9882 case EActions.GIZMO_OBJECT:
9883 GetGame().GizmoSelectObject(this);
9884 return true;
9885 case EActions.GIZMO_PHYSICS:
9886 GetGame().GizmoSelectPhysics(GetPhysics());
9887 return true;
9888 }
9889 }
9890
9891 if (GetGame().IsServer())
9892 {
9893 switch (action_id)
9894 {
9895 case EActions.DELETE:
9896 Delete();
9897 return true;
9898 }
9899 }
9900
9901 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9902 {
9903 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9904 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9905 PlayerBase p = PlayerBase.Cast(player);
9906 if (EActions.RECIPES_RANGE_START < 1000)
9907 {
9908 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9909 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9910 }
9911 }
9912 #ifndef SERVER
9913 else if (action_id == EActions.WATCH_PLAYER)
9914 {
9915 PluginDeveloper.SetDeveloperItemClientEx(player);
9916 }
9917 #endif
9918 if (GetGame().IsServer())
9919 {
9920 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
9921 {
9922 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
9923 OnDebugButtonPressServer(id + 1);
9924 }
9925
9926 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
9927 {
9928 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
9929 InsertAgent(agent_id,100);
9930 }
9931
9932 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
9933 {
9934 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
9935 RemoveAgent(agent_id2);
9936 }
9937
9938 else if (action_id == EActions.ADD_QUANTITY)
9939 {
9940 if (IsMagazine())
9941 {
9942 Magazine mag = Magazine.Cast(this);
9943 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
9944 }
9945 else
9946 {
9947 AddQuantity(GetQuantityMax() * 0.2);
9948 }
9949
9950 if (m_EM)
9951 {
9952 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
9953 }
9954 //PrintVariables();
9955 }
9956
9957 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
9958 {
9959 if (IsMagazine())
9960 {
9961 Magazine mag2 = Magazine.Cast(this);
9962 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
9963 }
9964 else
9965 {
9966 AddQuantity(- GetQuantityMax() * 0.2);
9967 }
9968 if (m_EM)
9969 {
9970 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
9971 }
9972 //PrintVariables();
9973 }
9974
9975 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
9976 {
9977 SetQuantity(0);
9978
9979 if (m_EM)
9980 {
9981 m_EM.SetEnergy(0);
9982 }
9983 }
9984
9985 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
9986 {
9988
9989 if (m_EM)
9990 {
9991 m_EM.SetEnergy(m_EM.GetEnergyMax());
9992 }
9993 }
9994
9995 else if (action_id == EActions.ADD_HEALTH)
9996 {
9997 AddHealth("","",GetMaxHealth("","Health")/5);
9998 }
9999 else if (action_id == EActions.REMOVE_HEALTH)
10000 {
10001 AddHealth("","",-GetMaxHealth("","Health")/5);
10002 }
10003 else if (action_id == EActions.DESTROY_HEALTH)
10004 {
10005 SetHealth01("","",0);
10006 }
10007 else if (action_id == EActions.WATCH_ITEM)
10008 {
10010 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10011 #ifdef DEVELOPER
10012 SetDebugDeveloper_item(this);
10013 #endif
10014 }
10015
10016 else if (action_id == EActions.ADD_TEMPERATURE)
10017 {
10018 AddTemperature(20);
10019 //PrintVariables();
10020 }
10021
10022 else if (action_id == EActions.REMOVE_TEMPERATURE)
10023 {
10024 AddTemperature(-20);
10025 //PrintVariables();
10026 }
10027
10028 else if (action_id == EActions.FLIP_FROZEN)
10029 {
10030 SetFrozen(!GetIsFrozen());
10031 //PrintVariables();
10032 }
10033
10034 else if (action_id == EActions.ADD_WETNESS)
10035 {
10036 AddWet(GetWetMax()/5);
10037 //PrintVariables();
10038 }
10039
10040 else if (action_id == EActions.REMOVE_WETNESS)
10041 {
10042 AddWet(-GetWetMax()/5);
10043 //PrintVariables();
10044 }
10045
10046 else if (action_id == EActions.LIQUIDTYPE_UP)
10047 {
10048 int curr_type = GetLiquidType();
10049 SetLiquidType(curr_type * 2);
10050 //AddWet(1);
10051 //PrintVariables();
10052 }
10053
10054 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10055 {
10056 int curr_type2 = GetLiquidType();
10057 SetLiquidType(curr_type2 / 2);
10058 }
10059
10060 else if (action_id == EActions.MAKE_SPECIAL)
10061 {
10062 auto debugParams = DebugSpawnParams.WithPlayer(player);
10063 OnDebugSpawnEx(debugParams);
10064 }
10065
10066 }
10067
10068
10069 return false;
10070 }
10071
10072 // -------------------------------------------------------------------------
10073
10074
10077 void OnActivatedByTripWire();
10078
10080 void OnActivatedByItem(notnull ItemBase item);
10081
10082 //----------------------------------------------------------------
10083 //returns true if item is able to explode when put in fire
10084 bool CanExplodeInFire()
10085 {
10086 return false;
10087 }
10088
10089 //----------------------------------------------------------------
10090 bool CanEat()
10091 {
10092 return true;
10093 }
10094
10095 //----------------------------------------------------------------
10096 override bool IsIgnoredByConstruction()
10097 {
10098 return true;
10099 }
10100
10101 //----------------------------------------------------------------
10102 //has FoodStages in config?
10103 bool HasFoodStage()
10104 {
10105 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10106 return GetGame().ConfigIsExisting(config_path);
10107 }
10108
10110 FoodStage GetFoodStage()
10111 {
10112 return null;
10113 }
10114
10115 bool CanBeCooked()
10116 {
10117 return false;
10118 }
10119
10120 bool CanBeCookedOnStick()
10121 {
10122 return false;
10123 }
10124
10126 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10128
10129 //----------------------------------------------------------------
10130 bool CanRepair(ItemBase item_repair_kit)
10131 {
10132 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10133 return module_repairing.CanRepair(this, item_repair_kit);
10134 }
10135
10136 //----------------------------------------------------------------
10137 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10138 {
10139 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10140 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10141 }
10142
10143 //----------------------------------------------------------------
10144 int GetItemSize()
10145 {
10146 /*
10147 vector v_size = this.ConfigGetVector("itemSize");
10148 int v_size_x = v_size[0];
10149 int v_size_y = v_size[1];
10150 int size = v_size_x * v_size_y;
10151 return size;
10152 */
10153
10154 return 1;
10155 }
10156
10157 //----------------------------------------------------------------
10158 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10159 bool CanBeMovedOverride()
10160 {
10161 return m_CanBeMovedOverride;
10162 }
10163
10164 //----------------------------------------------------------------
10165 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10166 void SetCanBeMovedOverride(bool setting)
10167 {
10168 m_CanBeMovedOverride = setting;
10169 }
10170
10171 //----------------------------------------------------------------
10179 void MessageToOwnerStatus(string text)
10180 {
10181 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10182
10183 if (player)
10184 {
10185 player.MessageStatus(text);
10186 }
10187 }
10188
10189 //----------------------------------------------------------------
10197 void MessageToOwnerAction(string text)
10198 {
10199 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10200
10201 if (player)
10202 {
10203 player.MessageAction(text);
10204 }
10205 }
10206
10207 //----------------------------------------------------------------
10215 void MessageToOwnerFriendly(string text)
10216 {
10217 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10218
10219 if (player)
10220 {
10221 player.MessageFriendly(text);
10222 }
10223 }
10224
10225 //----------------------------------------------------------------
10233 void MessageToOwnerImportant(string text)
10234 {
10235 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10236
10237 if (player)
10238 {
10239 player.MessageImportant(text);
10240 }
10241 }
10242
10243 override bool IsItemBase()
10244 {
10245 return true;
10246 }
10247
10248 // Checks if item is of questioned kind
10249 override bool KindOf(string tag)
10250 {
10251 bool found = false;
10252 string item_name = this.GetType();
10253 ref TStringArray item_tag_array = new TStringArray;
10254 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10255
10256 int array_size = item_tag_array.Count();
10257 for (int i = 0; i < array_size; i++)
10258 {
10259 if (item_tag_array.Get(i) == tag)
10260 {
10261 found = true;
10262 break;
10263 }
10264 }
10265 return found;
10266 }
10267
10268
10269 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10270 {
10271 //Debug.Log("OnRPC called");
10272 super.OnRPC(sender, rpc_type,ctx);
10273
10274 //Play soundset for attachment locking (ActionLockAttachment.c)
10275 switch (rpc_type)
10276 {
10277 #ifndef SERVER
10278 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10279 Param2<bool, string> p = new Param2<bool, string>(false, "");
10280
10281 if (!ctx.Read(p))
10282 return;
10283
10284 bool play = p.param1;
10285 string soundSet = p.param2;
10286
10287 if (play)
10288 {
10289 if (m_LockingSound)
10290 {
10292 {
10293 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10294 }
10295 }
10296 else
10297 {
10298 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10299 }
10300 }
10301 else
10302 {
10303 SEffectManager.DestroyEffect(m_LockingSound);
10304 }
10305
10306 break;
10307 #endif
10308
10309 }
10310
10311 if (GetWrittenNoteData())
10312 {
10313 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
10314 }
10315 }
10316
10317 //-----------------------------
10318 // VARIABLE MANIPULATION SYSTEM
10319 //-----------------------------
10320 int NameToID(string name)
10321 {
10322 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10323 return plugin.GetID(name);
10324 }
10325
10326 string IDToName(int id)
10327 {
10328 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10329 return plugin.GetName(id);
10330 }
10331
10333 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
10334 {
10335 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
10336 //read the flags
10337 int varFlags;
10338 if (!ctx.Read(varFlags))
10339 return;
10340
10341 if (varFlags & ItemVariableFlags.FLOAT)
10342 {
10343 ReadVarsFromCTX(ctx);
10344 }
10345 }
10346
10347 override void SerializeNumericalVars(array<float> floats_out)
10348 {
10349 //some variables handled on EntityAI level already!
10350 super.SerializeNumericalVars(floats_out);
10351
10352 // the order of serialization must be the same as the order of de-serialization
10353 //--------------------------------------------
10354 if (IsVariableSet(VARIABLE_QUANTITY))
10355 {
10356 floats_out.Insert(m_VarQuantity);
10357 }
10358 //--------------------------------------------
10359 if (IsVariableSet(VARIABLE_WET))
10360 {
10361 floats_out.Insert(m_VarWet);
10362 }
10363 //--------------------------------------------
10364 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10365 {
10366 floats_out.Insert(m_VarLiquidType);
10367 }
10368 //--------------------------------------------
10369 if (IsVariableSet(VARIABLE_COLOR))
10370 {
10371 floats_out.Insert(m_ColorComponentR);
10372 floats_out.Insert(m_ColorComponentG);
10373 floats_out.Insert(m_ColorComponentB);
10374 floats_out.Insert(m_ColorComponentA);
10375 }
10376 //--------------------------------------------
10377 if (IsVariableSet(VARIABLE_CLEANNESS))
10378 {
10379 floats_out.Insert(m_Cleanness);
10380 }
10381 }
10382
10383 override void DeSerializeNumericalVars(array<float> floats)
10384 {
10385 //some variables handled on EntityAI level already!
10386 super.DeSerializeNumericalVars(floats);
10387
10388 // the order of serialization must be the same as the order of de-serialization
10389 int index = 0;
10390 int mask = Math.Round(floats.Get(index));
10391
10392 index++;
10393 //--------------------------------------------
10394 if (mask & VARIABLE_QUANTITY)
10395 {
10396 if (m_IsStoreLoad)
10397 {
10398 SetStoreLoadedQuantity(floats.Get(index));
10399 }
10400 else
10401 {
10402 float quantity = floats.Get(index);
10403 SetQuantity(quantity, true, false, false, false);
10404 }
10405 index++;
10406 }
10407 //--------------------------------------------
10408 if (mask & VARIABLE_WET)
10409 {
10410 float wet = floats.Get(index);
10411 SetWet(wet);
10412 index++;
10413 }
10414 //--------------------------------------------
10415 if (mask & VARIABLE_LIQUIDTYPE)
10416 {
10417 int liquidtype = Math.Round(floats.Get(index));
10418 SetLiquidType(liquidtype);
10419 index++;
10420 }
10421 //--------------------------------------------
10422 if (mask & VARIABLE_COLOR)
10423 {
10424 m_ColorComponentR = Math.Round(floats.Get(index));
10425 index++;
10426 m_ColorComponentG = Math.Round(floats.Get(index));
10427 index++;
10428 m_ColorComponentB = Math.Round(floats.Get(index));
10429 index++;
10430 m_ColorComponentA = Math.Round(floats.Get(index));
10431 index++;
10432 }
10433 //--------------------------------------------
10434 if (mask & VARIABLE_CLEANNESS)
10435 {
10436 int cleanness = Math.Round(floats.Get(index));
10437 SetCleanness(cleanness);
10438 index++;
10439 }
10440 }
10441
10442 override void WriteVarsToCTX(ParamsWriteContext ctx)
10443 {
10444 super.WriteVarsToCTX(ctx);
10445
10446 //--------------------------------------------
10447 if (IsVariableSet(VARIABLE_QUANTITY))
10448 {
10449 ctx.Write(GetQuantity());
10450 }
10451 //--------------------------------------------
10452 if (IsVariableSet(VARIABLE_WET))
10453 {
10454 ctx.Write(GetWet());
10455 }
10456 //--------------------------------------------
10457 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10458 {
10459 ctx.Write(GetLiquidType());
10460 }
10461 //--------------------------------------------
10462 if (IsVariableSet(VARIABLE_COLOR))
10463 {
10464 int r,g,b,a;
10465 GetColor(r,g,b,a);
10466 ctx.Write(r);
10467 ctx.Write(g);
10468 ctx.Write(b);
10469 ctx.Write(a);
10470 }
10471 //--------------------------------------------
10472 if (IsVariableSet(VARIABLE_CLEANNESS))
10473 {
10474 ctx.Write(GetCleanness());
10475 }
10476 }
10477
10478 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
10479 {
10480 if (!super.ReadVarsFromCTX(ctx,version))
10481 return false;
10482
10483 int intValue;
10484 float value;
10485
10486 if (version < 140)
10487 {
10488 if (!ctx.Read(intValue))
10489 return false;
10490
10491 m_VariablesMask = intValue;
10492 }
10493
10494 if (m_VariablesMask & VARIABLE_QUANTITY)
10495 {
10496 if (!ctx.Read(value))
10497 return false;
10498
10499 if (IsStoreLoad())
10500 {
10502 }
10503 else
10504 {
10505 SetQuantity(value, true, false, false, false);
10506 }
10507 }
10508 //--------------------------------------------
10509 if (version < 140)
10510 {
10511 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10512 {
10513 if (!ctx.Read(value))
10514 return false;
10515 SetTemperatureDirect(value);
10516 }
10517 }
10518 //--------------------------------------------
10519 if (m_VariablesMask & VARIABLE_WET)
10520 {
10521 if (!ctx.Read(value))
10522 return false;
10523 SetWet(value);
10524 }
10525 //--------------------------------------------
10526 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
10527 {
10528 if (!ctx.Read(intValue))
10529 return false;
10530 SetLiquidType(intValue);
10531 }
10532 //--------------------------------------------
10533 if (m_VariablesMask & VARIABLE_COLOR)
10534 {
10535 int r,g,b,a;
10536 if (!ctx.Read(r))
10537 return false;
10538 if (!ctx.Read(g))
10539 return false;
10540 if (!ctx.Read(b))
10541 return false;
10542 if (!ctx.Read(a))
10543 return false;
10544
10545 SetColor(r,g,b,a);
10546 }
10547 //--------------------------------------------
10548 if (m_VariablesMask & VARIABLE_CLEANNESS)
10549 {
10550 if (!ctx.Read(intValue))
10551 return false;
10552 SetCleanness(intValue);
10553 }
10554 //--------------------------------------------
10555 if (version >= 138 && version < 140)
10556 {
10557 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10558 {
10559 if (!ctx.Read(intValue))
10560 return false;
10561 SetFrozen(intValue);
10562 }
10563 }
10564
10565 return true;
10566 }
10567
10568 //----------------------------------------------------------------
10569 override bool OnStoreLoad(ParamsReadContext ctx, int version)
10570 {
10571 m_IsStoreLoad = true;
10573 {
10574 m_FixDamageSystemInit = true;
10575 }
10576
10577 if (!super.OnStoreLoad(ctx, version))
10578 {
10579 m_IsStoreLoad = false;
10580 return false;
10581 }
10582
10583 if (version >= 114)
10584 {
10585 bool hasQuickBarIndexSaved;
10586
10587 if (!ctx.Read(hasQuickBarIndexSaved))
10588 {
10589 m_IsStoreLoad = false;
10590 return false;
10591 }
10592
10593 if (hasQuickBarIndexSaved)
10594 {
10595 int itmQBIndex;
10596
10597 //Load quickbar item bind
10598 if (!ctx.Read(itmQBIndex))
10599 {
10600 m_IsStoreLoad = false;
10601 return false;
10602 }
10603
10604 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
10605 if (itmQBIndex != -1 && parentPlayer)
10606 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
10607 }
10608 }
10609 else
10610 {
10611 // Backup of how it used to be
10612 PlayerBase player;
10613 int itemQBIndex;
10614 if (version == int.MAX)
10615 {
10616 if (!ctx.Read(itemQBIndex))
10617 {
10618 m_IsStoreLoad = false;
10619 return false;
10620 }
10621 }
10622 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10623 {
10624 //Load quickbar item bind
10625 if (!ctx.Read(itemQBIndex))
10626 {
10627 m_IsStoreLoad = false;
10628 return false;
10629 }
10630 if (itemQBIndex != -1 && player)
10631 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10632 }
10633 }
10634
10635 if (version < 140)
10636 {
10637 // variable management system
10638 if (!LoadVariables(ctx, version))
10639 {
10640 m_IsStoreLoad = false;
10641 return false;
10642 }
10643 }
10644
10645 //agent trasmission system
10646 if (!LoadAgents(ctx, version))
10647 {
10648 m_IsStoreLoad = false;
10649 return false;
10650 }
10651 if (version >= 132)
10652 {
10653 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10654 if (raib)
10655 {
10656 if (!raib.OnStoreLoad(ctx,version))
10657 {
10658 m_IsStoreLoad = false;
10659 return false;
10660 }
10661 }
10662 }
10663
10664 m_IsStoreLoad = false;
10665 return true;
10666 }
10667
10668 //----------------------------------------------------------------
10669
10670 override void OnStoreSave(ParamsWriteContext ctx)
10671 {
10672 super.OnStoreSave(ctx);
10673
10674 PlayerBase player;
10675 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10676 {
10677 ctx.Write(true); // Keep track of if we should actually read this in or not
10678 //Save quickbar item bind
10679 int itemQBIndex = -1;
10680 itemQBIndex = player.FindQuickBarEntityIndex(this);
10681 ctx.Write(itemQBIndex);
10682 }
10683 else
10684 {
10685 ctx.Write(false); // Keep track of if we should actually read this in or not
10686 }
10687
10688 SaveAgents(ctx);//agent trasmission system
10689
10690 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10691 if (raib)
10692 {
10693 raib.OnStoreSave(ctx);
10694 }
10695 }
10696 //----------------------------------------------------------------
10697
10698 override void AfterStoreLoad()
10699 {
10700 super.AfterStoreLoad();
10701
10703 {
10705 }
10706
10707 if (GetStoreLoadedQuantity() != float.LOWEST)
10708 {
10710 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
10711 }
10712 }
10713
10714 override void EEOnAfterLoad()
10715 {
10716 super.EEOnAfterLoad();
10717
10719 {
10720 m_FixDamageSystemInit = false;
10721 }
10722
10725 }
10726
10727 bool CanBeDisinfected()
10728 {
10729 return false;
10730 }
10731
10732
10733 //----------------------------------------------------------------
10734 override void OnVariablesSynchronized()
10735 {
10736 if (m_Initialized)
10737 {
10738 #ifdef PLATFORM_CONSOLE
10739 //bruteforce it is
10740 if (IsSplitable())
10741 {
10742 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
10743 if (menu)
10744 {
10745 menu.Refresh();
10746 }
10747 }
10748 #endif
10749 }
10750
10752 {
10753 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10754 m_WantPlayImpactSound = false;
10755 }
10756
10758 {
10759 SetWeightDirty();
10761 }
10762 if (m_VarWet != m_VarWetPrev)
10763 {
10766 }
10767
10768 if (m_SoundSyncPlay != 0)
10769 {
10770 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
10771 m_SoundSyncPlay = 0;
10772 }
10773 if (m_SoundSyncStop != 0)
10774 {
10775 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10776 m_SoundSyncStop = 0;
10777 }
10778
10779 super.OnVariablesSynchronized();
10780 }
10781
10782 //------------------------- Quantity
10783 //----------------------------------------------------------------
10785 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10786 {
10787 if (!IsServerCheck(allow_client))
10788 return false;
10789
10790 if (!HasQuantity())
10791 return false;
10792
10793 float min = GetQuantityMin();
10794 float max = GetQuantityMax();
10795
10796 if (value <= (min + 0.001))
10797 value = min;
10798
10799 if (value == min)
10800 {
10801 if (destroy_config)
10802 {
10803 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10804 if (dstr)
10805 {
10806 m_VarQuantity = Math.Clamp(value, min, max);
10807 this.Delete();
10808 return true;
10809 }
10810 }
10811 else if (destroy_forced)
10812 {
10813 m_VarQuantity = Math.Clamp(value, min, max);
10814 this.Delete();
10815 return true;
10816 }
10817 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10818 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10819 }
10820
10821 float delta = m_VarQuantity;
10822 m_VarQuantity = Math.Clamp(value, min, max);
10823
10824 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10825 {
10826 delta = m_VarQuantity - delta;
10827
10828 if (delta)
10829 OnQuantityChanged(delta);
10830 }
10831
10832 SetVariableMask(VARIABLE_QUANTITY);
10833
10834 return false;
10835 }
10836
10837 //----------------------------------------------------------------
10839 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10840 {
10841 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10842 }
10843 //----------------------------------------------------------------
10844 void SetQuantityMax()
10845 {
10846 float max = GetQuantityMax();
10847 SetQuantity(max);
10848 }
10849
10850 override void SetQuantityToMinimum()
10851 {
10852 float min = GetQuantityMin();
10853 SetQuantity(min);
10854 }
10855 //----------------------------------------------------------------
10857 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10858 {
10859 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10860 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10861 SetQuantity(result, destroy_config, destroy_forced);
10862 }
10863
10864 //----------------------------------------------------------------
10866 override float GetQuantityNormalized()
10867 {
10868 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10869 }
10870
10872 {
10873 return GetQuantityNormalized();
10874 }
10875
10876 /*void SetAmmoNormalized(float value)
10877 {
10878 float value_clamped = Math.Clamp(value, 0, 1);
10879 Magazine this_mag = Magazine.Cast(this);
10880 int max_rounds = this_mag.GetAmmoMax();
10881 int result = value * max_rounds;//can the rounded if higher precision is required
10882 this_mag.SetAmmoCount(result);
10883 }*/
10884 //----------------------------------------------------------------
10885 override int GetQuantityMax()
10886 {
10887 int slot = -1;
10888 if (GetInventory())
10889 {
10890 InventoryLocation il = new InventoryLocation;
10891 GetInventory().GetCurrentInventoryLocation(il);
10892 slot = il.GetSlot();
10893 }
10894
10895 return GetTargetQuantityMax(slot);
10896 }
10897
10898 override int GetTargetQuantityMax(int attSlotID = -1)
10899 {
10900 float quantity_max = 0;
10901
10902 if (IsSplitable()) //only stackable/splitable items can check for stack size
10903 {
10904 if (attSlotID != -1)
10905 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
10906
10907 if (quantity_max <= 0)
10908 quantity_max = m_VarStackMax;
10909 }
10910
10911 if (quantity_max <= 0)
10912 quantity_max = m_VarQuantityMax;
10913
10914 return quantity_max;
10915 }
10916 //----------------------------------------------------------------
10917 override int GetQuantityMin()
10918 {
10919 return m_VarQuantityMin;
10920 }
10921 //----------------------------------------------------------------
10922 int GetQuantityInit()
10923 {
10924 return m_VarQuantityInit;
10925 }
10926
10927 //----------------------------------------------------------------
10928 override bool HasQuantity()
10929 {
10930 return !(GetQuantityMax() - GetQuantityMin() == 0);
10931 }
10932
10933 override float GetQuantity()
10934 {
10935 return m_VarQuantity;
10936 }
10937
10938 bool IsFullQuantity()
10939 {
10940 return GetQuantity() >= GetQuantityMax();
10941 }
10942
10943 //Calculates weight of single item without attachments and cargo
10944 override float GetSingleInventoryItemWeightEx()
10945 {
10946 //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
10947 float weightEx = GetWeightEx();//overall weight of the item
10948 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
10949 return weightEx - special;
10950 }
10951
10952 // Obsolete, use GetSingleInventoryItemWeightEx() instead
10954 {
10956 }
10957
10958 override protected float GetWeightSpecialized(bool forceRecalc = false)
10959 {
10960 if (IsSplitable()) //quantity determines size of the stack
10961 {
10962 #ifdef DEVELOPER
10963 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10964 {
10965 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
10966 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
10967 }
10968 #endif
10969
10970 return GetQuantity() * GetConfigWeightModified();
10971 }
10972 else if (HasEnergyManager())// items with energy manager
10973 {
10974 #ifdef DEVELOPER
10975 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10976 {
10977 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
10978 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
10979 }
10980 #endif
10981 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10982 }
10983 else//everything else
10984 {
10985 #ifdef DEVELOPER
10986 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10987 {
10988 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
10989 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
10990 }
10991 #endif
10992 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
10993 }
10994 }
10995
10997 int GetNumberOfItems()
10998 {
10999 int item_count = 0;
11000 ItemBase item;
11001
11002 if (GetInventory().GetCargo() != NULL)
11003 {
11004 item_count = GetInventory().GetCargo().GetItemCount();
11005 }
11006
11007 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
11008 {
11009 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
11010 if (item)
11011 item_count += item.GetNumberOfItems();
11012 }
11013 return item_count;
11014 }
11015
11017 float GetUnitWeight(bool include_wetness = true)
11018 {
11019 float weight = 0;
11020 float wetness = 1;
11021 if (include_wetness)
11022 wetness += GetWet();
11023 if (IsSplitable()) //quantity determines size of the stack
11024 {
11025 weight = wetness * m_ConfigWeight;
11026 }
11027 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11028 {
11029 weight = 1;
11030 }
11031 return weight;
11032 }
11033
11034 //-----------------------------------------------------------------
11035
11036 override void ClearInventory()
11037 {
11038 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
11039 {
11040 GameInventory inv = GetInventory();
11041 array<EntityAI> items = new array<EntityAI>;
11042 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
11043 for (int i = 0; i < items.Count(); i++)
11044 {
11045 ItemBase item = ItemBase.Cast(items.Get(i));
11046 if (item)
11047 {
11048 GetGame().ObjectDelete(item);
11049 }
11050 }
11051 }
11052 }
11053
11054 //------------------------- Energy
11055
11056 //----------------------------------------------------------------
11057 float GetEnergy()
11058 {
11059 float energy = 0;
11060 if (HasEnergyManager())
11061 {
11062 energy = GetCompEM().GetEnergy();
11063 }
11064 return energy;
11065 }
11066
11067
11068 override void OnEnergyConsumed()
11069 {
11070 super.OnEnergyConsumed();
11071
11073 }
11074
11075 override void OnEnergyAdded()
11076 {
11077 super.OnEnergyAdded();
11078
11080 }
11081
11082 // Converts energy (from Energy Manager) to quantity, if enabled.
11084 {
11085 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11086 {
11087 if (HasQuantity())
11088 {
11089 float energy_0to1 = GetCompEM().GetEnergy0To1();
11090 SetQuantityNormalized(energy_0to1);
11091 }
11092 }
11093 }
11094
11095 //----------------------------------------------------------------
11096 float GetHeatIsolationInit()
11097 {
11098 return ConfigGetFloat("heatIsolation");
11099 }
11100
11101 float GetHeatIsolation()
11102 {
11103 return m_HeatIsolation;
11104 }
11105
11106 float GetDryingIncrement(string pIncrementName)
11107 {
11108 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11109 if (GetGame().ConfigIsExisting(paramPath))
11110 return GetGame().ConfigGetFloat(paramPath);
11111
11112 return 0.0;
11113 }
11114
11115 float GetSoakingIncrement(string pIncrementName)
11116 {
11117 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11118 if (GetGame().ConfigIsExisting(paramPath))
11119 return GetGame().ConfigGetFloat(paramPath);
11120
11121 return 0.0;
11122 }
11123 //----------------------------------------------------------------
11124 override void SetWet(float value, bool allow_client = false)
11125 {
11126 if (!IsServerCheck(allow_client))
11127 return;
11128
11129 float min = GetWetMin();
11130 float max = GetWetMax();
11131
11132 float previousValue = m_VarWet;
11133
11134 m_VarWet = Math.Clamp(value, min, max);
11135
11136 if (previousValue != m_VarWet)
11137 {
11138 SetVariableMask(VARIABLE_WET);
11139 OnWetChanged(m_VarWet, previousValue);
11140 }
11141 }
11142 //----------------------------------------------------------------
11143 override void AddWet(float value)
11144 {
11145 SetWet(GetWet() + value);
11146 }
11147 //----------------------------------------------------------------
11148 override void SetWetMax()
11149 {
11151 }
11152 //----------------------------------------------------------------
11153 override float GetWet()
11154 {
11155 return m_VarWet;
11156 }
11157 //----------------------------------------------------------------
11158 override float GetWetMax()
11159 {
11160 return m_VarWetMax;
11161 }
11162 //----------------------------------------------------------------
11163 override float GetWetMin()
11164 {
11165 return m_VarWetMin;
11166 }
11167 //----------------------------------------------------------------
11168 override float GetWetInit()
11169 {
11170 return m_VarWetInit;
11171 }
11172 //----------------------------------------------------------------
11173 override void OnWetChanged(float newVal, float oldVal)
11174 {
11175 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11176 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11177 if (newLevel != oldLevel)
11178 {
11179 OnWetLevelChanged(newLevel,oldLevel);
11180 }
11181 }
11182
11183 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11184 {
11185 SetWeightDirty();
11186 }
11187
11188 override EWetnessLevel GetWetLevel()
11189 {
11190 return GetWetLevelInternal(m_VarWet);
11191 }
11192
11193 //----------------------------------------------------------------
11194
11195 override void SetStoreLoad(bool value)
11196 {
11197 m_IsStoreLoad = value;
11198 }
11199
11200 override bool IsStoreLoad()
11201 {
11202 return m_IsStoreLoad;
11203 }
11204
11205 override void SetStoreLoadedQuantity(float value)
11206 {
11207 m_StoreLoadedQuantity = value;
11208 }
11209
11210 override float GetStoreLoadedQuantity()
11211 {
11212 return m_StoreLoadedQuantity;
11213 }
11214
11215 //----------------------------------------------------------------
11216
11217 float GetItemModelLength()
11218 {
11219 if (ConfigIsExisting("itemModelLength"))
11220 {
11221 return ConfigGetFloat("itemModelLength");
11222 }
11223 return 0;
11224 }
11225
11226 float GetItemAttachOffset()
11227 {
11228 if (ConfigIsExisting("itemAttachOffset"))
11229 {
11230 return ConfigGetFloat("itemAttachOffset");
11231 }
11232 return 0;
11233 }
11234
11235 override void SetCleanness(int value, bool allow_client = false)
11236 {
11237 if (!IsServerCheck(allow_client))
11238 return;
11239
11240 int previousValue = m_Cleanness;
11241
11242 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11243
11244 if (previousValue != m_Cleanness)
11245 SetVariableMask(VARIABLE_CLEANNESS);
11246 }
11247
11248 override int GetCleanness()
11249 {
11250 return m_Cleanness;
11251 }
11252
11254 {
11255 return true;
11256 }
11257
11258 //----------------------------------------------------------------
11259 // ATTACHMENT LOCKING
11260 // Getters relevant to generic ActionLockAttachment
11261 int GetLockType()
11262 {
11263 return m_LockType;
11264 }
11265
11266 string GetLockSoundSet()
11267 {
11268 return m_LockSoundSet;
11269 }
11270
11271 //----------------------------------------------------------------
11272 //------------------------- Color
11273 // sets items color variable given color components
11274 override void SetColor(int r, int g, int b, int a)
11275 {
11280 SetVariableMask(VARIABLE_COLOR);
11281 }
11283 override void GetColor(out int r,out int g,out int b,out int a)
11284 {
11289 }
11290
11291 bool IsColorSet()
11292 {
11293 return IsVariableSet(VARIABLE_COLOR);
11294 }
11295
11297 string GetColorString()
11298 {
11299 int r,g,b,a;
11300 GetColor(r,g,b,a);
11301 r = r/255;
11302 g = g/255;
11303 b = b/255;
11304 a = a/255;
11305 return MiscGameplayFunctions.GetColorString(r, g, b, a);
11306 }
11307 //----------------------------------------------------------------
11308 //------------------------- LiquidType
11309
11310 override void SetLiquidType(int value, bool allow_client = false)
11311 {
11312 if (!IsServerCheck(allow_client))
11313 return;
11314
11315 int old = m_VarLiquidType;
11316 m_VarLiquidType = value;
11317 OnLiquidTypeChanged(old,value);
11318 SetVariableMask(VARIABLE_LIQUIDTYPE);
11319 }
11320
11321 int GetLiquidTypeInit()
11322 {
11323 return ConfigGetInt("varLiquidTypeInit");
11324 }
11325
11326 override int GetLiquidType()
11327 {
11328 return m_VarLiquidType;
11329 }
11330
11331 protected void OnLiquidTypeChanged(int oldType, int newType)
11332 {
11333 if (newType == LIQUID_NONE && GetIsFrozen())
11334 SetFrozen(false);
11335 }
11336
11338 void UpdateQuickbarShortcutVisibility(PlayerBase player)
11339 {
11340 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11341 }
11342
11343 // -------------------------------------------------------------------------
11345 void OnInventoryEnter(Man player)
11346 {
11347 PlayerBase nplayer;
11348 if (PlayerBase.CastTo(nplayer, player))
11349 {
11350 m_CanPlayImpactSound = true;
11351 //nplayer.OnItemInventoryEnter(this);
11352 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11353 }
11354 }
11355
11356 // -------------------------------------------------------------------------
11358 void OnInventoryExit(Man player)
11359 {
11360 PlayerBase nplayer;
11361 if (PlayerBase.CastTo(nplayer,player))
11362 {
11363 //nplayer.OnItemInventoryExit(this);
11364 nplayer.SetEnableQuickBarEntityShortcut(this,false);
11365
11366 }
11367
11368 //if (!GetGame().IsDedicatedServer())
11369 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11370
11371
11372 if (HasEnergyManager())
11373 {
11374 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11375 }
11376 }
11377
11378 // ADVANCED PLACEMENT EVENTS
11379 override void OnPlacementStarted(Man player)
11380 {
11381 super.OnPlacementStarted(player);
11382
11383 SetTakeable(false);
11384 }
11385
11386 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11387 {
11388 if (m_AdminLog)
11389 {
11390 m_AdminLog.OnPlacementComplete(player, this);
11391 }
11392
11393 super.OnPlacementComplete(player, position, orientation);
11394 }
11395
11396 //-----------------------------
11397 // AGENT SYSTEM
11398 //-----------------------------
11399 //--------------------------------------------------------------------------
11400 bool ContainsAgent(int agent_id)
11401 {
11402 if (agent_id & m_AttachedAgents)
11403 {
11404 return true;
11405 }
11406 else
11407 {
11408 return false;
11409 }
11410 }
11411
11412 //--------------------------------------------------------------------------
11413 override void RemoveAgent(int agent_id)
11414 {
11415 if (ContainsAgent(agent_id))
11416 {
11417 m_AttachedAgents = ~agent_id & m_AttachedAgents;
11418 }
11419 }
11420
11421 //--------------------------------------------------------------------------
11422 override void RemoveAllAgents()
11423 {
11424 m_AttachedAgents = 0;
11425 }
11426 //--------------------------------------------------------------------------
11427 override void RemoveAllAgentsExcept(int agent_to_keep)
11428 {
11429 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
11430 }
11431 // -------------------------------------------------------------------------
11432 override void InsertAgent(int agent, float count = 1)
11433 {
11434 if (count < 1)
11435 return;
11436 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
11438 }
11439
11441 void TransferAgents(int agents)
11442 {
11444 }
11445
11446 // -------------------------------------------------------------------------
11447 override int GetAgents()
11448 {
11449 return m_AttachedAgents;
11450 }
11451 //----------------------------------------------------------------------
11452
11453 /*int GetContaminationType()
11454 {
11455 int contamination_type;
11456
11457 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
11458 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
11459 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
11460 const int DIRTY_MASK = eAgents.WOUND_AGENT;
11461
11462 Edible_Base edible = Edible_Base.Cast(this);
11463 int agents = GetAgents();
11464 if (edible)
11465 {
11466 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
11467 if (profile)
11468 {
11469 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
11470 }
11471 }
11472 if (agents & CONTAMINATED_MASK)
11473 {
11474 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
11475 }
11476 if (agents & POISONED_MASK)
11477 {
11478 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
11479 }
11480 if (agents & NERVE_GAS_MASK)
11481 {
11482 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
11483 }
11484 if (agents & DIRTY_MASK)
11485 {
11486 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
11487 }
11488
11489 return agents;
11490 }*/
11491
11492 // -------------------------------------------------------------------------
11493 bool LoadAgents(ParamsReadContext ctx, int version)
11494 {
11495 if (!ctx.Read(m_AttachedAgents))
11496 return false;
11497 return true;
11498 }
11499 // -------------------------------------------------------------------------
11501 {
11502
11504 }
11505 // -------------------------------------------------------------------------
11506
11508 override void CheckForRoofLimited(float timeTresholdMS = 3000)
11509 {
11510 super.CheckForRoofLimited(timeTresholdMS);
11511
11512 float time = GetGame().GetTime();
11513 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
11514 {
11515 m_PreviousRoofTestTime = time;
11516 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
11517 }
11518 }
11519
11520 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
11521 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
11522 {
11523 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
11524 {
11525 return 0;
11526 }
11527
11528 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
11529 {
11530 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
11531 if (filter)
11532 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11533 else
11534 return 0;//otherwise return 0 when no filter attached
11535 }
11536
11537 string subclassPath, entryName;
11538
11539 switch (type)
11540 {
11541 case DEF_BIOLOGICAL:
11542 entryName = "biological";
11543 break;
11544 case DEF_CHEMICAL:
11545 entryName = "chemical";
11546 break;
11547 default:
11548 entryName = "biological";
11549 break;
11550 }
11551
11552 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
11553
11554 return GetGame().ConfigGetFloat(subclassPath + entryName);
11555 }
11556
11557
11558
11560 override void EEOnCECreate()
11561 {
11562 if (!IsMagazine())
11564
11566 }
11567
11568
11569 //-------------------------
11570 // OPEN/CLOSE USER ACTIONS
11571 //-------------------------
11573 void Open();
11574 void Close();
11575 bool IsOpen()
11576 {
11577 return true;
11578 }
11579
11580 override bool CanDisplayCargo()
11581 {
11582 return IsOpen();
11583 }
11584
11585
11586 // ------------------------------------------------------------
11587 // CONDITIONS
11588 // ------------------------------------------------------------
11589 override bool CanPutInCargo(EntityAI parent)
11590 {
11591 if (parent)
11592 {
11593 if (parent.IsInherited(DayZInfected))
11594 return true;
11595
11596 if (!parent.IsRuined())
11597 return true;
11598 }
11599
11600 return true;
11601 }
11602
11603 override bool CanPutAsAttachment(EntityAI parent)
11604 {
11605 if (!super.CanPutAsAttachment(parent))
11606 {
11607 return false;
11608 }
11609
11610 if (!IsRuined() && !parent.IsRuined())
11611 {
11612 return true;
11613 }
11614
11615 return false;
11616 }
11617
11618 override bool CanReceiveItemIntoCargo(EntityAI item)
11619 {
11620 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11621 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11622 // return false;
11623
11624 return super.CanReceiveItemIntoCargo(item);
11625 }
11626
11627 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11628 {
11629 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11630 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11631 // return false;
11632
11633 GameInventory attachmentInv = attachment.GetInventory();
11634 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11635 {
11636 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11637 return false;
11638 }
11639
11640 InventoryLocation loc = new InventoryLocation();
11641 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11642 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11643 return false;
11644
11645 return super.CanReceiveAttachment(attachment, slotId);
11646 }
11647
11648 override bool CanReleaseAttachment(EntityAI attachment)
11649 {
11650 if (!super.CanReleaseAttachment(attachment))
11651 return false;
11652
11653 return GetInventory().AreChildrenAccessible();
11654 }
11655
11656 /*override bool CanLoadAttachment(EntityAI attachment)
11657 {
11658 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11659 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11660 // return false;
11661
11662 GameInventory attachmentInv = attachment.GetInventory();
11663 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11664 {
11665 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11666 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11667
11668 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11669 return false;
11670 }
11671
11672 return super.CanLoadAttachment(attachment);
11673 }*/
11674
11675 // Plays muzzle flash particle effects
11676 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11677 {
11678 int id = muzzle_owner.GetMuzzleID();
11679 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11680
11681 if (WPOF_array)
11682 {
11683 for (int i = 0; i < WPOF_array.Count(); i++)
11684 {
11685 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11686
11687 if (WPOF)
11688 {
11689 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11690 }
11691 }
11692 }
11693 }
11694
11695 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11696 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11697 {
11698 int id = muzzle_owner.GetMuzzleID();
11699 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11700
11701 if (WPOBE_array)
11702 {
11703 for (int i = 0; i < WPOBE_array.Count(); i++)
11704 {
11705 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11706
11707 if (WPOBE)
11708 {
11709 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11710 }
11711 }
11712 }
11713 }
11714
11715 // Plays all weapon overheating particles
11716 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11717 {
11718 int id = muzzle_owner.GetMuzzleID();
11719 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11720
11721 if (WPOOH_array)
11722 {
11723 for (int i = 0; i < WPOOH_array.Count(); i++)
11724 {
11725 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11726
11727 if (WPOOH)
11728 {
11729 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11730 }
11731 }
11732 }
11733 }
11734
11735 // Updates all weapon overheating particles
11736 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11737 {
11738 int id = muzzle_owner.GetMuzzleID();
11739 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11740
11741 if (WPOOH_array)
11742 {
11743 for (int i = 0; i < WPOOH_array.Count(); i++)
11744 {
11745 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11746
11747 if (WPOOH)
11748 {
11749 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11750 }
11751 }
11752 }
11753 }
11754
11755 // Stops overheating particles
11756 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11757 {
11758 int id = muzzle_owner.GetMuzzleID();
11759 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11760
11761 if (WPOOH_array)
11762 {
11763 for (int i = 0; i < WPOOH_array.Count(); i++)
11764 {
11765 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11766
11767 if (WPOOH)
11768 {
11769 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11770 }
11771 }
11772 }
11773 }
11774
11775 //----------------------------------------------------------------
11776 //Item Behaviour - unified approach
11777 override bool IsHeavyBehaviour()
11778 {
11779 if (m_ItemBehaviour == 0)
11780 {
11781 return true;
11782 }
11783
11784 return false;
11785 }
11786
11787 override bool IsOneHandedBehaviour()
11788 {
11789 if (m_ItemBehaviour == 1)
11790 {
11791 return true;
11792 }
11793
11794 return false;
11795 }
11796
11797 override bool IsTwoHandedBehaviour()
11798 {
11799 if (m_ItemBehaviour == 2)
11800 {
11801 return true;
11802 }
11803
11804 return false;
11805 }
11806
11807 bool IsDeployable()
11808 {
11809 return false;
11810 }
11811
11813 float GetDeployTime()
11814 {
11815 return UATimeSpent.DEFAULT_DEPLOY;
11816 }
11817
11818
11819 //----------------------------------------------------------------
11820 // Item Targeting (User Actions)
11821 override void SetTakeable(bool pState)
11822 {
11823 m_IsTakeable = pState;
11824 SetSynchDirty();
11825 }
11826
11827 override bool IsTakeable()
11828 {
11829 return m_IsTakeable;
11830 }
11831
11832 // For cases where we want to show object widget which cant be taken to hands
11834 {
11835 return false;
11836 }
11837
11839 protected void PreLoadSoundAttachmentType()
11840 {
11841 string att_type = "None";
11842
11843 if (ConfigIsExisting("soundAttType"))
11844 {
11845 att_type = ConfigGetString("soundAttType");
11846 }
11847
11848 m_SoundAttType = att_type;
11849 }
11850
11851 override string GetAttachmentSoundType()
11852 {
11853 return m_SoundAttType;
11854 }
11855
11856 //----------------------------------------------------------------
11857 //SOUNDS - ItemSoundHandler
11858 //----------------------------------------------------------------
11859
11860 string GetPlaceSoundset(); // played when deploy starts
11861 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11862 string GetDeploySoundset(); // played when deploy sucessfully finishes
11863 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
11864 string GetFoldSoundset(); // played when fold sucessfully finishes
11865
11867 {
11868 if (!m_ItemSoundHandler)
11870
11871 return m_ItemSoundHandler;
11872 }
11873
11874 // override to initialize sounds
11875 protected void InitItemSounds()
11876 {
11877 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
11878 return;
11879
11881
11882 if (GetPlaceSoundset() != string.Empty)
11883 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11884
11885 if (GetDeploySoundset() != string.Empty)
11886 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11887
11888 SoundParameters params = new SoundParameters();
11889 params.m_Loop = true;
11890 if (GetLoopDeploySoundset() != string.Empty)
11891 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11892 }
11893
11894 // Start sound using ItemSoundHandler
11895 void StartItemSoundServer(int id)
11896 {
11897 if (!GetGame().IsServer())
11898 return;
11899
11900 m_SoundSyncPlay = id;
11901 SetSynchDirty();
11902
11903 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
11905 }
11906
11907 // Stop sound using ItemSoundHandler
11908 void StopItemSoundServer(int id)
11909 {
11910 if (!GetGame().IsServer())
11911 return;
11912
11913 m_SoundSyncStop = id;
11914 SetSynchDirty();
11915
11916 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
11918 }
11919
11920 protected void ClearStartItemSoundServer()
11921 {
11922 m_SoundSyncPlay = 0;
11923 }
11924
11925 protected void ClearStopItemSoundServer()
11926 {
11927 m_SoundSyncStop = 0;
11928 }
11929
11931 void PlayAttachSound(string slot_type)
11932 {
11933 if (!GetGame().IsDedicatedServer())
11934 {
11935 if (ConfigIsExisting("attachSoundSet"))
11936 {
11937 string cfg_path = "";
11938 string soundset = "";
11939 string type_name = GetType();
11940
11941 TStringArray cfg_soundset_array = new TStringArray;
11942 TStringArray cfg_slot_array = new TStringArray;
11943 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
11944 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
11945
11946 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
11947 {
11948 for (int i = 0; i < cfg_soundset_array.Count(); i++)
11949 {
11950 if (cfg_slot_array[i] == slot_type)
11951 {
11952 soundset = cfg_soundset_array[i];
11953 break;
11954 }
11955 }
11956 }
11957
11958 if (soundset != "")
11959 {
11960 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
11961 sound.SetAutodestroy(true);
11962 }
11963 }
11964 }
11965 }
11966
11967 void PlayDetachSound(string slot_type)
11968 {
11969 //TODO - evaluate if needed and devise universal config structure if so
11970 }
11971
11972 void OnApply(PlayerBase player);
11973
11975 {
11976 return 1.0;
11977 };
11978 //returns applicable selection
11979 array<string> GetHeadHidingSelection()
11980 {
11982 }
11983
11985 {
11987 }
11988
11989 WrittenNoteData GetWrittenNoteData() {};
11990
11992 {
11993 SetDynamicPhysicsLifeTime(0.01);
11994 m_ItemBeingDroppedPhys = false;
11995 }
11996
11998 {
11999 array<string> zone_names = new array<string>;
12000 GetDamageZones(zone_names);
12001 for (int i = 0; i < zone_names.Count(); i++)
12002 {
12003 SetHealthMax(zone_names.Get(i),"Health");
12004 }
12005 SetHealthMax("","Health");
12006 }
12007
12009 void SetZoneDamageCEInit()
12010 {
12011 float global_health = GetHealth01("","Health");
12012 array<string> zones = new array<string>;
12013 GetDamageZones(zones);
12014 //set damage of all zones to match global health level
12015 for (int i = 0; i < zones.Count(); i++)
12016 {
12017 SetHealth01(zones.Get(i),"Health",global_health);
12018 }
12019 }
12020
12022 bool IsCoverFaceForShave(string slot_name)
12023 {
12024 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12025 }
12026
12027 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12028 {
12029 if (!hasRootAsPlayer)
12030 {
12031 if (refParentIB)
12032 {
12033 // parent is wet
12034 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12035 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12036 // parent has liquid inside
12037 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12038 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12039 // drying
12040 else if (m_VarWet > m_VarWetMin)
12041 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12042 }
12043 else
12044 {
12045 // drying on ground or inside non-itembase (car, ...)
12046 if (m_VarWet > m_VarWetMin)
12047 AddWet(-1 * delta * GetDryingIncrement("ground"));
12048 }
12049 }
12050 }
12051
12052 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12053 {
12055 {
12056 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12057 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12058 {
12059 float heatPermCoef = 1.0;
12060 EntityAI ent = this;
12061 while (ent)
12062 {
12063 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12064 ent = ent.GetHierarchyParent();
12065 }
12066
12067 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12068 }
12069 }
12070 }
12071
12072 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12073 {
12074 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12075 EntityAI parent = GetHierarchyParent();
12076 if (!parent)
12077 {
12078 hasParent = false;
12079 hasRootAsPlayer = false;
12080 }
12081 else
12082 {
12083 hasParent = true;
12084 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12085 refParentIB = ItemBase.Cast(parent);
12086 }
12087 }
12088
12089 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12090 {
12091 // this is stub, implemented on Edible_Base
12092 }
12093
12094 bool CanDecay()
12095 {
12096 // return true used on selected food clases so they can decay
12097 return false;
12098 }
12099
12100 protected bool CanProcessDecay()
12101 {
12102 // this is stub, implemented on Edible_Base class
12103 // used to determine whether it is still necessary for the food to decay
12104 return false;
12105 }
12106
12107 protected bool CanHaveWetness()
12108 {
12109 // return true used on selected items that have a wetness effect
12110 return false;
12111 }
12112
12114 bool CanBeConsumed(ConsumeConditionData data = null)
12115 {
12116 return !GetIsFrozen() && IsOpen();
12117 }
12118
12119 override void ProcessVariables()
12120 {
12121 bool hasParent = false, hasRootAsPlayer = false;
12122 ItemBase refParentIB;
12123
12124 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12125 bool foodDecay = g_Game.IsFoodDecayEnabled();
12126
12127 if (wwtu || foodDecay)
12128 {
12129 bool processWetness = wwtu && CanHaveWetness();
12130 bool processTemperature = wwtu && CanHaveTemperature();
12131 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12132
12133 if (processWetness || processTemperature || processDecay)
12134 {
12135 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12136
12137 if (processWetness)
12138 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12139
12140 if (processTemperature)
12141 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12142
12143 if (processDecay)
12144 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12145 }
12146 }
12147 }
12148
12151 {
12152 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12153 }
12154
12155 override float GetTemperatureFreezeThreshold()
12156 {
12158 return Liquid.GetFreezeThreshold(GetLiquidType());
12159
12160 return super.GetTemperatureFreezeThreshold();
12161 }
12162
12163 override float GetTemperatureThawThreshold()
12164 {
12166 return Liquid.GetThawThreshold(GetLiquidType());
12167
12168 return super.GetTemperatureThawThreshold();
12169 }
12170
12171 override float GetItemOverheatThreshold()
12172 {
12174 return Liquid.GetBoilThreshold(GetLiquidType());
12175
12176 return super.GetItemOverheatThreshold();
12177 }
12178
12179 override float GetTemperatureFreezeTime()
12180 {
12181 if (HasQuantity())
12182 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12183
12184 return super.GetTemperatureFreezeTime();
12185 }
12186
12187 override float GetTemperatureThawTime()
12188 {
12189 if (HasQuantity())
12190 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12191
12192 return super.GetTemperatureThawTime();
12193 }
12194
12196 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12198 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12199
12200 bool IsCargoException4x3(EntityAI item)
12201 {
12202 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12203 }
12204
12206 {
12207 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12208 }
12209
12211 void AddLightSourceItem(ItemBase lightsource)
12212 {
12213 m_LightSourceItem = lightsource;
12214 }
12215
12217 {
12218 m_LightSourceItem = null;
12219 }
12220
12222 {
12223 return m_LightSourceItem;
12224 }
12225
12227 array<int> GetValidFinishers()
12228 {
12229 return null;
12230 }
12231
12233 bool GetActionWidgetOverride(out typename name)
12234 {
12235 return false;
12236 }
12237
12238 bool PairWithDevice(notnull ItemBase otherDevice)
12239 {
12240 if (GetGame().IsServer())
12241 {
12242 ItemBase explosive = otherDevice;
12244 if (!trg)
12245 {
12246 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12247 explosive = this;
12248 }
12249
12250 explosive.PairRemote(trg);
12251 trg.SetControlledDevice(explosive);
12252
12253 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12254 trg.SetPersistentPairID(persistentID);
12255 explosive.SetPersistentPairID(persistentID);
12256
12257 return true;
12258 }
12259 return false;
12260 }
12261
12263 float GetBaitEffectivity()
12264 {
12265 float ret = 1.0;
12266 if (HasQuantity())
12267 ret *= GetQuantityNormalized();
12268 ret *= GetHealth01();
12269
12270 return ret;
12271 }
12272
12273 #ifdef DEVELOPER
12274 override void SetDebugItem()
12275 {
12276 super.SetDebugItem();
12277 _itemBase = this;
12278 }
12279
12280 override string GetDebugText()
12281 {
12282 string text = super.GetDebugText();
12283
12284 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12285 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12286
12287 return text;
12288 }
12289 #endif
12290
12291 bool CanBeUsedForSuicide()
12292 {
12293 return true;
12294 }
12295
12297 //DEPRECATED BELOW
12299 // Backwards compatibility
12300 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12301 {
12302 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12303 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12304 }
12305
12306 // replaced by ItemSoundHandler
12307 protected EffectSound m_SoundDeployFinish;
12308 protected EffectSound m_SoundPlace;
12309 protected EffectSound m_DeployLoopSoundEx;
12310 protected EffectSound m_SoundDeploy;
12311 bool m_IsPlaceSound;
12312 bool m_IsDeploySound;
12314
12315 string GetDeployFinishSoundset();
12316 void PlayDeploySound();
12317 void PlayDeployFinishSound();
12318 void PlayPlaceSound();
12319 void PlayDeployLoopSoundEx();
12320 void StopDeployLoopSoundEx();
12321 void SoundSynchRemoteReset();
12322 void SoundSynchRemote();
12323 bool UsesGlobalDeploy(){return false;}
12324 bool CanPlayDeployLoopSound(){return false;}
12326 bool IsPlaceSound(){return m_IsPlaceSound;}
12327 bool IsDeploySound(){return m_IsDeploySound;}
12328 void SetIsPlaceSound(bool is_place_sound);
12329 void SetIsDeploySound(bool is_deploy_sound);
12330}
12331
12332EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
12333{
12334 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
12335 if (entity)
12336 {
12337 bool is_item = entity.IsInherited(ItemBase);
12338 if (is_item && full_quantity)
12339 {
12340 ItemBase item = ItemBase.Cast(entity);
12341 item.SetQuantity(item.GetQuantityInit());
12342 }
12343 }
12344 else
12345 {
12346 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
12347 return NULL;
12348 }
12349 return entity;
12350}
12351
12352void SetupSpawnedItem(ItemBase item, float health, float quantity)
12353{
12354 if (item)
12355 {
12356 if (health > 0)
12357 item.SetHealth("", "", health);
12358
12359 if (item.CanHaveTemperature())
12360 {
12361 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12362 if (item.CanFreeze())
12363 item.SetFrozen(false);
12364 }
12365
12366 if (item.HasEnergyManager())
12367 {
12368 if (quantity >= 0)
12369 {
12370 item.GetCompEM().SetEnergy0To1(quantity);
12371 }
12372 else
12373 {
12374 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12375 }
12376 }
12377 else if (item.IsMagazine())
12378 {
12379 Magazine mag = Magazine.Cast(item);
12380 if (quantity >= 0)
12381 {
12382 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12383 }
12384 else
12385 {
12386 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12387 }
12388
12389 }
12390 else
12391 {
12392 if (quantity >= 0)
12393 {
12394 item.SetQuantityNormalized(quantity, false);
12395 }
12396 else
12397 {
12398 item.SetQuantity(Math.AbsFloat(quantity));
12399 }
12400
12401 }
12402 }
12403}
12404
12405#ifdef DEVELOPER
12406ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12407#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()