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

◆ CanReceiveAttachment()

override bool SpawnItemOnLocation::CanReceiveAttachment ( EntityAI attachment,
int slotId )
protected

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

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