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

◆ IsActionTargetVisible()

bool SpawnItemOnLocation::IsActionTargetVisible ( )
protected

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

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