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

◆ StartItemSoundServer()

void SpawnItemOnLocation::StartItemSoundServer ( int id)
protected

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

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

Используется в ShippingContainerKeys_ColorBase::DestroyKeyServer() и ItemBase::ToggleAnimation().