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

◆ GetWeightSpecialized()

float SpawnItemOnLocation::GetWeightSpecialized ( bool forceRecalc = false)
protected

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

8428{
8429 override bool CanPutAsAttachment(EntityAI parent)
8430 {
8431 return true;
8432 }
8433};
8434
8436{
8437
8438};
8439
8440//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8441
8442class ItemBase extends InventoryItem
8443{
8447
8449
8450 static int m_DebugActionsMask;
8452 // ============================================
8453 // Variable Manipulation System
8454 // ============================================
8455 // Quantity
8456
8457 float m_VarQuantity;
8458 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8460 int m_VarQuantityMin;
8461 int m_VarQuantityMax;
8462 int m_Count;
8463 float m_VarStackMax;
8464 float m_StoreLoadedQuantity = float.LOWEST;
8465 // Wet
8466 float m_VarWet;
8467 float m_VarWetPrev;//for client to know wetness changed during synchronization
8468 float m_VarWetInit;
8469 float m_VarWetMin;
8470 float m_VarWetMax;
8471 // Cleanness
8472 int m_Cleanness;
8473 int m_CleannessInit;
8474 int m_CleannessMin;
8475 int m_CleannessMax;
8476 // impact sounds
8478 bool m_CanPlayImpactSound = true;
8479 float m_ImpactSpeed;
8481 //
8482 float m_HeatIsolation;
8483 float m_ItemModelLength;
8484 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8486 int m_VarLiquidType;
8487 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8488 int m_QuickBarBonus;
8489 bool m_IsBeingPlaced;
8490 bool m_IsHologram;
8491 bool m_IsTakeable;
8492 bool m_ThrowItemOnDrop;
8495 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8496 bool can_this_be_combined; //Check if item can be combined
8497 bool m_CanThisBeSplit; //Check if item can be split
8498 bool m_IsStoreLoad = false;
8499 bool m_CanShowQuantity;
8500 bool m_HasQuantityBar;
8501 protected bool m_CanBeDigged;
8502 protected bool m_IsResultOfSplit
8503
8504 string m_SoundAttType;
8505 // items color variables
8510 //-------------------------------------------------------
8511
8512 // light source managing
8514
8518
8519 //==============================================
8520 // agent system
8521 private int m_AttachedAgents;
8522
8524 void TransferModifiers(PlayerBase reciever);
8525
8526
8527 // Weapons & suppressors particle effects
8531 ref static map<string, int> m_WeaponTypeToID;
8532 static int m_LastRegisteredWeaponID = 0;
8533
8534 // Overheating effects
8536 float m_OverheatingShots;
8537 ref Timer m_CheckOverheating;
8538 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8539 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8540 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8541 ref array <ref OverheatingParticle> m_OverheatingParticles;
8542
8544 protected bool m_HideSelectionsBySlot;
8545
8546 // Admin Log
8547 PluginAdminLog m_AdminLog;
8548
8549 // misc
8550 ref Timer m_PhysDropTimer;
8551
8552 // Attachment Locking variables
8553 ref array<int> m_CompatibleLocks;
8554 protected int m_LockType;
8555 protected ref EffectSound m_LockingSound;
8556 protected string m_LockSoundSet;
8557
8558 // ItemSoundHandler variables
8559 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8560 protected int m_SoundSyncPlay; // id for sound to play
8561 protected int m_SoundSyncStop; // id for sound to stop
8562 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8563
8565
8566 //temperature
8567 private float m_TemperaturePerQuantityWeight;
8568
8569 // -------------------------------------------------------------------------
8570 void ItemBase()
8571 {
8572 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8576
8577 if (!g_Game.IsDedicatedServer())
8578 {
8579 if (HasMuzzle())
8580 {
8582
8584 {
8586 }
8587 }
8588
8590 m_ActionsInitialize = false;
8591 }
8592
8593 m_OldLocation = null;
8594
8595 if (g_Game.IsServer())
8596 {
8597 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8598 }
8599
8600 if (ConfigIsExisting("headSelectionsToHide"))
8601 {
8603 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8604 }
8605
8606 m_HideSelectionsBySlot = false;
8607 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8608 {
8609 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8610 }
8611
8612 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8613
8614 m_IsResultOfSplit = false;
8615
8617 }
8618
8619 override void InitItemVariables()
8620 {
8621 super.InitItemVariables();
8622
8623 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8624 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8625 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8626 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8627 m_VarStackMax = ConfigGetFloat("varStackMax");
8628 m_Count = ConfigGetInt("count");
8629
8630 m_CanShowQuantity = ConfigGetBool("quantityShow");
8631 m_HasQuantityBar = ConfigGetBool("quantityBar");
8632
8633 m_CleannessInit = ConfigGetInt("varCleannessInit");
8635 m_CleannessMin = ConfigGetInt("varCleannessMin");
8636 m_CleannessMax = ConfigGetInt("varCleannessMax");
8637
8638 m_WantPlayImpactSound = false;
8639 m_ImpactSpeed = 0.0;
8640
8641 m_VarWetInit = ConfigGetFloat("varWetInit");
8643 m_VarWetMin = ConfigGetFloat("varWetMin");
8644 m_VarWetMax = ConfigGetFloat("varWetMax");
8645
8646 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8647 if (IsLiquidContainer() && GetQuantity() != 0)
8649 m_IsBeingPlaced = false;
8650 m_IsHologram = false;
8651 m_IsTakeable = true;
8652 m_CanBeMovedOverride = false;
8656 m_CanBeDigged = ConfigGetBool("canBeDigged");
8657
8658 m_CompatibleLocks = new array<int>();
8659 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8660 m_LockType = ConfigGetInt("lockType");
8661
8662 //Define if item can be split and set ability to be combined accordingly
8663 m_CanThisBeSplit = false;
8664 can_this_be_combined = false;
8665 if (ConfigIsExisting("canBeSplit"))
8666 {
8667 can_this_be_combined = ConfigGetBool("canBeSplit");
8669 }
8670
8671 m_ItemBehaviour = -1;
8672 if (ConfigIsExisting("itemBehaviour"))
8673 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8674
8675 //RegisterNetSyncVariableInt("m_VariablesMask");
8676 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8677 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8678 RegisterNetSyncVariableInt("m_VarLiquidType");
8679 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8680
8681 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8682 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8683 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8684
8685 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8686 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8687 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8688 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8689
8690 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8691 RegisterNetSyncVariableBool("m_IsTakeable");
8692 RegisterNetSyncVariableBool("m_IsHologram");
8693
8696 {
8697 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8698 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8699 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8700 }
8701
8702 m_LockSoundSet = ConfigGetString("lockSoundSet");
8703
8705 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8706 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8707
8708 m_SoundSyncSlotID = -1;
8709 }
8710
8711 override int GetQuickBarBonus()
8712 {
8713 return m_QuickBarBonus;
8714 }
8715
8716 void InitializeActions()
8717 {
8719 if (!m_InputActionMap)
8720 {
8722 m_InputActionMap = iam;
8723 SetActions();
8725 }
8726 }
8727
8728 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8729 {
8731 {
8732 m_ActionsInitialize = true;
8734 }
8735
8736 actions = m_InputActionMap.Get(action_input_type);
8737 }
8738
8739 void SetActions()
8740 {
8741 AddAction(ActionTakeItem);
8742 AddAction(ActionTakeItemToHands);
8743 AddAction(ActionWorldCraft);
8745 AddAction(ActionAttachWithSwitch);
8746 }
8747
8748 void SetActionAnimOverrides(); // Override action animation for specific item
8749
8750 void AddAction(typename actionName)
8751 {
8752 ActionBase action = ActionManagerBase.GetAction(actionName);
8753
8754 if (!action)
8755 {
8756 Debug.LogError("Action " + actionName + " dosn't exist!");
8757 return;
8758 }
8759
8760 typename ai = action.GetInputType();
8761 if (!ai)
8762 {
8763 m_ActionsInitialize = false;
8764 return;
8765 }
8766
8767 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8768 if (!action_array)
8769 {
8770 action_array = new array<ActionBase_Basic>;
8771 m_InputActionMap.Insert(ai, action_array);
8772 }
8773 if (LogManager.IsActionLogEnable())
8774 {
8775 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8776 }
8777
8778 if (action_array.Find(action) != -1)
8779 {
8780 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8781 }
8782 else
8783 {
8784 action_array.Insert(action);
8785 }
8786 }
8787
8788 void RemoveAction(typename actionName)
8789 {
8790 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8791 ActionBase action = player.GetActionManager().GetAction(actionName);
8792 typename ai = action.GetInputType();
8793 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8794
8795 if (action_array)
8796 {
8797 action_array.RemoveItem(action);
8798 }
8799 }
8800
8801 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8802 // Set -1 for params which should stay in default state
8803 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8804 {
8805 ActionOverrideData overrideData = new ActionOverrideData();
8806 overrideData.m_CommandUID = commandUID;
8807 overrideData.m_CommandUIDProne = commandUIDProne;
8808 overrideData.m_StanceMask = stanceMask;
8809
8810 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8811 if (!actionMap) // create new map of action > overidables map
8812 {
8813 actionMap = new TActionAnimOverrideMap();
8814 m_ItemActionOverrides.Insert(action, actionMap);
8815 }
8816
8817 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8818
8819 }
8820
8821 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8822
8823 ScriptedLightBase GetLight();
8824
8825 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8826 void LoadParticleConfigOnFire(int id)
8827 {
8828 if (!m_OnFireEffect)
8830
8833
8834 string config_to_search = "CfgVehicles";
8835 string muzzle_owner_config;
8836
8837 if (!m_OnFireEffect.Contains(id))
8838 {
8839 if (IsInherited(Weapon))
8840 config_to_search = "CfgWeapons";
8841
8842 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8843
8844 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8845
8846 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
8847
8848 if (config_OnFire_subclass_count > 0)
8849 {
8850 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8851
8852 for (int i = 0; i < config_OnFire_subclass_count; i++)
8853 {
8854 string particle_class = "";
8855 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
8856 string config_OnFire_entry = config_OnFire_class + particle_class;
8857 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8858 WPOF_array.Insert(WPOF);
8859 }
8860
8861
8862 m_OnFireEffect.Insert(id, WPOF_array);
8863 }
8864 }
8865
8866 if (!m_OnBulletCasingEjectEffect.Contains(id))
8867 {
8868 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8869 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8870
8871 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8872
8873 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8874
8875 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8876 {
8877 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8878
8879 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8880 {
8881 string particle_class2 = "";
8882 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8883 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8884 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8885 WPOBE_array.Insert(WPOBE);
8886 }
8887
8888
8889 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8890 }
8891 }
8892 }
8893
8894 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8896 {
8899
8900 if (!m_OnOverheatingEffect.Contains(id))
8901 {
8902 string config_to_search = "CfgVehicles";
8903
8904 if (IsInherited(Weapon))
8905 config_to_search = "CfgWeapons";
8906
8907 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8908 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8909
8910 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8911 {
8912
8913 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8914
8916 {
8917 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8918 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8919 Error(error);
8920 return;
8921 }
8922
8923 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8924 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8925
8926
8927
8928 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8929 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8930
8931 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8932 {
8933 string particle_class = "";
8934 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8935 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8936 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8937
8938 if (entry_type == CT_CLASS)
8939 {
8940 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8941 WPOOH_array.Insert(WPOF);
8942 }
8943 }
8944
8945
8946 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8947 }
8948 }
8949 }
8950
8951 float GetOverheatingValue()
8952 {
8953 return m_OverheatingShots;
8954 }
8955
8956 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8957 {
8958 if (m_MaxOverheatingValue > 0)
8959 {
8961
8962 if (!m_CheckOverheating)
8964
8966 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8967
8968 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8969 }
8970 }
8971
8972 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8973 {
8975 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8976
8978 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8979
8981 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8982
8984 {
8986 }
8987 }
8988
8990 {
8992 }
8993
8994 void OnOverheatingDecay()
8995 {
8996 if (m_MaxOverheatingValue > 0)
8997 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8998 else
9000
9001 if (m_OverheatingShots <= 0)
9002 {
9005 }
9006 else
9007 {
9008 if (!m_CheckOverheating)
9010
9012 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9013 }
9014
9015 CheckOverheating(this, "", this);
9016 }
9017
9018 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9019 {
9021 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9022 }
9023
9024 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9025 {
9027 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9029 }
9030
9031 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9032 {
9034 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9035 }
9036
9037 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9038 {
9040 m_OverheatingParticles = new array<ref OverheatingParticle>;
9041
9042 OverheatingParticle OP = new OverheatingParticle();
9043 OP.RegisterParticle(p);
9044 OP.SetOverheatingLimitMin(min_heat_coef);
9045 OP.SetOverheatingLimitMax(max_heat_coef);
9046 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9047
9048 m_OverheatingParticles.Insert(OP);
9049 }
9050
9051 float GetOverheatingCoef()
9052 {
9053 if (m_MaxOverheatingValue > 0)
9055
9056 return -1;
9057 }
9058
9060 {
9062 {
9063 float overheat_coef = GetOverheatingCoef();
9064 int count = m_OverheatingParticles.Count();
9065
9066 for (int i = count; i > 0; --i)
9067 {
9068 int id = i - 1;
9069 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9070 Particle p = OP.GetParticle();
9071
9072 float overheat_min = OP.GetOverheatingLimitMin();
9073 float overheat_max = OP.GetOverheatingLimitMax();
9074
9075 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9076 {
9077 if (p)
9078 {
9079 p.Stop();
9080 OP.RegisterParticle(null);
9081 }
9082 }
9083 }
9084 }
9085 }
9086
9088 {
9090 {
9091 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9092 {
9093 int id = i - 1;
9094 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9095
9096 if (OP)
9097 {
9098 Particle p = OP.GetParticle();
9099
9100 if (p)
9101 {
9102 p.Stop();
9103 }
9104
9105 delete OP;
9106 }
9107 }
9108
9109 m_OverheatingParticles.Clear();
9111 }
9112 }
9113
9115 float GetInfectionChance(int system = 0, Param param = null)
9116 {
9117 return 0.0;
9118 }
9119
9120
9121 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9122 {
9123 return 250;//default value
9124 }
9125
9126 float GetFilterDamageRatio()
9127 {
9128 return 0;
9129 }
9130
9132 bool HasMuzzle()
9133 {
9134 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9135 return true;
9136
9137 return false;
9138 }
9139
9141 int GetMuzzleID()
9142 {
9143 if (!m_WeaponTypeToID)
9144 m_WeaponTypeToID = new map<string, int>;
9145
9146 if (m_WeaponTypeToID.Contains(GetType()))
9147 {
9148 return m_WeaponTypeToID.Get(GetType());
9149 }
9150 else
9151 {
9152 // Register new weapon ID
9154 }
9155
9157 }
9158
9165 {
9166 return -1;
9167 }
9168
9169
9170
9171 // -------------------------------------------------------------------------
9172 void ~ItemBase()
9173 {
9174 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
9175 {
9176 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9177 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9178
9179 if (r_index >= 0)
9180 {
9181 InventoryLocation r_il = new InventoryLocation;
9182 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9183
9184 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9185 int r_type = r_il.GetType();
9186 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9187 {
9188 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9189 }
9190 else if (r_type == InventoryLocationType.ATTACHMENT)
9191 {
9192 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9193 }
9194
9195 }
9196
9197 player.GetHumanInventory().ClearUserReservedLocation(this);
9198 }
9199
9200 if (m_LockingSound)
9201 SEffectManager.DestroyEffect(m_LockingSound);
9202 }
9203
9204
9205
9206 // -------------------------------------------------------------------------
9207 static int GetDebugActionsMask()
9208 {
9209 return ItemBase.m_DebugActionsMask;
9210 }
9211
9212 static bool HasDebugActionsMask(int mask)
9213 {
9214 return ItemBase.m_DebugActionsMask & mask;
9215 }
9216
9217 static void SetDebugActionsMask(int mask)
9218 {
9219 ItemBase.m_DebugActionsMask = mask;
9220 }
9221
9222 static void AddDebugActionsMask(int mask)
9223 {
9224 ItemBase.m_DebugActionsMask |= mask;
9225 }
9226
9227 static void RemoveDebugActionsMask(int mask)
9228 {
9229 ItemBase.m_DebugActionsMask &= ~mask;
9230 }
9231
9232 static void ToggleDebugActionsMask(int mask)
9233 {
9234 if (HasDebugActionsMask(mask))
9235 {
9237 }
9238 else
9239 {
9240 AddDebugActionsMask(mask);
9241 }
9242 }
9243
9244 // -------------------------------------------------------------------------
9245 void SetCEBasedQuantity()
9246 {
9247 if (GetEconomyProfile())
9248 {
9249 float q_max = GetEconomyProfile().GetQuantityMax();
9250 if (q_max > 0)
9251 {
9252 float q_min = GetEconomyProfile().GetQuantityMin();
9253 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9254
9255 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9256 {
9257 ComponentEnergyManager comp = GetCompEM();
9258 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
9259 {
9260 comp.SetEnergy0To1(quantity_randomized);
9261 }
9262 }
9263 else if (HasQuantity())
9264 {
9265 SetQuantityNormalized(quantity_randomized, false);
9266 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9267 }
9268
9269 }
9270 }
9271 }
9272
9274 void LockToParent()
9275 {
9276 EntityAI parent = GetHierarchyParent();
9277
9278 if (parent)
9279 {
9280 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9281 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9282 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9283 }
9284 }
9285
9287 void UnlockFromParent()
9288 {
9289 EntityAI parent = GetHierarchyParent();
9290
9291 if (parent)
9292 {
9293 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9294 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9295 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9296 }
9297 }
9298
9299 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9300 {
9301 /*
9302 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9303 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9304 */
9305 ItemBase item2 = ItemBase.Cast(entity2);
9306
9307 if (g_Game.IsClient())
9308 {
9309 if (ScriptInputUserData.CanStoreInputUserData())
9310 {
9311 ScriptInputUserData ctx = new ScriptInputUserData;
9313 ctx.Write(-1);
9314 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9315 ctx.Write(i1);
9316 ctx.Write(item2);
9317 ctx.Write(use_stack_max);
9318 ctx.Write(-1);
9319 ctx.Send();
9320
9321 if (IsCombineAll(item2, use_stack_max))
9322 {
9323 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9324 }
9325 }
9326 }
9327 else if (!g_Game.IsMultiplayer())
9328 {
9329 CombineItems(item2, use_stack_max);
9330 }
9331 }
9332
9333 bool IsLiquidPresent()
9334 {
9335 return (GetLiquidType() != 0 && HasQuantity());
9336 }
9337
9338 bool IsLiquidContainer()
9339 {
9340 return m_LiquidContainerMask != 0;
9341 }
9342
9344 {
9345 return m_LiquidContainerMask;
9346 }
9347
9348 bool IsBloodContainer()
9349 {
9350 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9351 return false;
9352 }
9353
9354 bool IsNVG()
9355 {
9356 return false;
9357 }
9358
9361 bool IsExplosive()
9362 {
9363 return false;
9364 }
9365
9367 {
9368 return "";
9369 }
9370
9372
9373 bool IsLightSource()
9374 {
9375 return false;
9376 }
9377
9379 {
9380 return true;
9381 }
9382
9383 //--- ACTION CONDITIONS
9384 //direction
9385 bool IsFacingPlayer(PlayerBase player, string selection)
9386 {
9387 return true;
9388 }
9389
9390 bool IsPlayerInside(PlayerBase player, string selection)
9391 {
9392 return true;
9393 }
9394
9395 override bool CanObstruct()
9396 {
9397 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9398 return !player || !IsPlayerInside(player, "");
9399 }
9400
9401 override bool IsBeingPlaced()
9402 {
9403 return m_IsBeingPlaced;
9404 }
9405
9406 void SetIsBeingPlaced(bool is_being_placed)
9407 {
9408 m_IsBeingPlaced = is_being_placed;
9409 if (!is_being_placed)
9411 SetSynchDirty();
9412 }
9413
9414 //server-side
9415 void OnEndPlacement() {}
9416
9417 override bool IsHologram()
9418 {
9419 return m_IsHologram;
9420 }
9421
9422 bool CanBeDigged()
9423 {
9424 return m_CanBeDigged;
9425 }
9426
9428 {
9429 return 1;
9430 }
9431
9432 bool CanMakeGardenplot()
9433 {
9434 return false;
9435 }
9436
9437 void SetIsHologram(bool is_hologram)
9438 {
9439 m_IsHologram = is_hologram;
9440 SetSynchDirty();
9441 }
9442 /*
9443 protected float GetNutritionalEnergy()
9444 {
9445 Edible_Base edible = Edible_Base.Cast(this);
9446 return edible.GetFoodEnergy();
9447 }
9448
9449 protected float GetNutritionalWaterContent()
9450 {
9451 Edible_Base edible = Edible_Base.Cast(this);
9452 return edible.GetFoodWater();
9453 }
9454
9455 protected float GetNutritionalIndex()
9456 {
9457 Edible_Base edible = Edible_Base.Cast(this);
9458 return edible.GetFoodNutritionalIndex();
9459 }
9460
9461 protected float GetNutritionalFullnessIndex()
9462 {
9463 Edible_Base edible = Edible_Base.Cast(this);
9464 return edible.GetFoodTotalVolume();
9465 }
9466
9467 protected float GetNutritionalToxicity()
9468 {
9469 Edible_Base edible = Edible_Base.Cast(this);
9470 return edible.GetFoodToxicity();
9471
9472 }
9473 */
9474
9475
9476 // -------------------------------------------------------------------------
9477 override void OnMovedInsideCargo(EntityAI container)
9478 {
9479 super.OnMovedInsideCargo(container);
9480
9481 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9482 }
9483
9484 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9485 {
9486 super.EEItemLocationChanged(oldLoc, newLoc);
9487
9488 PlayerBase newPlayer = null;
9489 PlayerBase oldPlayer = null;
9490
9491 if (newLoc.GetParent())
9492 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9493
9494 if (oldLoc.GetParent())
9495 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9496
9497 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9498 {
9499 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9500
9501 if (rIndex >= 0)
9502 {
9503 InventoryLocation rIl = new InventoryLocation;
9504 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9505
9506 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9507 int rType = rIl.GetType();
9508 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9509 {
9510 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9511 }
9512 else if (rType == InventoryLocationType.ATTACHMENT)
9513 {
9514 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9515 }
9516
9517 }
9518 }
9519
9520 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9521 {
9522 if (newPlayer)
9523 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9524
9525 if (newPlayer == oldPlayer)
9526 {
9527 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9528 {
9529 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9530 {
9531 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9532 {
9533 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9534 }
9535 }
9536 else
9537 {
9538 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9539 }
9540 }
9541
9542 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9543 {
9544 int type = oldLoc.GetType();
9545 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9546 {
9547 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9548 }
9549 else if (type == InventoryLocationType.ATTACHMENT)
9550 {
9551 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9552 }
9553 }
9554 if (!m_OldLocation)
9555 {
9556 m_OldLocation = new InventoryLocation;
9557 }
9558 m_OldLocation.Copy(oldLoc);
9559 }
9560 else
9561 {
9562 if (m_OldLocation)
9563 {
9564 m_OldLocation.Reset();
9565 }
9566 }
9567
9568 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9569 }
9570 else
9571 {
9572 if (newPlayer)
9573 {
9574 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9575 if (resIndex >= 0)
9576 {
9577 InventoryLocation il = new InventoryLocation;
9578 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9579 ItemBase it = ItemBase.Cast(il.GetItem());
9580 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9581 int rel_type = il.GetType();
9582 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9583 {
9584 il.GetParent().GetOnReleaseLock().Invoke(it);
9585 }
9586 else if (rel_type == InventoryLocationType.ATTACHMENT)
9587 {
9588 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9589 }
9590 //it.GetOnReleaseLock().Invoke(it);
9591 }
9592 }
9593 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9594 {
9595 //ThrowPhysically(oldPlayer, vector.Zero);
9596 m_ThrowItemOnDrop = false;
9597 }
9598
9599 if (m_OldLocation)
9600 {
9601 m_OldLocation.Reset();
9602 }
9603 }
9604
9605 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9606 {
9607 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9608 }
9609
9610 if (newLoc.GetType() == InventoryLocationType.TEMP)
9611 {
9612 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9613 }
9614 }
9615
9616 override void EOnContact(IEntity other, Contact extra)
9617 {
9619 {
9620 int liquidType = -1;
9621 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9622 if (impactSpeed > 0.0)
9623 {
9624 m_ImpactSpeed = impactSpeed;
9625 #ifndef SERVER
9626 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9627 #else
9628 m_WantPlayImpactSound = true;
9629 SetSynchDirty();
9630 #endif
9631 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9632 }
9633 }
9634
9635 #ifdef SERVER
9636 if (GetCompEM() && GetCompEM().IsPlugged())
9637 {
9638 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9639 GetCompEM().UnplugThis();
9640 }
9641 #endif
9642 }
9643
9644 void RefreshPhysics();
9645
9646 override void OnCreatePhysics()
9647 {
9649 }
9650
9651 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9652 {
9653
9654 }
9655 // -------------------------------------------------------------------------
9656 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9657 {
9658 super.OnItemLocationChanged(old_owner, new_owner);
9659
9660 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9661 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9662
9663 if (!relatedPlayer && playerNew)
9664 relatedPlayer = playerNew;
9665
9666 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9667 {
9668 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9669 if (actionMgr)
9670 {
9671 ActionBase currentAction = actionMgr.GetRunningAction();
9672 if (currentAction)
9673 currentAction.OnItemLocationChanged(this);
9674 }
9675 }
9676
9677 Man ownerPlayerOld = null;
9678 Man ownerPlayerNew = null;
9679
9680 if (old_owner)
9681 {
9682 if (old_owner.IsMan())
9683 {
9684 ownerPlayerOld = Man.Cast(old_owner);
9685 }
9686 else
9687 {
9688 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9689 }
9690 }
9691 else
9692 {
9693 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9694 {
9695 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9696
9697 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9698 {
9699 GetCompEM().UnplugThis();
9700 }
9701 }
9702 }
9703
9704 if (new_owner)
9705 {
9706 if (new_owner.IsMan())
9707 {
9708 ownerPlayerNew = Man.Cast(new_owner);
9709 }
9710 else
9711 {
9712 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9713 }
9714 }
9715
9716 if (ownerPlayerOld != ownerPlayerNew)
9717 {
9718 if (ownerPlayerOld)
9719 {
9720 array<EntityAI> subItemsExit = new array<EntityAI>;
9721 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9722 for (int i = 0; i < subItemsExit.Count(); i++)
9723 {
9724 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9725 itemExit.OnInventoryExit(ownerPlayerOld);
9726 }
9727 }
9728
9729 if (ownerPlayerNew)
9730 {
9731 array<EntityAI> subItemsEnter = new array<EntityAI>;
9732 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9733 for (int j = 0; j < subItemsEnter.Count(); j++)
9734 {
9735 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9736 itemEnter.OnInventoryEnter(ownerPlayerNew);
9737 }
9738 }
9739 }
9740 else if (ownerPlayerNew != null)
9741 {
9742 PlayerBase nplayer;
9743 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9744 {
9745 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9746 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9747 for (int k = 0; k < subItemsUpdate.Count(); k++)
9748 {
9749 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9750 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9751 }
9752 }
9753 }
9754
9755 if (old_owner)
9756 old_owner.OnChildItemRemoved(this);
9757 if (new_owner)
9758 new_owner.OnChildItemReceived(this);
9759 }
9760
9761 // -------------------------------------------------------------------------------
9762 override void EEDelete(EntityAI parent)
9763 {
9764 super.EEDelete(parent);
9765 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9766 if (player)
9767 {
9768 OnInventoryExit(player);
9769
9770 if (player.IsAlive())
9771 {
9772 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9773 if (r_index >= 0)
9774 {
9775 InventoryLocation r_il = new InventoryLocation;
9776 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9777
9778 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9779 int r_type = r_il.GetType();
9780 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9781 {
9782 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9783 }
9784 else if (r_type == InventoryLocationType.ATTACHMENT)
9785 {
9786 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9787 }
9788
9789 }
9790
9791 player.RemoveQuickBarEntityShortcut(this);
9792 }
9793 }
9794 }
9795 // -------------------------------------------------------------------------------
9796 override void EEKilled(Object killer)
9797 {
9798 super.EEKilled(killer);
9799
9801 if (killer && killer.IsFireplace() && CanExplodeInFire())
9802 {
9803 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9804 {
9805 if (IsMagazine())
9806 {
9807 if (Magazine.Cast(this).GetAmmoCount() > 0)
9808 {
9809 ExplodeAmmo();
9810 }
9811 }
9812 else
9813 {
9814 Explode(DamageType.EXPLOSION);
9815 }
9816 }
9817 }
9818 }
9819
9820 override void OnWasAttached(EntityAI parent, int slot_id)
9821 {
9822 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9823
9824 super.OnWasAttached(parent, slot_id);
9825
9826 if (HasQuantity())
9827 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9828
9829 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9830 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
9831 }
9832
9833 override void OnWasDetached(EntityAI parent, int slot_id)
9834 {
9835 super.OnWasDetached(parent, slot_id);
9836
9837 if (HasQuantity())
9838 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9839
9840 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9841 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
9842 }
9843
9844 override string ChangeIntoOnAttach(string slot)
9845 {
9846 int idx;
9847 TStringArray inventory_slots = new TStringArray;
9848 TStringArray attach_types = new TStringArray;
9849
9850 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9851 if (inventory_slots.Count() < 1) //is string
9852 {
9853 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9854 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9855 }
9856 else //is array
9857 {
9858 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9859 }
9860
9861 idx = inventory_slots.Find(slot);
9862 if (idx < 0)
9863 return "";
9864
9865 return attach_types.Get(idx);
9866 }
9867
9868 override string ChangeIntoOnDetach()
9869 {
9870 int idx = -1;
9871 string slot;
9872
9873 TStringArray inventory_slots = new TStringArray;
9874 TStringArray detach_types = new TStringArray;
9875
9876 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9877 if (inventory_slots.Count() < 1) //is string
9878 {
9879 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9880 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9881 }
9882 else //is array
9883 {
9884 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9885 if (detach_types.Count() < 1)
9886 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9887 }
9888
9889 for (int i = 0; i < inventory_slots.Count(); i++)
9890 {
9891 slot = inventory_slots.Get(i);
9892 }
9893
9894 if (slot != "")
9895 {
9896 if (detach_types.Count() == 1)
9897 idx = 0;
9898 else
9899 idx = inventory_slots.Find(slot);
9900 }
9901 if (idx < 0)
9902 return "";
9903
9904 return detach_types.Get(idx);
9905 }
9906
9907 void ExplodeAmmo()
9908 {
9909 //timer
9910 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9911
9912 //min/max time
9913 float min_time = 1;
9914 float max_time = 3;
9915 float delay = Math.RandomFloat(min_time, max_time);
9916
9917 explode_timer.Run(delay, this, "DoAmmoExplosion");
9918 }
9919
9920 void DoAmmoExplosion()
9921 {
9922 Magazine magazine = Magazine.Cast(this);
9923 int pop_sounds_count = 6;
9924 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9925
9926 //play sound
9927 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9928 string sound_name = pop_sounds[ sound_idx ];
9929 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9930
9931 //remove ammo count
9932 magazine.ServerAddAmmoCount(-1);
9933
9934 //if condition then repeat -> ExplodeAmmo
9935 float min_temp_to_explode = 100; //min temperature for item to explode
9936
9937 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9938 {
9939 ExplodeAmmo();
9940 }
9941 }
9942
9943 // -------------------------------------------------------------------------------
9944 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9945 {
9946 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9947
9948 const int CHANCE_DAMAGE_CARGO = 4;
9949 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9950 const int CHANCE_DAMAGE_NOTHING = 2;
9951
9952 if (IsClothing() || IsContainer() || IsItemTent())
9953 {
9954 float dmg = damageResult.GetDamage("","Health") * -0.5;
9955 int chances;
9956 int rnd;
9957
9958 if (GetInventory().GetCargo())
9959 {
9960 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9961 rnd = Math.RandomInt(0,chances);
9962
9963 if (rnd < CHANCE_DAMAGE_CARGO)
9964 {
9965 DamageItemInCargo(dmg);
9966 }
9967 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9968 {
9970 }
9971 }
9972 else
9973 {
9974 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9975 rnd = Math.RandomInt(0,chances);
9976
9977 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9978 {
9980 }
9981 }
9982 }
9983 }
9984
9985 bool DamageItemInCargo(float damage)
9986 {
9987 CargoBase cargo = GetInventory().GetCargo();
9988 if (cargo)
9989 {
9990 int item_count = cargo.GetItemCount();
9991 if (item_count > 0)
9992 {
9993 int random_pick = Math.RandomInt(0, item_count);
9994 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9995 if (!item.IsExplosive())
9996 {
9997 item.AddHealth("","",damage);
9998 return true;
9999 }
10000 }
10001 }
10002 return false;
10003 }
10004
10005 bool DamageItemAttachments(float damage)
10006 {
10007 GameInventory inventory = GetInventory();
10008 int attachment_count = inventory.AttachmentCount();
10009 if (attachment_count > 0)
10010 {
10011 int random_pick = Math.RandomInt(0, attachment_count);
10012 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
10013 if (!attachment.IsExplosive())
10014 {
10015 attachment.AddHealth("","",damage);
10016 return true;
10017 }
10018 }
10019 return false;
10020 }
10021
10022 override bool IsSplitable()
10023 {
10024 return m_CanThisBeSplit;
10025 }
10026 //----------------
10027 override bool CanBeSplit()
10028 {
10029 if (IsSplitable() && (GetQuantity() > 1))
10030 return GetInventory().CanRemoveEntity();
10031
10032 return false;
10033 }
10034
10035 protected bool ShouldSplitQuantity(float quantity)
10036 {
10037 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10038 if (!IsSplitable())
10039 return false;
10040
10041 // nothing to split?
10042 if (GetQuantity() <= 1)
10043 return false;
10044
10045 // check if we should re-use the item instead of creating a new copy?
10046 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10047 int delta = GetQuantity() - quantity;
10048 if (delta == 0)
10049 return false;
10050
10051 // valid to split
10052 return true;
10053 }
10054
10055 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10056 {
10057 if (g_Game.IsClient())
10058 {
10059 if (ScriptInputUserData.CanStoreInputUserData())
10060 {
10061 ScriptInputUserData ctx = new ScriptInputUserData;
10063 ctx.Write(1);
10064 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10065 ctx.Write(i1);
10066 ctx.Write(destination_entity);
10067 ctx.Write(true);
10068 ctx.Write(slot_id);
10069 ctx.Send();
10070 }
10071 }
10072 else if (!g_Game.IsMultiplayer())
10073 {
10074 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
10075 }
10076 }
10077
10078 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10079 {
10080 float split_quantity_new;
10081 ItemBase new_item;
10082 float quantity = GetQuantity();
10083 float stack_max = GetTargetQuantityMax(slot_id);
10084 InventoryLocation loc = new InventoryLocation;
10085
10086 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10087 {
10088 if (stack_max <= GetQuantity())
10089 split_quantity_new = stack_max;
10090 else
10091 split_quantity_new = GetQuantity();
10092
10093 if (ShouldSplitQuantity(split_quantity_new))
10094 {
10095 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10096 if (new_item)
10097 {
10098 new_item.SetResultOfSplit(true);
10099 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10100 AddQuantity(-split_quantity_new, false, true);
10101 new_item.SetQuantity(split_quantity_new, false, true);
10102 }
10103 }
10104 }
10105 else if (destination_entity && slot_id == -1)
10106 {
10107 if (quantity > stack_max)
10108 split_quantity_new = stack_max;
10109 else
10110 split_quantity_new = quantity;
10111
10112 if (ShouldSplitQuantity(split_quantity_new))
10113 {
10114 GameInventory destinationInventory = destination_entity.GetInventory();
10115 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10116 {
10117 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10118 new_item = ItemBase.Cast(o);
10119 }
10120
10121 if (new_item)
10122 {
10123 new_item.SetResultOfSplit(true);
10124 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10125 AddQuantity(-split_quantity_new, false, true);
10126 new_item.SetQuantity(split_quantity_new, false, true);
10127 }
10128 }
10129 }
10130 else
10131 {
10132 if (stack_max != 0)
10133 {
10134 if (stack_max < GetQuantity())
10135 {
10136 split_quantity_new = GetQuantity() - stack_max;
10137 }
10138
10139 if (split_quantity_new == 0)
10140 {
10141 if (!g_Game.IsMultiplayer())
10142 player.PhysicalPredictiveDropItem(this);
10143 else
10144 player.ServerDropEntity(this);
10145 return;
10146 }
10147
10148 if (ShouldSplitQuantity(split_quantity_new))
10149 {
10150 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10151
10152 if (new_item)
10153 {
10154 new_item.SetResultOfSplit(true);
10155 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10156 SetQuantity(split_quantity_new, false, true);
10157 new_item.SetQuantity(stack_max, false, true);
10158 new_item.PlaceOnSurface();
10159 }
10160 }
10161 }
10162 }
10163 }
10164
10165 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10166 {
10167 float split_quantity_new;
10168 ItemBase new_item;
10169 float quantity = GetQuantity();
10170 float stack_max = GetTargetQuantityMax(slot_id);
10171 InventoryLocation loc = new InventoryLocation;
10172
10173 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10174 {
10175 if (stack_max <= GetQuantity())
10176 split_quantity_new = stack_max;
10177 else
10178 split_quantity_new = GetQuantity();
10179
10180 if (ShouldSplitQuantity(split_quantity_new))
10181 {
10182 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10183 if (new_item)
10184 {
10185 new_item.SetResultOfSplit(true);
10186 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10187 AddQuantity(-split_quantity_new, false, true);
10188 new_item.SetQuantity(split_quantity_new, false, true);
10189 }
10190 }
10191 }
10192 else if (destination_entity && slot_id == -1)
10193 {
10194 if (quantity > stack_max)
10195 split_quantity_new = stack_max;
10196 else
10197 split_quantity_new = quantity;
10198
10199 if (ShouldSplitQuantity(split_quantity_new))
10200 {
10201 GameInventory destinationInventory = destination_entity.GetInventory();
10202 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10203 {
10204 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10205 new_item = ItemBase.Cast(o);
10206 }
10207
10208 if (new_item)
10209 {
10210 new_item.SetResultOfSplit(true);
10211 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10212 AddQuantity(-split_quantity_new, false, true);
10213 new_item.SetQuantity(split_quantity_new, false, true);
10214 }
10215 }
10216 }
10217 else
10218 {
10219 if (stack_max != 0)
10220 {
10221 if (stack_max < GetQuantity())
10222 {
10223 split_quantity_new = GetQuantity() - stack_max;
10224 }
10225
10226 if (ShouldSplitQuantity(split_quantity_new))
10227 {
10228 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10229
10230 if (new_item)
10231 {
10232 new_item.SetResultOfSplit(true);
10233 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10234 SetQuantity(split_quantity_new, false, true);
10235 new_item.SetQuantity(stack_max, false, true);
10236 new_item.PlaceOnSurface();
10237 }
10238 }
10239 }
10240 }
10241 }
10242
10243 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10244 {
10245 if (g_Game.IsClient())
10246 {
10247 if (ScriptInputUserData.CanStoreInputUserData())
10248 {
10249 ScriptInputUserData ctx = new ScriptInputUserData;
10251 ctx.Write(4);
10252 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10253 ctx.Write(thiz);
10254 dst.WriteToContext(ctx);
10255 ctx.Send();
10256 }
10257 }
10258 else if (!g_Game.IsMultiplayer())
10259 {
10261 }
10262 }
10263
10264 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10265 {
10266 if (g_Game.IsClient())
10267 {
10268 if (ScriptInputUserData.CanStoreInputUserData())
10269 {
10270 ScriptInputUserData ctx = new ScriptInputUserData;
10272 ctx.Write(2);
10273 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10274 ctx.Write(dummy);
10275 ctx.Write(destination_entity);
10276 ctx.Write(true);
10277 ctx.Write(idx);
10278 ctx.Write(row);
10279 ctx.Write(col);
10280 ctx.Send();
10281 }
10282 }
10283 else if (!g_Game.IsMultiplayer())
10284 {
10285 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10286 }
10287 }
10288
10289 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10290 {
10292 }
10293
10294 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10295 {
10296 float quantity = GetQuantity();
10297 float split_quantity_new;
10298 ItemBase new_item;
10299 if (dst.IsValid())
10300 {
10301 int slot_id = dst.GetSlot();
10302 float stack_max = GetTargetQuantityMax(slot_id);
10303
10304 if (quantity > stack_max)
10305 split_quantity_new = stack_max;
10306 else
10307 split_quantity_new = quantity;
10308
10309 if (ShouldSplitQuantity(split_quantity_new))
10310 {
10311 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10312
10313 if (new_item)
10314 {
10315 new_item.SetResultOfSplit(true);
10316 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10317 AddQuantity(-split_quantity_new, false, true);
10318 new_item.SetQuantity(split_quantity_new, false, true);
10319 }
10320
10321 return new_item;
10322 }
10323 }
10324
10325 return null;
10326 }
10327
10328 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10329 {
10330 float quantity = GetQuantity();
10331 float split_quantity_new;
10332 ItemBase new_item;
10333 if (destination_entity)
10334 {
10335 float stackable = GetTargetQuantityMax();
10336 if (quantity > stackable)
10337 split_quantity_new = stackable;
10338 else
10339 split_quantity_new = quantity;
10340
10341 if (ShouldSplitQuantity(split_quantity_new))
10342 {
10343 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10344 if (new_item)
10345 {
10346 new_item.SetResultOfSplit(true);
10347 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10348 AddQuantity(-split_quantity_new, false, true);
10349 new_item.SetQuantity(split_quantity_new, false, true);
10350 }
10351 }
10352 }
10353 }
10354
10355 void SplitIntoStackMaxHandsClient(PlayerBase player)
10356 {
10357 if (g_Game.IsClient())
10358 {
10359 if (ScriptInputUserData.CanStoreInputUserData())
10360 {
10361 ScriptInputUserData ctx = new ScriptInputUserData;
10363 ctx.Write(3);
10364 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10365 ctx.Write(i1);
10366 ItemBase destination_entity = this;
10367 ctx.Write(destination_entity);
10368 ctx.Write(true);
10369 ctx.Write(0);
10370 ctx.Send();
10371 }
10372 }
10373 else if (!g_Game.IsMultiplayer())
10374 {
10375 SplitIntoStackMaxHands(player);
10376 }
10377 }
10378
10379 void SplitIntoStackMaxHands(PlayerBase player)
10380 {
10381 float quantity = GetQuantity();
10382 float split_quantity_new;
10383 ref ItemBase new_item;
10384 if (player)
10385 {
10386 float stackable = GetTargetQuantityMax();
10387 if (quantity > stackable)
10388 split_quantity_new = stackable;
10389 else
10390 split_quantity_new = quantity;
10391
10392 if (ShouldSplitQuantity(split_quantity_new))
10393 {
10394 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10395 new_item = ItemBase.Cast(in_hands);
10396 if (new_item)
10397 {
10398 new_item.SetResultOfSplit(true);
10399 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10400 AddQuantity(-split_quantity_new, false, true);
10401 new_item.SetQuantity(split_quantity_new, false, true);
10402 }
10403 }
10404 }
10405 }
10406
10407 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10408 {
10409 float quantity = GetQuantity();
10410 float split_quantity_new = Math.Floor(quantity * 0.5);
10411
10412 if (!ShouldSplitQuantity(split_quantity_new))
10413 return;
10414
10415 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10416
10417 if (new_item)
10418 {
10419 if (new_item.GetQuantityMax() < split_quantity_new)
10420 {
10421 split_quantity_new = new_item.GetQuantityMax();
10422 }
10423
10424 new_item.SetResultOfSplit(true);
10425 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10426
10427 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10428 {
10429 AddQuantity(-1, false, true);
10430 new_item.SetQuantity(1, false, true);
10431 }
10432 else
10433 {
10434 AddQuantity(-split_quantity_new, false, true);
10435 new_item.SetQuantity(split_quantity_new, false, true);
10436 }
10437 }
10438 }
10439
10440 void SplitItem(PlayerBase player)
10441 {
10442 float quantity = GetQuantity();
10443 float split_quantity_new = Math.Floor(quantity / 2);
10444
10445 if (!ShouldSplitQuantity(split_quantity_new))
10446 return;
10447
10448 InventoryLocation invloc = new InventoryLocation;
10449 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10450
10451 ItemBase new_item;
10452 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10453
10454 if (new_item)
10455 {
10456 if (new_item.GetQuantityMax() < split_quantity_new)
10457 {
10458 split_quantity_new = new_item.GetQuantityMax();
10459 }
10460 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10461 {
10462 AddQuantity(-1, false, true);
10463 new_item.SetQuantity(1, false, true);
10464 }
10465 else if (split_quantity_new > 1)
10466 {
10467 AddQuantity(-split_quantity_new, false, true);
10468 new_item.SetQuantity(split_quantity_new, false, true);
10469 }
10470 }
10471 }
10472
10474 void OnQuantityChanged(float delta)
10475 {
10476 SetWeightDirty();
10477 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10478
10479 if (parent)
10480 parent.OnAttachmentQuantityChangedEx(this, delta);
10481
10482 if (IsLiquidContainer())
10483 {
10484 if (GetQuantityNormalized() <= 0.0)
10485 {
10487 }
10488 else if (GetLiquidType() == LIQUID_NONE)
10489 {
10490 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10492 }
10493 }
10494 }
10495
10498 {
10499 // insert code here
10500 }
10501
10503 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10504 {
10506 }
10507
10508 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10509 {
10510 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10511
10512 if (g_Game.IsServer())
10513 {
10514 if (newLevel == GameConstants.STATE_RUINED)
10515 {
10517 EntityAI parent = GetHierarchyParent();
10518 if (parent && parent.IsFireplace())
10519 {
10520 CargoBase cargo = GetInventory().GetCargo();
10521 if (cargo)
10522 {
10523 for (int i = 0; i < cargo.GetItemCount(); ++i)
10524 {
10525 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10526 }
10527 }
10528 }
10529 }
10530
10531 if (IsResultOfSplit())
10532 {
10533 // reset the splitting result flag, return to normal item behavior
10534 SetResultOfSplit(false);
10535 return;
10536 }
10537
10538 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10539 {
10540 SetCleanness(0);//unclean the item upon damage dealt
10541 }
10542 }
10543 }
10544
10545 // just the split? TODO: verify
10546 override void OnRightClick()
10547 {
10548 super.OnRightClick();
10549
10550 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10551 {
10552 if (g_Game.IsClient())
10553 {
10554 if (ScriptInputUserData.CanStoreInputUserData())
10555 {
10556 EntityAI root = GetHierarchyRoot();
10557 Man playerOwner = GetHierarchyRootPlayer();
10558 InventoryLocation dst = new InventoryLocation;
10559
10560 // 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
10561 if (!playerOwner && root && root == this)
10562 {
10564 }
10565 else
10566 {
10567 // 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
10568 GetInventory().GetCurrentInventoryLocation(dst);
10569 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10570 {
10571 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10572 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10573 {
10575 }
10576 else
10577 {
10578 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10579 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10580 this shouldnt cause issues within this scope*/
10581 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10582 {
10584 }
10585 else
10586 {
10587 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10588 }
10589 }
10590 }
10591 }
10592
10593 ScriptInputUserData ctx = new ScriptInputUserData;
10595 ctx.Write(4);
10596 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10597 ctx.Write(thiz);
10598 dst.WriteToContext(ctx);
10599 ctx.Write(true); // dummy
10600 ctx.Send();
10601 }
10602 }
10603 else if (!g_Game.IsMultiplayer())
10604 {
10605 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10606 }
10607 }
10608 }
10609
10610 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10611 {
10612 if (root)
10613 {
10614 vector m4[4];
10615 root.GetTransform(m4);
10616 dst.SetGround(this, m4);
10617 }
10618 else
10619 {
10620 GetInventory().GetCurrentInventoryLocation(dst);
10621 }
10622 }
10623
10624 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10625 {
10626 //TODO: delete check zero quantity check after fix double posts hands fsm events
10627 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10628 return false;
10629
10630 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10631 return false;
10632
10633 //can_this_be_combined = ConfigGetBool("canBeSplit");
10635 return false;
10636
10637
10638 Magazine mag = Magazine.Cast(this);
10639 if (mag)
10640 {
10641 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10642 return false;
10643
10644 if (stack_max_limit)
10645 {
10646 Magazine other_mag = Magazine.Cast(other_item);
10647 if (other_item)
10648 {
10649 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10650 return false;
10651 }
10652
10653 }
10654 }
10655 else
10656 {
10657 //TODO: delete check zero quantity check after fix double posts hands fsm events
10658 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10659 return false;
10660
10661 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10662 return false;
10663 }
10664
10665 PlayerBase player = null;
10666 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10667 {
10668 if (player.GetInventory().HasAttachment(this))
10669 return false;
10670
10671 if (player.IsItemsToDelete())
10672 return false;
10673 }
10674
10675 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10676 return false;
10677
10678 int slotID;
10679 string slotName;
10680 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10681 return false;
10682
10683 return true;
10684 }
10685
10686 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10687 {
10688 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10689 }
10690
10691 bool IsResultOfSplit()
10692 {
10693 return m_IsResultOfSplit;
10694 }
10695
10696 void SetResultOfSplit(bool value)
10697 {
10698 m_IsResultOfSplit = value;
10699 }
10700
10701 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10702 {
10703 return ComputeQuantityUsedEx(other_item, use_stack_max);
10704 }
10705
10706 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10707 {
10708 float other_item_quantity = other_item.GetQuantity();
10709 float this_free_space;
10710
10711 float stack_max = GetQuantityMax();
10712
10713 this_free_space = stack_max - GetQuantity();
10714
10715 if (other_item_quantity > this_free_space)
10716 {
10717 return this_free_space;
10718 }
10719 else
10720 {
10721 return other_item_quantity;
10722 }
10723 }
10724
10725 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10726 {
10727 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10728 }
10729
10730 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10731 {
10732 if (!CanBeCombined(other_item, false))
10733 return;
10734
10735 if (!IsMagazine() && other_item)
10736 {
10737 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10738 if (quantity_used != 0)
10739 {
10740 float hp1 = GetHealth01("","");
10741 float hp2 = other_item.GetHealth01("","");
10742 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10743 hpResult = hpResult / (GetQuantity() + quantity_used);
10744
10745 hpResult *= GetMaxHealth();
10746 Math.Round(hpResult);
10747 SetHealth("", "Health", hpResult);
10748
10749 AddQuantity(quantity_used);
10750 other_item.AddQuantity(-quantity_used);
10751 }
10752 }
10753 OnCombine(other_item);
10754 }
10755
10756 void OnCombine(ItemBase other_item)
10757 {
10758 #ifdef SERVER
10759 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10760 GetHierarchyParent().IncreaseLifetimeUp();
10761 #endif
10762 };
10763
10764 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10765 {
10766 PlayerBase p = PlayerBase.Cast(player);
10767
10768 array<int> recipesIds = p.m_Recipes;
10769 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10770 if (moduleRecipesManager)
10771 {
10772 EntityAI itemInHands = player.GetEntityInHands();
10773 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10774 }
10775
10776 for (int i = 0;i < recipesIds.Count(); i++)
10777 {
10778 int key = recipesIds.Get(i);
10779 string recipeName = moduleRecipesManager.GetRecipeName(key);
10780 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10781 }
10782 }
10783
10784 // -------------------------------------------------------------------------
10785 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10786 {
10787 super.GetDebugActions(outputList);
10788
10789 //quantity
10790 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10791 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10792 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10793 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10794 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10795
10796 //health
10797 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10798 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10799 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10800 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10801 //temperature
10802 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10803 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10804 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10805 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10806
10807 //wet
10808 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10809 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10810 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10811
10812 //liquidtype
10813 if (IsLiquidContainer())
10814 {
10815 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10816 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10817 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10818 }
10819
10820 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10821 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10822
10823 // watch
10824 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10825 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10826 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10827
10828 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10829
10830 InventoryLocation loc = new InventoryLocation();
10831 GetInventory().GetCurrentInventoryLocation(loc);
10832 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10833 {
10834 if (Gizmo_IsSupported())
10835 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10836 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10837 }
10838
10839 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10840 }
10841
10842 // -------------------------------------------------------------------------
10843 // -------------------------------------------------------------------------
10844 // -------------------------------------------------------------------------
10845 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10846 {
10847 super.OnAction(action_id, player, ctx);
10848
10849 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
10850 {
10851 switch (action_id)
10852 {
10853 case EActions.GIZMO_OBJECT:
10854 if (GetGizmoApi())
10855 GetGizmoApi().SelectObject(this);
10856 return true;
10857 case EActions.GIZMO_PHYSICS:
10858 if (GetGizmoApi())
10859 GetGizmoApi().SelectPhysics(GetPhysics());
10860 return true;
10861 }
10862 }
10863
10864 if (g_Game.IsServer())
10865 {
10866 switch (action_id)
10867 {
10868 case EActions.DELETE:
10869 Delete();
10870 return true;
10871 }
10872 }
10873
10874 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10875 {
10876 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10877 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10878 PlayerBase p = PlayerBase.Cast(player);
10879 if (EActions.RECIPES_RANGE_START < 1000)
10880 {
10881 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10882 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10883 }
10884 }
10885 #ifndef SERVER
10886 else if (action_id == EActions.WATCH_PLAYER)
10887 {
10888 PluginDeveloper.SetDeveloperItemClientEx(player);
10889 }
10890 #endif
10891 if (g_Game.IsServer())
10892 {
10893 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10894 {
10895 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10896 OnDebugButtonPressServer(id + 1);
10897 }
10898
10899 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10900 {
10901 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10902 InsertAgent(agent_id,100);
10903 }
10904
10905 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10906 {
10907 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10908 RemoveAgent(agent_id2);
10909 }
10910
10911 else if (action_id == EActions.ADD_QUANTITY)
10912 {
10913 if (IsMagazine())
10914 {
10915 Magazine mag = Magazine.Cast(this);
10916 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10917 }
10918 else
10919 {
10920 AddQuantity(GetQuantityMax() * 0.2);
10921 }
10922
10923 if (m_EM)
10924 {
10925 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10926 }
10927 //PrintVariables();
10928 }
10929
10930 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10931 {
10932 if (IsMagazine())
10933 {
10934 Magazine mag2 = Magazine.Cast(this);
10935 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10936 }
10937 else
10938 {
10939 AddQuantity(- GetQuantityMax() * 0.2);
10940 }
10941 if (m_EM)
10942 {
10943 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10944 }
10945 //PrintVariables();
10946 }
10947
10948 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10949 {
10950 SetQuantity(0);
10951
10952 if (m_EM)
10953 {
10954 m_EM.SetEnergy(0);
10955 }
10956 }
10957
10958 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10959 {
10961
10962 if (m_EM)
10963 {
10964 m_EM.SetEnergy(m_EM.GetEnergyMax());
10965 }
10966 }
10967
10968 else if (action_id == EActions.ADD_HEALTH)
10969 {
10970 AddHealth("","",GetMaxHealth("","Health")/5);
10971 }
10972 else if (action_id == EActions.REMOVE_HEALTH)
10973 {
10974 AddHealth("","",-GetMaxHealth("","Health")/5);
10975 }
10976 else if (action_id == EActions.DESTROY_HEALTH)
10977 {
10978 SetHealth01("","",0);
10979 }
10980 else if (action_id == EActions.WATCH_ITEM)
10981 {
10983 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10984 #ifdef DEVELOPER
10985 SetDebugDeveloper_item(this);
10986 #endif
10987 }
10988
10989 else if (action_id == EActions.ADD_TEMPERATURE)
10990 {
10991 AddTemperature(20);
10992 //PrintVariables();
10993 }
10994
10995 else if (action_id == EActions.REMOVE_TEMPERATURE)
10996 {
10997 AddTemperature(-20);
10998 //PrintVariables();
10999 }
11000
11001 else if (action_id == EActions.FLIP_FROZEN)
11002 {
11003 SetFrozen(!GetIsFrozen());
11004 //PrintVariables();
11005 }
11006
11007 else if (action_id == EActions.ADD_WETNESS)
11008 {
11009 AddWet(GetWetMax()/5);
11010 //PrintVariables();
11011 }
11012
11013 else if (action_id == EActions.REMOVE_WETNESS)
11014 {
11015 AddWet(-GetWetMax()/5);
11016 //PrintVariables();
11017 }
11018
11019 else if (action_id == EActions.LIQUIDTYPE_UP)
11020 {
11021 int curr_type = GetLiquidType();
11022 SetLiquidType(curr_type * 2);
11023 //AddWet(1);
11024 //PrintVariables();
11025 }
11026
11027 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11028 {
11029 int curr_type2 = GetLiquidType();
11030 SetLiquidType(curr_type2 / 2);
11031 }
11032
11033 else if (action_id == EActions.MAKE_SPECIAL)
11034 {
11035 auto debugParams = DebugSpawnParams.WithPlayer(player);
11036 OnDebugSpawnEx(debugParams);
11037 }
11038
11039 }
11040
11041
11042 return false;
11043 }
11044
11045 // -------------------------------------------------------------------------
11046
11047
11050 void OnActivatedByTripWire();
11051
11053 void OnActivatedByItem(notnull ItemBase item);
11054
11055 //----------------------------------------------------------------
11056 //returns true if item is able to explode when put in fire
11057 bool CanExplodeInFire()
11058 {
11059 return false;
11060 }
11061
11062 //----------------------------------------------------------------
11063 bool CanEat()
11064 {
11065 return true;
11066 }
11067
11068 //----------------------------------------------------------------
11069 override bool IsIgnoredByConstruction()
11070 {
11071 return true;
11072 }
11073
11074 //----------------------------------------------------------------
11075 //has FoodStages in config?
11076 bool HasFoodStage()
11077 {
11078 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11079 return g_Game.ConfigIsExisting(config_path);
11080 }
11081
11083 FoodStage GetFoodStage()
11084 {
11085 return null;
11086 }
11087
11088 bool CanBeCooked()
11089 {
11090 return false;
11091 }
11092
11093 bool CanBeCookedOnStick()
11094 {
11095 return false;
11096 }
11097
11099 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11101
11102 //----------------------------------------------------------------
11103 bool CanRepair(ItemBase item_repair_kit)
11104 {
11105 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11106 return module_repairing.CanRepair(this, item_repair_kit);
11107 }
11108
11109 //----------------------------------------------------------------
11110 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11111 {
11112 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11113 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11114 }
11115
11116 //----------------------------------------------------------------
11117 int GetItemSize()
11118 {
11119 /*
11120 vector v_size = this.ConfigGetVector("itemSize");
11121 int v_size_x = v_size[0];
11122 int v_size_y = v_size[1];
11123 int size = v_size_x * v_size_y;
11124 return size;
11125 */
11126
11127 return 1;
11128 }
11129
11130 //----------------------------------------------------------------
11131 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11132 bool CanBeMovedOverride()
11133 {
11134 return m_CanBeMovedOverride;
11135 }
11136
11137 //----------------------------------------------------------------
11138 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11139 void SetCanBeMovedOverride(bool setting)
11140 {
11141 m_CanBeMovedOverride = setting;
11142 }
11143
11144 //----------------------------------------------------------------
11152 void MessageToOwnerStatus(string text)
11153 {
11154 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11155
11156 if (player)
11157 {
11158 player.MessageStatus(text);
11159 }
11160 }
11161
11162 //----------------------------------------------------------------
11170 void MessageToOwnerAction(string text)
11171 {
11172 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11173
11174 if (player)
11175 {
11176 player.MessageAction(text);
11177 }
11178 }
11179
11180 //----------------------------------------------------------------
11188 void MessageToOwnerFriendly(string text)
11189 {
11190 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11191
11192 if (player)
11193 {
11194 player.MessageFriendly(text);
11195 }
11196 }
11197
11198 //----------------------------------------------------------------
11206 void MessageToOwnerImportant(string text)
11207 {
11208 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11209
11210 if (player)
11211 {
11212 player.MessageImportant(text);
11213 }
11214 }
11215
11216 override bool IsItemBase()
11217 {
11218 return true;
11219 }
11220
11221 // Checks if item is of questioned kind
11222 override bool KindOf(string tag)
11223 {
11224 bool found = false;
11225 string item_name = this.GetType();
11226 ref TStringArray item_tag_array = new TStringArray;
11227 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11228
11229 int array_size = item_tag_array.Count();
11230 for (int i = 0; i < array_size; i++)
11231 {
11232 if (item_tag_array.Get(i) == tag)
11233 {
11234 found = true;
11235 break;
11236 }
11237 }
11238 return found;
11239 }
11240
11241
11242 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11243 {
11244 //Debug.Log("OnRPC called");
11245 super.OnRPC(sender, rpc_type,ctx);
11246
11247 //Play soundset for attachment locking (ActionLockAttachment.c)
11248 switch (rpc_type)
11249 {
11250 #ifndef SERVER
11251 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11252 Param2<bool, string> p = new Param2<bool, string>(false, "");
11253
11254 if (!ctx.Read(p))
11255 return;
11256
11257 bool play = p.param1;
11258 string soundSet = p.param2;
11259
11260 if (play)
11261 {
11262 if (m_LockingSound)
11263 {
11265 {
11266 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11267 }
11268 }
11269 else
11270 {
11271 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11272 }
11273 }
11274 else
11275 {
11276 SEffectManager.DestroyEffect(m_LockingSound);
11277 }
11278
11279 break;
11280 #endif
11281
11282 }
11283
11284 if (GetWrittenNoteData())
11285 {
11286 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11287 }
11288 }
11289
11290 //-----------------------------
11291 // VARIABLE MANIPULATION SYSTEM
11292 //-----------------------------
11293 int NameToID(string name)
11294 {
11295 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11296 return plugin.GetID(name);
11297 }
11298
11299 string IDToName(int id)
11300 {
11301 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11302 return plugin.GetName(id);
11303 }
11304
11306 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11307 {
11308 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11309 //read the flags
11310 int varFlags;
11311 if (!ctx.Read(varFlags))
11312 return;
11313
11314 if (varFlags & ItemVariableFlags.FLOAT)
11315 {
11316 ReadVarsFromCTX(ctx);
11317 }
11318 }
11319
11320 override void SerializeNumericalVars(array<float> floats_out)
11321 {
11322 //some variables handled on EntityAI level already!
11323 super.SerializeNumericalVars(floats_out);
11324
11325 // the order of serialization must be the same as the order of de-serialization
11326 //--------------------------------------------
11327 if (IsVariableSet(VARIABLE_QUANTITY))
11328 {
11329 floats_out.Insert(m_VarQuantity);
11330 }
11331 //--------------------------------------------
11332 if (IsVariableSet(VARIABLE_WET))
11333 {
11334 floats_out.Insert(m_VarWet);
11335 }
11336 //--------------------------------------------
11337 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11338 {
11339 floats_out.Insert(m_VarLiquidType);
11340 }
11341 //--------------------------------------------
11342 if (IsVariableSet(VARIABLE_COLOR))
11343 {
11344 floats_out.Insert(m_ColorComponentR);
11345 floats_out.Insert(m_ColorComponentG);
11346 floats_out.Insert(m_ColorComponentB);
11347 floats_out.Insert(m_ColorComponentA);
11348 }
11349 //--------------------------------------------
11350 if (IsVariableSet(VARIABLE_CLEANNESS))
11351 {
11352 floats_out.Insert(m_Cleanness);
11353 }
11354 }
11355
11356 override void DeSerializeNumericalVars(array<float> floats)
11357 {
11358 //some variables handled on EntityAI level already!
11359 super.DeSerializeNumericalVars(floats);
11360
11361 // the order of serialization must be the same as the order of de-serialization
11362 int index = 0;
11363 int mask = Math.Round(floats.Get(index));
11364
11365 index++;
11366 //--------------------------------------------
11367 if (mask & VARIABLE_QUANTITY)
11368 {
11369 if (m_IsStoreLoad)
11370 {
11371 SetStoreLoadedQuantity(floats.Get(index));
11372 }
11373 else
11374 {
11375 float quantity = floats.Get(index);
11376 SetQuantity(quantity, true, false, false, false);
11377 }
11378 index++;
11379 }
11380 //--------------------------------------------
11381 if (mask & VARIABLE_WET)
11382 {
11383 float wet = floats.Get(index);
11384 SetWet(wet);
11385 index++;
11386 }
11387 //--------------------------------------------
11388 if (mask & VARIABLE_LIQUIDTYPE)
11389 {
11390 int liquidtype = Math.Round(floats.Get(index));
11391 SetLiquidType(liquidtype);
11392 index++;
11393 }
11394 //--------------------------------------------
11395 if (mask & VARIABLE_COLOR)
11396 {
11397 m_ColorComponentR = Math.Round(floats.Get(index));
11398 index++;
11399 m_ColorComponentG = Math.Round(floats.Get(index));
11400 index++;
11401 m_ColorComponentB = Math.Round(floats.Get(index));
11402 index++;
11403 m_ColorComponentA = Math.Round(floats.Get(index));
11404 index++;
11405 }
11406 //--------------------------------------------
11407 if (mask & VARIABLE_CLEANNESS)
11408 {
11409 int cleanness = Math.Round(floats.Get(index));
11410 SetCleanness(cleanness);
11411 index++;
11412 }
11413 }
11414
11415 override void WriteVarsToCTX(ParamsWriteContext ctx)
11416 {
11417 super.WriteVarsToCTX(ctx);
11418
11419 //--------------------------------------------
11420 if (IsVariableSet(VARIABLE_QUANTITY))
11421 {
11422 ctx.Write(GetQuantity());
11423 }
11424 //--------------------------------------------
11425 if (IsVariableSet(VARIABLE_WET))
11426 {
11427 ctx.Write(GetWet());
11428 }
11429 //--------------------------------------------
11430 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11431 {
11432 ctx.Write(GetLiquidType());
11433 }
11434 //--------------------------------------------
11435 if (IsVariableSet(VARIABLE_COLOR))
11436 {
11437 int r,g,b,a;
11438 GetColor(r,g,b,a);
11439 ctx.Write(r);
11440 ctx.Write(g);
11441 ctx.Write(b);
11442 ctx.Write(a);
11443 }
11444 //--------------------------------------------
11445 if (IsVariableSet(VARIABLE_CLEANNESS))
11446 {
11447 ctx.Write(GetCleanness());
11448 }
11449 }
11450
11451 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11452 {
11453 if (!super.ReadVarsFromCTX(ctx,version))
11454 return false;
11455
11456 int intValue;
11457 float value;
11458
11459 if (version < 140)
11460 {
11461 if (!ctx.Read(intValue))
11462 return false;
11463
11464 m_VariablesMask = intValue;
11465 }
11466
11467 if (m_VariablesMask & VARIABLE_QUANTITY)
11468 {
11469 if (!ctx.Read(value))
11470 return false;
11471
11472 if (IsStoreLoad())
11473 {
11475 }
11476 else
11477 {
11478 SetQuantity(value, true, false, false, false);
11479 }
11480 }
11481 //--------------------------------------------
11482 if (version < 140)
11483 {
11484 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11485 {
11486 if (!ctx.Read(value))
11487 return false;
11488 SetTemperatureDirect(value);
11489 }
11490 }
11491 //--------------------------------------------
11492 if (m_VariablesMask & VARIABLE_WET)
11493 {
11494 if (!ctx.Read(value))
11495 return false;
11496 SetWet(value);
11497 }
11498 //--------------------------------------------
11499 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11500 {
11501 if (!ctx.Read(intValue))
11502 return false;
11503 SetLiquidType(intValue);
11504 }
11505 //--------------------------------------------
11506 if (m_VariablesMask & VARIABLE_COLOR)
11507 {
11508 int r,g,b,a;
11509 if (!ctx.Read(r))
11510 return false;
11511 if (!ctx.Read(g))
11512 return false;
11513 if (!ctx.Read(b))
11514 return false;
11515 if (!ctx.Read(a))
11516 return false;
11517
11518 SetColor(r,g,b,a);
11519 }
11520 //--------------------------------------------
11521 if (m_VariablesMask & VARIABLE_CLEANNESS)
11522 {
11523 if (!ctx.Read(intValue))
11524 return false;
11525 SetCleanness(intValue);
11526 }
11527 //--------------------------------------------
11528 if (version >= 138 && version < 140)
11529 {
11530 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11531 {
11532 if (!ctx.Read(intValue))
11533 return false;
11534 SetFrozen(intValue);
11535 }
11536 }
11537
11538 return true;
11539 }
11540
11541 //----------------------------------------------------------------
11542 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11543 {
11544 m_IsStoreLoad = true;
11546 {
11547 m_FixDamageSystemInit = true;
11548 }
11549
11550 if (!super.OnStoreLoad(ctx, version))
11551 {
11552 m_IsStoreLoad = false;
11553 return false;
11554 }
11555
11556 if (version >= 114)
11557 {
11558 bool hasQuickBarIndexSaved;
11559
11560 if (!ctx.Read(hasQuickBarIndexSaved))
11561 {
11562 m_IsStoreLoad = false;
11563 return false;
11564 }
11565
11566 if (hasQuickBarIndexSaved)
11567 {
11568 int itmQBIndex;
11569
11570 //Load quickbar item bind
11571 if (!ctx.Read(itmQBIndex))
11572 {
11573 m_IsStoreLoad = false;
11574 return false;
11575 }
11576
11577 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11578 if (itmQBIndex != -1 && parentPlayer)
11579 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11580 }
11581 }
11582 else
11583 {
11584 // Backup of how it used to be
11585 PlayerBase player;
11586 int itemQBIndex;
11587 if (version == int.MAX)
11588 {
11589 if (!ctx.Read(itemQBIndex))
11590 {
11591 m_IsStoreLoad = false;
11592 return false;
11593 }
11594 }
11595 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11596 {
11597 //Load quickbar item bind
11598 if (!ctx.Read(itemQBIndex))
11599 {
11600 m_IsStoreLoad = false;
11601 return false;
11602 }
11603 if (itemQBIndex != -1 && player)
11604 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11605 }
11606 }
11607
11608 if (version < 140)
11609 {
11610 // variable management system
11611 if (!LoadVariables(ctx, version))
11612 {
11613 m_IsStoreLoad = false;
11614 return false;
11615 }
11616 }
11617
11618 //agent trasmission system
11619 if (!LoadAgents(ctx, version))
11620 {
11621 m_IsStoreLoad = false;
11622 return false;
11623 }
11624 if (version >= 132)
11625 {
11626 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11627 if (raib)
11628 {
11629 if (!raib.OnStoreLoad(ctx,version))
11630 {
11631 m_IsStoreLoad = false;
11632 return false;
11633 }
11634 }
11635 }
11636
11637 m_IsStoreLoad = false;
11638 return true;
11639 }
11640
11641 //----------------------------------------------------------------
11642
11643 override void OnStoreSave(ParamsWriteContext ctx)
11644 {
11645 super.OnStoreSave(ctx);
11646
11647 PlayerBase player;
11648 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11649 {
11650 ctx.Write(true); // Keep track of if we should actually read this in or not
11651 //Save quickbar item bind
11652 int itemQBIndex = -1;
11653 itemQBIndex = player.FindQuickBarEntityIndex(this);
11654 ctx.Write(itemQBIndex);
11655 }
11656 else
11657 {
11658 ctx.Write(false); // Keep track of if we should actually read this in or not
11659 }
11660
11661 SaveAgents(ctx);//agent trasmission system
11662
11663 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11664 if (raib)
11665 {
11666 raib.OnStoreSave(ctx);
11667 }
11668 }
11669 //----------------------------------------------------------------
11670
11671 override void AfterStoreLoad()
11672 {
11673 super.AfterStoreLoad();
11674
11676 {
11678 }
11679
11680 if (GetStoreLoadedQuantity() != float.LOWEST)
11681 {
11683 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
11684 }
11685 }
11686
11687 override void EEOnAfterLoad()
11688 {
11689 super.EEOnAfterLoad();
11690
11692 {
11693 m_FixDamageSystemInit = false;
11694 }
11695
11698 }
11699
11700 bool CanBeDisinfected()
11701 {
11702 return false;
11703 }
11704
11705
11706 //----------------------------------------------------------------
11707 override void OnVariablesSynchronized()
11708 {
11709 if (m_Initialized)
11710 {
11711 #ifdef PLATFORM_CONSOLE
11712 //bruteforce it is
11713 if (IsSplitable())
11714 {
11715 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11716 if (menu)
11717 {
11718 menu.Refresh();
11719 }
11720 }
11721 #endif
11722 }
11723
11725 {
11726 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11727 m_WantPlayImpactSound = false;
11728 }
11729
11731 {
11732 SetWeightDirty();
11734 }
11735 if (m_VarWet != m_VarWetPrev)
11736 {
11739 }
11740
11741 if (m_SoundSyncPlay != 0)
11742 {
11745
11746 m_SoundSyncPlay = 0;
11747 m_SoundSyncSlotID = -1;
11748 }
11749 if (m_SoundSyncStop != 0)
11750 {
11752 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11753 m_SoundSyncStop = 0;
11754 }
11755
11756 super.OnVariablesSynchronized();
11757 }
11758
11759 //------------------------- Quantity
11760 //----------------------------------------------------------------
11762 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11763 {
11764 if (!IsServerCheck(allow_client))
11765 return false;
11766
11767 if (!HasQuantity())
11768 return false;
11769
11770 float min = GetQuantityMin();
11771 float max = GetQuantityMax();
11772
11773 if (value <= (min + 0.001))
11774 value = min;
11775
11776 if (value == min)
11777 {
11778 if (destroy_config)
11779 {
11780 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11781 if (dstr)
11782 {
11783 m_VarQuantity = Math.Clamp(value, min, max);
11784 this.Delete();
11785 return true;
11786 }
11787 }
11788 else if (destroy_forced)
11789 {
11790 m_VarQuantity = Math.Clamp(value, min, max);
11791 this.Delete();
11792 return true;
11793 }
11794 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11795 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11796 }
11797
11798 float delta = m_VarQuantity;
11799 m_VarQuantity = Math.Clamp(value, min, max);
11800
11801 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11802 {
11803 EntityAI parent = GetHierarchyRoot();
11804 InventoryLocation iLoc = new InventoryLocation();
11805 GetInventory().GetCurrentInventoryLocation(iLoc);
11806 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
11807 {
11808 int iLocSlot = iLoc.GetSlot();
11809 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
11810 {
11811 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
11812 }
11813 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
11814 {
11815 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
11816 }
11817 }
11818 }
11819
11820 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11821 {
11822 delta = m_VarQuantity - delta;
11823
11824 if (delta)
11825 OnQuantityChanged(delta);
11826 }
11827
11828 SetVariableMask(VARIABLE_QUANTITY);
11829
11830 return false;
11831 }
11832
11833 //----------------------------------------------------------------
11835 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11836 {
11837 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11838 }
11839 //----------------------------------------------------------------
11840 void SetQuantityMax()
11841 {
11842 float max = GetQuantityMax();
11843 SetQuantity(max);
11844 }
11845
11846 override void SetQuantityToMinimum()
11847 {
11848 float min = GetQuantityMin();
11849 SetQuantity(min);
11850 }
11851 //----------------------------------------------------------------
11853 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11854 {
11855 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11856 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11857 SetQuantity(result, destroy_config, destroy_forced);
11858 }
11859
11860 //----------------------------------------------------------------
11862 override float GetQuantityNormalized()
11863 {
11864 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11865 }
11866
11868 {
11869 return GetQuantityNormalized();
11870 }
11871
11872 /*void SetAmmoNormalized(float value)
11873 {
11874 float value_clamped = Math.Clamp(value, 0, 1);
11875 Magazine this_mag = Magazine.Cast(this);
11876 int max_rounds = this_mag.GetAmmoMax();
11877 int result = value * max_rounds;//can the rounded if higher precision is required
11878 this_mag.SetAmmoCount(result);
11879 }*/
11880 //----------------------------------------------------------------
11881 override int GetQuantityMax()
11882 {
11883 int slot = -1;
11884 GameInventory inventory = GetInventory();
11885 if (inventory)
11886 {
11887 InventoryLocation il = new InventoryLocation;
11888 inventory.GetCurrentInventoryLocation(il);
11889 slot = il.GetSlot();
11890 }
11891
11892 return GetTargetQuantityMax(slot);
11893 }
11894
11895 override int GetTargetQuantityMax(int attSlotID = -1)
11896 {
11897 float quantity_max = 0;
11898
11899 if (IsSplitable()) //only stackable/splitable items can check for stack size
11900 {
11901 if (attSlotID != -1)
11902 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11903
11904 if (quantity_max <= 0)
11905 quantity_max = m_VarStackMax;
11906 }
11907
11908 if (quantity_max <= 0)
11909 quantity_max = m_VarQuantityMax;
11910
11911 return quantity_max;
11912 }
11913 //----------------------------------------------------------------
11914 override int GetQuantityMin()
11915 {
11916 return m_VarQuantityMin;
11917 }
11918 //----------------------------------------------------------------
11919 int GetQuantityInit()
11920 {
11921 return m_VarQuantityInit;
11922 }
11923
11924 //----------------------------------------------------------------
11925 override bool HasQuantity()
11926 {
11927 return !(GetQuantityMax() - GetQuantityMin() == 0);
11928 }
11929
11930 override float GetQuantity()
11931 {
11932 return m_VarQuantity;
11933 }
11934
11935 bool IsFullQuantity()
11936 {
11937 return GetQuantity() >= GetQuantityMax();
11938 }
11939
11940 //Calculates weight of single item without attachments and cargo
11941 override float GetSingleInventoryItemWeightEx()
11942 {
11943 //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
11944 float weightEx = GetWeightEx();//overall weight of the item
11945 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11946 return weightEx - special;
11947 }
11948
11949 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11951 {
11953 }
11954
11955 override protected float GetWeightSpecialized(bool forceRecalc = false)
11956 {
11957 if (IsSplitable()) //quantity determines size of the stack
11958 {
11959 #ifdef DEVELOPER
11960 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11961 {
11962 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11963 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11964 }
11965 #endif
11966
11967 return GetQuantity() * GetConfigWeightModified();
11968 }
11969 else if (HasEnergyManager())// items with energy manager
11970 {
11971 #ifdef DEVELOPER
11972 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11973 {
11974 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11975 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11976 }
11977 #endif
11978 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11979 }
11980 else//everything else
11981 {
11982 #ifdef DEVELOPER
11983 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11984 {
11985 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11986 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11987 }
11988 #endif
11989 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11990 }
11991 }
11992
11994 int GetNumberOfItems()
11995 {
11996 int item_count = 0;
11997 ItemBase item;
11998
11999 GameInventory inventory = GetInventory();
12000 CargoBase cargo = inventory.GetCargo();
12001 if (cargo != NULL)
12002 {
12003 item_count = cargo.GetItemCount();
12004 }
12005
12006 int nAttachments = inventory.AttachmentCount();
12007 for (int i = 0; i < nAttachments; ++i)
12008 {
12009 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
12010 if (item)
12011 item_count += item.GetNumberOfItems();
12012 }
12013 return item_count;
12014 }
12015
12017 float GetUnitWeight(bool include_wetness = true)
12018 {
12019 float weight = 0;
12020 float wetness = 1;
12021 if (include_wetness)
12022 wetness += GetWet();
12023 if (IsSplitable()) //quantity determines size of the stack
12024 {
12025 weight = wetness * m_ConfigWeight;
12026 }
12027 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12028 {
12029 weight = 1;
12030 }
12031 return weight;
12032 }
12033
12034 //-----------------------------------------------------------------
12035
12036 override void ClearInventory()
12037 {
12038 GameInventory inventory = GetInventory();
12039 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
12040 {
12041 array<EntityAI> items = new array<EntityAI>;
12042 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
12043 for (int i = 0; i < items.Count(); ++i)
12044 {
12045 ItemBase item = ItemBase.Cast(items.Get(i));
12046 if (item)
12047 {
12048 g_Game.ObjectDelete(item);
12049 }
12050 }
12051 }
12052 }
12053
12054 //------------------------- Energy
12055
12056 //----------------------------------------------------------------
12057 float GetEnergy()
12058 {
12059 float energy = 0;
12060 if (HasEnergyManager())
12061 {
12062 energy = GetCompEM().GetEnergy();
12063 }
12064 return energy;
12065 }
12066
12067
12068 override void OnEnergyConsumed()
12069 {
12070 super.OnEnergyConsumed();
12071
12073 }
12074
12075 override void OnEnergyAdded()
12076 {
12077 super.OnEnergyAdded();
12078
12080 }
12081
12082 // Converts energy (from Energy Manager) to quantity, if enabled.
12084 {
12085 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12086 {
12087 if (HasQuantity())
12088 {
12089 float energy_0to1 = GetCompEM().GetEnergy0To1();
12090 SetQuantityNormalized(energy_0to1);
12091 }
12092 }
12093 }
12094
12095 //----------------------------------------------------------------
12096 float GetHeatIsolationInit()
12097 {
12098 return ConfigGetFloat("heatIsolation");
12099 }
12100
12101 float GetHeatIsolation()
12102 {
12103 return m_HeatIsolation;
12104 }
12105
12106 float GetDryingIncrement(string pIncrementName)
12107 {
12108 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12109 if (g_Game.ConfigIsExisting(paramPath))
12110 return g_Game.ConfigGetFloat(paramPath);
12111
12112 return 0.0;
12113 }
12114
12115 float GetSoakingIncrement(string pIncrementName)
12116 {
12117 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12118 if (g_Game.ConfigIsExisting(paramPath))
12119 return g_Game.ConfigGetFloat(paramPath);
12120
12121 return 0.0;
12122 }
12123 //----------------------------------------------------------------
12124 override void SetWet(float value, bool allow_client = false)
12125 {
12126 if (!IsServerCheck(allow_client))
12127 return;
12128
12129 float min = GetWetMin();
12130 float max = GetWetMax();
12131
12132 float previousValue = m_VarWet;
12133
12134 m_VarWet = Math.Clamp(value, min, max);
12135
12136 if (previousValue != m_VarWet)
12137 {
12138 SetVariableMask(VARIABLE_WET);
12139 OnWetChanged(m_VarWet, previousValue);
12140 }
12141 }
12142 //----------------------------------------------------------------
12143 override void AddWet(float value)
12144 {
12145 SetWet(GetWet() + value);
12146 }
12147 //----------------------------------------------------------------
12148 override void SetWetMax()
12149 {
12151 }
12152 //----------------------------------------------------------------
12153 override float GetWet()
12154 {
12155 return m_VarWet;
12156 }
12157 //----------------------------------------------------------------
12158 override float GetWetMax()
12159 {
12160 return m_VarWetMax;
12161 }
12162 //----------------------------------------------------------------
12163 override float GetWetMin()
12164 {
12165 return m_VarWetMin;
12166 }
12167 //----------------------------------------------------------------
12168 override float GetWetInit()
12169 {
12170 return m_VarWetInit;
12171 }
12172 //----------------------------------------------------------------
12173 override void OnWetChanged(float newVal, float oldVal)
12174 {
12175 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12176 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12177 if (newLevel != oldLevel)
12178 {
12179 OnWetLevelChanged(newLevel,oldLevel);
12180 }
12181 }
12182
12183 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12184 {
12185 SetWeightDirty();
12186 }
12187
12188 override EWetnessLevel GetWetLevel()
12189 {
12190 return GetWetLevelInternal(m_VarWet);
12191 }
12192
12193 //----------------------------------------------------------------
12194
12195 override void SetStoreLoad(bool value)
12196 {
12197 m_IsStoreLoad = value;
12198 }
12199
12200 override bool IsStoreLoad()
12201 {
12202 return m_IsStoreLoad;
12203 }
12204
12205 override void SetStoreLoadedQuantity(float value)
12206 {
12207 m_StoreLoadedQuantity = value;
12208 }
12209
12210 override float GetStoreLoadedQuantity()
12211 {
12212 return m_StoreLoadedQuantity;
12213 }
12214
12215 //----------------------------------------------------------------
12216
12217 float GetItemModelLength()
12218 {
12219 if (ConfigIsExisting("itemModelLength"))
12220 {
12221 return ConfigGetFloat("itemModelLength");
12222 }
12223 return 0;
12224 }
12225
12226 float GetItemAttachOffset()
12227 {
12228 if (ConfigIsExisting("itemAttachOffset"))
12229 {
12230 return ConfigGetFloat("itemAttachOffset");
12231 }
12232 return 0;
12233 }
12234
12235 override void SetCleanness(int value, bool allow_client = false)
12236 {
12237 if (!IsServerCheck(allow_client))
12238 return;
12239
12240 int previousValue = m_Cleanness;
12241
12242 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12243
12244 if (previousValue != m_Cleanness)
12245 SetVariableMask(VARIABLE_CLEANNESS);
12246 }
12247
12248 override int GetCleanness()
12249 {
12250 return m_Cleanness;
12251 }
12252
12254 {
12255 return true;
12256 }
12257
12258 //----------------------------------------------------------------
12259 // ATTACHMENT LOCKING
12260 // Getters relevant to generic ActionLockAttachment
12261 int GetLockType()
12262 {
12263 return m_LockType;
12264 }
12265
12266 string GetLockSoundSet()
12267 {
12268 return m_LockSoundSet;
12269 }
12270
12271 //----------------------------------------------------------------
12272 //------------------------- Color
12273 // sets items color variable given color components
12274 override void SetColor(int r, int g, int b, int a)
12275 {
12280 SetVariableMask(VARIABLE_COLOR);
12281 }
12283 override void GetColor(out int r,out int g,out int b,out int a)
12284 {
12289 }
12290
12291 bool IsColorSet()
12292 {
12293 return IsVariableSet(VARIABLE_COLOR);
12294 }
12295
12297 string GetColorString()
12298 {
12299 int r,g,b,a;
12300 GetColor(r,g,b,a);
12301 r = r/255;
12302 g = g/255;
12303 b = b/255;
12304 a = a/255;
12305 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12306 }
12307 //----------------------------------------------------------------
12308 //------------------------- LiquidType
12309
12310 override void SetLiquidType(int value, bool allow_client = false)
12311 {
12312 if (!IsServerCheck(allow_client))
12313 return;
12314
12315 int old = m_VarLiquidType;
12316 m_VarLiquidType = value;
12317 OnLiquidTypeChanged(old,value);
12318 SetVariableMask(VARIABLE_LIQUIDTYPE);
12319 }
12320
12321 int GetLiquidTypeInit()
12322 {
12323 return ConfigGetInt("varLiquidTypeInit");
12324 }
12325
12326 override int GetLiquidType()
12327 {
12328 return m_VarLiquidType;
12329 }
12330
12331 protected void OnLiquidTypeChanged(int oldType, int newType)
12332 {
12333 if (newType == LIQUID_NONE && GetIsFrozen())
12334 SetFrozen(false);
12335 }
12336
12338 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12339 {
12340 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12341 }
12342
12343 // -------------------------------------------------------------------------
12345 void OnInventoryEnter(Man player)
12346 {
12347 PlayerBase nplayer;
12348 if (PlayerBase.CastTo(nplayer, player))
12349 {
12350 m_CanPlayImpactSound = true;
12351 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12352 }
12353 }
12354
12355 // -------------------------------------------------------------------------
12357 void OnInventoryExit(Man player)
12358 {
12359 PlayerBase nplayer;
12360 if (PlayerBase.CastTo(nplayer,player))
12361 {
12362 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12363 }
12364
12365 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12366
12367 if (HasEnergyManager())
12368 {
12369 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12370 }
12371 }
12372
12373 // ADVANCED PLACEMENT EVENTS
12374 override void OnPlacementStarted(Man player)
12375 {
12376 super.OnPlacementStarted(player);
12377
12378 SetTakeable(false);
12379 }
12380
12381 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12382 {
12383 if (m_AdminLog)
12384 {
12385 m_AdminLog.OnPlacementComplete(player, this);
12386 }
12387
12388 super.OnPlacementComplete(player, position, orientation);
12389 }
12390
12391 //-----------------------------
12392 // AGENT SYSTEM
12393 //-----------------------------
12394 //--------------------------------------------------------------------------
12395 bool ContainsAgent(int agent_id)
12396 {
12397 if (agent_id & m_AttachedAgents)
12398 {
12399 return true;
12400 }
12401 else
12402 {
12403 return false;
12404 }
12405 }
12406
12407 //--------------------------------------------------------------------------
12408 override void RemoveAgent(int agent_id)
12409 {
12410 if (ContainsAgent(agent_id))
12411 {
12412 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12413 }
12414 }
12415
12416 //--------------------------------------------------------------------------
12417 override void RemoveAllAgents()
12418 {
12419 m_AttachedAgents = 0;
12420 }
12421 //--------------------------------------------------------------------------
12422 override void RemoveAllAgentsExcept(int agent_to_keep)
12423 {
12424 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12425 }
12426 // -------------------------------------------------------------------------
12427 override void InsertAgent(int agent, float count = 1)
12428 {
12429 if (count < 1)
12430 return;
12431 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12433 }
12434
12436 void TransferAgents(int agents)
12437 {
12439 }
12440
12441 // -------------------------------------------------------------------------
12442 override int GetAgents()
12443 {
12444 return m_AttachedAgents;
12445 }
12446 //----------------------------------------------------------------------
12447
12448 /*int GetContaminationType()
12449 {
12450 int contamination_type;
12451
12452 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12453 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12454 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12455 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12456
12457 Edible_Base edible = Edible_Base.Cast(this);
12458 int agents = GetAgents();
12459 if (edible)
12460 {
12461 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12462 if (profile)
12463 {
12464 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12465 }
12466 }
12467 if (agents & CONTAMINATED_MASK)
12468 {
12469 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12470 }
12471 if (agents & POISONED_MASK)
12472 {
12473 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12474 }
12475 if (agents & NERVE_GAS_MASK)
12476 {
12477 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12478 }
12479 if (agents & DIRTY_MASK)
12480 {
12481 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12482 }
12483
12484 return agents;
12485 }*/
12486
12487 // -------------------------------------------------------------------------
12488 bool LoadAgents(ParamsReadContext ctx, int version)
12489 {
12490 if (!ctx.Read(m_AttachedAgents))
12491 return false;
12492 return true;
12493 }
12494 // -------------------------------------------------------------------------
12496 {
12497
12499 }
12500 // -------------------------------------------------------------------------
12501
12503 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12504 {
12505 super.CheckForRoofLimited(timeTresholdMS);
12506
12507 float time = g_Game.GetTime();
12508 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12509 {
12510 m_PreviousRoofTestTime = time;
12511 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12512 }
12513 }
12514
12515 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12516 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12517 {
12518 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12519 {
12520 return 0;
12521 }
12522
12523 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12524 {
12525 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12526 if (filter)
12527 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12528 else
12529 return 0;//otherwise return 0 when no filter attached
12530 }
12531
12532 string subclassPath, entryName;
12533
12534 switch (type)
12535 {
12536 case DEF_BIOLOGICAL:
12537 entryName = "biological";
12538 break;
12539 case DEF_CHEMICAL:
12540 entryName = "chemical";
12541 break;
12542 default:
12543 entryName = "biological";
12544 break;
12545 }
12546
12547 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12548
12549 return g_Game.ConfigGetFloat(subclassPath + entryName);
12550 }
12551
12552
12553
12555 override void EEOnCECreate()
12556 {
12557 if (!IsMagazine())
12559
12561 }
12562
12563
12564 //-------------------------
12565 // OPEN/CLOSE USER ACTIONS
12566 //-------------------------
12568 void Open();
12569 void Close();
12570 bool IsOpen()
12571 {
12572 return true;
12573 }
12574
12575 override bool CanDisplayCargo()
12576 {
12577 return IsOpen();
12578 }
12579
12580
12581 // ------------------------------------------------------------
12582 // CONDITIONS
12583 // ------------------------------------------------------------
12584 override bool CanPutInCargo(EntityAI parent)
12585 {
12586 if (parent)
12587 {
12588 if (parent.IsInherited(DayZInfected))
12589 return true;
12590
12591 if (!parent.IsRuined())
12592 return true;
12593 }
12594
12595 return true;
12596 }
12597
12598 override bool CanPutAsAttachment(EntityAI parent)
12599 {
12600 if (!super.CanPutAsAttachment(parent))
12601 {
12602 return false;
12603 }
12604
12605 if (!IsRuined() && !parent.IsRuined())
12606 {
12607 return true;
12608 }
12609
12610 return false;
12611 }
12612
12613 override bool CanReceiveItemIntoCargo(EntityAI item)
12614 {
12615 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12616 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12617 // return false;
12618
12619 return super.CanReceiveItemIntoCargo(item);
12620 }
12621
12622 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12623 {
12624 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12625 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12626 // return false;
12627
12628 GameInventory attachmentInv = attachment.GetInventory();
12629 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12630 {
12631 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12632 return false;
12633 }
12634
12635 InventoryLocation loc = new InventoryLocation();
12636 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12637 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12638 return false;
12639
12640 return super.CanReceiveAttachment(attachment, slotId);
12641 }
12642
12643 override bool CanReleaseAttachment(EntityAI attachment)
12644 {
12645 if (!super.CanReleaseAttachment(attachment))
12646 return false;
12647
12648 return GetInventory().AreChildrenAccessible();
12649 }
12650
12651 /*override bool CanLoadAttachment(EntityAI attachment)
12652 {
12653 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12654 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12655 // return false;
12656
12657 GameInventory attachmentInv = attachment.GetInventory();
12658 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12659 {
12660 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12661 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12662
12663 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12664 return false;
12665 }
12666
12667 return super.CanLoadAttachment(attachment);
12668 }*/
12669
12670 // Plays muzzle flash particle effects
12671 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12672 {
12673 int id = muzzle_owner.GetMuzzleID();
12674 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12675
12676 if (WPOF_array)
12677 {
12678 for (int i = 0; i < WPOF_array.Count(); i++)
12679 {
12680 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12681
12682 if (WPOF)
12683 {
12684 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12685 }
12686 }
12687 }
12688 }
12689
12690 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12691 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12692 {
12693 int id = muzzle_owner.GetMuzzleID();
12694 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12695
12696 if (WPOBE_array)
12697 {
12698 for (int i = 0; i < WPOBE_array.Count(); i++)
12699 {
12700 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12701
12702 if (WPOBE)
12703 {
12704 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12705 }
12706 }
12707 }
12708 }
12709
12710 // Plays all weapon overheating particles
12711 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12712 {
12713 int id = muzzle_owner.GetMuzzleID();
12714 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12715
12716 if (WPOOH_array)
12717 {
12718 for (int i = 0; i < WPOOH_array.Count(); i++)
12719 {
12720 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12721
12722 if (WPOOH)
12723 {
12724 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12725 }
12726 }
12727 }
12728 }
12729
12730 // Updates all weapon overheating particles
12731 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12732 {
12733 int id = muzzle_owner.GetMuzzleID();
12734 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12735
12736 if (WPOOH_array)
12737 {
12738 for (int i = 0; i < WPOOH_array.Count(); i++)
12739 {
12740 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12741
12742 if (WPOOH)
12743 {
12744 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12745 }
12746 }
12747 }
12748 }
12749
12750 // Stops overheating particles
12751 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12752 {
12753 int id = muzzle_owner.GetMuzzleID();
12754 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12755
12756 if (WPOOH_array)
12757 {
12758 for (int i = 0; i < WPOOH_array.Count(); i++)
12759 {
12760 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12761
12762 if (WPOOH)
12763 {
12764 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12765 }
12766 }
12767 }
12768 }
12769
12770 //----------------------------------------------------------------
12771 //Item Behaviour - unified approach
12772 override bool IsHeavyBehaviour()
12773 {
12774 if (m_ItemBehaviour == 0)
12775 {
12776 return true;
12777 }
12778
12779 return false;
12780 }
12781
12782 override bool IsOneHandedBehaviour()
12783 {
12784 if (m_ItemBehaviour == 1)
12785 {
12786 return true;
12787 }
12788
12789 return false;
12790 }
12791
12792 override bool IsTwoHandedBehaviour()
12793 {
12794 if (m_ItemBehaviour == 2)
12795 {
12796 return true;
12797 }
12798
12799 return false;
12800 }
12801
12802 bool IsDeployable()
12803 {
12804 return false;
12805 }
12806
12808 float GetDeployTime()
12809 {
12810 return UATimeSpent.DEFAULT_DEPLOY;
12811 }
12812
12813
12814 //----------------------------------------------------------------
12815 // Item Targeting (User Actions)
12816 override void SetTakeable(bool pState)
12817 {
12818 m_IsTakeable = pState;
12819 SetSynchDirty();
12820 }
12821
12822 override bool IsTakeable()
12823 {
12824 return m_IsTakeable;
12825 }
12826
12827 // For cases where we want to show object widget which cant be taken to hands
12829 {
12830 return false;
12831 }
12832
12834 protected void PreLoadSoundAttachmentType()
12835 {
12836 string att_type = "None";
12837
12838 if (ConfigIsExisting("soundAttType"))
12839 {
12840 att_type = ConfigGetString("soundAttType");
12841 }
12842
12843 m_SoundAttType = att_type;
12844 }
12845
12846 override string GetAttachmentSoundType()
12847 {
12848 return m_SoundAttType;
12849 }
12850
12851 //----------------------------------------------------------------
12852 //SOUNDS - ItemSoundHandler
12853 //----------------------------------------------------------------
12854
12855 string GetPlaceSoundset(); // played when deploy starts
12856 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12857 string GetDeploySoundset(); // played when deploy sucessfully finishes
12858 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12859 string GetFoldSoundset(); // played when fold sucessfully finishes
12860
12862 {
12863 if (!m_ItemSoundHandler)
12865
12866 return m_ItemSoundHandler;
12867 }
12868
12869 // override to initialize sounds
12870 protected void InitItemSounds()
12871 {
12872 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
12873 return;
12874
12876
12877 if (GetPlaceSoundset() != string.Empty)
12878 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12879
12880 if (GetDeploySoundset() != string.Empty)
12881 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12882
12883 SoundParameters params = new SoundParameters();
12884 params.m_Loop = true;
12885 if (GetLoopDeploySoundset() != string.Empty)
12886 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12887 }
12888
12889 // Start sound using ItemSoundHandler
12890 void StartItemSoundServer(int id, int slotId)
12891 {
12892 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12893 {
12894 m_SoundSyncSlotID = slotId;
12895 m_SoundSyncPlay = id;
12896
12897 SetSynchDirty();
12898
12899 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12900 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12901 }
12902 }
12903
12904 void StartItemSoundServer(int id)
12905 {
12906 StartItemSoundServer(id, InventorySlots.INVALID);
12907 }
12908
12909 // Stop sound using ItemSoundHandler
12910 void StopItemSoundServer(int id)
12911 {
12912 if (!g_Game.IsServer())
12913 return;
12914
12915 m_SoundSyncStop = id;
12916 SetSynchDirty();
12917
12918 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12919 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12920 }
12921
12922 protected void ClearStartItemSoundServer()
12923 {
12924 m_SoundSyncPlay = 0;
12925 m_SoundSyncSlotID = InventorySlots.INVALID;
12926 }
12927
12928 protected void ClearStopItemSoundServer()
12929 {
12930 m_SoundSyncStop = 0;
12931 }
12932
12933 void OnApply(PlayerBase player);
12934
12936 {
12937 return 1.0;
12938 };
12939 //returns applicable selection
12940 array<string> GetHeadHidingSelection()
12941 {
12943 }
12944
12946 {
12948 }
12949
12950 WrittenNoteData GetWrittenNoteData() {};
12951
12953 {
12954 SetDynamicPhysicsLifeTime(0.01);
12955 m_ItemBeingDroppedPhys = false;
12956 }
12957
12959 {
12960 array<string> zone_names = new array<string>;
12961 GetDamageZones(zone_names);
12962 for (int i = 0; i < zone_names.Count(); i++)
12963 {
12964 SetHealthMax(zone_names.Get(i),"Health");
12965 }
12966 SetHealthMax("","Health");
12967 }
12968
12970 void SetZoneDamageCEInit()
12971 {
12972 float global_health = GetHealth01("","Health");
12973 array<string> zones = new array<string>;
12974 GetDamageZones(zones);
12975 //set damage of all zones to match global health level
12976 for (int i = 0; i < zones.Count(); i++)
12977 {
12978 SetHealth01(zones.Get(i),"Health",global_health);
12979 }
12980 }
12981
12983 bool IsCoverFaceForShave(string slot_name)
12984 {
12985 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12986 }
12987
12988 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12989 {
12990 if (!hasRootAsPlayer)
12991 {
12992 if (refParentIB)
12993 {
12994 // parent is wet
12995 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12996 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12997 // parent has liquid inside
12998 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12999 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13000 // drying
13001 else if (m_VarWet > m_VarWetMin)
13002 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13003 }
13004 else
13005 {
13006 // drying on ground or inside non-itembase (car, ...)
13007 if (m_VarWet > m_VarWetMin)
13008 AddWet(-1 * delta * GetDryingIncrement("ground"));
13009 }
13010 }
13011 }
13012
13013 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13014 {
13016 {
13017 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13018 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13019 {
13020 float heatPermCoef = 1.0;
13021 EntityAI ent = this;
13022 while (ent)
13023 {
13024 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13025 ent = ent.GetHierarchyParent();
13026 }
13027
13028 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13029 }
13030 }
13031 }
13032
13033 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13034 {
13035 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13036 EntityAI parent = GetHierarchyParent();
13037 if (!parent)
13038 {
13039 hasParent = false;
13040 hasRootAsPlayer = false;
13041 }
13042 else
13043 {
13044 hasParent = true;
13045 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13046 refParentIB = ItemBase.Cast(parent);
13047 }
13048 }
13049
13050 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13051 {
13052 // this is stub, implemented on Edible_Base
13053 }
13054
13055 bool CanDecay()
13056 {
13057 // return true used on selected food clases so they can decay
13058 return false;
13059 }
13060
13061 protected bool CanProcessDecay()
13062 {
13063 // this is stub, implemented on Edible_Base class
13064 // used to determine whether it is still necessary for the food to decay
13065 return false;
13066 }
13067
13068 protected bool CanHaveWetness()
13069 {
13070 // return true used on selected items that have a wetness effect
13071 return false;
13072 }
13073
13075 bool CanBeConsumed(ConsumeConditionData data = null)
13076 {
13077 return !GetIsFrozen() && IsOpen();
13078 }
13079
13080 override void ProcessVariables()
13081 {
13082 bool hasParent = false, hasRootAsPlayer = false;
13083 ItemBase refParentIB;
13084
13085 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13086 bool foodDecay = g_Game.IsFoodDecayEnabled();
13087
13088 if (wwtu || foodDecay)
13089 {
13090 bool processWetness = wwtu && CanHaveWetness();
13091 bool processTemperature = wwtu && CanHaveTemperature();
13092 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13093
13094 if (processWetness || processTemperature || processDecay)
13095 {
13096 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13097
13098 if (processWetness)
13099 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13100
13101 if (processTemperature)
13102 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13103
13104 if (processDecay)
13105 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13106 }
13107 }
13108 }
13109
13112 {
13113 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13114 }
13115
13116 override float GetTemperatureFreezeThreshold()
13117 {
13119 return Liquid.GetFreezeThreshold(GetLiquidType());
13120
13121 return super.GetTemperatureFreezeThreshold();
13122 }
13123
13124 override float GetTemperatureThawThreshold()
13125 {
13127 return Liquid.GetThawThreshold(GetLiquidType());
13128
13129 return super.GetTemperatureThawThreshold();
13130 }
13131
13132 override float GetItemOverheatThreshold()
13133 {
13135 return Liquid.GetBoilThreshold(GetLiquidType());
13136
13137 return super.GetItemOverheatThreshold();
13138 }
13139
13140 override float GetTemperatureFreezeTime()
13141 {
13142 if (HasQuantity())
13143 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13144
13145 return super.GetTemperatureFreezeTime();
13146 }
13147
13148 override float GetTemperatureThawTime()
13149 {
13150 if (HasQuantity())
13151 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13152
13153 return super.GetTemperatureThawTime();
13154 }
13155
13157 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13159 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13160
13161 bool IsCargoException4x3(EntityAI item)
13162 {
13163 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13164 }
13165
13167 {
13168 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13169 }
13170
13172 void AddLightSourceItem(ItemBase lightsource)
13173 {
13174 m_LightSourceItem = lightsource;
13175 }
13176
13178 {
13179 m_LightSourceItem = null;
13180 }
13181
13183 {
13184 return m_LightSourceItem;
13185 }
13186
13188 array<int> GetValidFinishers()
13189 {
13190 return null;
13191 }
13192
13194 bool GetActionWidgetOverride(out typename name)
13195 {
13196 return false;
13197 }
13198
13199 bool PairWithDevice(notnull ItemBase otherDevice)
13200 {
13201 if (g_Game.IsServer())
13202 {
13203 ItemBase explosive = otherDevice;
13205 if (!trg)
13206 {
13207 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13208 explosive = this;
13209 }
13210
13211 explosive.PairRemote(trg);
13212 trg.SetControlledDevice(explosive);
13213
13214 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13215 trg.SetPersistentPairID(persistentID);
13216 explosive.SetPersistentPairID(persistentID);
13217
13218 return true;
13219 }
13220 return false;
13221 }
13222
13224 float GetBaitEffectivity()
13225 {
13226 float ret = 1.0;
13227 if (HasQuantity())
13228 ret *= GetQuantityNormalized();
13229 ret *= GetHealth01();
13230
13231 return ret;
13232 }
13233
13234 #ifdef DEVELOPER
13235 override void SetDebugItem()
13236 {
13237 super.SetDebugItem();
13238 _itemBase = this;
13239 }
13240
13241 override string GetDebugText()
13242 {
13243 string text = super.GetDebugText();
13244
13245 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13246 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13247
13248 return text;
13249 }
13250 #endif
13251
13252 bool CanBeUsedForSuicide()
13253 {
13254 return true;
13255 }
13256
13258 //DEPRECATED BELOW
13260 // Backwards compatibility
13261 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13262 {
13263 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13264 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13265 }
13266
13267 // replaced by ItemSoundHandler
13268 protected EffectSound m_SoundDeployFinish;
13269 protected EffectSound m_SoundPlace;
13270 protected EffectSound m_DeployLoopSoundEx;
13271 protected EffectSound m_SoundDeploy;
13272 bool m_IsPlaceSound;
13273 bool m_IsDeploySound;
13275
13276 string GetDeployFinishSoundset();
13277 void PlayDeploySound();
13278 void PlayDeployFinishSound();
13279 void PlayPlaceSound();
13280 void PlayDeployLoopSoundEx();
13281 void StopDeployLoopSoundEx();
13282 void SoundSynchRemoteReset();
13283 void SoundSynchRemote();
13284 bool UsesGlobalDeploy(){return false;}
13285 bool CanPlayDeployLoopSound(){return false;}
13287 bool IsPlaceSound(){return m_IsPlaceSound;}
13288 bool IsDeploySound(){return m_IsDeploySound;}
13289 void SetIsPlaceSound(bool is_place_sound);
13290 void SetIsDeploySound(bool is_deploy_sound);
13291
13292 [Obsolete("Use ItemSoundHandler instead")]
13294 void PlayAttachSound(string slot_type)
13295 {
13296 if (!g_Game.IsDedicatedServer())
13297 {
13298 if (ConfigIsExisting("attachSoundSet"))
13299 {
13300 string cfg_path = "";
13301 string soundset = "";
13302 string type_name = GetType();
13303
13304 TStringArray cfg_soundset_array = new TStringArray;
13305 TStringArray cfg_slot_array = new TStringArray;
13306 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13307 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13308
13309 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13310 {
13311 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13312 {
13313 if (cfg_slot_array[i] == slot_type)
13314 {
13315 soundset = cfg_soundset_array[i];
13316 break;
13317 }
13318 }
13319 }
13320
13321 if (soundset != "")
13322 {
13323 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13324 sound.SetAutodestroy(true);
13325 }
13326 }
13327 }
13328 }
13329
13330 void PlayDetachSound(string slot_type) {}
13331}
13332
13333EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13334{
13335 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13336 if (entity)
13337 {
13338 bool is_item = entity.IsInherited(ItemBase);
13339 if (is_item && full_quantity)
13340 {
13341 ItemBase item = ItemBase.Cast(entity);
13342 item.SetQuantity(item.GetQuantityInit());
13343 }
13344 }
13345 else
13346 {
13347 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13348 return NULL;
13349 }
13350 return entity;
13351}
13352
13353void SetupSpawnedItem(ItemBase item, float health, float quantity)
13354{
13355 if (item)
13356 {
13357 if (health > 0)
13358 item.SetHealth("", "", health);
13359
13360 if (item.CanHaveTemperature())
13361 {
13362 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13363 if (item.CanFreeze())
13364 item.SetFrozen(false);
13365 }
13366
13367 if (item.HasEnergyManager())
13368 {
13369 if (quantity >= 0)
13370 {
13371 item.GetCompEM().SetEnergy0To1(quantity);
13372 }
13373 else
13374 {
13375 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13376 }
13377 }
13378 else if (item.IsMagazine())
13379 {
13380 Magazine mag = Magazine.Cast(item);
13381 if (quantity >= 0)
13382 {
13383 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13384 }
13385 else
13386 {
13387 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13388 }
13389
13390 }
13391 else
13392 {
13393 if (quantity >= 0)
13394 {
13395 item.SetQuantityNormalized(quantity, false);
13396 }
13397 else
13398 {
13399 item.SetQuantity(Math.AbsFloat(quantity));
13400 }
13401
13402 }
13403 }
13404}
13405
13406#ifdef DEVELOPER
13407ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13408#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()

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