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

◆ CanReleaseAttachment()

override bool SpawnItemOnLocation::CanReleaseAttachment ( EntityAI attachment)
protected

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

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