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

◆ InitItemSounds()

void SpawnItemOnLocation::InitItemSounds ( )
protected

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

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