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

◆ GetItemSize()

int SpawnItemOnLocation::GetItemSize ( )
protected

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

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