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

◆ ClearStopItemSoundServer()

void SpawnItemOnLocation::ClearStopItemSoundServer ( )
protected

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

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