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

◆ PreLoadSoundAttachmentType()

void SpawnItemOnLocation::PreLoadSoundAttachmentType ( )
protected

Attachment Sound Type getting from config file.

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

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

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