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

◆ PlayOverheatingParticles()

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

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

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