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

◆ MessageToOwnerStatus()

void SpawnItemOnLocation::MessageToOwnerStatus ( string text)
protected

Send message to owner player in grey color.

Возвращает
void
item_stone.MessageToOwnerStatus("Some Status Message");

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

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