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

◆ PlayBulletCasingEjectParticles()

static void SpawnItemOnLocation::PlayBulletCasingEjectParticles ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
staticprotected

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

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