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

◆ IsCoverFaceForShave()

bool SpawnItemOnLocation::IsCoverFaceForShave ( string slot_name)
protected

DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.

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

9456{
9457 override bool CanPutAsAttachment(EntityAI parent)
9458 {
9459 return true;
9460 }
9461};
9462
9464{
9465
9466};
9467
9468//const bool QUANTITY_DEBUG_REMOVE_ME = false;
9469
9470class ItemBase extends InventoryItem
9471{
9475
9477
9478 static int m_DebugActionsMask;
9480 // ============================================
9481 // Variable Manipulation System
9482 // ============================================
9483 // Quantity
9484
9485 float m_VarQuantity;
9486 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
9488 int m_VarQuantityMin;
9489 int m_VarQuantityMax;
9490 int m_Count;
9491 float m_VarStackMax;
9492 float m_StoreLoadedQuantity = float.LOWEST;
9493 // Wet
9494 float m_VarWet;
9495 float m_VarWetPrev;//for client to know wetness changed during synchronization
9496 float m_VarWetInit;
9497 float m_VarWetMin;
9498 float m_VarWetMax;
9499 // Cleanness
9500 int m_Cleanness;
9501 int m_CleannessInit;
9502 int m_CleannessMin;
9503 int m_CleannessMax;
9504 // impact sounds
9506 bool m_CanPlayImpactSound = true;
9507 float m_ImpactSpeed;
9509 //
9510 float m_HeatIsolation;
9511 float m_ItemModelLength;
9512 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
9514 int m_VarLiquidType;
9515 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
9516 int m_QuickBarBonus;
9517 bool m_IsBeingPlaced;
9518 bool m_IsHologram;
9519 bool m_IsTakeable;
9520 bool m_ThrowItemOnDrop;
9523 bool m_FixDamageSystemInit = false; //can be changed on storage version check
9524 bool can_this_be_combined; //Check if item can be combined
9525 bool m_CanThisBeSplit; //Check if item can be split
9526 bool m_IsStoreLoad = false;
9527 bool m_CanShowQuantity;
9528 bool m_HasQuantityBar;
9529 protected bool m_CanBeDigged;
9530 protected bool m_IsResultOfSplit
9531
9532 string m_SoundAttType;
9533 // items color variables
9538 //-------------------------------------------------------
9539
9540 // light source managing
9542
9546
9547 //==============================================
9548 // agent system
9549 private int m_AttachedAgents;
9550
9552 void TransferModifiers(PlayerBase reciever);
9553
9554
9555 // Weapons & suppressors particle effects
9559 ref static map<string, int> m_WeaponTypeToID;
9560 static int m_LastRegisteredWeaponID = 0;
9561
9562 // Overheating effects
9564 float m_OverheatingShots;
9565 ref Timer m_CheckOverheating;
9566 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
9567 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
9568 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
9569 ref array <ref OverheatingParticle> m_OverheatingParticles;
9570
9572 protected bool m_HideSelectionsBySlot;
9573
9574 // Admin Log
9575 PluginAdminLog m_AdminLog;
9576
9577 // misc
9578 ref Timer m_PhysDropTimer;
9579
9580 // Attachment Locking variables
9581 ref array<int> m_CompatibleLocks;
9582 protected int m_LockType;
9583 protected ref EffectSound m_LockingSound;
9584 protected string m_LockSoundSet;
9585
9586 // ItemSoundHandler variables
9587 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
9588 protected int m_SoundSyncPlay; // id for sound to play
9589 protected int m_SoundSyncStop; // id for sound to stop
9590 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
9591
9593
9594 //temperature
9595 private float m_TemperaturePerQuantityWeight;
9596
9597 // -------------------------------------------------------------------------
9598 void ItemBase()
9599 {
9600 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9604
9605 if (!g_Game.IsDedicatedServer())
9606 {
9607 if (HasMuzzle())
9608 {
9610
9612 {
9614 }
9615 }
9616
9618 m_ActionsInitialize = false;
9619 }
9620
9621 m_OldLocation = null;
9622
9623 if (g_Game.IsServer())
9624 {
9625 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9626 }
9627
9628 if (ConfigIsExisting("headSelectionsToHide"))
9629 {
9631 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9632 }
9633
9634 m_HideSelectionsBySlot = false;
9635 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9636 {
9637 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9638 }
9639
9640 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9641
9642 m_IsResultOfSplit = false;
9643
9645 }
9646
9647 override void InitItemVariables()
9648 {
9649 super.InitItemVariables();
9650
9651 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9652 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9653 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9654 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9655 m_VarStackMax = ConfigGetFloat("varStackMax");
9656 m_Count = ConfigGetInt("count");
9657
9658 m_CanShowQuantity = ConfigGetBool("quantityShow");
9659 m_HasQuantityBar = ConfigGetBool("quantityBar");
9660
9661 m_CleannessInit = ConfigGetInt("varCleannessInit");
9663 m_CleannessMin = ConfigGetInt("varCleannessMin");
9664 m_CleannessMax = ConfigGetInt("varCleannessMax");
9665
9666 m_WantPlayImpactSound = false;
9667 m_ImpactSpeed = 0.0;
9668
9669 m_VarWetInit = ConfigGetFloat("varWetInit");
9671 m_VarWetMin = ConfigGetFloat("varWetMin");
9672 m_VarWetMax = ConfigGetFloat("varWetMax");
9673
9674 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9675 if (IsLiquidContainer() && GetQuantity() != 0)
9677 m_IsBeingPlaced = false;
9678 m_IsHologram = false;
9679 m_IsTakeable = true;
9680 m_CanBeMovedOverride = false;
9684 m_CanBeDigged = ConfigGetBool("canBeDigged");
9685
9686 m_CompatibleLocks = new array<int>();
9687 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9688 m_LockType = ConfigGetInt("lockType");
9689
9690 //Define if item can be split and set ability to be combined accordingly
9691 m_CanThisBeSplit = false;
9692 can_this_be_combined = false;
9693 if (ConfigIsExisting("canBeSplit"))
9694 {
9695 can_this_be_combined = ConfigGetBool("canBeSplit");
9697 }
9698
9699 m_ItemBehaviour = -1;
9700 if (ConfigIsExisting("itemBehaviour"))
9701 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9702
9703 //RegisterNetSyncVariableInt("m_VariablesMask");
9704 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9705 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9706 RegisterNetSyncVariableInt("m_VarLiquidType");
9707 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9708
9709 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9710 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9711 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9712
9713 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9714 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9715 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9716 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9717
9718 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9719 RegisterNetSyncVariableBool("m_IsTakeable");
9720 RegisterNetSyncVariableBool("m_IsHologram");
9721
9724 {
9725 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9726 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9727 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
9728 }
9729
9730 m_LockSoundSet = ConfigGetString("lockSoundSet");
9731
9733 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9734 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9735
9736 m_SoundSyncSlotID = -1;
9737 }
9738
9739 override int GetQuickBarBonus()
9740 {
9741 return m_QuickBarBonus;
9742 }
9743
9744 void InitializeActions()
9745 {
9747 if (!m_InputActionMap)
9748 {
9750 m_InputActionMap = iam;
9751 SetActions();
9753 }
9754 }
9755
9756 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9757 {
9759 {
9760 m_ActionsInitialize = true;
9762 }
9763
9764 actions = m_InputActionMap.Get(action_input_type);
9765 }
9766
9767 void SetActions()
9768 {
9769 AddAction(ActionTakeItem);
9770 AddAction(ActionTakeItemToHands);
9771 AddAction(ActionWorldCraft);
9773 AddAction(ActionAttachWithSwitch);
9774 }
9775
9776 void SetActionAnimOverrides(); // Override action animation for specific item
9777
9778 void AddAction(typename actionName)
9779 {
9780 ActionBase action = ActionManagerBase.GetAction(actionName);
9781
9782 if (!action)
9783 {
9784 Debug.LogError("Action " + actionName + " dosn't exist!");
9785 return;
9786 }
9787
9788 typename ai = action.GetInputType();
9789 if (!ai)
9790 {
9791 m_ActionsInitialize = false;
9792 return;
9793 }
9794
9795 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9796 if (!action_array)
9797 {
9798 action_array = new array<ActionBase_Basic>;
9799 m_InputActionMap.Insert(ai, action_array);
9800 }
9801 if (LogManager.IsActionLogEnable())
9802 {
9803 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9804 }
9805
9806 if (action_array.Find(action) != -1)
9807 {
9808 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9809 }
9810 else
9811 {
9812 action_array.Insert(action);
9813 }
9814 }
9815
9816 void RemoveAction(typename actionName)
9817 {
9818 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9819 ActionBase action = player.GetActionManager().GetAction(actionName);
9820 typename ai = action.GetInputType();
9821 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9822
9823 if (action_array)
9824 {
9825 action_array.RemoveItem(action);
9826 }
9827 }
9828
9829 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9830 // Set -1 for params which should stay in default state
9831 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9832 {
9833 ActionOverrideData overrideData = new ActionOverrideData();
9834 overrideData.m_CommandUID = commandUID;
9835 overrideData.m_CommandUIDProne = commandUIDProne;
9836 overrideData.m_StanceMask = stanceMask;
9837
9838 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9839 if (!actionMap) // create new map of action > overidables map
9840 {
9841 actionMap = new TActionAnimOverrideMap();
9842 m_ItemActionOverrides.Insert(action, actionMap);
9843 }
9844
9845 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9846
9847 }
9848
9849 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9850
9851 ScriptedLightBase GetLight();
9852
9853 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9854 void LoadParticleConfigOnFire(int id)
9855 {
9856 if (!m_OnFireEffect)
9858
9861
9862 string config_to_search = "CfgVehicles";
9863 string muzzle_owner_config;
9864
9865 if (!m_OnFireEffect.Contains(id))
9866 {
9867 if (IsInherited(Weapon))
9868 config_to_search = "CfgWeapons";
9869
9870 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9871
9872 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9873
9874 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
9875
9876 if (config_OnFire_subclass_count > 0)
9877 {
9878 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9879
9880 for (int i = 0; i < config_OnFire_subclass_count; i++)
9881 {
9882 string particle_class = "";
9883 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
9884 string config_OnFire_entry = config_OnFire_class + particle_class;
9885 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9886 WPOF_array.Insert(WPOF);
9887 }
9888
9889
9890 m_OnFireEffect.Insert(id, WPOF_array);
9891 }
9892 }
9893
9894 if (!m_OnBulletCasingEjectEffect.Contains(id))
9895 {
9896 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9897 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9898
9899 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9900
9901 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9902
9903 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9904 {
9905 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9906
9907 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9908 {
9909 string particle_class2 = "";
9910 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9911 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9912 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9913 WPOBE_array.Insert(WPOBE);
9914 }
9915
9916
9917 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9918 }
9919 }
9920 }
9921
9922 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9924 {
9927
9928 if (!m_OnOverheatingEffect.Contains(id))
9929 {
9930 string config_to_search = "CfgVehicles";
9931
9932 if (IsInherited(Weapon))
9933 config_to_search = "CfgWeapons";
9934
9935 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9936 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9937
9938 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
9939 {
9940
9941 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9942
9944 {
9945 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9946 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9947 Error(error);
9948 return;
9949 }
9950
9951 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9952 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9953
9954
9955
9956 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
9957 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9958
9959 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9960 {
9961 string particle_class = "";
9962 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9963 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9964 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
9965
9966 if (entry_type == CT_CLASS)
9967 {
9968 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9969 WPOOH_array.Insert(WPOF);
9970 }
9971 }
9972
9973
9974 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9975 }
9976 }
9977 }
9978
9979 float GetOverheatingValue()
9980 {
9981 return m_OverheatingShots;
9982 }
9983
9984 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9985 {
9986 if (m_MaxOverheatingValue > 0)
9987 {
9989
9990 if (!m_CheckOverheating)
9992
9994 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9995
9996 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9997 }
9998 }
9999
10000 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10001 {
10003 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10004
10006 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10007
10009 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10010
10012 {
10014 }
10015 }
10016
10018 {
10020 }
10021
10022 void OnOverheatingDecay()
10023 {
10024 if (m_MaxOverheatingValue > 0)
10025 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
10026 else
10028
10029 if (m_OverheatingShots <= 0)
10030 {
10033 }
10034 else
10035 {
10036 if (!m_CheckOverheating)
10038
10040 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
10041 }
10042
10043 CheckOverheating(this, "", this);
10044 }
10045
10046 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10047 {
10049 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
10050 }
10051
10052 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10053 {
10055 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
10057 }
10058
10059 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
10060 {
10062 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10063 }
10064
10065 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
10066 {
10068 m_OverheatingParticles = new array<ref OverheatingParticle>;
10069
10070 OverheatingParticle OP = new OverheatingParticle();
10071 OP.RegisterParticle(p);
10072 OP.SetOverheatingLimitMin(min_heat_coef);
10073 OP.SetOverheatingLimitMax(max_heat_coef);
10074 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
10075
10076 m_OverheatingParticles.Insert(OP);
10077 }
10078
10079 float GetOverheatingCoef()
10080 {
10081 if (m_MaxOverheatingValue > 0)
10083
10084 return -1;
10085 }
10086
10088 {
10090 {
10091 float overheat_coef = GetOverheatingCoef();
10092 int count = m_OverheatingParticles.Count();
10093
10094 for (int i = count; i > 0; --i)
10095 {
10096 int id = i - 1;
10097 OverheatingParticle OP = m_OverheatingParticles.Get(id);
10098 Particle p = OP.GetParticle();
10099
10100 float overheat_min = OP.GetOverheatingLimitMin();
10101 float overheat_max = OP.GetOverheatingLimitMax();
10102
10103 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
10104 {
10105 if (p)
10106 {
10107 p.Stop();
10108 OP.RegisterParticle(null);
10109 }
10110 }
10111 }
10112 }
10113 }
10114
10116 {
10118 {
10119 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
10120 {
10121 int id = i - 1;
10122 OverheatingParticle OP = m_OverheatingParticles.Get(id);
10123
10124 if (OP)
10125 {
10126 Particle p = OP.GetParticle();
10127
10128 if (p)
10129 {
10130 p.Stop();
10131 }
10132
10133 delete OP;
10134 }
10135 }
10136
10137 m_OverheatingParticles.Clear();
10139 }
10140 }
10141
10143 float GetInfectionChance(int system = 0, Param param = null)
10144 {
10145 return 0.0;
10146 }
10147
10148
10149 float GetDisinfectQuantity(int system = 0, Param param1 = null)
10150 {
10151 return 250;//default value
10152 }
10153
10154 float GetFilterDamageRatio()
10155 {
10156 return 0;
10157 }
10158
10160 bool HasMuzzle()
10161 {
10162 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
10163 return true;
10164
10165 return false;
10166 }
10167
10169 int GetMuzzleID()
10170 {
10171 if (!m_WeaponTypeToID)
10172 m_WeaponTypeToID = new map<string, int>;
10173
10174 if (m_WeaponTypeToID.Contains(GetType()))
10175 {
10176 return m_WeaponTypeToID.Get(GetType());
10177 }
10178 else
10179 {
10180 // Register new weapon ID
10182 }
10183
10185 }
10186
10193 {
10194 return -1;
10195 }
10196
10197
10198
10199 // -------------------------------------------------------------------------
10200 void ~ItemBase()
10201 {
10202 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
10203 {
10204 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10205 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10206
10207 if (r_index >= 0)
10208 {
10209 InventoryLocation r_il = new InventoryLocation;
10210 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10211
10212 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10213 int r_type = r_il.GetType();
10214 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10215 {
10216 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10217 }
10218 else if (r_type == InventoryLocationType.ATTACHMENT)
10219 {
10220 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10221 }
10222
10223 }
10224
10225 player.GetHumanInventory().ClearUserReservedLocation(this);
10226 }
10227
10228 if (m_LockingSound)
10229 SEffectManager.DestroyEffect(m_LockingSound);
10230 }
10231
10232
10233
10234 // -------------------------------------------------------------------------
10235 static int GetDebugActionsMask()
10236 {
10237 return ItemBase.m_DebugActionsMask;
10238 }
10239
10240 static bool HasDebugActionsMask(int mask)
10241 {
10242 return ItemBase.m_DebugActionsMask & mask;
10243 }
10244
10245 static void SetDebugActionsMask(int mask)
10246 {
10247 ItemBase.m_DebugActionsMask = mask;
10248 }
10249
10250 static void AddDebugActionsMask(int mask)
10251 {
10252 ItemBase.m_DebugActionsMask |= mask;
10253 }
10254
10255 static void RemoveDebugActionsMask(int mask)
10256 {
10257 ItemBase.m_DebugActionsMask &= ~mask;
10258 }
10259
10260 static void ToggleDebugActionsMask(int mask)
10261 {
10262 if (HasDebugActionsMask(mask))
10263 {
10265 }
10266 else
10267 {
10268 AddDebugActionsMask(mask);
10269 }
10270 }
10271
10272 // -------------------------------------------------------------------------
10273 void SetCEBasedQuantity()
10274 {
10275 if (GetEconomyProfile())
10276 {
10277 float q_max = GetEconomyProfile().GetQuantityMax();
10278 if (q_max > 0)
10279 {
10280 float q_min = GetEconomyProfile().GetQuantityMin();
10281 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
10282
10283 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
10284 {
10285 ComponentEnergyManager comp = GetCompEM();
10286 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
10287 {
10288 comp.SetEnergy0To1(quantity_randomized);
10289 }
10290 }
10291 else if (HasQuantity())
10292 {
10293 SetQuantityNormalized(quantity_randomized, false);
10294 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
10295 }
10296
10297 }
10298 }
10299 }
10300
10302 void LockToParent()
10303 {
10304 EntityAI parent = GetHierarchyParent();
10305
10306 if (parent)
10307 {
10308 InventoryLocation inventory_location_to_lock = new InventoryLocation;
10309 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
10310 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
10311 }
10312 }
10313
10315 void UnlockFromParent()
10316 {
10317 EntityAI parent = GetHierarchyParent();
10318
10319 if (parent)
10320 {
10321 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
10322 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
10323 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
10324 }
10325 }
10326
10327 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
10328 {
10329 /*
10330 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
10331 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
10332 */
10333 ItemBase item2 = ItemBase.Cast(entity2);
10334
10335 if (g_Game.IsClient())
10336 {
10337 if (ScriptInputUserData.CanStoreInputUserData())
10338 {
10339 ScriptInputUserData ctx = new ScriptInputUserData;
10341 ctx.Write(-1);
10342 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10343 ctx.Write(i1);
10344 ctx.Write(item2);
10345 ctx.Write(use_stack_max);
10346 ctx.Write(-1);
10347 ctx.Send();
10348
10349 if (IsCombineAll(item2, use_stack_max))
10350 {
10351 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
10352 }
10353 }
10354 }
10355 else if (!g_Game.IsMultiplayer())
10356 {
10357 CombineItems(item2, use_stack_max);
10358 }
10359 }
10360
10361 bool IsLiquidPresent()
10362 {
10363 return (GetLiquidType() != 0 && HasQuantity());
10364 }
10365
10366 bool IsLiquidContainer()
10367 {
10368 return m_LiquidContainerMask != 0;
10369 }
10370
10372 {
10373 return m_LiquidContainerMask;
10374 }
10375
10376 bool IsBloodContainer()
10377 {
10378 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
10379 return false;
10380 }
10381
10382 bool IsNVG()
10383 {
10384 return false;
10385 }
10386
10389 bool IsExplosive()
10390 {
10391 return false;
10392 }
10393
10395 {
10396 return "";
10397 }
10398
10400
10401 bool IsLightSource()
10402 {
10403 return false;
10404 }
10405
10407 {
10408 return true;
10409 }
10410
10411 //--- ACTION CONDITIONS
10412 //direction
10413 bool IsFacingPlayer(PlayerBase player, string selection)
10414 {
10415 return true;
10416 }
10417
10418 bool IsPlayerInside(PlayerBase player, string selection)
10419 {
10420 return true;
10421 }
10422
10423 override bool CanObstruct()
10424 {
10425 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10426 return !player || !IsPlayerInside(player, "");
10427 }
10428
10429 override bool IsBeingPlaced()
10430 {
10431 return m_IsBeingPlaced;
10432 }
10433
10434 void SetIsBeingPlaced(bool is_being_placed)
10435 {
10436 m_IsBeingPlaced = is_being_placed;
10437 if (!is_being_placed)
10439 SetSynchDirty();
10440 }
10441
10442 //server-side
10443 void OnEndPlacement() {}
10444
10445 override bool IsHologram()
10446 {
10447 return m_IsHologram;
10448 }
10449
10450 bool CanBeDigged()
10451 {
10452 return m_CanBeDigged;
10453 }
10454
10456 {
10457 return 1;
10458 }
10459
10460 bool CanMakeGardenplot()
10461 {
10462 return false;
10463 }
10464
10465 void SetIsHologram(bool is_hologram)
10466 {
10467 m_IsHologram = is_hologram;
10468 SetSynchDirty();
10469 }
10470 /*
10471 protected float GetNutritionalEnergy()
10472 {
10473 Edible_Base edible = Edible_Base.Cast(this);
10474 return edible.GetFoodEnergy();
10475 }
10476
10477 protected float GetNutritionalWaterContent()
10478 {
10479 Edible_Base edible = Edible_Base.Cast(this);
10480 return edible.GetFoodWater();
10481 }
10482
10483 protected float GetNutritionalIndex()
10484 {
10485 Edible_Base edible = Edible_Base.Cast(this);
10486 return edible.GetFoodNutritionalIndex();
10487 }
10488
10489 protected float GetNutritionalFullnessIndex()
10490 {
10491 Edible_Base edible = Edible_Base.Cast(this);
10492 return edible.GetFoodTotalVolume();
10493 }
10494
10495 protected float GetNutritionalToxicity()
10496 {
10497 Edible_Base edible = Edible_Base.Cast(this);
10498 return edible.GetFoodToxicity();
10499
10500 }
10501 */
10502
10503
10504 // -------------------------------------------------------------------------
10505 override void OnMovedInsideCargo(EntityAI container)
10506 {
10507 super.OnMovedInsideCargo(container);
10508
10509 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10510 }
10511
10512 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10513 {
10514 super.EEItemLocationChanged(oldLoc, newLoc);
10515
10516 PlayerBase newPlayer = null;
10517 PlayerBase oldPlayer = null;
10518
10519 if (newLoc.GetParent())
10520 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
10521
10522 if (oldLoc.GetParent())
10523 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
10524
10525 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
10526 {
10527 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
10528
10529 if (rIndex >= 0)
10530 {
10531 InventoryLocation rIl = new InventoryLocation;
10532 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
10533
10534 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
10535 int rType = rIl.GetType();
10536 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
10537 {
10538 rIl.GetParent().GetOnReleaseLock().Invoke(this);
10539 }
10540 else if (rType == InventoryLocationType.ATTACHMENT)
10541 {
10542 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
10543 }
10544
10545 }
10546 }
10547
10548 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
10549 {
10550 if (newPlayer)
10551 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
10552
10553 if (newPlayer == oldPlayer)
10554 {
10555 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
10556 {
10557 if (oldLoc.GetType() == InventoryLocationType.CARGO)
10558 {
10559 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
10560 {
10561 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10562 }
10563 }
10564 else
10565 {
10566 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
10567 }
10568 }
10569
10570 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
10571 {
10572 int type = oldLoc.GetType();
10573 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
10574 {
10575 oldLoc.GetParent().GetOnSetLock().Invoke(this);
10576 }
10577 else if (type == InventoryLocationType.ATTACHMENT)
10578 {
10579 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
10580 }
10581 }
10582 if (!m_OldLocation)
10583 {
10584 m_OldLocation = new InventoryLocation;
10585 }
10586 m_OldLocation.Copy(oldLoc);
10587 }
10588 else
10589 {
10590 if (m_OldLocation)
10591 {
10592 m_OldLocation.Reset();
10593 }
10594 }
10595
10596 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
10597 }
10598 else
10599 {
10600 if (newPlayer)
10601 {
10602 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
10603 if (resIndex >= 0)
10604 {
10605 InventoryLocation il = new InventoryLocation;
10606 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
10607 ItemBase it = ItemBase.Cast(il.GetItem());
10608 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
10609 int rel_type = il.GetType();
10610 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10611 {
10612 il.GetParent().GetOnReleaseLock().Invoke(it);
10613 }
10614 else if (rel_type == InventoryLocationType.ATTACHMENT)
10615 {
10616 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10617 }
10618 //it.GetOnReleaseLock().Invoke(it);
10619 }
10620 }
10621 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10622 {
10623 //ThrowPhysically(oldPlayer, vector.Zero);
10624 m_ThrowItemOnDrop = false;
10625 }
10626
10627 if (m_OldLocation)
10628 {
10629 m_OldLocation.Reset();
10630 }
10631 }
10632
10633 if (oldLoc.GetType() == InventoryLocationType.TEMP)
10634 {
10635 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
10636 }
10637
10638 if (newLoc.GetType() == InventoryLocationType.TEMP)
10639 {
10640 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
10641 }
10642 }
10643
10644 override void EOnContact(IEntity other, Contact extra)
10645 {
10647 {
10648 int liquidType = -1;
10649 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10650 if (impactSpeed > 0.0)
10651 {
10652 m_ImpactSpeed = impactSpeed;
10653 #ifndef SERVER
10654 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10655 #else
10656 m_WantPlayImpactSound = true;
10657 SetSynchDirty();
10658 #endif
10659 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10660 }
10661 }
10662
10663 #ifdef SERVER
10664 if (GetCompEM() && GetCompEM().IsPlugged())
10665 {
10666 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10667 GetCompEM().UnplugThis();
10668 }
10669 #endif
10670 }
10671
10672 void RefreshPhysics();
10673
10674 override void OnCreatePhysics()
10675 {
10677 }
10678
10679 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10680 {
10681
10682 }
10683 // -------------------------------------------------------------------------
10684 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10685 {
10686 super.OnItemLocationChanged(old_owner, new_owner);
10687
10688 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10689 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10690
10691 if (!relatedPlayer && playerNew)
10692 relatedPlayer = playerNew;
10693
10694 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10695 {
10696 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10697 if (actionMgr)
10698 {
10699 ActionBase currentAction = actionMgr.GetRunningAction();
10700 if (currentAction)
10701 currentAction.OnItemLocationChanged(this);
10702 }
10703 }
10704
10705 Man ownerPlayerOld = null;
10706 Man ownerPlayerNew = null;
10707
10708 if (old_owner)
10709 {
10710 if (old_owner.IsMan())
10711 {
10712 ownerPlayerOld = Man.Cast(old_owner);
10713 }
10714 else
10715 {
10716 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10717 }
10718 }
10719 else
10720 {
10721 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10722 {
10723 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10724
10725 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10726 {
10727 GetCompEM().UnplugThis();
10728 }
10729 }
10730 }
10731
10732 if (new_owner)
10733 {
10734 if (new_owner.IsMan())
10735 {
10736 ownerPlayerNew = Man.Cast(new_owner);
10737 }
10738 else
10739 {
10740 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10741 }
10742 }
10743
10744 if (ownerPlayerOld != ownerPlayerNew)
10745 {
10746 if (ownerPlayerOld)
10747 {
10748 array<EntityAI> subItemsExit = new array<EntityAI>;
10749 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10750 for (int i = 0; i < subItemsExit.Count(); i++)
10751 {
10752 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10753 itemExit.OnInventoryExit(ownerPlayerOld);
10754 }
10755 }
10756
10757 if (ownerPlayerNew)
10758 {
10759 array<EntityAI> subItemsEnter = new array<EntityAI>;
10760 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10761 for (int j = 0; j < subItemsEnter.Count(); j++)
10762 {
10763 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10764 itemEnter.OnInventoryEnter(ownerPlayerNew);
10765 }
10766 }
10767 }
10768 else if (ownerPlayerNew != null)
10769 {
10770 PlayerBase nplayer;
10771 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10772 {
10773 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10774 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10775 for (int k = 0; k < subItemsUpdate.Count(); k++)
10776 {
10777 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10778 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10779 }
10780 }
10781 }
10782
10783 if (old_owner)
10784 old_owner.OnChildItemRemoved(this);
10785 if (new_owner)
10786 new_owner.OnChildItemReceived(this);
10787 }
10788
10789 // -------------------------------------------------------------------------------
10790 override void EEDelete(EntityAI parent)
10791 {
10792 super.EEDelete(parent);
10793 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10794 if (player)
10795 {
10796 OnInventoryExit(player);
10797
10798 if (player.IsAlive())
10799 {
10800 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10801 if (r_index >= 0)
10802 {
10803 InventoryLocation r_il = new InventoryLocation;
10804 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10805
10806 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10807 int r_type = r_il.GetType();
10808 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10809 {
10810 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10811 }
10812 else if (r_type == InventoryLocationType.ATTACHMENT)
10813 {
10814 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10815 }
10816
10817 }
10818
10819 player.RemoveQuickBarEntityShortcut(this);
10820 }
10821 }
10822 }
10823 // -------------------------------------------------------------------------------
10824 override void EEKilled(Object killer)
10825 {
10826 super.EEKilled(killer);
10827
10829 if (killer && killer.IsFireplace() && CanExplodeInFire())
10830 {
10831 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10832 {
10833 if (IsMagazine())
10834 {
10835 if (Magazine.Cast(this).GetAmmoCount() > 0)
10836 {
10837 ExplodeAmmo();
10838 }
10839 }
10840 else
10841 {
10842 Explode(DamageType.EXPLOSION);
10843 }
10844 }
10845 }
10846 }
10847
10848 override void OnWasAttached(EntityAI parent, int slot_id)
10849 {
10850 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10851
10852 super.OnWasAttached(parent, slot_id);
10853
10854 if (HasQuantity())
10855 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10856
10857 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10858 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
10859 }
10860
10861 override void OnWasDetached(EntityAI parent, int slot_id)
10862 {
10863 super.OnWasDetached(parent, slot_id);
10864
10865 if (HasQuantity())
10866 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10867
10868 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
10869 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
10870 }
10871
10872 override string ChangeIntoOnAttach(string slot)
10873 {
10874 int idx;
10875 TStringArray inventory_slots = new TStringArray;
10876 TStringArray attach_types = new TStringArray;
10877
10878 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10879 if (inventory_slots.Count() < 1) //is string
10880 {
10881 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10882 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10883 }
10884 else //is array
10885 {
10886 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10887 }
10888
10889 idx = inventory_slots.Find(slot);
10890 if (idx < 0)
10891 return "";
10892
10893 return attach_types.Get(idx);
10894 }
10895
10896 override string ChangeIntoOnDetach()
10897 {
10898 int idx = -1;
10899 string slot;
10900
10901 TStringArray inventory_slots = new TStringArray;
10902 TStringArray detach_types = new TStringArray;
10903
10904 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10905 if (inventory_slots.Count() < 1) //is string
10906 {
10907 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10908 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10909 }
10910 else //is array
10911 {
10912 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10913 if (detach_types.Count() < 1)
10914 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10915 }
10916
10917 for (int i = 0; i < inventory_slots.Count(); i++)
10918 {
10919 slot = inventory_slots.Get(i);
10920 }
10921
10922 if (slot != "")
10923 {
10924 if (detach_types.Count() == 1)
10925 idx = 0;
10926 else
10927 idx = inventory_slots.Find(slot);
10928 }
10929 if (idx < 0)
10930 return "";
10931
10932 return detach_types.Get(idx);
10933 }
10934
10935 void ExplodeAmmo()
10936 {
10937 //timer
10938 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10939
10940 //min/max time
10941 float min_time = 1;
10942 float max_time = 3;
10943 float delay = Math.RandomFloat(min_time, max_time);
10944
10945 explode_timer.Run(delay, this, "DoAmmoExplosion");
10946 }
10947
10948 void DoAmmoExplosion()
10949 {
10950 Magazine magazine = Magazine.Cast(this);
10951 int pop_sounds_count = 6;
10952 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10953
10954 //play sound
10955 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10956 string sound_name = pop_sounds[ sound_idx ];
10957 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
10958
10959 //remove ammo count
10960 magazine.ServerAddAmmoCount(-1);
10961
10962 //if condition then repeat -> ExplodeAmmo
10963 float min_temp_to_explode = 100; //min temperature for item to explode
10964
10965 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10966 {
10967 ExplodeAmmo();
10968 }
10969 }
10970
10971 // -------------------------------------------------------------------------------
10972 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10973 {
10974 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10975
10976 const int CHANCE_DAMAGE_CARGO = 4;
10977 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10978 const int CHANCE_DAMAGE_NOTHING = 2;
10979
10980 if (IsClothing() || IsContainer() || IsItemTent())
10981 {
10982 float dmg = damageResult.GetDamage("","Health") * -0.5;
10983 int chances;
10984 int rnd;
10985
10986 if (GetInventory().GetCargo())
10987 {
10988 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10989 rnd = Math.RandomInt(0,chances);
10990
10991 if (rnd < CHANCE_DAMAGE_CARGO)
10992 {
10993 DamageItemInCargo(dmg);
10994 }
10995 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10996 {
10998 }
10999 }
11000 else
11001 {
11002 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
11003 rnd = Math.RandomInt(0,chances);
11004
11005 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
11006 {
11008 }
11009 }
11010 }
11011 }
11012
11013 bool DamageItemInCargo(float damage)
11014 {
11015 CargoBase cargo = GetInventory().GetCargo();
11016 if (cargo)
11017 {
11018 int item_count = cargo.GetItemCount();
11019 if (item_count > 0)
11020 {
11021 int random_pick = Math.RandomInt(0, item_count);
11022 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
11023 if (!item.IsExplosive())
11024 {
11025 item.AddHealth("","",damage);
11026 return true;
11027 }
11028 }
11029 }
11030 return false;
11031 }
11032
11033 bool DamageItemAttachments(float damage)
11034 {
11035 GameInventory inventory = GetInventory();
11036 int attachment_count = inventory.AttachmentCount();
11037 if (attachment_count > 0)
11038 {
11039 int random_pick = Math.RandomInt(0, attachment_count);
11040 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
11041 if (!attachment.IsExplosive())
11042 {
11043 attachment.AddHealth("","",damage);
11044 return true;
11045 }
11046 }
11047 return false;
11048 }
11049
11050 override bool IsSplitable()
11051 {
11052 return m_CanThisBeSplit;
11053 }
11054 //----------------
11055 override bool CanBeSplit()
11056 {
11057 if (IsSplitable() && (GetQuantity() > 1))
11058 return GetInventory().CanRemoveEntity();
11059
11060 return false;
11061 }
11062
11063 protected bool ShouldSplitQuantity(float quantity)
11064 {
11065 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
11066 if (!IsSplitable())
11067 return false;
11068
11069 // nothing to split?
11070 if (GetQuantity() <= 1)
11071 return false;
11072
11073 // check if we should re-use the item instead of creating a new copy?
11074 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
11075 int delta = GetQuantity() - quantity;
11076 if (delta == 0)
11077 return false;
11078
11079 // valid to split
11080 return true;
11081 }
11082
11083 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
11084 {
11085 if (g_Game.IsClient())
11086 {
11087 if (ScriptInputUserData.CanStoreInputUserData())
11088 {
11089 ScriptInputUserData ctx = new ScriptInputUserData;
11091 ctx.Write(1);
11092 ItemBase i1 = this; // @NOTE: workaround for correct serialization
11093 ctx.Write(i1);
11094 ctx.Write(destination_entity);
11095 ctx.Write(true);
11096 ctx.Write(slot_id);
11097 ctx.Send();
11098 }
11099 }
11100 else if (!g_Game.IsMultiplayer())
11101 {
11102 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
11103 }
11104 }
11105
11106 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
11107 {
11108 float split_quantity_new;
11109 ItemBase new_item;
11110 float quantity = GetQuantity();
11111 float stack_max = GetTargetQuantityMax(slot_id);
11112 InventoryLocation loc = new InventoryLocation;
11113
11114 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
11115 {
11116 if (stack_max <= GetQuantity())
11117 split_quantity_new = stack_max;
11118 else
11119 split_quantity_new = GetQuantity();
11120
11121 if (ShouldSplitQuantity(split_quantity_new))
11122 {
11123 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
11124 if (new_item)
11125 {
11126 new_item.SetResultOfSplit(true);
11127 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11128 AddQuantity(-split_quantity_new, false, true);
11129 new_item.SetQuantity(split_quantity_new, false, true);
11130 }
11131 }
11132 }
11133 else if (destination_entity && slot_id == -1)
11134 {
11135 if (quantity > stack_max)
11136 split_quantity_new = stack_max;
11137 else
11138 split_quantity_new = quantity;
11139
11140 if (ShouldSplitQuantity(split_quantity_new))
11141 {
11142 GameInventory destinationInventory = destination_entity.GetInventory();
11143 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
11144 {
11145 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
11146 new_item = ItemBase.Cast(o);
11147 }
11148
11149 if (new_item)
11150 {
11151 new_item.SetResultOfSplit(true);
11152 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11153 AddQuantity(-split_quantity_new, false, true);
11154 new_item.SetQuantity(split_quantity_new, false, true);
11155 }
11156 }
11157 }
11158 else
11159 {
11160 if (stack_max != 0)
11161 {
11162 if (stack_max < GetQuantity())
11163 {
11164 split_quantity_new = GetQuantity() - stack_max;
11165 }
11166
11167 if (split_quantity_new == 0)
11168 {
11169 if (!g_Game.IsMultiplayer())
11170 player.PhysicalPredictiveDropItem(this);
11171 else
11172 player.ServerDropEntity(this);
11173 return;
11174 }
11175
11176 if (ShouldSplitQuantity(split_quantity_new))
11177 {
11178 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
11179
11180 if (new_item)
11181 {
11182 new_item.SetResultOfSplit(true);
11183 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11184 SetQuantity(split_quantity_new, false, true);
11185 new_item.SetQuantity(stack_max, false, true);
11186 new_item.PlaceOnSurface();
11187 }
11188 }
11189 }
11190 }
11191 }
11192
11193 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
11194 {
11195 float split_quantity_new;
11196 ItemBase new_item;
11197 float quantity = GetQuantity();
11198 float stack_max = GetTargetQuantityMax(slot_id);
11199 InventoryLocation loc = new InventoryLocation;
11200
11201 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
11202 {
11203 if (stack_max <= GetQuantity())
11204 split_quantity_new = stack_max;
11205 else
11206 split_quantity_new = GetQuantity();
11207
11208 if (ShouldSplitQuantity(split_quantity_new))
11209 {
11210 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
11211 if (new_item)
11212 {
11213 new_item.SetResultOfSplit(true);
11214 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11215 AddQuantity(-split_quantity_new, false, true);
11216 new_item.SetQuantity(split_quantity_new, false, true);
11217 }
11218 }
11219 }
11220 else if (destination_entity && slot_id == -1)
11221 {
11222 if (quantity > stack_max)
11223 split_quantity_new = stack_max;
11224 else
11225 split_quantity_new = quantity;
11226
11227 if (ShouldSplitQuantity(split_quantity_new))
11228 {
11229 GameInventory destinationInventory = destination_entity.GetInventory();
11230 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
11231 {
11232 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
11233 new_item = ItemBase.Cast(o);
11234 }
11235
11236 if (new_item)
11237 {
11238 new_item.SetResultOfSplit(true);
11239 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11240 AddQuantity(-split_quantity_new, false, true);
11241 new_item.SetQuantity(split_quantity_new, false, true);
11242 }
11243 }
11244 }
11245 else
11246 {
11247 if (stack_max != 0)
11248 {
11249 if (stack_max < GetQuantity())
11250 {
11251 split_quantity_new = GetQuantity() - stack_max;
11252 }
11253
11254 if (ShouldSplitQuantity(split_quantity_new))
11255 {
11256 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
11257
11258 if (new_item)
11259 {
11260 new_item.SetResultOfSplit(true);
11261 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11262 SetQuantity(split_quantity_new, false, true);
11263 new_item.SetQuantity(stack_max, false, true);
11264 new_item.PlaceOnSurface();
11265 }
11266 }
11267 }
11268 }
11269 }
11270
11271 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
11272 {
11273 if (g_Game.IsClient())
11274 {
11275 if (ScriptInputUserData.CanStoreInputUserData())
11276 {
11277 ScriptInputUserData ctx = new ScriptInputUserData;
11279 ctx.Write(4);
11280 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11281 ctx.Write(thiz);
11282 dst.WriteToContext(ctx);
11283 ctx.Send();
11284 }
11285 }
11286 else if (!g_Game.IsMultiplayer())
11287 {
11289 }
11290 }
11291
11292 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
11293 {
11294 if (g_Game.IsClient())
11295 {
11296 if (ScriptInputUserData.CanStoreInputUserData())
11297 {
11298 ScriptInputUserData ctx = new ScriptInputUserData;
11300 ctx.Write(2);
11301 ItemBase dummy = this; // @NOTE: workaround for correct serialization
11302 ctx.Write(dummy);
11303 ctx.Write(destination_entity);
11304 ctx.Write(true);
11305 ctx.Write(idx);
11306 ctx.Write(row);
11307 ctx.Write(col);
11308 ctx.Send();
11309 }
11310 }
11311 else if (!g_Game.IsMultiplayer())
11312 {
11313 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
11314 }
11315 }
11316
11317 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
11318 {
11320 }
11321
11322 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
11323 {
11324 float quantity = GetQuantity();
11325 float split_quantity_new;
11326 ItemBase new_item;
11327 if (dst.IsValid())
11328 {
11329 int slot_id = dst.GetSlot();
11330 float stack_max = GetTargetQuantityMax(slot_id);
11331
11332 if (quantity > stack_max)
11333 split_quantity_new = stack_max;
11334 else
11335 split_quantity_new = quantity;
11336
11337 if (ShouldSplitQuantity(split_quantity_new))
11338 {
11339 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11340
11341 if (new_item)
11342 {
11343 new_item.SetResultOfSplit(true);
11344 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11345 AddQuantity(-split_quantity_new, false, true);
11346 new_item.SetQuantity(split_quantity_new, false, true);
11347 }
11348
11349 return new_item;
11350 }
11351 }
11352
11353 return null;
11354 }
11355
11356 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
11357 {
11358 float quantity = GetQuantity();
11359 float split_quantity_new;
11360 ItemBase new_item;
11361 if (destination_entity)
11362 {
11363 float stackable = GetTargetQuantityMax();
11364 if (quantity > stackable)
11365 split_quantity_new = stackable;
11366 else
11367 split_quantity_new = quantity;
11368
11369 if (ShouldSplitQuantity(split_quantity_new))
11370 {
11371 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
11372 if (new_item)
11373 {
11374 new_item.SetResultOfSplit(true);
11375 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11376 AddQuantity(-split_quantity_new, false, true);
11377 new_item.SetQuantity(split_quantity_new, false, true);
11378 }
11379 }
11380 }
11381 }
11382
11383 void SplitIntoStackMaxHandsClient(PlayerBase player)
11384 {
11385 if (g_Game.IsClient())
11386 {
11387 if (ScriptInputUserData.CanStoreInputUserData())
11388 {
11389 ScriptInputUserData ctx = new ScriptInputUserData;
11391 ctx.Write(3);
11392 ItemBase i1 = this; // @NOTE: workaround for correct serialization
11393 ctx.Write(i1);
11394 ItemBase destination_entity = this;
11395 ctx.Write(destination_entity);
11396 ctx.Write(true);
11397 ctx.Write(0);
11398 ctx.Send();
11399 }
11400 }
11401 else if (!g_Game.IsMultiplayer())
11402 {
11403 SplitIntoStackMaxHands(player);
11404 }
11405 }
11406
11407 void SplitIntoStackMaxHands(PlayerBase player)
11408 {
11409 float quantity = GetQuantity();
11410 float split_quantity_new;
11411 ref ItemBase new_item;
11412 if (player)
11413 {
11414 float stackable = GetTargetQuantityMax();
11415 if (quantity > stackable)
11416 split_quantity_new = stackable;
11417 else
11418 split_quantity_new = quantity;
11419
11420 if (ShouldSplitQuantity(split_quantity_new))
11421 {
11422 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
11423 new_item = ItemBase.Cast(in_hands);
11424 if (new_item)
11425 {
11426 new_item.SetResultOfSplit(true);
11427 MiscGameplayFunctions.TransferItemProperties(this,new_item);
11428 AddQuantity(-split_quantity_new, false, true);
11429 new_item.SetQuantity(split_quantity_new, false, true);
11430 }
11431 }
11432 }
11433 }
11434
11435 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
11436 {
11437 float quantity = GetQuantity();
11438 float split_quantity_new = Math.Floor(quantity * 0.5);
11439
11440 if (!ShouldSplitQuantity(split_quantity_new))
11441 return;
11442
11443 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
11444
11445 if (new_item)
11446 {
11447 if (new_item.GetQuantityMax() < split_quantity_new)
11448 {
11449 split_quantity_new = new_item.GetQuantityMax();
11450 }
11451
11452 new_item.SetResultOfSplit(true);
11453 MiscGameplayFunctions.TransferItemProperties(this, new_item);
11454
11455 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11456 {
11457 AddQuantity(-1, false, true);
11458 new_item.SetQuantity(1, false, true);
11459 }
11460 else
11461 {
11462 AddQuantity(-split_quantity_new, false, true);
11463 new_item.SetQuantity(split_quantity_new, false, true);
11464 }
11465 }
11466 }
11467
11468 void SplitItem(PlayerBase player)
11469 {
11470 float quantity = GetQuantity();
11471 float split_quantity_new = Math.Floor(quantity / 2);
11472
11473 if (!ShouldSplitQuantity(split_quantity_new))
11474 return;
11475
11476 InventoryLocation invloc = new InventoryLocation;
11477 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
11478
11479 ItemBase new_item;
11480 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
11481
11482 if (new_item)
11483 {
11484 if (new_item.GetQuantityMax() < split_quantity_new)
11485 {
11486 split_quantity_new = new_item.GetQuantityMax();
11487 }
11488 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
11489 {
11490 AddQuantity(-1, false, true);
11491 new_item.SetQuantity(1, false, true);
11492 }
11493 else if (split_quantity_new > 1)
11494 {
11495 AddQuantity(-split_quantity_new, false, true);
11496 new_item.SetQuantity(split_quantity_new, false, true);
11497 }
11498 }
11499 }
11500
11502 void OnQuantityChanged(float delta)
11503 {
11504 SetWeightDirty();
11505 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
11506
11507 if (parent)
11508 parent.OnAttachmentQuantityChangedEx(this, delta);
11509
11510 if (IsLiquidContainer())
11511 {
11512 if (GetQuantityNormalized() <= 0.0)
11513 {
11515 }
11516 else if (GetLiquidType() == LIQUID_NONE)
11517 {
11518 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
11520 }
11521 }
11522 }
11523
11526 {
11527 // insert code here
11528 }
11529
11531 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
11532 {
11534 }
11535
11536 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
11537 {
11538 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
11539
11540 if (g_Game.IsServer())
11541 {
11542 if (newLevel == GameConstants.STATE_RUINED)
11543 {
11545 EntityAI parent = GetHierarchyParent();
11546 if (parent && parent.IsFireplace())
11547 {
11548 CargoBase cargo = GetInventory().GetCargo();
11549 if (cargo)
11550 {
11551 for (int i = 0; i < cargo.GetItemCount(); ++i)
11552 {
11553 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
11554 }
11555 }
11556 }
11557 }
11558
11559 if (IsResultOfSplit())
11560 {
11561 // reset the splitting result flag, return to normal item behavior
11562 SetResultOfSplit(false);
11563 return;
11564 }
11565
11566 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
11567 {
11568 SetCleanness(0);//unclean the item upon damage dealt
11569 }
11570 }
11571 }
11572
11573 // just the split? TODO: verify
11574 override void OnRightClick()
11575 {
11576 super.OnRightClick();
11577
11578 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
11579 {
11580 if (g_Game.IsClient())
11581 {
11582 if (ScriptInputUserData.CanStoreInputUserData())
11583 {
11584 EntityAI root = GetHierarchyRoot();
11585 Man playerOwner = GetHierarchyRootPlayer();
11586 InventoryLocation dst = new InventoryLocation;
11587
11588 // 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
11589 if (!playerOwner && root && root == this)
11590 {
11592 }
11593 else
11594 {
11595 // 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
11596 GetInventory().GetCurrentInventoryLocation(dst);
11597 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
11598 {
11599 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
11600 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
11601 {
11603 }
11604 else
11605 {
11606 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
11607 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
11608 this shouldnt cause issues within this scope*/
11609 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
11610 {
11612 }
11613 else
11614 {
11615 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
11616 }
11617 }
11618 }
11619 }
11620
11621 ScriptInputUserData ctx = new ScriptInputUserData;
11623 ctx.Write(4);
11624 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11625 ctx.Write(thiz);
11626 dst.WriteToContext(ctx);
11627 ctx.Write(true); // dummy
11628 ctx.Send();
11629 }
11630 }
11631 else if (!g_Game.IsMultiplayer())
11632 {
11633 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
11634 }
11635 }
11636 }
11637
11638 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11639 {
11640 if (root)
11641 {
11642 vector m4[4];
11643 root.GetTransform(m4);
11644 dst.SetGround(this, m4);
11645 }
11646 else
11647 {
11648 GetInventory().GetCurrentInventoryLocation(dst);
11649 }
11650 }
11651
11652 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11653 {
11654 //TODO: delete check zero quantity check after fix double posts hands fsm events
11655 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11656 return false;
11657
11658 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11659 return false;
11660
11661 //can_this_be_combined = ConfigGetBool("canBeSplit");
11663 return false;
11664
11665
11666 Magazine mag = Magazine.Cast(this);
11667 if (mag)
11668 {
11669 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11670 return false;
11671
11672 if (stack_max_limit)
11673 {
11674 Magazine other_mag = Magazine.Cast(other_item);
11675 if (other_item)
11676 {
11677 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11678 return false;
11679 }
11680
11681 }
11682 }
11683 else
11684 {
11685 //TODO: delete check zero quantity check after fix double posts hands fsm events
11686 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11687 return false;
11688
11689 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11690 return false;
11691 }
11692
11693 PlayerBase player = null;
11694 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11695 {
11696 if (player.GetInventory().HasAttachment(this))
11697 return false;
11698
11699 if (player.IsItemsToDelete())
11700 return false;
11701 }
11702
11703 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11704 return false;
11705
11706 int slotID;
11707 string slotName;
11708 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11709 return false;
11710
11711 return true;
11712 }
11713
11714 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11715 {
11716 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11717 }
11718
11719 bool IsResultOfSplit()
11720 {
11721 return m_IsResultOfSplit;
11722 }
11723
11724 void SetResultOfSplit(bool value)
11725 {
11726 m_IsResultOfSplit = value;
11727 }
11728
11729 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11730 {
11731 return ComputeQuantityUsedEx(other_item, use_stack_max);
11732 }
11733
11734 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11735 {
11736 float other_item_quantity = other_item.GetQuantity();
11737 float this_free_space;
11738
11739 float stack_max = GetQuantityMax();
11740
11741 this_free_space = stack_max - GetQuantity();
11742
11743 if (other_item_quantity > this_free_space)
11744 {
11745 return this_free_space;
11746 }
11747 else
11748 {
11749 return other_item_quantity;
11750 }
11751 }
11752
11753 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11754 {
11755 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11756 }
11757
11758 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11759 {
11760 if (!CanBeCombined(other_item, false))
11761 return;
11762
11763 if (!IsMagazine() && other_item)
11764 {
11765 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11766 if (quantity_used != 0)
11767 {
11768 float hp1 = GetHealth01("","");
11769 float hp2 = other_item.GetHealth01("","");
11770 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11771 hpResult = hpResult / (GetQuantity() + quantity_used);
11772
11773 hpResult *= GetMaxHealth();
11774 Math.Round(hpResult);
11775 SetHealth("", "Health", hpResult);
11776
11777 AddQuantity(quantity_used);
11778 other_item.AddQuantity(-quantity_used);
11779 }
11780 }
11781 OnCombine(other_item);
11782 }
11783
11784 void OnCombine(ItemBase other_item)
11785 {
11786 #ifdef SERVER
11787 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11788 GetHierarchyParent().IncreaseLifetimeUp();
11789 #endif
11790 };
11791
11792 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11793 {
11794 PlayerBase p = PlayerBase.Cast(player);
11795
11796 array<int> recipesIds = p.m_Recipes;
11797 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11798 if (moduleRecipesManager)
11799 {
11800 EntityAI itemInHands = player.GetEntityInHands();
11801 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11802 }
11803
11804 for (int i = 0;i < recipesIds.Count(); i++)
11805 {
11806 int key = recipesIds.Get(i);
11807 string recipeName = moduleRecipesManager.GetRecipeName(key);
11808 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11809 }
11810 }
11811
11812 // -------------------------------------------------------------------------
11813 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11814 {
11815 super.GetDebugActions(outputList);
11816
11817 //quantity
11818 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11819 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11820 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11821 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11822 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11823
11824 //health
11825 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11826 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11827 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11828 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11829 //temperature
11830 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11831 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11832 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11833 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11834
11835 //wet
11836 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11837 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11838 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11839
11840 //liquidtype
11841 if (IsLiquidContainer())
11842 {
11843 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11844 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11845 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11846 }
11847
11848 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11849 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11850
11851 // watch
11852 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11853 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11854 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11855
11856 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11857
11858 InventoryLocation loc = new InventoryLocation();
11859 GetInventory().GetCurrentInventoryLocation(loc);
11860 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11861 {
11862 if (Gizmo_IsSupported())
11863 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11864 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11865 }
11866
11867 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11868 }
11869
11870 // -------------------------------------------------------------------------
11871 // -------------------------------------------------------------------------
11872 // -------------------------------------------------------------------------
11873 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11874 {
11875 super.OnAction(action_id, player, ctx);
11876
11877 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
11878 {
11879 switch (action_id)
11880 {
11881 case EActions.GIZMO_OBJECT:
11882 if (GetGizmoApi())
11883 GetGizmoApi().SelectObject(this);
11884 return true;
11885 case EActions.GIZMO_PHYSICS:
11886 if (GetGizmoApi())
11887 GetGizmoApi().SelectPhysics(GetPhysics());
11888 return true;
11889 }
11890 }
11891
11892 if (g_Game.IsServer())
11893 {
11894 switch (action_id)
11895 {
11896 case EActions.DELETE:
11897 Delete();
11898 return true;
11899 }
11900 }
11901
11902 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11903 {
11904 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11905 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11906 PlayerBase p = PlayerBase.Cast(player);
11907 if (EActions.RECIPES_RANGE_START < 1000)
11908 {
11909 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11910 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11911 }
11912 }
11913 #ifndef SERVER
11914 else if (action_id == EActions.WATCH_PLAYER)
11915 {
11916 PluginDeveloper.SetDeveloperItemClientEx(player);
11917 }
11918 #endif
11919 if (g_Game.IsServer())
11920 {
11921 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11922 {
11923 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11924 OnDebugButtonPressServer(id + 1);
11925 }
11926
11927 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11928 {
11929 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11930 InsertAgent(agent_id,100);
11931 }
11932
11933 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11934 {
11935 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11936 RemoveAgent(agent_id2);
11937 }
11938
11939 else if (action_id == EActions.ADD_QUANTITY)
11940 {
11941 if (IsMagazine())
11942 {
11943 Magazine mag = Magazine.Cast(this);
11944 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11945 }
11946 else
11947 {
11948 AddQuantity(GetQuantityMax() * 0.2);
11949 }
11950
11951 if (m_EM)
11952 {
11953 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11954 }
11955 //PrintVariables();
11956 }
11957
11958 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11959 {
11960 if (IsMagazine())
11961 {
11962 Magazine mag2 = Magazine.Cast(this);
11963 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11964 }
11965 else
11966 {
11967 AddQuantity(- GetQuantityMax() * 0.2);
11968 }
11969 if (m_EM)
11970 {
11971 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11972 }
11973 //PrintVariables();
11974 }
11975
11976 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11977 {
11978 SetQuantity(0);
11979
11980 if (m_EM)
11981 {
11982 m_EM.SetEnergy(0);
11983 }
11984 }
11985
11986 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11987 {
11989
11990 if (m_EM)
11991 {
11992 m_EM.SetEnergy(m_EM.GetEnergyMax());
11993 }
11994 }
11995
11996 else if (action_id == EActions.ADD_HEALTH)
11997 {
11998 AddHealth("","",GetMaxHealth("","Health")/5);
11999 }
12000 else if (action_id == EActions.REMOVE_HEALTH)
12001 {
12002 AddHealth("","",-GetMaxHealth("","Health")/5);
12003 }
12004 else if (action_id == EActions.DESTROY_HEALTH)
12005 {
12006 SetHealth01("","",0);
12007 }
12008 else if (action_id == EActions.WATCH_ITEM)
12009 {
12011 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
12012 #ifdef DEVELOPER
12013 SetDebugDeveloper_item(this);
12014 #endif
12015 }
12016
12017 else if (action_id == EActions.ADD_TEMPERATURE)
12018 {
12019 AddTemperature(20);
12020 //PrintVariables();
12021 }
12022
12023 else if (action_id == EActions.REMOVE_TEMPERATURE)
12024 {
12025 AddTemperature(-20);
12026 //PrintVariables();
12027 }
12028
12029 else if (action_id == EActions.FLIP_FROZEN)
12030 {
12031 SetFrozen(!GetIsFrozen());
12032 //PrintVariables();
12033 }
12034
12035 else if (action_id == EActions.ADD_WETNESS)
12036 {
12037 AddWet(GetWetMax()/5);
12038 //PrintVariables();
12039 }
12040
12041 else if (action_id == EActions.REMOVE_WETNESS)
12042 {
12043 AddWet(-GetWetMax()/5);
12044 //PrintVariables();
12045 }
12046
12047 else if (action_id == EActions.LIQUIDTYPE_UP)
12048 {
12049 int curr_type = GetLiquidType();
12050 SetLiquidType(curr_type * 2);
12051 //AddWet(1);
12052 //PrintVariables();
12053 }
12054
12055 else if (action_id == EActions.LIQUIDTYPE_DOWN)
12056 {
12057 int curr_type2 = GetLiquidType();
12058 SetLiquidType(curr_type2 / 2);
12059 }
12060
12061 else if (action_id == EActions.MAKE_SPECIAL)
12062 {
12063 auto debugParams = DebugSpawnParams.WithPlayer(player);
12064 OnDebugSpawnEx(debugParams);
12065 }
12066
12067 }
12068
12069
12070 return false;
12071 }
12072
12073 // -------------------------------------------------------------------------
12074
12075
12078 void OnActivatedByTripWire();
12079
12081 void OnActivatedByItem(notnull ItemBase item);
12082
12083 //----------------------------------------------------------------
12084 //returns true if item is able to explode when put in fire
12085 bool CanExplodeInFire()
12086 {
12087 return false;
12088 }
12089
12090 //----------------------------------------------------------------
12091 bool CanEat()
12092 {
12093 return true;
12094 }
12095
12096 //----------------------------------------------------------------
12097 override bool IsIgnoredByConstruction()
12098 {
12099 return true;
12100 }
12101
12102 //----------------------------------------------------------------
12103 //has FoodStages in config?
12104 bool HasFoodStage()
12105 {
12106 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
12107 return g_Game.ConfigIsExisting(config_path);
12108 }
12109
12111 FoodStage GetFoodStage()
12112 {
12113 return null;
12114 }
12115
12116 bool CanBeCooked()
12117 {
12118 return false;
12119 }
12120
12121 bool CanBeCookedOnStick()
12122 {
12123 return false;
12124 }
12125
12127 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
12129
12130 //----------------------------------------------------------------
12131 bool CanRepair(ItemBase item_repair_kit)
12132 {
12133 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
12134 return module_repairing.CanRepair(this, item_repair_kit);
12135 }
12136
12137 //----------------------------------------------------------------
12138 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
12139 {
12140 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
12141 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
12142 }
12143
12144 //----------------------------------------------------------------
12145 int GetItemSize()
12146 {
12147 /*
12148 vector v_size = this.ConfigGetVector("itemSize");
12149 int v_size_x = v_size[0];
12150 int v_size_y = v_size[1];
12151 int size = v_size_x * v_size_y;
12152 return size;
12153 */
12154
12155 return 1;
12156 }
12157
12158 //----------------------------------------------------------------
12159 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
12160 bool CanBeMovedOverride()
12161 {
12162 return m_CanBeMovedOverride;
12163 }
12164
12165 //----------------------------------------------------------------
12166 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
12167 void SetCanBeMovedOverride(bool setting)
12168 {
12169 m_CanBeMovedOverride = setting;
12170 }
12171
12172 //----------------------------------------------------------------
12180 void MessageToOwnerStatus(string text)
12181 {
12182 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12183
12184 if (player)
12185 {
12186 player.MessageStatus(text);
12187 }
12188 }
12189
12190 //----------------------------------------------------------------
12198 void MessageToOwnerAction(string text)
12199 {
12200 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12201
12202 if (player)
12203 {
12204 player.MessageAction(text);
12205 }
12206 }
12207
12208 //----------------------------------------------------------------
12216 void MessageToOwnerFriendly(string text)
12217 {
12218 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12219
12220 if (player)
12221 {
12222 player.MessageFriendly(text);
12223 }
12224 }
12225
12226 //----------------------------------------------------------------
12234 void MessageToOwnerImportant(string text)
12235 {
12236 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
12237
12238 if (player)
12239 {
12240 player.MessageImportant(text);
12241 }
12242 }
12243
12244 override bool IsItemBase()
12245 {
12246 return true;
12247 }
12248
12249 // Checks if item is of questioned kind
12250 override bool KindOf(string tag)
12251 {
12252 bool found = false;
12253 string item_name = this.GetType();
12254 ref TStringArray item_tag_array = new TStringArray;
12255 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
12256
12257 int array_size = item_tag_array.Count();
12258 for (int i = 0; i < array_size; i++)
12259 {
12260 if (item_tag_array.Get(i) == tag)
12261 {
12262 found = true;
12263 break;
12264 }
12265 }
12266 return found;
12267 }
12268
12269
12270 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
12271 {
12272 //Debug.Log("OnRPC called");
12273 super.OnRPC(sender, rpc_type,ctx);
12274
12275 //Play soundset for attachment locking (ActionLockAttachment.c)
12276 switch (rpc_type)
12277 {
12278 #ifndef SERVER
12279 case ERPCs.RPC_SOUND_LOCK_ATTACH:
12280 Param2<bool, string> p = new Param2<bool, string>(false, "");
12281
12282 if (!ctx.Read(p))
12283 return;
12284
12285 bool play = p.param1;
12286 string soundSet = p.param2;
12287
12288 if (play)
12289 {
12290 if (m_LockingSound)
12291 {
12293 {
12294 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
12295 }
12296 }
12297 else
12298 {
12299 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
12300 }
12301 }
12302 else
12303 {
12304 SEffectManager.DestroyEffect(m_LockingSound);
12305 }
12306
12307 break;
12308 #endif
12309
12310 }
12311
12312 if (GetWrittenNoteData())
12313 {
12314 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
12315 }
12316 }
12317
12318 //-----------------------------
12319 // VARIABLE MANIPULATION SYSTEM
12320 //-----------------------------
12321 int NameToID(string name)
12322 {
12323 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
12324 return plugin.GetID(name);
12325 }
12326
12327 string IDToName(int id)
12328 {
12329 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
12330 return plugin.GetName(id);
12331 }
12332
12334 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
12335 {
12336 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
12337 //read the flags
12338 int varFlags;
12339 if (!ctx.Read(varFlags))
12340 return;
12341
12342 if (varFlags & ItemVariableFlags.FLOAT)
12343 {
12344 ReadVarsFromCTX(ctx);
12345 }
12346 }
12347
12348 override void SerializeNumericalVars(array<float> floats_out)
12349 {
12350 //some variables handled on EntityAI level already!
12351 super.SerializeNumericalVars(floats_out);
12352
12353 // the order of serialization must be the same as the order of de-serialization
12354 //--------------------------------------------
12355 if (IsVariableSet(VARIABLE_QUANTITY))
12356 {
12357 floats_out.Insert(m_VarQuantity);
12358 }
12359 //--------------------------------------------
12360 if (IsVariableSet(VARIABLE_WET))
12361 {
12362 floats_out.Insert(m_VarWet);
12363 }
12364 //--------------------------------------------
12365 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12366 {
12367 floats_out.Insert(m_VarLiquidType);
12368 }
12369 //--------------------------------------------
12370 if (IsVariableSet(VARIABLE_COLOR))
12371 {
12372 floats_out.Insert(m_ColorComponentR);
12373 floats_out.Insert(m_ColorComponentG);
12374 floats_out.Insert(m_ColorComponentB);
12375 floats_out.Insert(m_ColorComponentA);
12376 }
12377 //--------------------------------------------
12378 if (IsVariableSet(VARIABLE_CLEANNESS))
12379 {
12380 floats_out.Insert(m_Cleanness);
12381 }
12382 }
12383
12384 override void DeSerializeNumericalVars(array<float> floats)
12385 {
12386 //some variables handled on EntityAI level already!
12387 super.DeSerializeNumericalVars(floats);
12388
12389 // the order of serialization must be the same as the order of de-serialization
12390 int index = 0;
12391 int mask = Math.Round(floats.Get(index));
12392
12393 index++;
12394 //--------------------------------------------
12395 if (mask & VARIABLE_QUANTITY)
12396 {
12397 if (m_IsStoreLoad)
12398 {
12399 SetStoreLoadedQuantity(floats.Get(index));
12400 }
12401 else
12402 {
12403 float quantity = floats.Get(index);
12404 SetQuantity(quantity, true, false, false, false);
12405 }
12406 index++;
12407 }
12408 //--------------------------------------------
12409 if (mask & VARIABLE_WET)
12410 {
12411 float wet = floats.Get(index);
12412 SetWet(wet);
12413 index++;
12414 }
12415 //--------------------------------------------
12416 if (mask & VARIABLE_LIQUIDTYPE)
12417 {
12418 int liquidtype = Math.Round(floats.Get(index));
12419 SetLiquidType(liquidtype);
12420 index++;
12421 }
12422 //--------------------------------------------
12423 if (mask & VARIABLE_COLOR)
12424 {
12425 m_ColorComponentR = Math.Round(floats.Get(index));
12426 index++;
12427 m_ColorComponentG = Math.Round(floats.Get(index));
12428 index++;
12429 m_ColorComponentB = Math.Round(floats.Get(index));
12430 index++;
12431 m_ColorComponentA = Math.Round(floats.Get(index));
12432 index++;
12433 }
12434 //--------------------------------------------
12435 if (mask & VARIABLE_CLEANNESS)
12436 {
12437 int cleanness = Math.Round(floats.Get(index));
12438 SetCleanness(cleanness);
12439 index++;
12440 }
12441 }
12442
12443 override void WriteVarsToCTX(ParamsWriteContext ctx)
12444 {
12445 super.WriteVarsToCTX(ctx);
12446
12447 //--------------------------------------------
12448 if (IsVariableSet(VARIABLE_QUANTITY))
12449 {
12450 ctx.Write(GetQuantity());
12451 }
12452 //--------------------------------------------
12453 if (IsVariableSet(VARIABLE_WET))
12454 {
12455 ctx.Write(GetWet());
12456 }
12457 //--------------------------------------------
12458 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
12459 {
12460 ctx.Write(GetLiquidType());
12461 }
12462 //--------------------------------------------
12463 if (IsVariableSet(VARIABLE_COLOR))
12464 {
12465 int r,g,b,a;
12466 GetColor(r,g,b,a);
12467 ctx.Write(r);
12468 ctx.Write(g);
12469 ctx.Write(b);
12470 ctx.Write(a);
12471 }
12472 //--------------------------------------------
12473 if (IsVariableSet(VARIABLE_CLEANNESS))
12474 {
12475 ctx.Write(GetCleanness());
12476 }
12477 }
12478
12479 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
12480 {
12481 if (!super.ReadVarsFromCTX(ctx,version))
12482 return false;
12483
12484 int intValue;
12485 float value;
12486
12487 if (version < 140)
12488 {
12489 if (!ctx.Read(intValue))
12490 return false;
12491
12492 m_VariablesMask = intValue;
12493 }
12494
12495 if (m_VariablesMask & VARIABLE_QUANTITY)
12496 {
12497 if (!ctx.Read(value))
12498 return false;
12499
12500 if (IsStoreLoad())
12501 {
12503 }
12504 else
12505 {
12506 SetQuantity(value, true, false, false, false);
12507 }
12508 }
12509 //--------------------------------------------
12510 if (version < 140)
12511 {
12512 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12513 {
12514 if (!ctx.Read(value))
12515 return false;
12516 SetTemperatureDirect(value);
12517 }
12518 }
12519 //--------------------------------------------
12520 if (m_VariablesMask & VARIABLE_WET)
12521 {
12522 if (!ctx.Read(value))
12523 return false;
12524 SetWet(value);
12525 }
12526 //--------------------------------------------
12527 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
12528 {
12529 if (!ctx.Read(intValue))
12530 return false;
12531 SetLiquidType(intValue);
12532 }
12533 //--------------------------------------------
12534 if (m_VariablesMask & VARIABLE_COLOR)
12535 {
12536 int r,g,b,a;
12537 if (!ctx.Read(r))
12538 return false;
12539 if (!ctx.Read(g))
12540 return false;
12541 if (!ctx.Read(b))
12542 return false;
12543 if (!ctx.Read(a))
12544 return false;
12545
12546 SetColor(r,g,b,a);
12547 }
12548 //--------------------------------------------
12549 if (m_VariablesMask & VARIABLE_CLEANNESS)
12550 {
12551 if (!ctx.Read(intValue))
12552 return false;
12553 SetCleanness(intValue);
12554 }
12555 //--------------------------------------------
12556 if (version >= 138 && version < 140)
12557 {
12558 if (m_VariablesMask & VARIABLE_TEMPERATURE)
12559 {
12560 if (!ctx.Read(intValue))
12561 return false;
12562 SetFrozen(intValue);
12563 }
12564 }
12565
12566 return true;
12567 }
12568
12569 //----------------------------------------------------------------
12570 override bool OnStoreLoad(ParamsReadContext ctx, int version)
12571 {
12572 m_IsStoreLoad = true;
12574 {
12575 m_FixDamageSystemInit = true;
12576 }
12577
12578 if (!super.OnStoreLoad(ctx, version))
12579 {
12580 m_IsStoreLoad = false;
12581 return false;
12582 }
12583
12584 if (version >= 114)
12585 {
12586 bool hasQuickBarIndexSaved;
12587
12588 if (!ctx.Read(hasQuickBarIndexSaved))
12589 {
12590 m_IsStoreLoad = false;
12591 return false;
12592 }
12593
12594 if (hasQuickBarIndexSaved)
12595 {
12596 int itmQBIndex;
12597
12598 //Load quickbar item bind
12599 if (!ctx.Read(itmQBIndex))
12600 {
12601 m_IsStoreLoad = false;
12602 return false;
12603 }
12604
12605 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
12606 if (itmQBIndex != -1 && parentPlayer)
12607 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
12608 }
12609 }
12610 else
12611 {
12612 // Backup of how it used to be
12613 PlayerBase player;
12614 int itemQBIndex;
12615 if (version == int.MAX)
12616 {
12617 if (!ctx.Read(itemQBIndex))
12618 {
12619 m_IsStoreLoad = false;
12620 return false;
12621 }
12622 }
12623 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12624 {
12625 //Load quickbar item bind
12626 if (!ctx.Read(itemQBIndex))
12627 {
12628 m_IsStoreLoad = false;
12629 return false;
12630 }
12631 if (itemQBIndex != -1 && player)
12632 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12633 }
12634 }
12635
12636 if (version < 140)
12637 {
12638 // variable management system
12639 if (!LoadVariables(ctx, version))
12640 {
12641 m_IsStoreLoad = false;
12642 return false;
12643 }
12644 }
12645
12646 //agent trasmission system
12647 if (!LoadAgents(ctx, version))
12648 {
12649 m_IsStoreLoad = false;
12650 return false;
12651 }
12652 if (version >= 132)
12653 {
12654 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12655 if (raib)
12656 {
12657 if (!raib.OnStoreLoad(ctx,version))
12658 {
12659 m_IsStoreLoad = false;
12660 return false;
12661 }
12662 }
12663 }
12664
12665 m_IsStoreLoad = false;
12666 return true;
12667 }
12668
12669 //----------------------------------------------------------------
12670
12671 override void OnStoreSave(ParamsWriteContext ctx)
12672 {
12673 super.OnStoreSave(ctx);
12674
12675 PlayerBase player;
12676 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12677 {
12678 ctx.Write(true); // Keep track of if we should actually read this in or not
12679 //Save quickbar item bind
12680 int itemQBIndex = -1;
12681 itemQBIndex = player.FindQuickBarEntityIndex(this);
12682 ctx.Write(itemQBIndex);
12683 }
12684 else
12685 {
12686 ctx.Write(false); // Keep track of if we should actually read this in or not
12687 }
12688
12689 SaveAgents(ctx);//agent trasmission system
12690
12691 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12692 if (raib)
12693 {
12694 raib.OnStoreSave(ctx);
12695 }
12696 }
12697 //----------------------------------------------------------------
12698
12699 override void AfterStoreLoad()
12700 {
12701 super.AfterStoreLoad();
12702
12704 {
12706 }
12707
12708 if (GetStoreLoadedQuantity() != float.LOWEST)
12709 {
12711 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
12712 }
12713 }
12714
12715 override void EEOnAfterLoad()
12716 {
12717 super.EEOnAfterLoad();
12718
12720 {
12721 m_FixDamageSystemInit = false;
12722 }
12723
12726 }
12727
12728 bool CanBeDisinfected()
12729 {
12730 return false;
12731 }
12732
12733
12734 //----------------------------------------------------------------
12735 override void OnVariablesSynchronized()
12736 {
12737 if (m_Initialized)
12738 {
12739 #ifdef PLATFORM_CONSOLE
12740 //bruteforce it is
12741 if (IsSplitable())
12742 {
12743 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
12744 if (menu)
12745 {
12746 menu.Refresh();
12747 }
12748 }
12749 #endif
12750 }
12751
12753 {
12754 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12755 m_WantPlayImpactSound = false;
12756 }
12757
12759 {
12760 SetWeightDirty();
12762 }
12763 if (m_VarWet != m_VarWetPrev)
12764 {
12767 }
12768
12769 if (m_SoundSyncPlay != 0)
12770 {
12773
12774 m_SoundSyncPlay = 0;
12775 m_SoundSyncSlotID = -1;
12776 }
12777 if (m_SoundSyncStop != 0)
12778 {
12780 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12781 m_SoundSyncStop = 0;
12782 }
12783
12784 super.OnVariablesSynchronized();
12785 }
12786
12787 //------------------------- Quantity
12788 //----------------------------------------------------------------
12790 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12791 {
12792 if (!IsServerCheck(allow_client))
12793 return false;
12794
12795 if (!HasQuantity())
12796 return false;
12797
12798 float min = GetQuantityMin();
12799 float max = GetQuantityMax();
12800
12801 if (value <= (min + 0.001))
12802 value = min;
12803
12804 if (value == min)
12805 {
12806 if (destroy_config)
12807 {
12808 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12809 if (dstr)
12810 {
12811 m_VarQuantity = Math.Clamp(value, min, max);
12812 this.Delete();
12813 return true;
12814 }
12815 }
12816 else if (destroy_forced)
12817 {
12818 m_VarQuantity = Math.Clamp(value, min, max);
12819 this.Delete();
12820 return true;
12821 }
12822 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12823 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12824 }
12825
12826 float delta = m_VarQuantity;
12827 m_VarQuantity = Math.Clamp(value, min, max);
12828
12829 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12830 {
12831 EntityAI parent = GetHierarchyRoot();
12832 InventoryLocation iLoc = new InventoryLocation();
12833 GetInventory().GetCurrentInventoryLocation(iLoc);
12834 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
12835 {
12836 int iLocSlot = iLoc.GetSlot();
12837 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
12838 {
12839 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
12840 }
12841 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
12842 {
12843 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
12844 }
12845 }
12846 }
12847
12848 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12849 {
12850 delta = m_VarQuantity - delta;
12851
12852 if (delta)
12853 OnQuantityChanged(delta);
12854 }
12855
12856 SetVariableMask(VARIABLE_QUANTITY);
12857
12858 return false;
12859 }
12860
12861 //----------------------------------------------------------------
12863 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12864 {
12865 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12866 }
12867 //----------------------------------------------------------------
12868 void SetQuantityMax()
12869 {
12870 float max = GetQuantityMax();
12871 SetQuantity(max);
12872 }
12873
12874 override void SetQuantityToMinimum()
12875 {
12876 float min = GetQuantityMin();
12877 SetQuantity(min);
12878 }
12879 //----------------------------------------------------------------
12881 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12882 {
12883 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12884 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12885 SetQuantity(result, destroy_config, destroy_forced);
12886 }
12887
12888 //----------------------------------------------------------------
12890 override float GetQuantityNormalized()
12891 {
12892 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12893 }
12894
12896 {
12897 return GetQuantityNormalized();
12898 }
12899
12900 /*void SetAmmoNormalized(float value)
12901 {
12902 float value_clamped = Math.Clamp(value, 0, 1);
12903 Magazine this_mag = Magazine.Cast(this);
12904 int max_rounds = this_mag.GetAmmoMax();
12905 int result = value * max_rounds;//can the rounded if higher precision is required
12906 this_mag.SetAmmoCount(result);
12907 }*/
12908 //----------------------------------------------------------------
12909 override int GetQuantityMax()
12910 {
12911 int slot = -1;
12912 GameInventory inventory = GetInventory();
12913 if (inventory)
12914 {
12915 InventoryLocation il = new InventoryLocation;
12916 inventory.GetCurrentInventoryLocation(il);
12917 slot = il.GetSlot();
12918 }
12919
12920 return GetTargetQuantityMax(slot);
12921 }
12922
12923 override int GetTargetQuantityMax(int attSlotID = -1)
12924 {
12925 float quantity_max = 0;
12926
12927 if (IsSplitable()) //only stackable/splitable items can check for stack size
12928 {
12929 if (attSlotID != -1)
12930 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12931
12932 if (quantity_max <= 0)
12933 quantity_max = m_VarStackMax;
12934 }
12935
12936 if (quantity_max <= 0)
12937 quantity_max = m_VarQuantityMax;
12938
12939 return quantity_max;
12940 }
12941 //----------------------------------------------------------------
12942 override int GetQuantityMin()
12943 {
12944 return m_VarQuantityMin;
12945 }
12946 //----------------------------------------------------------------
12947 int GetQuantityInit()
12948 {
12949 return m_VarQuantityInit;
12950 }
12951
12952 //----------------------------------------------------------------
12953 override bool HasQuantity()
12954 {
12955 return !(GetQuantityMax() - GetQuantityMin() == 0);
12956 }
12957
12958 override float GetQuantity()
12959 {
12960 return m_VarQuantity;
12961 }
12962
12963 bool IsFullQuantity()
12964 {
12965 return GetQuantity() >= GetQuantityMax();
12966 }
12967
12968 //Calculates weight of single item without attachments and cargo
12969 override float GetSingleInventoryItemWeightEx()
12970 {
12971 //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
12972 float weightEx = GetWeightEx();//overall weight of the item
12973 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12974 return weightEx - special;
12975 }
12976
12977 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12979 {
12981 }
12982
12983 override protected float GetWeightSpecialized(bool forceRecalc = false)
12984 {
12985 if (IsSplitable()) //quantity determines size of the stack
12986 {
12987 #ifdef DEVELOPER
12988 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12989 {
12990 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12991 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12992 }
12993 #endif
12994
12995 return GetQuantity() * GetConfigWeightModified();
12996 }
12997 else if (HasEnergyManager())// items with energy manager
12998 {
12999 #ifdef DEVELOPER
13000 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
13001 {
13002 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
13003 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
13004 }
13005 #endif
13006 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
13007 }
13008 else//everything else
13009 {
13010 #ifdef DEVELOPER
13011 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
13012 {
13013 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
13014 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
13015 }
13016 #endif
13017 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
13018 }
13019 }
13020
13022 int GetNumberOfItems()
13023 {
13024 int item_count = 0;
13025 ItemBase item;
13026
13027 GameInventory inventory = GetInventory();
13028 CargoBase cargo = inventory.GetCargo();
13029 if (cargo != NULL)
13030 {
13031 item_count = cargo.GetItemCount();
13032 }
13033
13034 int nAttachments = inventory.AttachmentCount();
13035 for (int i = 0; i < nAttachments; ++i)
13036 {
13037 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
13038 if (item)
13039 item_count += item.GetNumberOfItems();
13040 }
13041 return item_count;
13042 }
13043
13045 float GetUnitWeight(bool include_wetness = true)
13046 {
13047 float weight = 0;
13048 float wetness = 1;
13049 if (include_wetness)
13050 wetness += GetWet();
13051 if (IsSplitable()) //quantity determines size of the stack
13052 {
13053 weight = wetness * m_ConfigWeight;
13054 }
13055 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
13056 {
13057 weight = 1;
13058 }
13059 return weight;
13060 }
13061
13062 //-----------------------------------------------------------------
13063
13064 override void ClearInventory()
13065 {
13066 GameInventory inventory = GetInventory();
13067 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
13068 {
13069 array<EntityAI> items = new array<EntityAI>;
13070 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
13071 for (int i = 0; i < items.Count(); ++i)
13072 {
13073 ItemBase item = ItemBase.Cast(items.Get(i));
13074 if (item)
13075 {
13076 g_Game.ObjectDelete(item);
13077 }
13078 }
13079 }
13080 }
13081
13082 //------------------------- Energy
13083
13084 //----------------------------------------------------------------
13085 float GetEnergy()
13086 {
13087 float energy = 0;
13088 if (HasEnergyManager())
13089 {
13090 energy = GetCompEM().GetEnergy();
13091 }
13092 return energy;
13093 }
13094
13095
13096 override void OnEnergyConsumed()
13097 {
13098 super.OnEnergyConsumed();
13099
13101 }
13102
13103 override void OnEnergyAdded()
13104 {
13105 super.OnEnergyAdded();
13106
13108 }
13109
13110 // Converts energy (from Energy Manager) to quantity, if enabled.
13112 {
13113 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
13114 {
13115 if (HasQuantity())
13116 {
13117 float energy_0to1 = GetCompEM().GetEnergy0To1();
13118 SetQuantityNormalized(energy_0to1);
13119 }
13120 }
13121 }
13122
13123 //----------------------------------------------------------------
13124 float GetHeatIsolationInit()
13125 {
13126 return ConfigGetFloat("heatIsolation");
13127 }
13128
13129 float GetHeatIsolation()
13130 {
13131 return m_HeatIsolation;
13132 }
13133
13134 float GetDryingIncrement(string pIncrementName)
13135 {
13136 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
13137 if (g_Game.ConfigIsExisting(paramPath))
13138 return g_Game.ConfigGetFloat(paramPath);
13139
13140 return 0.0;
13141 }
13142
13143 float GetSoakingIncrement(string pIncrementName)
13144 {
13145 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
13146 if (g_Game.ConfigIsExisting(paramPath))
13147 return g_Game.ConfigGetFloat(paramPath);
13148
13149 return 0.0;
13150 }
13151 //----------------------------------------------------------------
13152 override void SetWet(float value, bool allow_client = false)
13153 {
13154 if (!IsServerCheck(allow_client))
13155 return;
13156
13157 float min = GetWetMin();
13158 float max = GetWetMax();
13159
13160 float previousValue = m_VarWet;
13161
13162 m_VarWet = Math.Clamp(value, min, max);
13163
13164 if (previousValue != m_VarWet)
13165 {
13166 SetVariableMask(VARIABLE_WET);
13167 OnWetChanged(m_VarWet, previousValue);
13168 }
13169 }
13170 //----------------------------------------------------------------
13171 override void AddWet(float value)
13172 {
13173 SetWet(GetWet() + value);
13174 }
13175 //----------------------------------------------------------------
13176 override void SetWetMax()
13177 {
13179 }
13180 //----------------------------------------------------------------
13181 override float GetWet()
13182 {
13183 return m_VarWet;
13184 }
13185 //----------------------------------------------------------------
13186 override float GetWetMax()
13187 {
13188 return m_VarWetMax;
13189 }
13190 //----------------------------------------------------------------
13191 override float GetWetMin()
13192 {
13193 return m_VarWetMin;
13194 }
13195 //----------------------------------------------------------------
13196 override float GetWetInit()
13197 {
13198 return m_VarWetInit;
13199 }
13200 //----------------------------------------------------------------
13201 override void OnWetChanged(float newVal, float oldVal)
13202 {
13203 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
13204 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
13205 if (newLevel != oldLevel)
13206 {
13207 OnWetLevelChanged(newLevel,oldLevel);
13208 }
13209 }
13210
13211 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
13212 {
13213 SetWeightDirty();
13214 }
13215
13216 override EWetnessLevel GetWetLevel()
13217 {
13218 return GetWetLevelInternal(m_VarWet);
13219 }
13220
13221 //----------------------------------------------------------------
13222
13223 override void SetStoreLoad(bool value)
13224 {
13225 m_IsStoreLoad = value;
13226 }
13227
13228 override bool IsStoreLoad()
13229 {
13230 return m_IsStoreLoad;
13231 }
13232
13233 override void SetStoreLoadedQuantity(float value)
13234 {
13235 m_StoreLoadedQuantity = value;
13236 }
13237
13238 override float GetStoreLoadedQuantity()
13239 {
13240 return m_StoreLoadedQuantity;
13241 }
13242
13243 //----------------------------------------------------------------
13244
13245 float GetItemModelLength()
13246 {
13247 if (ConfigIsExisting("itemModelLength"))
13248 {
13249 return ConfigGetFloat("itemModelLength");
13250 }
13251 return 0;
13252 }
13253
13254 float GetItemAttachOffset()
13255 {
13256 if (ConfigIsExisting("itemAttachOffset"))
13257 {
13258 return ConfigGetFloat("itemAttachOffset");
13259 }
13260 return 0;
13261 }
13262
13263 override void SetCleanness(int value, bool allow_client = false)
13264 {
13265 if (!IsServerCheck(allow_client))
13266 return;
13267
13268 int previousValue = m_Cleanness;
13269
13270 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
13271
13272 if (previousValue != m_Cleanness)
13273 SetVariableMask(VARIABLE_CLEANNESS);
13274 }
13275
13276 override int GetCleanness()
13277 {
13278 return m_Cleanness;
13279 }
13280
13282 {
13283 return true;
13284 }
13285
13286 //----------------------------------------------------------------
13287 // ATTACHMENT LOCKING
13288 // Getters relevant to generic ActionLockAttachment
13289 int GetLockType()
13290 {
13291 return m_LockType;
13292 }
13293
13294 string GetLockSoundSet()
13295 {
13296 return m_LockSoundSet;
13297 }
13298
13299 //----------------------------------------------------------------
13300 //------------------------- Color
13301 // sets items color variable given color components
13302 override void SetColor(int r, int g, int b, int a)
13303 {
13308 SetVariableMask(VARIABLE_COLOR);
13309 }
13311 override void GetColor(out int r,out int g,out int b,out int a)
13312 {
13317 }
13318
13319 bool IsColorSet()
13320 {
13321 return IsVariableSet(VARIABLE_COLOR);
13322 }
13323
13325 string GetColorString()
13326 {
13327 int r,g,b,a;
13328 GetColor(r,g,b,a);
13329 r = r/255;
13330 g = g/255;
13331 b = b/255;
13332 a = a/255;
13333 return MiscGameplayFunctions.GetColorString(r, g, b, a);
13334 }
13335 //----------------------------------------------------------------
13336 //------------------------- LiquidType
13337
13338 override void SetLiquidType(int value, bool allow_client = false)
13339 {
13340 if (!IsServerCheck(allow_client))
13341 return;
13342
13343 int old = m_VarLiquidType;
13344 m_VarLiquidType = value;
13345 OnLiquidTypeChanged(old,value);
13346 SetVariableMask(VARIABLE_LIQUIDTYPE);
13347 }
13348
13349 int GetLiquidTypeInit()
13350 {
13351 return ConfigGetInt("varLiquidTypeInit");
13352 }
13353
13354 override int GetLiquidType()
13355 {
13356 return m_VarLiquidType;
13357 }
13358
13359 protected void OnLiquidTypeChanged(int oldType, int newType)
13360 {
13361 if (newType == LIQUID_NONE && GetIsFrozen())
13362 SetFrozen(false);
13363 }
13364
13366 void UpdateQuickbarShortcutVisibility(PlayerBase player)
13367 {
13368 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13369 }
13370
13371 // -------------------------------------------------------------------------
13373 void OnInventoryEnter(Man player)
13374 {
13375 PlayerBase nplayer;
13376 if (PlayerBase.CastTo(nplayer, player))
13377 {
13378 m_CanPlayImpactSound = true;
13379 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
13380 }
13381 }
13382
13383 // -------------------------------------------------------------------------
13385 void OnInventoryExit(Man player)
13386 {
13387 PlayerBase nplayer;
13388 if (PlayerBase.CastTo(nplayer,player))
13389 {
13390 nplayer.SetEnableQuickBarEntityShortcut(this, false);
13391 }
13392
13393 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
13394
13395 if (HasEnergyManager())
13396 {
13397 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
13398 }
13399 }
13400
13401 // ADVANCED PLACEMENT EVENTS
13402 override void OnPlacementStarted(Man player)
13403 {
13404 super.OnPlacementStarted(player);
13405
13406 SetTakeable(false);
13407 }
13408
13409 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
13410 {
13411 if (m_AdminLog)
13412 {
13413 m_AdminLog.OnPlacementComplete(player, this);
13414 }
13415
13416 super.OnPlacementComplete(player, position, orientation);
13417 }
13418
13419 //-----------------------------
13420 // AGENT SYSTEM
13421 //-----------------------------
13422 //--------------------------------------------------------------------------
13423 bool ContainsAgent(int agent_id)
13424 {
13425 if (agent_id & m_AttachedAgents)
13426 {
13427 return true;
13428 }
13429 else
13430 {
13431 return false;
13432 }
13433 }
13434
13435 //--------------------------------------------------------------------------
13436 override void RemoveAgent(int agent_id)
13437 {
13438 if (ContainsAgent(agent_id))
13439 {
13440 m_AttachedAgents = ~agent_id & m_AttachedAgents;
13441 }
13442 }
13443
13444 //--------------------------------------------------------------------------
13445 override void RemoveAllAgents()
13446 {
13447 m_AttachedAgents = 0;
13448 }
13449 //--------------------------------------------------------------------------
13450 override void RemoveAllAgentsExcept(int agent_to_keep)
13451 {
13452 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
13453 }
13454 // -------------------------------------------------------------------------
13455 override void InsertAgent(int agent, float count = 1)
13456 {
13457 if (count < 1)
13458 return;
13459 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
13461 }
13462
13464 void TransferAgents(int agents)
13465 {
13467 }
13468
13469 // -------------------------------------------------------------------------
13470 override int GetAgents()
13471 {
13472 return m_AttachedAgents;
13473 }
13474 //----------------------------------------------------------------------
13475
13476 /*int GetContaminationType()
13477 {
13478 int contamination_type;
13479
13480 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
13481 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
13482 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
13483 const int DIRTY_MASK = eAgents.WOUND_AGENT;
13484
13485 Edible_Base edible = Edible_Base.Cast(this);
13486 int agents = GetAgents();
13487 if (edible)
13488 {
13489 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
13490 if (profile)
13491 {
13492 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
13493 }
13494 }
13495 if (agents & CONTAMINATED_MASK)
13496 {
13497 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
13498 }
13499 if (agents & POISONED_MASK)
13500 {
13501 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
13502 }
13503 if (agents & NERVE_GAS_MASK)
13504 {
13505 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
13506 }
13507 if (agents & DIRTY_MASK)
13508 {
13509 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
13510 }
13511
13512 return agents;
13513 }*/
13514
13515 // -------------------------------------------------------------------------
13516 bool LoadAgents(ParamsReadContext ctx, int version)
13517 {
13518 if (!ctx.Read(m_AttachedAgents))
13519 return false;
13520 return true;
13521 }
13522 // -------------------------------------------------------------------------
13524 {
13525
13527 }
13528 // -------------------------------------------------------------------------
13529
13531 override void CheckForRoofLimited(float timeTresholdMS = 3000)
13532 {
13533 super.CheckForRoofLimited(timeTresholdMS);
13534
13535 float time = g_Game.GetTime();
13536 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
13537 {
13538 m_PreviousRoofTestTime = time;
13539 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
13540 }
13541 }
13542
13543 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
13544 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
13545 {
13546 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
13547 {
13548 return 0;
13549 }
13550
13551 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
13552 {
13553 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
13554 if (filter)
13555 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
13556 else
13557 return 0;//otherwise return 0 when no filter attached
13558 }
13559
13560 string subclassPath, entryName;
13561
13562 switch (type)
13563 {
13564 case DEF_BIOLOGICAL:
13565 entryName = "biological";
13566 break;
13567 case DEF_CHEMICAL:
13568 entryName = "chemical";
13569 break;
13570 default:
13571 entryName = "biological";
13572 break;
13573 }
13574
13575 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
13576
13577 return g_Game.ConfigGetFloat(subclassPath + entryName);
13578 }
13579
13580
13581
13583 override void EEOnCECreate()
13584 {
13585 if (!IsMagazine())
13587
13589 }
13590
13591
13592 //-------------------------
13593 // OPEN/CLOSE USER ACTIONS
13594 //-------------------------
13596 void Open();
13597 void Close();
13598 bool IsOpen()
13599 {
13600 return true;
13601 }
13602
13603 override bool CanDisplayCargo()
13604 {
13605 return IsOpen();
13606 }
13607
13608
13609 // ------------------------------------------------------------
13610 // CONDITIONS
13611 // ------------------------------------------------------------
13612 override bool CanPutInCargo(EntityAI parent)
13613 {
13614 if (parent)
13615 {
13616 if (parent.IsInherited(DayZInfected))
13617 return true;
13618
13619 if (!parent.IsRuined())
13620 return true;
13621 }
13622
13623 return true;
13624 }
13625
13626 override bool CanPutAsAttachment(EntityAI parent)
13627 {
13628 if (!super.CanPutAsAttachment(parent))
13629 {
13630 return false;
13631 }
13632
13633 if (!IsRuined() && !parent.IsRuined())
13634 {
13635 return true;
13636 }
13637
13638 return false;
13639 }
13640
13641 override bool CanReceiveItemIntoCargo(EntityAI item)
13642 {
13643 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13644 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13645 // return false;
13646
13647 return super.CanReceiveItemIntoCargo(item);
13648 }
13649
13650 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13651 {
13652 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13653 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13654 // return false;
13655
13656 GameInventory attachmentInv = attachment.GetInventory();
13657 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13658 {
13659 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13660 return false;
13661 }
13662
13663 InventoryLocation loc = new InventoryLocation();
13664 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13665 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13666 return false;
13667
13668 return super.CanReceiveAttachment(attachment, slotId);
13669 }
13670
13671 override bool CanReleaseAttachment(EntityAI attachment)
13672 {
13673 if (!super.CanReleaseAttachment(attachment))
13674 return false;
13675
13676 return GetInventory().AreChildrenAccessible();
13677 }
13678
13679 /*override bool CanLoadAttachment(EntityAI attachment)
13680 {
13681 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13682 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13683 // return false;
13684
13685 GameInventory attachmentInv = attachment.GetInventory();
13686 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13687 {
13688 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13689 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13690
13691 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13692 return false;
13693 }
13694
13695 return super.CanLoadAttachment(attachment);
13696 }*/
13697
13698 // Plays muzzle flash particle effects
13699 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13700 {
13701 int id = muzzle_owner.GetMuzzleID();
13702 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13703
13704 if (WPOF_array)
13705 {
13706 for (int i = 0; i < WPOF_array.Count(); i++)
13707 {
13708 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13709
13710 if (WPOF)
13711 {
13712 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13713 }
13714 }
13715 }
13716 }
13717
13718 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13719 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13720 {
13721 int id = muzzle_owner.GetMuzzleID();
13722 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13723
13724 if (WPOBE_array)
13725 {
13726 for (int i = 0; i < WPOBE_array.Count(); i++)
13727 {
13728 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13729
13730 if (WPOBE)
13731 {
13732 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13733 }
13734 }
13735 }
13736 }
13737
13738 // Plays all weapon overheating particles
13739 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13740 {
13741 int id = muzzle_owner.GetMuzzleID();
13742 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13743
13744 if (WPOOH_array)
13745 {
13746 for (int i = 0; i < WPOOH_array.Count(); i++)
13747 {
13748 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13749
13750 if (WPOOH)
13751 {
13752 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13753 }
13754 }
13755 }
13756 }
13757
13758 // Updates all weapon overheating particles
13759 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13760 {
13761 int id = muzzle_owner.GetMuzzleID();
13762 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13763
13764 if (WPOOH_array)
13765 {
13766 for (int i = 0; i < WPOOH_array.Count(); i++)
13767 {
13768 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13769
13770 if (WPOOH)
13771 {
13772 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13773 }
13774 }
13775 }
13776 }
13777
13778 // Stops overheating particles
13779 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13780 {
13781 int id = muzzle_owner.GetMuzzleID();
13782 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13783
13784 if (WPOOH_array)
13785 {
13786 for (int i = 0; i < WPOOH_array.Count(); i++)
13787 {
13788 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13789
13790 if (WPOOH)
13791 {
13792 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13793 }
13794 }
13795 }
13796 }
13797
13798 //----------------------------------------------------------------
13799 //Item Behaviour - unified approach
13800 override bool IsHeavyBehaviour()
13801 {
13802 if (m_ItemBehaviour == 0)
13803 {
13804 return true;
13805 }
13806
13807 return false;
13808 }
13809
13810 override bool IsOneHandedBehaviour()
13811 {
13812 if (m_ItemBehaviour == 1)
13813 {
13814 return true;
13815 }
13816
13817 return false;
13818 }
13819
13820 override bool IsTwoHandedBehaviour()
13821 {
13822 if (m_ItemBehaviour == 2)
13823 {
13824 return true;
13825 }
13826
13827 return false;
13828 }
13829
13830 bool IsDeployable()
13831 {
13832 return false;
13833 }
13834
13836 float GetDeployTime()
13837 {
13838 return UATimeSpent.DEFAULT_DEPLOY;
13839 }
13840
13841
13842 //----------------------------------------------------------------
13843 // Item Targeting (User Actions)
13844 override void SetTakeable(bool pState)
13845 {
13846 m_IsTakeable = pState;
13847 SetSynchDirty();
13848 }
13849
13850 override bool IsTakeable()
13851 {
13852 return m_IsTakeable;
13853 }
13854
13855 // For cases where we want to show object widget which cant be taken to hands
13857 {
13858 return false;
13859 }
13860
13862 protected void PreLoadSoundAttachmentType()
13863 {
13864 string att_type = "None";
13865
13866 if (ConfigIsExisting("soundAttType"))
13867 {
13868 att_type = ConfigGetString("soundAttType");
13869 }
13870
13871 m_SoundAttType = att_type;
13872 }
13873
13874 override string GetAttachmentSoundType()
13875 {
13876 return m_SoundAttType;
13877 }
13878
13879 //----------------------------------------------------------------
13880 //SOUNDS - ItemSoundHandler
13881 //----------------------------------------------------------------
13882
13883 string GetPlaceSoundset(); // played when deploy starts
13884 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13885 string GetDeploySoundset(); // played when deploy sucessfully finishes
13886 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13887 string GetFoldSoundset(); // played when fold sucessfully finishes
13888
13890 {
13891 if (!m_ItemSoundHandler)
13893
13894 return m_ItemSoundHandler;
13895 }
13896
13897 // override to initialize sounds
13898 protected void InitItemSounds()
13899 {
13900 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
13901 return;
13902
13904
13905 if (GetPlaceSoundset() != string.Empty)
13906 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13907
13908 if (GetDeploySoundset() != string.Empty)
13909 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13910
13911 SoundParameters params = new SoundParameters();
13912 params.m_Loop = true;
13913 if (GetLoopDeploySoundset() != string.Empty)
13914 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13915 }
13916
13917 // Start sound using ItemSoundHandler
13918 void StartItemSoundServer(int id, int slotId)
13919 {
13920 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
13921 {
13922 m_SoundSyncSlotID = slotId;
13923 m_SoundSyncPlay = id;
13924
13925 SetSynchDirty();
13926
13927 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13928 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
13929 }
13930 }
13931
13932 void StartItemSoundServer(int id)
13933 {
13934 StartItemSoundServer(id, InventorySlots.INVALID);
13935 }
13936
13937 // Stop sound using ItemSoundHandler
13938 void StopItemSoundServer(int id)
13939 {
13940 if (!g_Game.IsServer())
13941 return;
13942
13943 m_SoundSyncStop = id;
13944 SetSynchDirty();
13945
13946 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13947 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
13948 }
13949
13950 protected void ClearStartItemSoundServer()
13951 {
13952 m_SoundSyncPlay = 0;
13953 m_SoundSyncSlotID = InventorySlots.INVALID;
13954 }
13955
13956 protected void ClearStopItemSoundServer()
13957 {
13958 m_SoundSyncStop = 0;
13959 }
13960
13961 void OnApply(PlayerBase player);
13962
13964 {
13965 return 1.0;
13966 };
13967 //returns applicable selection
13968 array<string> GetHeadHidingSelection()
13969 {
13971 }
13972
13974 {
13976 }
13977
13978 WrittenNoteData GetWrittenNoteData() {};
13979
13981 {
13982 SetDynamicPhysicsLifeTime(0.01);
13983 m_ItemBeingDroppedPhys = false;
13984 }
13985
13987 {
13988 array<string> zone_names = new array<string>;
13989 GetDamageZones(zone_names);
13990 for (int i = 0; i < zone_names.Count(); i++)
13991 {
13992 SetHealthMax(zone_names.Get(i),"Health");
13993 }
13994 SetHealthMax("","Health");
13995 }
13996
13998 void SetZoneDamageCEInit()
13999 {
14000 float global_health = GetHealth01("","Health");
14001 array<string> zones = new array<string>;
14002 GetDamageZones(zones);
14003 //set damage of all zones to match global health level
14004 for (int i = 0; i < zones.Count(); i++)
14005 {
14006 SetHealth01(zones.Get(i),"Health",global_health);
14007 }
14008 }
14009
14011 bool IsCoverFaceForShave(string slot_name)
14012 {
14013 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
14014 }
14015
14016 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
14017 {
14018 if (!hasRootAsPlayer)
14019 {
14020 if (refParentIB)
14021 {
14022 // parent is wet
14023 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
14024 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
14025 // parent has liquid inside
14026 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
14027 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
14028 // drying
14029 else if (m_VarWet > m_VarWetMin)
14030 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
14031 }
14032 else
14033 {
14034 // drying on ground or inside non-itembase (car, ...)
14035 if (m_VarWet > m_VarWetMin)
14036 AddWet(-1 * delta * GetDryingIncrement("ground"));
14037 }
14038 }
14039 }
14040
14041 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
14042 {
14044 {
14045 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
14046 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
14047 {
14048 float heatPermCoef = 1.0;
14049 EntityAI ent = this;
14050 while (ent)
14051 {
14052 heatPermCoef *= ent.GetHeatPermeabilityCoef();
14053 ent = ent.GetHierarchyParent();
14054 }
14055
14056 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
14057 }
14058 }
14059 }
14060
14061 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
14062 {
14063 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
14064 EntityAI parent = GetHierarchyParent();
14065 if (!parent)
14066 {
14067 hasParent = false;
14068 hasRootAsPlayer = false;
14069 }
14070 else
14071 {
14072 hasParent = true;
14073 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
14074 refParentIB = ItemBase.Cast(parent);
14075 }
14076 }
14077
14078 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
14079 {
14080 // this is stub, implemented on Edible_Base
14081 }
14082
14083 bool CanDecay()
14084 {
14085 // return true used on selected food clases so they can decay
14086 return false;
14087 }
14088
14089 protected bool CanProcessDecay()
14090 {
14091 // this is stub, implemented on Edible_Base class
14092 // used to determine whether it is still necessary for the food to decay
14093 return false;
14094 }
14095
14096 protected bool CanHaveWetness()
14097 {
14098 // return true used on selected items that have a wetness effect
14099 return false;
14100 }
14101
14103 bool CanBeConsumed(ConsumeConditionData data = null)
14104 {
14105 return !GetIsFrozen() && IsOpen();
14106 }
14107
14108 override void ProcessVariables()
14109 {
14110 bool hasParent = false, hasRootAsPlayer = false;
14111 ItemBase refParentIB;
14112
14113 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
14114 bool foodDecay = g_Game.IsFoodDecayEnabled();
14115
14116 if (wwtu || foodDecay)
14117 {
14118 bool processWetness = wwtu && CanHaveWetness();
14119 bool processTemperature = wwtu && CanHaveTemperature();
14120 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
14121
14122 if (processWetness || processTemperature || processDecay)
14123 {
14124 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
14125
14126 if (processWetness)
14127 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
14128
14129 if (processTemperature)
14130 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
14131
14132 if (processDecay)
14133 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
14134 }
14135 }
14136 }
14137
14140 {
14141 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
14142 }
14143
14144 override float GetTemperatureFreezeThreshold()
14145 {
14147 return Liquid.GetFreezeThreshold(GetLiquidType());
14148
14149 return super.GetTemperatureFreezeThreshold();
14150 }
14151
14152 override float GetTemperatureThawThreshold()
14153 {
14155 return Liquid.GetThawThreshold(GetLiquidType());
14156
14157 return super.GetTemperatureThawThreshold();
14158 }
14159
14160 override float GetItemOverheatThreshold()
14161 {
14163 return Liquid.GetBoilThreshold(GetLiquidType());
14164
14165 return super.GetItemOverheatThreshold();
14166 }
14167
14168 override float GetTemperatureFreezeTime()
14169 {
14170 if (HasQuantity())
14171 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
14172
14173 return super.GetTemperatureFreezeTime();
14174 }
14175
14176 override float GetTemperatureThawTime()
14177 {
14178 if (HasQuantity())
14179 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
14180
14181 return super.GetTemperatureThawTime();
14182 }
14183
14185 void AffectLiquidContainerOnFill(int liquid_type, float amount);
14187 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
14188
14189 bool IsCargoException4x3(EntityAI item)
14190 {
14191 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
14192 }
14193
14195 {
14196 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
14197 }
14198
14200 void AddLightSourceItem(ItemBase lightsource)
14201 {
14202 m_LightSourceItem = lightsource;
14203 }
14204
14206 {
14207 m_LightSourceItem = null;
14208 }
14209
14211 {
14212 return m_LightSourceItem;
14213 }
14214
14216 array<int> GetValidFinishers()
14217 {
14218 return null;
14219 }
14220
14222 bool GetActionWidgetOverride(out typename name)
14223 {
14224 return false;
14225 }
14226
14227 bool PairWithDevice(notnull ItemBase otherDevice)
14228 {
14229 if (g_Game.IsServer())
14230 {
14231 ItemBase explosive = otherDevice;
14233 if (!trg)
14234 {
14235 trg = RemoteDetonatorTrigger.Cast(otherDevice);
14236 explosive = this;
14237 }
14238
14239 explosive.PairRemote(trg);
14240 trg.SetControlledDevice(explosive);
14241
14242 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
14243 trg.SetPersistentPairID(persistentID);
14244 explosive.SetPersistentPairID(persistentID);
14245
14246 return true;
14247 }
14248 return false;
14249 }
14250
14252 float GetBaitEffectivity()
14253 {
14254 float ret = 1.0;
14255 if (HasQuantity())
14256 ret *= GetQuantityNormalized();
14257 ret *= GetHealth01();
14258
14259 return ret;
14260 }
14261
14262 #ifdef DEVELOPER
14263 override void SetDebugItem()
14264 {
14265 super.SetDebugItem();
14266 _itemBase = this;
14267 }
14268
14269 override string GetDebugText()
14270 {
14271 string text = super.GetDebugText();
14272
14273 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
14274 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
14275
14276 return text;
14277 }
14278 #endif
14279
14280 bool CanBeUsedForSuicide()
14281 {
14282 return true;
14283 }
14284
14286 //DEPRECATED BELOW
14288 // Backwards compatibility
14289 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
14290 {
14291 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
14292 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
14293 }
14294
14295 // replaced by ItemSoundHandler
14296 protected EffectSound m_SoundDeployFinish;
14297 protected EffectSound m_SoundPlace;
14298 protected EffectSound m_DeployLoopSoundEx;
14299 protected EffectSound m_SoundDeploy;
14300 bool m_IsPlaceSound;
14301 bool m_IsDeploySound;
14303
14304 string GetDeployFinishSoundset();
14305 void PlayDeploySound();
14306 void PlayDeployFinishSound();
14307 void PlayPlaceSound();
14308 void PlayDeployLoopSoundEx();
14309 void StopDeployLoopSoundEx();
14310 void SoundSynchRemoteReset();
14311 void SoundSynchRemote();
14312 bool UsesGlobalDeploy(){return false;}
14313 bool CanPlayDeployLoopSound(){return false;}
14315 bool IsPlaceSound(){return m_IsPlaceSound;}
14316 bool IsDeploySound(){return m_IsDeploySound;}
14317 void SetIsPlaceSound(bool is_place_sound);
14318 void SetIsDeploySound(bool is_deploy_sound);
14319
14320 [Obsolete("Use ItemSoundHandler instead")]
14322 void PlayAttachSound(string slot_type)
14323 {
14324 if (!g_Game.IsDedicatedServer())
14325 {
14326 if (ConfigIsExisting("attachSoundSet"))
14327 {
14328 string cfg_path = "";
14329 string soundset = "";
14330 string type_name = GetType();
14331
14332 TStringArray cfg_soundset_array = new TStringArray;
14333 TStringArray cfg_slot_array = new TStringArray;
14334 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
14335 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
14336
14337 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
14338 {
14339 for (int i = 0; i < cfg_soundset_array.Count(); i++)
14340 {
14341 if (cfg_slot_array[i] == slot_type)
14342 {
14343 soundset = cfg_soundset_array[i];
14344 break;
14345 }
14346 }
14347 }
14348
14349 if (soundset != "")
14350 {
14351 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
14352 sound.SetAutodestroy(true);
14353 }
14354 }
14355 }
14356 }
14357
14358 void PlayDetachSound(string slot_type) {}
14359}
14360
14361EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
14362{
14363 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
14364 if (entity)
14365 {
14366 bool is_item = entity.IsInherited(ItemBase);
14367 if (is_item && full_quantity)
14368 {
14369 ItemBase item = ItemBase.Cast(entity);
14370 item.SetQuantity(item.GetQuantityInit());
14371 }
14372 }
14373 else
14374 {
14375 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
14376 return NULL;
14377 }
14378 return entity;
14379}
14380
14381void SetupSpawnedItem(ItemBase item, float health, float quantity)
14382{
14383 if (item)
14384 {
14385 if (health > 0)
14386 item.SetHealth("", "", health);
14387
14388 if (item.CanHaveTemperature())
14389 {
14390 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
14391 if (item.CanFreeze())
14392 item.SetFrozen(false);
14393 }
14394
14395 if (item.HasEnergyManager())
14396 {
14397 if (quantity >= 0)
14398 {
14399 item.GetCompEM().SetEnergy0To1(quantity);
14400 }
14401 else
14402 {
14403 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
14404 }
14405 }
14406 else if (item.IsMagazine())
14407 {
14408 Magazine mag = Magazine.Cast(item);
14409 if (quantity >= 0)
14410 {
14411 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
14412 }
14413 else
14414 {
14415 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
14416 }
14417
14418 }
14419 else
14420 {
14421 if (quantity >= 0)
14422 {
14423 item.SetQuantityNormalized(quantity, false);
14424 }
14425 else
14426 {
14427 item.SetQuantity(Math.AbsFloat(quantity));
14428 }
14429
14430 }
14431 }
14432}
14433
14434#ifdef DEVELOPER
14435ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
14436#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()