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

◆ IsTwoHandedBehaviour()

override bool SpawnItemOnLocation::IsTwoHandedBehaviour ( )
protected

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

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