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

◆ GetWrittenNoteData()

WrittenNoteData SpawnItemOnLocation::GetWrittenNoteData ( )
protected

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

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