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

◆ InitItemSounds()

void SpawnItemOnLocation::InitItemSounds ( )
protected

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

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