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

◆ PlayBulletCasingEjectParticles()

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

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

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