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

◆ StopItemDynamicPhysics()

void SpawnItemOnLocation::StopItemDynamicPhysics ( )
protected

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

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