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

◆ CanBeMovedOverride()

bool SpawnItemOnLocation::CanBeMovedOverride ( )
protected

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

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