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

◆ PlayAttachSound()

void SpawnItemOnLocation::PlayAttachSound ( string slot_type)
protected

Plays sound on item attach. Be advised, the config structure may slightly change in 1.11 update to allow for more complex use.

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

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

Используется в InventoryItem::OnWasAttached().