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

◆ UpdateOverheatingParticles()

static void SpawnItemOnLocation::UpdateOverheatingParticles ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
staticprotected

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

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