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

◆ IsTwoHandedBehaviour()

override bool SpawnItemOnLocation::IsTwoHandedBehaviour ( )
protected

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

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