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

◆ IsTakeable()

override bool SpawnItemOnLocation::IsTakeable ( )
protected

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

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