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

◆ IsOpen()

override bool IsOpen ( )
protected

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

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

Используется в InventoryItem::CanBeConsumed(), FireplaceBase::CanBeIgnitedBy(), FireplaceBase::CanDisplayAttachmentCategory(), FireplaceBase::CanDisplayCargo(), InventoryItem::CanDisplayCargo(), FireplaceBase::CanExtinguishFire(), FireplaceBase::CanIgniteItem(), FireplaceBase::CanPutInCargo(), FireplaceBase::CanPutIntoHands(), FireplaceBase::CanReceiveAttachment(), FireplaceBase::CanReceiveItemIntoCargo(), FireplaceBase::CanReleaseCargo(), FireplaceBase::CanShowSmoke(), FireplaceBase::IsThisIgnitionSuccessful() и FireplaceBase::UpdateVisualState().