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

◆ GetAttachmentSoundType()

override string SpawnItemOnLocation::GetAttachmentSoundType ( )
protected

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

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