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

◆ PlayFireParticles()

static void SpawnItemOnLocation::PlayFireParticles ( ItemBase weapon,
int muzzle_index,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
staticprotected

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

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