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

◆ CanPutAsAttachment()

override bool SpawnItemOnLocation::CanPutAsAttachment ( EntityAI parent)
protected

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

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