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

◆ HasFoodStage()

bool SpawnItemOnLocation::HasFoodStage ( )
protected

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

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

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