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

◆ GetDeployTime()

float SpawnItemOnLocation::GetDeployTime ( )
protected

how long it takes to deploy this item in seconds

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

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