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

◆ CanReceiveItemIntoCargo()

override bool SpawnItemOnLocation::CanReceiveItemIntoCargo ( EntityAI item)
protected

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

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