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

◆ CanPutInCargo()

override bool SpawnItemOnLocation::CanPutInCargo ( EntityAI parent)
protected

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

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