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

◆ CombineItems()

void SpawnItemOnLocation::CombineItems ( ItemBase other_item,
bool use_stack_max = true )
private

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

7020{
7021 override bool CanPutAsAttachment(EntityAI parent)
7022 {
7023 return true;
7024 }
7025};
7026
7027//const bool QUANTITY_DEBUG_REMOVE_ME = false;
7028
7029class ItemBase extends InventoryItem
7030{
7034
7036
7037 static int m_DebugActionsMask;
7039 // ============================================
7040 // Variable Manipulation System
7041 // ============================================
7042 // Quantity
7043
7044 float m_VarQuantity;
7045 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7047 int m_VarQuantityMin;
7048 int m_VarQuantityMax;
7049 int m_Count;
7050 float m_VarStackMax;
7051 float m_StoreLoadedQuantity = float.LOWEST;
7052 // Wet
7053 float m_VarWet;
7054 float m_VarWetPrev;//for client to know wetness changed during synchronization
7055 float m_VarWetInit;
7056 float m_VarWetMin;
7057 float m_VarWetMax;
7058 // Cleanness
7059 int m_Cleanness;
7060 int m_CleannessInit;
7061 int m_CleannessMin;
7062 int m_CleannessMax;
7063 // impact sounds
7065 bool m_CanPlayImpactSound = true;
7066 float m_ImpactSpeed;
7068 //
7069 float m_HeatIsolation;
7070 float m_ItemModelLength;
7071 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7073 int m_VarLiquidType;
7074 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7075 int m_QuickBarBonus;
7076 bool m_IsBeingPlaced;
7077 bool m_IsHologram;
7078 bool m_IsTakeable;
7079 bool m_ThrowItemOnDrop;
7082 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7083 bool can_this_be_combined; //Check if item can be combined
7084 bool m_CanThisBeSplit; //Check if item can be split
7085 bool m_IsStoreLoad = false;
7086 bool m_CanShowQuantity;
7087 bool m_HasQuantityBar;
7088 protected bool m_CanBeDigged;
7089 protected bool m_IsResultOfSplit
7090
7091 string m_SoundAttType;
7092 // items color variables
7097 //-------------------------------------------------------
7098
7099 // light source managing
7101
7105
7106 //==============================================
7107 // agent system
7108 private int m_AttachedAgents;
7109
7111 void TransferModifiers(PlayerBase reciever);
7112
7113
7114 // Weapons & suppressors particle effects
7119 static int m_LastRegisteredWeaponID = 0;
7120
7121 // Overheating effects
7123 float m_OverheatingShots;
7124 ref Timer m_CheckOverheating;
7125 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7126 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
7127 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
7128 ref array <ref OverheatingParticle> m_OverheatingParticles;
7129
7131 protected bool m_HideSelectionsBySlot;
7132
7133 // Admin Log
7134 PluginAdminLog m_AdminLog;
7135
7136 // misc
7137 ref Timer m_PhysDropTimer;
7138
7139 // Attachment Locking variables
7140 ref array<int> m_CompatibleLocks;
7141 protected int m_LockType;
7142 protected ref EffectSound m_LockingSound;
7143 protected string m_LockSoundSet;
7144
7145 // ItemSoundHandler
7146 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
7147 protected int m_SoundSyncPlay; // id for sound to play
7148 protected int m_SoundSyncStop; // id for sound to stop
7150
7151 //temperature
7152 private float m_TemperaturePerQuantityWeight;
7153
7154 // -------------------------------------------------------------------------
7155 void ItemBase()
7156 {
7157 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
7161
7162 if (!GetGame().IsDedicatedServer())
7163 {
7164 if (HasMuzzle())
7165 {
7167
7169 {
7171 }
7172 }
7173
7175 m_ActionsInitialize = false;
7176 }
7177
7178 m_OldLocation = null;
7179
7180 if (GetGame().IsServer())
7181 {
7182 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
7183 }
7184
7185 if (ConfigIsExisting("headSelectionsToHide"))
7186 {
7188 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
7189 }
7190
7191 m_HideSelectionsBySlot = false;
7192 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
7193 {
7194 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
7195 }
7196
7197 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
7198
7199 m_IsResultOfSplit = false;
7200
7202 }
7203
7204 override void InitItemVariables()
7205 {
7206 super.InitItemVariables();
7207
7208 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
7209 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
7210 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
7211 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
7212 m_VarStackMax = ConfigGetFloat("varStackMax");
7213 m_Count = ConfigGetInt("count");
7214
7215 m_CanShowQuantity = ConfigGetBool("quantityShow");
7216 m_HasQuantityBar = ConfigGetBool("quantityBar");
7217
7218 m_CleannessInit = ConfigGetInt("varCleannessInit");
7220 m_CleannessMin = ConfigGetInt("varCleannessMin");
7221 m_CleannessMax = ConfigGetInt("varCleannessMax");
7222
7223 m_WantPlayImpactSound = false;
7224 m_ImpactSpeed = 0.0;
7225
7226 m_VarWetInit = ConfigGetFloat("varWetInit");
7228 m_VarWetMin = ConfigGetFloat("varWetMin");
7229 m_VarWetMax = ConfigGetFloat("varWetMax");
7230
7231 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
7232 if (IsLiquidContainer() && GetQuantity() != 0)
7234 m_IsBeingPlaced = false;
7235 m_IsHologram = false;
7236 m_IsTakeable = true;
7237 m_CanBeMovedOverride = false;
7241 m_CanBeDigged = ConfigGetBool("canBeDigged");
7242
7243 m_CompatibleLocks = new array<int>();
7244 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
7245 m_LockType = ConfigGetInt("lockType");
7246
7247 //Define if item can be split and set ability to be combined accordingly
7248 m_CanThisBeSplit = false;
7249 can_this_be_combined = false;
7250 if (ConfigIsExisting("canBeSplit"))
7251 {
7252 can_this_be_combined = ConfigGetBool("canBeSplit");
7254 }
7255
7256 m_ItemBehaviour = -1;
7257 if (ConfigIsExisting("itemBehaviour"))
7258 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
7259
7260 //RegisterNetSyncVariableInt("m_VariablesMask");
7261 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7262 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
7263 RegisterNetSyncVariableInt("m_VarLiquidType");
7264 RegisterNetSyncVariableInt("m_Cleanness",0,1);
7265
7266 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
7267 RegisterNetSyncVariableFloat("m_ImpactSpeed");
7268 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
7269
7270 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
7271 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
7272 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
7273 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
7274
7275 RegisterNetSyncVariableBool("m_IsBeingPlaced");
7276 RegisterNetSyncVariableBool("m_IsTakeable");
7277 RegisterNetSyncVariableBool("m_IsHologram");
7278
7279 InitItemSounds();
7281 {
7282 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
7283 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
7284 }
7285
7286 m_LockSoundSet = ConfigGetString("lockSoundSet");
7287
7289 if (ConfigIsExisting("temperaturePerQuantityWeight"))
7290 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
7291
7292 }
7293
7294 override int GetQuickBarBonus()
7295 {
7296 return m_QuickBarBonus;
7297 }
7298
7299 void InitializeActions()
7300 {
7302 if (!m_InputActionMap)
7303 {
7305 m_InputActionMap = iam;
7306 SetActions();
7308 }
7309 }
7310
7311 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
7312 {
7314 {
7315 m_ActionsInitialize = true;
7317 }
7318
7319 actions = m_InputActionMap.Get(action_input_type);
7320 }
7321
7322 void SetActions()
7323 {
7324 AddAction(ActionTakeItem);
7325 AddAction(ActionTakeItemToHands);
7326 AddAction(ActionWorldCraft);
7328 AddAction(ActionAttachWithSwitch);
7329 }
7330
7331 void SetActionAnimOverrides(); // Override action animation for specific item
7332
7333 void AddAction(typename actionName)
7334 {
7335 ActionBase action = ActionManagerBase.GetAction(actionName);
7336
7337 if (!action)
7338 {
7339 Debug.LogError("Action " + actionName + " dosn't exist!");
7340 return;
7341 }
7342
7343 typename ai = action.GetInputType();
7344 if (!ai)
7345 {
7346 m_ActionsInitialize = false;
7347 return;
7348 }
7349
7350 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7351 if (!action_array)
7352 {
7353 action_array = new array<ActionBase_Basic>;
7354 m_InputActionMap.Insert(ai, action_array);
7355 }
7356 if (LogManager.IsActionLogEnable())
7357 {
7358 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
7359 }
7360
7361 if (action_array.Find(action) != -1)
7362 {
7363 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
7364 }
7365 else
7366 {
7367 action_array.Insert(action);
7368 }
7369 }
7370
7371 void RemoveAction(typename actionName)
7372 {
7373 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7374 ActionBase action = player.GetActionManager().GetAction(actionName);
7375 typename ai = action.GetInputType();
7376 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
7377
7378 if (action_array)
7379 {
7380 action_array.RemoveItem(action);
7381 }
7382 }
7383
7384 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
7385 // Set -1 for params which should stay in default state
7386 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
7387 {
7388 ActionOverrideData overrideData = new ActionOverrideData();
7389 overrideData.m_CommandUID = commandUID;
7390 overrideData.m_CommandUIDProne = commandUIDProne;
7391 overrideData.m_StanceMask = stanceMask;
7392
7393 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
7394 if (!actionMap) // create new map of action > overidables map
7395 {
7396 actionMap = new TActionAnimOverrideMap();
7397 m_ItemActionOverrides.Insert(action, actionMap);
7398 }
7399
7400 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
7401
7402 }
7403
7404 void OnItemInHandsPlayerSwimStart(PlayerBase player);
7405
7406 ScriptedLightBase GetLight();
7407
7408 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7409 void LoadParticleConfigOnFire(int id)
7410 {
7411 if (!m_OnFireEffect)
7413
7416
7417 string config_to_search = "CfgVehicles";
7418 string muzzle_owner_config;
7419
7420 if (!m_OnFireEffect.Contains(id))
7421 {
7422 if (IsInherited(Weapon))
7423 config_to_search = "CfgWeapons";
7424
7425 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7426
7427 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
7428
7429 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
7430
7431 if (config_OnFire_subclass_count > 0)
7432 {
7433 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
7434
7435 for (int i = 0; i < config_OnFire_subclass_count; i++)
7436 {
7437 string particle_class = "";
7438 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
7439 string config_OnFire_entry = config_OnFire_class + particle_class;
7440 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
7441 WPOF_array.Insert(WPOF);
7442 }
7443
7444
7445 m_OnFireEffect.Insert(id, WPOF_array);
7446 }
7447 }
7448
7449 if (!m_OnBulletCasingEjectEffect.Contains(id))
7450 {
7451 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
7452 muzzle_owner_config = config_to_search + " " + GetType() + " ";
7453
7454 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
7455
7456 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
7457
7458 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
7459 {
7460 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
7461
7462 for (i = 0; i < config_OnBulletCasingEject_count; i++)
7463 {
7464 string particle_class2 = "";
7465 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
7466 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
7467 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
7468 WPOBE_array.Insert(WPOBE);
7469 }
7470
7471
7472 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
7473 }
7474 }
7475 }
7476
7477 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
7479 {
7482
7483 if (!m_OnOverheatingEffect.Contains(id))
7484 {
7485 string config_to_search = "CfgVehicles";
7486
7487 if (IsInherited(Weapon))
7488 config_to_search = "CfgWeapons";
7489
7490 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
7491 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
7492
7493 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
7494 {
7495
7496 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
7497
7499 {
7500 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
7501 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
7502 Error(error);
7503 return;
7504 }
7505
7506 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
7507 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
7508
7509
7510
7511 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
7512 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
7513
7514 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
7515 {
7516 string particle_class = "";
7517 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
7518 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
7519 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
7520
7521 if (entry_type == CT_CLASS)
7522 {
7523 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
7524 WPOOH_array.Insert(WPOF);
7525 }
7526 }
7527
7528
7529 m_OnOverheatingEffect.Insert(id, WPOOH_array);
7530 }
7531 }
7532 }
7533
7534 float GetOverheatingValue()
7535 {
7536 return m_OverheatingShots;
7537 }
7538
7539 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
7540 {
7541 if (m_MaxOverheatingValue > 0)
7542 {
7544
7545 if (!m_CheckOverheating)
7547
7549 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7550
7551 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7552 }
7553 }
7554
7555 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7556 {
7558 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7559
7561 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7562
7564 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7565
7567 {
7569 }
7570 }
7571
7573 {
7575 }
7576
7577 void OnOverheatingDecay()
7578 {
7579 if (m_MaxOverheatingValue > 0)
7580 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
7581 else
7583
7584 if (m_OverheatingShots <= 0)
7585 {
7588 }
7589 else
7590 {
7591 if (!m_CheckOverheating)
7593
7595 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
7596 }
7597
7598 CheckOverheating(this, "", this);
7599 }
7600
7601 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7602 {
7604 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7605 }
7606
7607 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7608 {
7610 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
7612 }
7613
7614 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
7615 {
7617 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
7618 }
7619
7620 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
7621 {
7623 m_OverheatingParticles = new array<ref OverheatingParticle>;
7624
7625 OverheatingParticle OP = new OverheatingParticle();
7626 OP.RegisterParticle(p);
7627 OP.SetOverheatingLimitMin(min_heat_coef);
7628 OP.SetOverheatingLimitMax(max_heat_coef);
7629 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
7630
7631 m_OverheatingParticles.Insert(OP);
7632 }
7633
7634 float GetOverheatingCoef()
7635 {
7636 if (m_MaxOverheatingValue > 0)
7638
7639 return -1;
7640 }
7641
7643 {
7645 {
7646 float overheat_coef = GetOverheatingCoef();
7647 int count = m_OverheatingParticles.Count();
7648
7649 for (int i = count; i > 0; --i)
7650 {
7651 int id = i - 1;
7652 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7653 Particle p = OP.GetParticle();
7654
7655 float overheat_min = OP.GetOverheatingLimitMin();
7656 float overheat_max = OP.GetOverheatingLimitMax();
7657
7658 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
7659 {
7660 if (p)
7661 {
7662 p.Stop();
7663 OP.RegisterParticle(null);
7664 }
7665 }
7666 }
7667 }
7668 }
7669
7671 {
7673 {
7674 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
7675 {
7676 int id = i - 1;
7677 OverheatingParticle OP = m_OverheatingParticles.Get(id);
7678
7679 if (OP)
7680 {
7681 Particle p = OP.GetParticle();
7682
7683 if (p)
7684 {
7685 p.Stop();
7686 }
7687
7688 delete OP;
7689 }
7690 }
7691
7692 m_OverheatingParticles.Clear();
7694 }
7695 }
7696
7698 float GetInfectionChance(int system = 0, Param param = null)
7699 {
7700 return 0.0;
7701 }
7702
7703
7704 float GetDisinfectQuantity(int system = 0, Param param1 = null)
7705 {
7706 return 250;//default value
7707 }
7708
7709 float GetFilterDamageRatio()
7710 {
7711 return 0;
7712 }
7713
7715 bool HasMuzzle()
7716 {
7717 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
7718 return true;
7719
7720 return false;
7721 }
7722
7724 int GetMuzzleID()
7725 {
7726 if (!m_WeaponTypeToID)
7728
7729 if (m_WeaponTypeToID.Contains(GetType()))
7730 {
7731 return m_WeaponTypeToID.Get(GetType());
7732 }
7733 else
7734 {
7735 // Register new weapon ID
7737 }
7738
7740 }
7741
7748 {
7749 return -1;
7750 }
7751
7752
7753
7754 // -------------------------------------------------------------------------
7755 void ~ItemBase()
7756 {
7757 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
7758 {
7759 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
7760 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7761
7762 if (r_index >= 0)
7763 {
7764 InventoryLocation r_il = new InventoryLocation;
7765 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7766
7767 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7768 int r_type = r_il.GetType();
7769 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7770 {
7771 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7772 }
7773 else if (r_type == InventoryLocationType.ATTACHMENT)
7774 {
7775 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7776 }
7777
7778 }
7779
7780 player.GetHumanInventory().ClearUserReservedLocation(this);
7781 }
7782
7783 if (m_LockingSound)
7784 SEffectManager.DestroyEffect(m_LockingSound);
7785 }
7786
7787
7788
7789 // -------------------------------------------------------------------------
7790 static int GetDebugActionsMask()
7791 {
7792 return ItemBase.m_DebugActionsMask;
7793 }
7794
7795 static bool HasDebugActionsMask(int mask)
7796 {
7797 return ItemBase.m_DebugActionsMask & mask;
7798 }
7799
7800 static void SetDebugActionsMask(int mask)
7801 {
7802 ItemBase.m_DebugActionsMask = mask;
7803 }
7804
7805 static void AddDebugActionsMask(int mask)
7806 {
7807 ItemBase.m_DebugActionsMask |= mask;
7808 }
7809
7810 static void RemoveDebugActionsMask(int mask)
7811 {
7812 ItemBase.m_DebugActionsMask &= ~mask;
7813 }
7814
7815 static void ToggleDebugActionsMask(int mask)
7816 {
7817 if (HasDebugActionsMask(mask))
7818 {
7820 }
7821 else
7822 {
7823 AddDebugActionsMask(mask);
7824 }
7825 }
7826
7827 // -------------------------------------------------------------------------
7828 void SetCEBasedQuantity()
7829 {
7830 if (GetEconomyProfile())
7831 {
7832 float q_max = GetEconomyProfile().GetQuantityMax();
7833 if (q_max > 0)
7834 {
7835 float q_min = GetEconomyProfile().GetQuantityMin();
7836 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
7837
7838 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
7839 {
7840 ComponentEnergyManager comp = GetCompEM();
7841 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
7842 {
7843 comp.SetEnergy0To1(quantity_randomized);
7844 }
7845 }
7846 else if (HasQuantity())
7847 {
7848 SetQuantityNormalized(quantity_randomized, false);
7849 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
7850 }
7851
7852 }
7853 }
7854 }
7855
7857 void LockToParent()
7858 {
7859 EntityAI parent = GetHierarchyParent();
7860
7861 if (parent)
7862 {
7863 InventoryLocation inventory_location_to_lock = new InventoryLocation;
7864 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
7865 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
7866 }
7867 }
7868
7870 void UnlockFromParent()
7871 {
7872 EntityAI parent = GetHierarchyParent();
7873
7874 if (parent)
7875 {
7876 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
7877 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
7878 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
7879 }
7880 }
7881
7882 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
7883 {
7884 /*
7885 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
7886 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
7887 */
7888 ItemBase item2 = ItemBase.Cast(entity2);
7889
7890 if (GetGame().IsClient())
7891 {
7892 if (ScriptInputUserData.CanStoreInputUserData())
7893 {
7894 ScriptInputUserData ctx = new ScriptInputUserData;
7896 ctx.Write(-1);
7897 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7898 ctx.Write(i1);
7899 ctx.Write(item2);
7900 ctx.Write(use_stack_max);
7901 ctx.Write(-1);
7902 ctx.Send();
7903
7904 if (IsCombineAll(item2, use_stack_max))
7905 {
7906 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
7907 }
7908 }
7909 }
7910 else if (!GetGame().IsMultiplayer())
7911 {
7912 CombineItems(item2, use_stack_max);
7913 }
7914 }
7915
7916 bool IsLiquidPresent()
7917 {
7918 return (GetLiquidType() != 0 && HasQuantity());
7919 }
7920
7921 bool IsLiquidContainer()
7922 {
7923 return m_LiquidContainerMask != 0;
7924 }
7925
7927 {
7928 return m_LiquidContainerMask;
7929 }
7930
7931 bool IsBloodContainer()
7932 {
7933 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
7934 return false;
7935 }
7936
7937 bool IsNVG()
7938 {
7939 return false;
7940 }
7941
7944 bool IsExplosive()
7945 {
7946 return false;
7947 }
7948
7950 {
7951 return "";
7952 }
7953
7955
7956 bool IsLightSource()
7957 {
7958 return false;
7959 }
7960
7962 {
7963 return true;
7964 }
7965
7966 //--- ACTION CONDITIONS
7967 //direction
7968 bool IsFacingPlayer(PlayerBase player, string selection)
7969 {
7970 return true;
7971 }
7972
7973 bool IsPlayerInside(PlayerBase player, string selection)
7974 {
7975 return true;
7976 }
7977
7978 override bool CanObstruct()
7979 {
7980 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7981 return !player || !IsPlayerInside(player, "");
7982 }
7983
7984 override bool IsBeingPlaced()
7985 {
7986 return m_IsBeingPlaced;
7987 }
7988
7989 void SetIsBeingPlaced(bool is_being_placed)
7990 {
7991 m_IsBeingPlaced = is_being_placed;
7992 if (!is_being_placed)
7994 SetSynchDirty();
7995 }
7996
7997 //server-side
7998 void OnEndPlacement() {}
7999
8000 override bool IsHologram()
8001 {
8002 return m_IsHologram;
8003 }
8004
8005 bool CanBeDigged()
8006 {
8007 return m_CanBeDigged;
8008 }
8009
8011 {
8012 return 1;
8013 }
8014
8015 bool CanMakeGardenplot()
8016 {
8017 return false;
8018 }
8019
8020 void SetIsHologram(bool is_hologram)
8021 {
8022 m_IsHologram = is_hologram;
8023 SetSynchDirty();
8024 }
8025 /*
8026 protected float GetNutritionalEnergy()
8027 {
8028 Edible_Base edible = Edible_Base.Cast(this);
8029 return edible.GetFoodEnergy();
8030 }
8031
8032 protected float GetNutritionalWaterContent()
8033 {
8034 Edible_Base edible = Edible_Base.Cast(this);
8035 return edible.GetFoodWater();
8036 }
8037
8038 protected float GetNutritionalIndex()
8039 {
8040 Edible_Base edible = Edible_Base.Cast(this);
8041 return edible.GetFoodNutritionalIndex();
8042 }
8043
8044 protected float GetNutritionalFullnessIndex()
8045 {
8046 Edible_Base edible = Edible_Base.Cast(this);
8047 return edible.GetFoodTotalVolume();
8048 }
8049
8050 protected float GetNutritionalToxicity()
8051 {
8052 Edible_Base edible = Edible_Base.Cast(this);
8053 return edible.GetFoodToxicity();
8054
8055 }
8056 */
8057
8058
8059 // -------------------------------------------------------------------------
8060 override void OnMovedInsideCargo(EntityAI container)
8061 {
8062 super.OnMovedInsideCargo(container);
8063
8064 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8065 }
8066
8067 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8068 {
8069 super.EEItemLocationChanged(oldLoc,newLoc);
8070
8071 PlayerBase new_player = null;
8072 PlayerBase old_player = null;
8073
8074 if (newLoc.GetParent())
8075 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8076
8077 if (oldLoc.GetParent())
8078 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8079
8080 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
8081 {
8082 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
8083
8084 if (r_index >= 0)
8085 {
8086 InventoryLocation r_il = new InventoryLocation;
8087 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8088
8089 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8090 int r_type = r_il.GetType();
8091 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8092 {
8093 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8094 }
8095 else if (r_type == InventoryLocationType.ATTACHMENT)
8096 {
8097 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8098 }
8099
8100 }
8101 }
8102
8103 if (newLoc.GetType() == InventoryLocationType.HANDS)
8104 {
8105 if (new_player)
8106 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
8107
8108 if (new_player == old_player)
8109 {
8110
8111 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8112 {
8113 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8114 {
8115 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8116 {
8117 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8118 }
8119 }
8120 else
8121 {
8122 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8123 }
8124 }
8125
8126 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
8127 {
8128 int type = oldLoc.GetType();
8129 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
8130 {
8131 oldLoc.GetParent().GetOnSetLock().Invoke(this);
8132 }
8133 else if (type == InventoryLocationType.ATTACHMENT)
8134 {
8135 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
8136 }
8137 }
8138 if (!m_OldLocation)
8139 {
8140 m_OldLocation = new InventoryLocation;
8141 }
8142 m_OldLocation.Copy(oldLoc);
8143 }
8144 else
8145 {
8146 if (m_OldLocation)
8147 {
8148 m_OldLocation.Reset();
8149 }
8150 }
8151
8153 }
8154 else
8155 {
8156 if (new_player)
8157 {
8158 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
8159 if (res_index >= 0)
8160 {
8161 InventoryLocation il = new InventoryLocation;
8162 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
8163 ItemBase it = ItemBase.Cast(il.GetItem());
8164 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
8165 int rel_type = il.GetType();
8166 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
8167 {
8168 il.GetParent().GetOnReleaseLock().Invoke(it);
8169 }
8170 else if (rel_type == InventoryLocationType.ATTACHMENT)
8171 {
8172 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
8173 }
8174 //it.GetOnReleaseLock().Invoke(it);
8175 }
8176 }
8177 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
8178 {
8179 //ThrowPhysically(old_player, vector.Zero);
8180 m_ThrowItemOnDrop = false;
8181 }
8182
8183 if (m_OldLocation)
8184 {
8185 m_OldLocation.Reset();
8186 }
8187 }
8188 }
8189
8190 override void EOnContact(IEntity other, Contact extra)
8191 {
8193 {
8194 int liquidType = -1;
8195 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
8196 if (impactSpeed > 0.0)
8197 {
8198 m_ImpactSpeed = impactSpeed;
8199 #ifndef SERVER
8200 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8201 #else
8202 m_WantPlayImpactSound = true;
8203 SetSynchDirty();
8204 #endif
8205 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
8206 }
8207 }
8208
8209 #ifdef SERVER
8210 if (GetCompEM() && GetCompEM().IsPlugged())
8211 {
8212 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
8213 GetCompEM().UnplugThis();
8214 }
8215 #endif
8216 }
8217
8218 void RefreshPhysics();
8219
8220 override void OnCreatePhysics()
8221 {
8223 }
8224
8225 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8226 {
8227
8228 }
8229 // -------------------------------------------------------------------------
8230 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
8231 {
8232 super.OnItemLocationChanged(old_owner, new_owner);
8233
8234 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
8235 PlayerBase playerNew = PlayerBase.Cast(new_owner);
8236
8237 if (!relatedPlayer && playerNew)
8238 relatedPlayer = playerNew;
8239
8240 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
8241 {
8242 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
8243 if (actionMgr)
8244 {
8245 ActionBase currentAction = actionMgr.GetRunningAction();
8246 if (currentAction)
8247 currentAction.OnItemLocationChanged(this);
8248 }
8249 }
8250
8251 Man ownerPlayerOld = null;
8252 Man ownerPlayerNew = null;
8253
8254 if (old_owner)
8255 {
8256 if (old_owner.IsMan())
8257 {
8258 ownerPlayerOld = Man.Cast(old_owner);
8259 }
8260 else
8261 {
8262 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
8263 }
8264 }
8265 else
8266 {
8267 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
8268 {
8269 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
8270
8271 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
8272 {
8273 GetCompEM().UnplugThis();
8274 }
8275 }
8276 }
8277
8278 if (new_owner)
8279 {
8280 if (new_owner.IsMan())
8281 {
8282 ownerPlayerNew = Man.Cast(new_owner);
8283 }
8284 else
8285 {
8286 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
8287 }
8288 }
8289
8290 if (ownerPlayerOld != ownerPlayerNew)
8291 {
8292 if (ownerPlayerOld)
8293 {
8294 array<EntityAI> subItemsExit = new array<EntityAI>;
8295 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
8296 for (int i = 0; i < subItemsExit.Count(); i++)
8297 {
8298 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
8299 itemExit.OnInventoryExit(ownerPlayerOld);
8300 }
8301 }
8302
8303 if (ownerPlayerNew)
8304 {
8305 array<EntityAI> subItemsEnter = new array<EntityAI>;
8306 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
8307 for (int j = 0; j < subItemsEnter.Count(); j++)
8308 {
8309 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
8310 itemEnter.OnInventoryEnter(ownerPlayerNew);
8311 }
8312 }
8313 }
8314 else if (ownerPlayerNew != null)
8315 {
8316 PlayerBase nplayer;
8317 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
8318 {
8319 array<EntityAI> subItemsUpdate = new array<EntityAI>;
8320 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
8321 for (int k = 0; k < subItemsUpdate.Count(); k++)
8322 {
8323 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
8324 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
8325 }
8326 }
8327 }
8328
8329 if (old_owner)
8330 old_owner.OnChildItemRemoved(this);
8331 if (new_owner)
8332 new_owner.OnChildItemReceived(this);
8333 }
8334
8335 // -------------------------------------------------------------------------------
8336 override void EEDelete(EntityAI parent)
8337 {
8338 super.EEDelete(parent);
8339 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
8340 if (player)
8341 {
8342 OnInventoryExit(player);
8343
8344 if (player.IsAlive())
8345 {
8346 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8347 if (r_index >= 0)
8348 {
8349 InventoryLocation r_il = new InventoryLocation;
8350 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8351
8352 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8353 int r_type = r_il.GetType();
8354 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8355 {
8356 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8357 }
8358 else if (r_type == InventoryLocationType.ATTACHMENT)
8359 {
8360 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8361 }
8362
8363 }
8364
8365 player.RemoveQuickBarEntityShortcut(this);
8366 }
8367 }
8368 }
8369 // -------------------------------------------------------------------------------
8370 override void EEKilled(Object killer)
8371 {
8372 super.EEKilled(killer);
8373
8375 if (killer && killer.IsFireplace() && CanExplodeInFire())
8376 {
8377 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
8378 {
8379 if (IsMagazine())
8380 {
8381 if (Magazine.Cast(this).GetAmmoCount() > 0)
8382 {
8383 ExplodeAmmo();
8384 }
8385 }
8386 else
8387 {
8388 Explode(DamageType.EXPLOSION);
8389 }
8390 }
8391 }
8392 }
8393
8394 override void OnWasAttached(EntityAI parent, int slot_id)
8395 {
8396 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8397
8398 super.OnWasAttached(parent, slot_id);
8399
8400 if (HasQuantity())
8401 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8402
8403 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
8404 }
8405
8406 override void OnWasDetached(EntityAI parent, int slot_id)
8407 {
8408 super.OnWasDetached(parent, slot_id);
8409
8410 if (HasQuantity())
8411 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8412 }
8413
8414 override string ChangeIntoOnAttach(string slot)
8415 {
8416 int idx;
8417 TStringArray inventory_slots = new TStringArray;
8418 TStringArray attach_types = new TStringArray;
8419
8420 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8421 if (inventory_slots.Count() < 1) //is string
8422 {
8423 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
8424 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
8425 }
8426 else //is array
8427 {
8428 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
8429 }
8430
8431 idx = inventory_slots.Find(slot);
8432 if (idx < 0)
8433 return "";
8434
8435 return attach_types.Get(idx);
8436 }
8437
8438 override string ChangeIntoOnDetach()
8439 {
8440 int idx = -1;
8441 string slot;
8442
8443 TStringArray inventory_slots = new TStringArray;
8444 TStringArray detach_types = new TStringArray;
8445
8446 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
8447 if (inventory_slots.Count() < 1) //is string
8448 {
8449 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
8450 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8451 }
8452 else //is array
8453 {
8454 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
8455 if (detach_types.Count() < 1)
8456 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
8457 }
8458
8459 for (int i = 0; i < inventory_slots.Count(); i++)
8460 {
8461 slot = inventory_slots.Get(i);
8462 }
8463
8464 if (slot != "")
8465 {
8466 if (detach_types.Count() == 1)
8467 idx = 0;
8468 else
8469 idx = inventory_slots.Find(slot);
8470 }
8471 if (idx < 0)
8472 return "";
8473
8474 return detach_types.Get(idx);
8475 }
8476
8477 void ExplodeAmmo()
8478 {
8479 //timer
8480 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
8481
8482 //min/max time
8483 float min_time = 1;
8484 float max_time = 3;
8485 float delay = Math.RandomFloat(min_time, max_time);
8486
8487 explode_timer.Run(delay, this, "DoAmmoExplosion");
8488 }
8489
8490 void DoAmmoExplosion()
8491 {
8492 Magazine magazine = Magazine.Cast(this);
8493 int pop_sounds_count = 6;
8494 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
8495
8496 //play sound
8497 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
8498 string sound_name = pop_sounds[ sound_idx ];
8499 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
8500
8501 //remove ammo count
8502 magazine.ServerAddAmmoCount(-1);
8503
8504 //if condition then repeat -> ExplodeAmmo
8505 float min_temp_to_explode = 100; //min temperature for item to explode
8506
8507 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
8508 {
8509 ExplodeAmmo();
8510 }
8511 }
8512
8513 // -------------------------------------------------------------------------------
8514 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
8515 {
8516 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
8517
8518 const int CHANCE_DAMAGE_CARGO = 4;
8519 const int CHANCE_DAMAGE_ATTACHMENT = 1;
8520 const int CHANCE_DAMAGE_NOTHING = 2;
8521
8522 if (IsClothing() || IsContainer() || IsItemTent())
8523 {
8524 float dmg = damageResult.GetDamage("","Health") * -0.5;
8525 int chances;
8526 int rnd;
8527
8528 if (GetInventory().GetCargo())
8529 {
8530 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8531 rnd = Math.RandomInt(0,chances);
8532
8533 if (rnd < CHANCE_DAMAGE_CARGO)
8534 {
8535 DamageItemInCargo(dmg);
8536 }
8537 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
8538 {
8540 }
8541 }
8542 else
8543 {
8544 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
8545 rnd = Math.RandomInt(0,chances);
8546
8547 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
8548 {
8550 }
8551 }
8552 }
8553 }
8554
8555 bool DamageItemInCargo(float damage)
8556 {
8557 if (GetInventory().GetCargo())
8558 {
8559 int item_count = GetInventory().GetCargo().GetItemCount();
8560 if (item_count > 0)
8561 {
8562 int random_pick = Math.RandomInt(0, item_count);
8563 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
8564 if (!item.IsExplosive())
8565 {
8566 item.AddHealth("","",damage);
8567 return true;
8568 }
8569 }
8570 }
8571 return false;
8572 }
8573
8574 bool DamageItemAttachments(float damage)
8575 {
8576 int attachment_count = GetInventory().AttachmentCount();
8577 if (attachment_count > 0)
8578 {
8579 int random_pick = Math.RandomInt(0, attachment_count);
8580 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
8581 if (!attachment.IsExplosive())
8582 {
8583 attachment.AddHealth("","",damage);
8584 return true;
8585 }
8586 }
8587 return false;
8588 }
8589
8590 override bool IsSplitable()
8591 {
8592 return m_CanThisBeSplit;
8593 }
8594 //----------------
8595 override bool CanBeSplit()
8596 {
8597 if (IsSplitable() && (GetQuantity() > 1))
8598 return GetInventory().CanRemoveEntity();
8599
8600 return false;
8601 }
8602
8603 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
8604 {
8605 if (!CanBeSplit())
8606 return;
8607
8608 if (GetGame().IsClient())
8609 {
8610 if (ScriptInputUserData.CanStoreInputUserData())
8611 {
8612 ScriptInputUserData ctx = new ScriptInputUserData;
8614 ctx.Write(1);
8615 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8616 ctx.Write(i1);
8617 ctx.Write(destination_entity);
8618 ctx.Write(true);
8619 ctx.Write(slot_id);
8620 ctx.Send();
8621 }
8622 }
8623 else if (!GetGame().IsMultiplayer())
8624 {
8625 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
8626 }
8627 }
8628
8629 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
8630 {
8631 if (!CanBeSplit())
8632 return;
8633
8634 float split_quantity_new;
8635 ref ItemBase new_item;
8636 float quantity = GetQuantity();
8637 float stack_max = GetTargetQuantityMax(slot_id);
8638 InventoryLocation loc = new InventoryLocation;
8639
8640 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8641 {
8642 if (stack_max <= GetQuantity())
8643 split_quantity_new = stack_max;
8644 else
8645 split_quantity_new = GetQuantity();
8646
8647 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8648 if (new_item)
8649 {
8650 new_item.SetResultOfSplit(true);
8651 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8652 AddQuantity(-split_quantity_new);
8653 new_item.SetQuantity(split_quantity_new);
8654 }
8655 }
8656 else if (destination_entity && slot_id == -1)
8657 {
8658 if (quantity > stack_max)
8659 split_quantity_new = stack_max;
8660 else
8661 split_quantity_new = quantity;
8662
8663 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8664 {
8665 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8666 new_item = ItemBase.Cast(o);
8667 }
8668
8669 if (new_item)
8670 {
8671 new_item.SetResultOfSplit(true);
8672 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8673 AddQuantity(-split_quantity_new);
8674 new_item.SetQuantity(split_quantity_new);
8675 }
8676 }
8677 else
8678 {
8679 if (stack_max != 0)
8680 {
8681 if (stack_max < GetQuantity())
8682 {
8683 split_quantity_new = GetQuantity() - stack_max;
8684 }
8685
8686 if (split_quantity_new == 0)
8687 {
8688 if (!GetGame().IsMultiplayer())
8689 player.PhysicalPredictiveDropItem(this);
8690 else
8691 player.ServerDropEntity(this);
8692 return;
8693 }
8694
8695 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8696
8697 if (new_item)
8698 {
8699 new_item.SetResultOfSplit(true);
8700 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8701 SetQuantity(split_quantity_new);
8702 new_item.SetQuantity(stack_max);
8703 new_item.PlaceOnSurface();
8704 }
8705 }
8706 }
8707 }
8708
8709 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
8710 {
8711 if (!CanBeSplit())
8712 return;
8713
8714 float split_quantity_new;
8715 ref ItemBase new_item;
8716 float quantity = GetQuantity();
8717 float stack_max = GetTargetQuantityMax(slot_id);
8718 InventoryLocation loc = new InventoryLocation;
8719
8720 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
8721 {
8722 if (stack_max <= GetQuantity())
8723 split_quantity_new = stack_max;
8724 else
8725 split_quantity_new = GetQuantity();
8726
8727 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
8728 if (new_item)
8729 {
8730 new_item.SetResultOfSplit(true);
8731 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8732 AddQuantity(-split_quantity_new);
8733 new_item.SetQuantity(split_quantity_new);
8734 }
8735 }
8736 else if (destination_entity && slot_id == -1)
8737 {
8738 if (quantity > stack_max)
8739 split_quantity_new = stack_max;
8740 else
8741 split_quantity_new = quantity;
8742
8743 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
8744 {
8745 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
8746 new_item = ItemBase.Cast(o);
8747 }
8748
8749 if (new_item)
8750 {
8751 new_item.SetResultOfSplit(true);
8752 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8753 AddQuantity(-split_quantity_new);
8754 new_item.SetQuantity(split_quantity_new);
8755 }
8756 }
8757 else
8758 {
8759 if (stack_max != 0)
8760 {
8761 if (stack_max < GetQuantity())
8762 {
8763 split_quantity_new = GetQuantity() - stack_max;
8764 }
8765
8766 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
8767
8768 if (new_item)
8769 {
8770 new_item.SetResultOfSplit(true);
8771 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8772 SetQuantity(split_quantity_new);
8773 new_item.SetQuantity(stack_max);
8774 new_item.PlaceOnSurface();
8775 }
8776 }
8777 }
8778 }
8779
8780 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
8781 {
8782 if (!CanBeSplit())
8783 return;
8784
8785 if (GetGame().IsClient())
8786 {
8787 if (ScriptInputUserData.CanStoreInputUserData())
8788 {
8789 ScriptInputUserData ctx = new ScriptInputUserData;
8791 ctx.Write(4);
8792 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8793 ctx.Write(thiz);
8794 dst.WriteToContext(ctx);
8795 ctx.Send();
8796 }
8797 }
8798 else if (!GetGame().IsMultiplayer())
8799 {
8801 }
8802 }
8803
8804 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
8805 {
8806 if (!CanBeSplit())
8807 return;
8808
8809 if (GetGame().IsClient())
8810 {
8811 if (ScriptInputUserData.CanStoreInputUserData())
8812 {
8813 ScriptInputUserData ctx = new ScriptInputUserData;
8815 ctx.Write(2);
8816 ItemBase dummy = this; // @NOTE: workaround for correct serialization
8817 ctx.Write(dummy);
8818 ctx.Write(destination_entity);
8819 ctx.Write(true);
8820 ctx.Write(idx);
8821 ctx.Write(row);
8822 ctx.Write(col);
8823 ctx.Send();
8824 }
8825 }
8826 else if (!GetGame().IsMultiplayer())
8827 {
8828 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
8829 }
8830 }
8831
8832 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
8833 {
8835 }
8836
8837 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
8838 {
8839 if (!CanBeSplit())
8840 return this;
8841
8842 float quantity = GetQuantity();
8843 float split_quantity_new;
8844 ItemBase new_item;
8845 if (dst.IsValid())
8846 {
8847 int slot_id = dst.GetSlot();
8848 float stack_max = GetTargetQuantityMax(slot_id);
8849
8850 if (quantity > stack_max)
8851 split_quantity_new = stack_max;
8852 else
8853 split_quantity_new = quantity;
8854
8855 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8856
8857 if (new_item)
8858 {
8859 new_item.SetResultOfSplit(true);
8860 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8861 AddQuantity(-split_quantity_new);
8862 new_item.SetQuantity(split_quantity_new);
8863 }
8864
8865 return new_item;
8866 }
8867
8868 return null;
8869 }
8870
8871 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
8872 {
8873 if (!CanBeSplit())
8874 return;
8875
8876 float quantity = GetQuantity();
8877 float split_quantity_new;
8878 ref ItemBase new_item;
8879 if (destination_entity)
8880 {
8881 float stackable = GetTargetQuantityMax();
8882 if (quantity > stackable)
8883 split_quantity_new = stackable;
8884 else
8885 split_quantity_new = quantity;
8886
8887 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
8888 if (new_item)
8889 {
8890 new_item.SetResultOfSplit(true);
8891 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8892 AddQuantity(-split_quantity_new);
8893 new_item.SetQuantity(split_quantity_new);
8894 }
8895 }
8896 }
8897
8898 void SplitIntoStackMaxHandsClient(PlayerBase player)
8899 {
8900 if (!CanBeSplit())
8901 return;
8902
8903 if (GetGame().IsClient())
8904 {
8905 if (ScriptInputUserData.CanStoreInputUserData())
8906 {
8907 ScriptInputUserData ctx = new ScriptInputUserData;
8909 ctx.Write(3);
8910 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8911 ctx.Write(i1);
8912 ItemBase destination_entity = this;
8913 ctx.Write(destination_entity);
8914 ctx.Write(true);
8915 ctx.Write(0);
8916 ctx.Send();
8917 }
8918 }
8919 else if (!GetGame().IsMultiplayer())
8920 {
8921 SplitIntoStackMaxHands(player);
8922 }
8923 }
8924
8925 void SplitIntoStackMaxHands(PlayerBase player)
8926 {
8927 if (!CanBeSplit())
8928 return;
8929
8930 float quantity = GetQuantity();
8931 float split_quantity_new;
8932 ref ItemBase new_item;
8933 if (player)
8934 {
8935 float stackable = GetTargetQuantityMax();
8936 if (quantity > stackable)
8937 split_quantity_new = stackable;
8938 else
8939 split_quantity_new = quantity;
8940
8941 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
8942 new_item = ItemBase.Cast(in_hands);
8943 if (new_item)
8944 {
8945 new_item.SetResultOfSplit(true);
8946 MiscGameplayFunctions.TransferItemProperties(this,new_item);
8947 AddQuantity(-split_quantity_new);
8948 new_item.SetQuantity(split_quantity_new);
8949 }
8950 }
8951 }
8952
8953 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
8954 {
8955 if (!CanBeSplit())
8956 return;
8957
8958 float quantity = GetQuantity();
8959 float split_quantity_new = Math.Floor(quantity * 0.5);
8960
8961 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
8962
8963 if (new_item)
8964 {
8965 if (new_item.GetQuantityMax() < split_quantity_new)
8966 {
8967 split_quantity_new = new_item.GetQuantityMax();
8968 }
8969
8970 new_item.SetResultOfSplit(true);
8971 MiscGameplayFunctions.TransferItemProperties(this, new_item);
8972
8973 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
8974 {
8975 AddQuantity(-1);
8976 new_item.SetQuantity(1);
8977 }
8978 else
8979 {
8980 AddQuantity(-split_quantity_new);
8981 new_item.SetQuantity(split_quantity_new);
8982 }
8983 }
8984 }
8985
8986 void SplitItem(PlayerBase player)
8987 {
8988 if (!CanBeSplit())
8989 return;
8990
8991 float quantity = GetQuantity();
8992 float split_quantity_new = Math.Floor(quantity / 2);
8993
8994 InventoryLocation invloc = new InventoryLocation;
8995 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
8996
8997 ItemBase new_item;
8998 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
8999
9000 if (new_item)
9001 {
9002 if (new_item.GetQuantityMax() < split_quantity_new)
9003 {
9004 split_quantity_new = new_item.GetQuantityMax();
9005 }
9006 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9007 {
9008 AddQuantity(-1);
9009 new_item.SetQuantity(1);
9010 }
9011 else
9012 {
9013 AddQuantity(-split_quantity_new);
9014 new_item.SetQuantity(split_quantity_new);
9015 }
9016 }
9017 }
9018
9020 void OnQuantityChanged(float delta)
9021 {
9022 SetWeightDirty();
9023 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9024
9025 if (parent)
9026 parent.OnAttachmentQuantityChangedEx(this, delta);
9027
9028 if (IsLiquidContainer())
9029 {
9030 if (GetQuantityNormalized() <= 0.0)
9031 {
9033 }
9034 else if (GetLiquidType() == LIQUID_NONE)
9035 {
9036 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
9038 }
9039 }
9040
9041 }
9042
9045 {
9046 // insert code here
9047 }
9048
9050 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
9051 {
9053 }
9054
9055 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
9056 {
9057 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
9058
9059 if (GetGame().IsServer())
9060 {
9061 if (newLevel == GameConstants.STATE_RUINED)
9062 {
9064 EntityAI parent = GetHierarchyParent();
9065 if (parent && parent.IsFireplace())
9066 {
9067 CargoBase cargo = GetInventory().GetCargo();
9068 if (cargo)
9069 {
9070 for (int i = 0; i < cargo.GetItemCount(); ++i)
9071 {
9072 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
9073 }
9074 }
9075 }
9076 }
9077
9078 if (IsResultOfSplit())
9079 {
9080 // reset the splitting result flag, return to normal item behavior
9081 SetResultOfSplit(false);
9082 return;
9083 }
9084
9085 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
9086 {
9087 SetCleanness(0);//unclean the item upon damage dealt
9088 }
9089 }
9090 }
9091
9092 // just the split? TODO: verify
9093 override void OnRightClick()
9094 {
9095 super.OnRightClick();
9096
9097 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
9098 {
9099 if (GetGame().IsClient())
9100 {
9101 if (ScriptInputUserData.CanStoreInputUserData())
9102 {
9103 vector m4[4];
9104 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9105
9106 EntityAI root = GetHierarchyRoot();
9107
9108 InventoryLocation dst = new InventoryLocation;
9109 if (!player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.CARGO, dst))
9110 {
9111 if (root)
9112 {
9113 root.GetTransform(m4);
9114 dst.SetGround(this, m4);
9115 }
9116 else
9117 GetInventory().GetCurrentInventoryLocation(dst);
9118 }
9119 else
9120 {
9121 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
9122 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
9123 this shouldnt cause issues within this scope*/
9124 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
9125 {
9126 if (root)
9127 {
9128 root.GetTransform(m4);
9129 dst.SetGround(this, m4);
9130 }
9131 else
9132 GetInventory().GetCurrentInventoryLocation(dst);
9133 }
9134 else
9135 {
9136 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
9137 }
9138 }
9139
9140 ScriptInputUserData ctx = new ScriptInputUserData;
9142 ctx.Write(4);
9143 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9144 ctx.Write(thiz);
9145 dst.WriteToContext(ctx);
9146 ctx.Write(true); // dummy
9147 ctx.Send();
9148 }
9149 }
9150 else if (!GetGame().IsMultiplayer())
9151 {
9152 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
9153 }
9154 }
9155 }
9156
9157 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
9158 {
9159 //TODO: delete check zero quantity check after fix double posts hands fsm events
9160 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
9161 return false;
9162
9163 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
9164 return false;
9165
9166 //can_this_be_combined = ConfigGetBool("canBeSplit");
9168 return false;
9169
9170
9171 Magazine mag = Magazine.Cast(this);
9172 if (mag)
9173 {
9174 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
9175 return false;
9176
9177 if (stack_max_limit)
9178 {
9179 Magazine other_mag = Magazine.Cast(other_item);
9180 if (other_item)
9181 {
9182 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
9183 return false;
9184 }
9185
9186 }
9187 }
9188 else
9189 {
9190 //TODO: delete check zero quantity check after fix double posts hands fsm events
9191 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
9192 return false;
9193
9194 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
9195 return false;
9196 }
9197
9198 PlayerBase player = null;
9199 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
9200 {
9201 if (player.GetInventory().HasAttachment(this))
9202 return false;
9203
9204 if (player.IsItemsToDelete())
9205 return false;
9206 }
9207
9208 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
9209 return false;
9210
9211 int slotID;
9212 string slotName;
9213 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
9214 return false;
9215
9216 return true;
9217 }
9218
9219 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
9220 {
9221 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
9222 }
9223
9224 bool IsResultOfSplit()
9225 {
9226 return m_IsResultOfSplit;
9227 }
9228
9229 void SetResultOfSplit(bool value)
9230 {
9231 m_IsResultOfSplit = value;
9232 }
9233
9234 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
9235 {
9236 return ComputeQuantityUsedEx(other_item, use_stack_max);
9237 }
9238
9239 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
9240 {
9241 float other_item_quantity = other_item.GetQuantity();
9242 float this_free_space;
9243
9244 float stack_max = GetQuantityMax();
9245
9246 this_free_space = stack_max - GetQuantity();
9247
9248 if (other_item_quantity > this_free_space)
9249 {
9250 return this_free_space;
9251 }
9252 else
9253 {
9254 return other_item_quantity;
9255 }
9256 }
9257
9258 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
9259 {
9260 CombineItems(ItemBase.Cast(entity2),use_stack_max);
9261 }
9262
9263 void CombineItems(ItemBase other_item, bool use_stack_max = true)
9264 {
9265 if (!CanBeCombined(other_item, false))
9266 return;
9267
9268 if (!IsMagazine() && other_item)
9269 {
9270 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
9271 if (quantity_used != 0)
9272 {
9273 float hp1 = GetHealth01("","");
9274 float hp2 = other_item.GetHealth01("","");
9275 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
9276 hpResult = hpResult / (GetQuantity() + quantity_used);
9277
9278 hpResult *= GetMaxHealth();
9279 Math.Round(hpResult);
9280 SetHealth("", "Health", hpResult);
9281
9282 AddQuantity(quantity_used);
9283 other_item.AddQuantity(-quantity_used);
9284 }
9285 }
9286 OnCombine(other_item);
9287 }
9288
9289 void OnCombine(ItemBase other_item)
9290 {
9291 #ifdef SERVER
9292 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
9293 GetHierarchyParent().IncreaseLifetimeUp();
9294 #endif
9295 };
9296
9297 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
9298 {
9299 PlayerBase p = PlayerBase.Cast(player);
9300
9301 array<int> recipesIds = p.m_Recipes;
9302 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9303 if (moduleRecipesManager)
9304 {
9305 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
9306 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
9307 }
9308
9309 for (int i = 0;i < recipesIds.Count(); i++)
9310 {
9311 int key = recipesIds.Get(i);
9312 string recipeName = moduleRecipesManager.GetRecipeName(key);
9313 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
9314 }
9315 }
9316
9317 // -------------------------------------------------------------------------
9318 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
9319 {
9320 super.GetDebugActions(outputList);
9321
9322 //quantity
9323 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
9324 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
9325 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
9326 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
9327
9328 //health
9329 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
9330 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
9331 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
9332 //temperature
9333 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
9334 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
9335 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
9336
9337 //wet
9338 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
9339 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
9340
9341 //liquidtype
9342 if (IsLiquidContainer())
9343 {
9344 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
9345 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
9346 }
9347
9348 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
9349 // watch
9350 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
9351 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
9352
9353 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
9354 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
9355 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
9356 }
9357
9358 // -------------------------------------------------------------------------
9359 // -------------------------------------------------------------------------
9360 // -------------------------------------------------------------------------
9361 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
9362 {
9363 super.OnAction(action_id, player, ctx);
9364 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
9365 {
9366 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
9367 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
9368 PlayerBase p = PlayerBase.Cast(player);
9369 if (EActions.RECIPES_RANGE_START < 1000)
9370 {
9371 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
9372 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
9373 }
9374 }
9375 #ifndef SERVER
9376 else if (action_id == EActions.WATCH_PLAYER)
9377 {
9378 PluginDeveloper.SetDeveloperItemClientEx(player);
9379 }
9380 #endif
9381 if (GetGame().IsServer())
9382 {
9383 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
9384 {
9385 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
9386 OnDebugButtonPressServer(id + 1);
9387 }
9388
9389 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
9390 {
9391 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
9392 InsertAgent(agent_id,100);
9393 }
9394
9395 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
9396 {
9397 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
9398 RemoveAgent(agent_id2);
9399 }
9400
9401 else if (action_id == EActions.ADD_QUANTITY)
9402 {
9403 if (IsMagazine())
9404 {
9405 Magazine mag = Magazine.Cast(this);
9406 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
9407 }
9408 else
9409 {
9410 AddQuantity(GetQuantityMax() * 0.2);
9411 }
9412
9413 if (m_EM)
9414 {
9415 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
9416 }
9417 //PrintVariables();
9418 }
9419
9420 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
9421 {
9422 if (IsMagazine())
9423 {
9424 Magazine mag2 = Magazine.Cast(this);
9425 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
9426 }
9427 else
9428 {
9429 AddQuantity(- GetQuantityMax() * 0.2);
9430 }
9431 if (m_EM)
9432 {
9433 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
9434 }
9435 //PrintVariables();
9436 }
9437
9438 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
9439 {
9440 SetQuantity(0);
9441
9442 if (m_EM)
9443 {
9444 m_EM.SetEnergy(0);
9445 }
9446 }
9447
9448 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
9449 {
9451
9452 if (m_EM)
9453 {
9454 m_EM.SetEnergy(m_EM.GetEnergyMax());
9455 }
9456 }
9457
9458 else if (action_id == EActions.ADD_HEALTH)
9459 {
9460 AddHealth("","",GetMaxHealth("","Health")/5);
9461 }
9462 else if (action_id == EActions.REMOVE_HEALTH)
9463 {
9464 AddHealth("","",-GetMaxHealth("","Health")/5);
9465 }
9466 else if (action_id == EActions.DESTROY_HEALTH)
9467 {
9468 SetHealth01("","",0);
9469 }
9470 else if (action_id == EActions.WATCH_ITEM)
9471 {
9473 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
9474 #ifdef DEVELOPER
9475 SetDebugDeveloper_item(this);
9476 #endif
9477 }
9478
9479 else if (action_id == EActions.ADD_TEMPERATURE)
9480 {
9481 AddTemperature(20);
9482 //PrintVariables();
9483 }
9484
9485 else if (action_id == EActions.REMOVE_TEMPERATURE)
9486 {
9487 AddTemperature(-20);
9488 //PrintVariables();
9489 }
9490
9491 else if (action_id == EActions.FLIP_FROZEN)
9492 {
9493 SetFrozen(!GetIsFrozen());
9494 //PrintVariables();
9495 }
9496
9497 else if (action_id == EActions.ADD_WETNESS)
9498 {
9499 AddWet(GetWetMax()/5);
9500 //PrintVariables();
9501 }
9502
9503 else if (action_id == EActions.REMOVE_WETNESS)
9504 {
9505 AddWet(-GetWetMax()/5);
9506 //PrintVariables();
9507 }
9508
9509 else if (action_id == EActions.LIQUIDTYPE_UP)
9510 {
9511 int curr_type = GetLiquidType();
9512 SetLiquidType(curr_type * 2);
9513 //AddWet(1);
9514 //PrintVariables();
9515 }
9516
9517 else if (action_id == EActions.LIQUIDTYPE_DOWN)
9518 {
9519 int curr_type2 = GetLiquidType();
9520 SetLiquidType(curr_type2 / 2);
9521 }
9522
9523 else if (action_id == EActions.MAKE_SPECIAL)
9524 {
9525 auto debugParams = DebugSpawnParams.WithPlayer(player);
9526 OnDebugSpawnEx(debugParams);
9527 }
9528
9529 else if (action_id == EActions.DELETE)
9530 {
9531 Delete();
9532 }
9533
9534 }
9535
9536
9537 return false;
9538 }
9539
9540 // -------------------------------------------------------------------------
9541
9542
9545 void OnActivatedByTripWire();
9546
9548 void OnActivatedByItem(notnull ItemBase item);
9549
9550 //----------------------------------------------------------------
9551 //returns true if item is able to explode when put in fire
9552 bool CanExplodeInFire()
9553 {
9554 return false;
9555 }
9556
9557 //----------------------------------------------------------------
9558 bool CanEat()
9559 {
9560 return true;
9561 }
9562
9563 //----------------------------------------------------------------
9564 override bool IsIgnoredByConstruction()
9565 {
9566 return true;
9567 }
9568
9569 //----------------------------------------------------------------
9570 //has FoodStages in config?
9571 bool HasFoodStage()
9572 {
9573 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
9574 return GetGame().ConfigIsExisting(config_path);
9575 }
9576
9578 FoodStage GetFoodStage()
9579 {
9580 return null;
9581 }
9582
9583 bool CanBeCooked()
9584 {
9585 return false;
9586 }
9587
9588 bool CanBeCookedOnStick()
9589 {
9590 return false;
9591 }
9592
9594 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
9596
9597 //----------------------------------------------------------------
9598 bool CanRepair(ItemBase item_repair_kit)
9599 {
9600 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9601 return module_repairing.CanRepair(this, item_repair_kit);
9602 }
9603
9604 //----------------------------------------------------------------
9605 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
9606 {
9607 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
9608 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
9609 }
9610
9611 //----------------------------------------------------------------
9612 int GetItemSize()
9613 {
9614 /*
9615 vector v_size = this.ConfigGetVector("itemSize");
9616 int v_size_x = v_size[0];
9617 int v_size_y = v_size[1];
9618 int size = v_size_x * v_size_y;
9619 return size;
9620 */
9621
9622 return 1;
9623 }
9624
9625 //----------------------------------------------------------------
9626 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9627 bool CanBeMovedOverride()
9628 {
9629 return m_CanBeMovedOverride;
9630 }
9631
9632 //----------------------------------------------------------------
9633 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
9634 void SetCanBeMovedOverride(bool setting)
9635 {
9636 m_CanBeMovedOverride = setting;
9637 }
9638
9639 //----------------------------------------------------------------
9647 void MessageToOwnerStatus(string text)
9648 {
9649 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9650
9651 if (player)
9652 {
9653 player.MessageStatus(text);
9654 }
9655 }
9656
9657 //----------------------------------------------------------------
9665 void MessageToOwnerAction(string text)
9666 {
9667 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9668
9669 if (player)
9670 {
9671 player.MessageAction(text);
9672 }
9673 }
9674
9675 //----------------------------------------------------------------
9683 void MessageToOwnerFriendly(string text)
9684 {
9685 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9686
9687 if (player)
9688 {
9689 player.MessageFriendly(text);
9690 }
9691 }
9692
9693 //----------------------------------------------------------------
9701 void MessageToOwnerImportant(string text)
9702 {
9703 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
9704
9705 if (player)
9706 {
9707 player.MessageImportant(text);
9708 }
9709 }
9710
9711 override bool IsItemBase()
9712 {
9713 return true;
9714 }
9715
9716 // Checks if item is of questioned kind
9717 override bool KindOf(string tag)
9718 {
9719 bool found = false;
9720 string item_name = this.GetType();
9721 ref TStringArray item_tag_array = new TStringArray;
9722 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
9723
9724 int array_size = item_tag_array.Count();
9725 for (int i = 0; i < array_size; i++)
9726 {
9727 if (item_tag_array.Get(i) == tag)
9728 {
9729 found = true;
9730 break;
9731 }
9732 }
9733 return found;
9734 }
9735
9736
9737 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
9738 {
9739 //Debug.Log("OnRPC called");
9740 super.OnRPC(sender, rpc_type,ctx);
9741
9742 //Play soundset for attachment locking (ActionLockAttachment.c)
9743 switch (rpc_type)
9744 {
9745 #ifndef SERVER
9746 case ERPCs.RPC_SOUND_LOCK_ATTACH:
9747 Param2<bool, string> p = new Param2<bool, string>(false, "");
9748
9749 if (!ctx.Read(p))
9750 return;
9751
9752 bool play = p.param1;
9753 string soundSet = p.param2;
9754
9755 if (play)
9756 {
9757 if (m_LockingSound)
9758 {
9760 {
9761 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9762 }
9763 }
9764 else
9765 {
9766 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
9767 }
9768 }
9769 else
9770 {
9771 SEffectManager.DestroyEffect(m_LockingSound);
9772 }
9773
9774 break;
9775 #endif
9776
9777 }
9778
9779 if (GetWrittenNoteData())
9780 {
9781 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
9782 }
9783 }
9784
9785 //-----------------------------
9786 // VARIABLE MANIPULATION SYSTEM
9787 //-----------------------------
9788 int NameToID(string name)
9789 {
9790 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9791 return plugin.GetID(name);
9792 }
9793
9794 string IDToName(int id)
9795 {
9796 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
9797 return plugin.GetName(id);
9798 }
9799
9801 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
9802 {
9803 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
9804 //read the flags
9805 int varFlags;
9806 if (!ctx.Read(varFlags))
9807 return;
9808
9809 if (varFlags & ItemVariableFlags.FLOAT)
9810 {
9811 ReadVarsFromCTX(ctx);
9812 }
9813 }
9814
9815 override void SerializeNumericalVars(array<float> floats_out)
9816 {
9817 //some variables handled on EntityAI level already!
9818 super.SerializeNumericalVars(floats_out);
9819
9820 // the order of serialization must be the same as the order of de-serialization
9821 //--------------------------------------------
9822 if (IsVariableSet(VARIABLE_QUANTITY))
9823 {
9824 floats_out.Insert(m_VarQuantity);
9825 }
9826 //--------------------------------------------
9827 if (IsVariableSet(VARIABLE_WET))
9828 {
9829 floats_out.Insert(m_VarWet);
9830 }
9831 //--------------------------------------------
9832 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9833 {
9834 floats_out.Insert(m_VarLiquidType);
9835 }
9836 //--------------------------------------------
9837 if (IsVariableSet(VARIABLE_COLOR))
9838 {
9839 floats_out.Insert(m_ColorComponentR);
9840 floats_out.Insert(m_ColorComponentG);
9841 floats_out.Insert(m_ColorComponentB);
9842 floats_out.Insert(m_ColorComponentA);
9843 }
9844 //--------------------------------------------
9845 if (IsVariableSet(VARIABLE_CLEANNESS))
9846 {
9847 floats_out.Insert(m_Cleanness);
9848 }
9849 }
9850
9851 override void DeSerializeNumericalVars(array<float> floats)
9852 {
9853 //some variables handled on EntityAI level already!
9854 super.DeSerializeNumericalVars(floats);
9855
9856 // the order of serialization must be the same as the order of de-serialization
9857 int index = 0;
9858 int mask = Math.Round(floats.Get(index));
9859
9860 index++;
9861 //--------------------------------------------
9862 if (mask & VARIABLE_QUANTITY)
9863 {
9864 if (m_IsStoreLoad)
9865 {
9866 SetStoreLoadedQuantity(floats.Get(index));
9867 }
9868 else
9869 {
9870 float quantity = floats.Get(index);
9871 SetQuantity(quantity, true, false, false, false);
9872 }
9873 index++;
9874 }
9875 //--------------------------------------------
9876 if (mask & VARIABLE_WET)
9877 {
9878 float wet = floats.Get(index);
9879 SetWet(wet);
9880 index++;
9881 }
9882 //--------------------------------------------
9883 if (mask & VARIABLE_LIQUIDTYPE)
9884 {
9885 int liquidtype = Math.Round(floats.Get(index));
9886 SetLiquidType(liquidtype);
9887 index++;
9888 }
9889 //--------------------------------------------
9890 if (mask & VARIABLE_COLOR)
9891 {
9892 m_ColorComponentR = Math.Round(floats.Get(index));
9893 index++;
9894 m_ColorComponentG = Math.Round(floats.Get(index));
9895 index++;
9896 m_ColorComponentB = Math.Round(floats.Get(index));
9897 index++;
9898 m_ColorComponentA = Math.Round(floats.Get(index));
9899 index++;
9900 }
9901 //--------------------------------------------
9902 if (mask & VARIABLE_CLEANNESS)
9903 {
9904 int cleanness = Math.Round(floats.Get(index));
9905 SetCleanness(cleanness);
9906 index++;
9907 }
9908 }
9909
9910 override void WriteVarsToCTX(ParamsWriteContext ctx)
9911 {
9912 super.WriteVarsToCTX(ctx);
9913
9914 //--------------------------------------------
9915 if (IsVariableSet(VARIABLE_QUANTITY))
9916 {
9917 ctx.Write(GetQuantity());
9918 }
9919 //--------------------------------------------
9920 if (IsVariableSet(VARIABLE_WET))
9921 {
9922 ctx.Write(GetWet());
9923 }
9924 //--------------------------------------------
9925 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
9926 {
9927 ctx.Write(GetLiquidType());
9928 }
9929 //--------------------------------------------
9930 if (IsVariableSet(VARIABLE_COLOR))
9931 {
9932 int r,g,b,a;
9933 GetColor(r,g,b,a);
9934 ctx.Write(r);
9935 ctx.Write(g);
9936 ctx.Write(b);
9937 ctx.Write(a);
9938 }
9939 //--------------------------------------------
9940 if (IsVariableSet(VARIABLE_CLEANNESS))
9941 {
9942 ctx.Write(GetCleanness());
9943 }
9944 }
9945
9946 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
9947 {
9948 if (!super.ReadVarsFromCTX(ctx,version))
9949 return false;
9950
9951 int intValue;
9952 float value;
9953
9954 if (version < 140)
9955 {
9956 if (!ctx.Read(intValue))
9957 return false;
9958
9959 m_VariablesMask = intValue;
9960 }
9961
9962 if (m_VariablesMask & VARIABLE_QUANTITY)
9963 {
9964 if (!ctx.Read(value))
9965 return false;
9966
9967 if (IsStoreLoad())
9968 {
9970 }
9971 else
9972 {
9973 SetQuantity(value, true, false, false, false);
9974 }
9975 }
9976 //--------------------------------------------
9977 if (version < 140)
9978 {
9979 if (m_VariablesMask & VARIABLE_TEMPERATURE)
9980 {
9981 if (!ctx.Read(value))
9982 return false;
9983 SetTemperatureDirect(value);
9984 }
9985 }
9986 //--------------------------------------------
9987 if (m_VariablesMask & VARIABLE_WET)
9988 {
9989 if (!ctx.Read(value))
9990 return false;
9991 SetWet(value);
9992 }
9993 //--------------------------------------------
9994 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
9995 {
9996 if (!ctx.Read(intValue))
9997 return false;
9998 SetLiquidType(intValue);
9999 }
10000 //--------------------------------------------
10001 if (m_VariablesMask & VARIABLE_COLOR)
10002 {
10003 int r,g,b,a;
10004 if (!ctx.Read(r))
10005 return false;
10006 if (!ctx.Read(g))
10007 return false;
10008 if (!ctx.Read(b))
10009 return false;
10010 if (!ctx.Read(a))
10011 return false;
10012
10013 SetColor(r,g,b,a);
10014 }
10015 //--------------------------------------------
10016 if (m_VariablesMask & VARIABLE_CLEANNESS)
10017 {
10018 if (!ctx.Read(intValue))
10019 return false;
10020 SetCleanness(intValue);
10021 }
10022 //--------------------------------------------
10023 if (version >= 138 && version < 140)
10024 {
10025 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10026 {
10027 if (!ctx.Read(intValue))
10028 return false;
10029 SetFrozen(intValue);
10030 }
10031 }
10032
10033 return true;
10034 }
10035
10036 //----------------------------------------------------------------
10037 override bool OnStoreLoad(ParamsReadContext ctx, int version)
10038 {
10039 m_IsStoreLoad = true;
10041 {
10042 m_FixDamageSystemInit = true;
10043 }
10044
10045 if (!super.OnStoreLoad(ctx, version))
10046 {
10047 m_IsStoreLoad = false;
10048 return false;
10049 }
10050
10051 if (version >= 114)
10052 {
10053 bool hasQuickBarIndexSaved;
10054
10055 if (!ctx.Read(hasQuickBarIndexSaved))
10056 {
10057 m_IsStoreLoad = false;
10058 return false;
10059 }
10060
10061 if (hasQuickBarIndexSaved)
10062 {
10063 int itmQBIndex;
10064
10065 //Load quickbar item bind
10066 if (!ctx.Read(itmQBIndex))
10067 {
10068 m_IsStoreLoad = false;
10069 return false;
10070 }
10071
10072 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
10073 if (itmQBIndex != -1 && parentPlayer)
10074 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
10075 }
10076 }
10077 else
10078 {
10079 // Backup of how it used to be
10080 PlayerBase player;
10081 int itemQBIndex;
10082 if (version == int.MAX)
10083 {
10084 if (!ctx.Read(itemQBIndex))
10085 {
10086 m_IsStoreLoad = false;
10087 return false;
10088 }
10089 }
10090 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
10091 {
10092 //Load quickbar item bind
10093 if (!ctx.Read(itemQBIndex))
10094 {
10095 m_IsStoreLoad = false;
10096 return false;
10097 }
10098 if (itemQBIndex != -1 && player)
10099 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
10100 }
10101 }
10102
10103 if (version < 140)
10104 {
10105 // variable management system
10106 if (!LoadVariables(ctx, version))
10107 {
10108 m_IsStoreLoad = false;
10109 return false;
10110 }
10111 }
10112
10113 //agent trasmission system
10114 if (!LoadAgents(ctx, version))
10115 {
10116 m_IsStoreLoad = false;
10117 return false;
10118 }
10119 if (version >= 132)
10120 {
10121 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10122 if (raib)
10123 {
10124 if (!raib.OnStoreLoad(ctx,version))
10125 {
10126 m_IsStoreLoad = false;
10127 return false;
10128 }
10129 }
10130 }
10131
10132 m_IsStoreLoad = false;
10133 return true;
10134 }
10135
10136 //----------------------------------------------------------------
10137
10138 override void OnStoreSave(ParamsWriteContext ctx)
10139 {
10140 super.OnStoreSave(ctx);
10141
10142 PlayerBase player;
10143 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
10144 {
10145 ctx.Write(true); // Keep track of if we should actually read this in or not
10146 //Save quickbar item bind
10147 int itemQBIndex = -1;
10148 itemQBIndex = player.FindQuickBarEntityIndex(this);
10149 ctx.Write(itemQBIndex);
10150 }
10151 else
10152 {
10153 ctx.Write(false); // Keep track of if we should actually read this in or not
10154 }
10155
10156 SaveAgents(ctx);//agent trasmission system
10157
10158 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
10159 if (raib)
10160 {
10161 raib.OnStoreSave(ctx);
10162 }
10163 }
10164 //----------------------------------------------------------------
10165
10166 override void AfterStoreLoad()
10167 {
10168 super.AfterStoreLoad();
10169
10171 {
10173 }
10174
10175 if (GetStoreLoadedQuantity() != float.LOWEST)
10176 {
10178 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
10179 }
10180 }
10181
10182 override void EEOnAfterLoad()
10183 {
10184 super.EEOnAfterLoad();
10185
10187 {
10188 m_FixDamageSystemInit = false;
10189 }
10190
10193 }
10194
10195 bool CanBeDisinfected()
10196 {
10197 return false;
10198 }
10199
10200
10201 //----------------------------------------------------------------
10202 override void OnVariablesSynchronized()
10203 {
10204 if (m_Initialized)
10205 {
10206 #ifdef PLATFORM_CONSOLE
10207 //bruteforce it is
10208 if (IsSplitable())
10209 {
10210 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
10211 if (menu)
10212 {
10213 menu.Refresh();
10214 }
10215 }
10216 #endif
10217 }
10218
10220 {
10221 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10222 m_WantPlayImpactSound = false;
10223 }
10224
10226 {
10227 SetWeightDirty();
10229 }
10230 if (m_VarWet != m_VarWetPrev)
10231 {
10234 }
10235
10236 if (m_SoundSyncPlay != 0)
10237 {
10238 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
10239 m_SoundSyncPlay = 0;
10240 }
10241 if (m_SoundSyncStop != 0)
10242 {
10243 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
10244 m_SoundSyncStop = 0;
10245 }
10246
10247 super.OnVariablesSynchronized();
10248 }
10249
10250 //------------------------- Quantity
10251 //----------------------------------------------------------------
10253 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
10254 {
10255 if (!IsServerCheck(allow_client))
10256 return false;
10257
10258 if (!HasQuantity())
10259 return false;
10260
10261 float min = GetQuantityMin();
10262 float max = GetQuantityMax();
10263
10264 if (value <= (min + 0.001))
10265 value = min;
10266
10267 if (value == min)
10268 {
10269 if (destroy_config)
10270 {
10271 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
10272 if (dstr)
10273 {
10274 m_VarQuantity = Math.Clamp(value, min, max);
10275 this.Delete();
10276 return true;
10277 }
10278 }
10279 else if (destroy_forced)
10280 {
10281 m_VarQuantity = Math.Clamp(value, min, max);
10282 this.Delete();
10283 return true;
10284 }
10285 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
10286 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
10287 }
10288
10289 float delta = m_VarQuantity;
10290 m_VarQuantity = Math.Clamp(value, min, max);
10291
10292 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
10293 {
10294 delta = m_VarQuantity - delta;
10295
10296 if (delta)
10297 OnQuantityChanged(delta);
10298 }
10299
10300 SetVariableMask(VARIABLE_QUANTITY);
10301
10302 return false;
10303 }
10304
10305 //----------------------------------------------------------------
10307 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
10308 {
10309 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
10310 }
10311 //----------------------------------------------------------------
10312 void SetQuantityMax()
10313 {
10314 float max = GetQuantityMax();
10315 SetQuantity(max);
10316 }
10317
10318 override void SetQuantityToMinimum()
10319 {
10320 float min = GetQuantityMin();
10321 SetQuantity(min);
10322 }
10323 //----------------------------------------------------------------
10325 void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
10326 {
10327 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
10328 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
10329 SetQuantity(result, destroy_config, destroy_forced);
10330 }
10331
10332 //----------------------------------------------------------------
10334 override float GetQuantityNormalized()
10335 {
10336 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
10337 }
10338
10340 {
10341 return GetQuantityNormalized();
10342 }
10343
10344 /*void SetAmmoNormalized(float value)
10345 {
10346 float value_clamped = Math.Clamp(value, 0, 1);
10347 Magazine this_mag = Magazine.Cast(this);
10348 int max_rounds = this_mag.GetAmmoMax();
10349 int result = value * max_rounds;//can the rounded if higher precision is required
10350 this_mag.SetAmmoCount(result);
10351 }*/
10352 //----------------------------------------------------------------
10353 override int GetQuantityMax()
10354 {
10355 int slot = -1;
10356 if (GetInventory())
10357 {
10358 InventoryLocation il = new InventoryLocation;
10359 GetInventory().GetCurrentInventoryLocation(il);
10360 slot = il.GetSlot();
10361 }
10362
10363 return GetTargetQuantityMax(slot);
10364 }
10365
10366 override int GetTargetQuantityMax(int attSlotID = -1)
10367 {
10368 float quantity_max = 0;
10369
10370 if (IsSplitable()) //only stackable/splitable items can check for stack size
10371 {
10372 if (attSlotID != -1)
10373 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
10374
10375 if (quantity_max <= 0)
10376 quantity_max = m_VarStackMax;
10377 }
10378
10379 if (quantity_max <= 0)
10380 quantity_max = m_VarQuantityMax;
10381
10382 return quantity_max;
10383 }
10384 //----------------------------------------------------------------
10385 override int GetQuantityMin()
10386 {
10387 return m_VarQuantityMin;
10388 }
10389 //----------------------------------------------------------------
10390 int GetQuantityInit()
10391 {
10392 return m_VarQuantityInit;
10393 }
10394
10395 //----------------------------------------------------------------
10396 override bool HasQuantity()
10397 {
10398 return !(GetQuantityMax() - GetQuantityMin() == 0);
10399 }
10400
10401 override float GetQuantity()
10402 {
10403 return m_VarQuantity;
10404 }
10405
10406 bool IsFullQuantity()
10407 {
10408 return GetQuantity() >= GetQuantityMax();
10409 }
10410
10411 //Calculates weight of single item without attachments and cargo
10412 override float GetSingleInventoryItemWeightEx()
10413 {
10414 //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
10415 float weightEx = GetWeightEx();//overall weight of the item
10416 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
10417 return weightEx - special;
10418 }
10419
10420 // Obsolete, use GetSingleInventoryItemWeightEx() instead
10422 {
10424 }
10425
10426 override protected float GetWeightSpecialized(bool forceRecalc = false)
10427 {
10428 if (IsSplitable()) //quantity determines size of the stack
10429 {
10430 #ifdef DEVELOPER
10431 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10432 {
10433 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
10434 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
10435 }
10436 #endif
10437
10438 return GetQuantity() * GetConfigWeightModified();
10439 }
10440 else if (HasEnergyManager())// items with energy manager
10441 {
10442 #ifdef DEVELOPER
10443 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10444 {
10445 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
10446 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
10447 }
10448 #endif
10449 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
10450 }
10451 else//everything else
10452 {
10453 #ifdef DEVELOPER
10454 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
10455 {
10456 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
10457 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
10458 }
10459 #endif
10460 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
10461 }
10462 }
10463
10465 int GetNumberOfItems()
10466 {
10467 int item_count = 0;
10468 ItemBase item;
10469
10470 if (GetInventory().GetCargo() != NULL)
10471 {
10472 item_count = GetInventory().GetCargo().GetItemCount();
10473 }
10474
10475 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
10476 {
10477 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
10478 if (item)
10479 item_count += item.GetNumberOfItems();
10480 }
10481 return item_count;
10482 }
10483
10485 float GetUnitWeight(bool include_wetness = true)
10486 {
10487 float weight = 0;
10488 float wetness = 1;
10489 if (include_wetness)
10490 wetness += GetWet();
10491 if (IsSplitable()) //quantity determines size of the stack
10492 {
10493 weight = wetness * m_ConfigWeight;
10494 }
10495 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
10496 {
10497 weight = 1;
10498 }
10499 return weight;
10500 }
10501
10502 //-----------------------------------------------------------------
10503
10504 override void ClearInventory()
10505 {
10506 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
10507 {
10508 GameInventory inv = GetInventory();
10509 array<EntityAI> items = new array<EntityAI>;
10510 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
10511 for (int i = 0; i < items.Count(); i++)
10512 {
10513 ItemBase item = ItemBase.Cast(items.Get(i));
10514 if (item)
10515 {
10516 GetGame().ObjectDelete(item);
10517 }
10518 }
10519 }
10520 }
10521
10522 //------------------------- Energy
10523
10524 //----------------------------------------------------------------
10525 float GetEnergy()
10526 {
10527 float energy = 0;
10528 if (HasEnergyManager())
10529 {
10530 energy = GetCompEM().GetEnergy();
10531 }
10532 return energy;
10533 }
10534
10535
10536 override void OnEnergyConsumed()
10537 {
10538 super.OnEnergyConsumed();
10539
10541 }
10542
10543 override void OnEnergyAdded()
10544 {
10545 super.OnEnergyAdded();
10546
10548 }
10549
10550 // Converts energy (from Energy Manager) to quantity, if enabled.
10552 {
10553 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
10554 {
10555 if (HasQuantity())
10556 {
10557 float energy_0to1 = GetCompEM().GetEnergy0To1();
10558 SetQuantityNormalized(energy_0to1);
10559 }
10560 }
10561 }
10562
10563 //----------------------------------------------------------------
10564 float GetHeatIsolationInit()
10565 {
10566 return ConfigGetFloat("heatIsolation");
10567 }
10568
10569 float GetHeatIsolation()
10570 {
10571 return m_HeatIsolation;
10572 }
10573
10574 float GetDryingIncrement(string pIncrementName)
10575 {
10576 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
10577 if (GetGame().ConfigIsExisting(paramPath))
10578 return GetGame().ConfigGetFloat(paramPath);
10579
10580 return 0.0;
10581 }
10582
10583 float GetSoakingIncrement(string pIncrementName)
10584 {
10585 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
10586 if (GetGame().ConfigIsExisting(paramPath))
10587 return GetGame().ConfigGetFloat(paramPath);
10588
10589 return 0.0;
10590 }
10591 //----------------------------------------------------------------
10592 override void SetWet(float value, bool allow_client = false)
10593 {
10594 if (!IsServerCheck(allow_client))
10595 return;
10596
10597 float min = GetWetMin();
10598 float max = GetWetMax();
10599
10600 float previousValue = m_VarWet;
10601
10602 m_VarWet = Math.Clamp(value, min, max);
10603
10604 if (previousValue != m_VarWet)
10605 {
10606 SetVariableMask(VARIABLE_WET);
10607 OnWetChanged(m_VarWet, previousValue);
10608 }
10609 }
10610 //----------------------------------------------------------------
10611 override void AddWet(float value)
10612 {
10613 SetWet(GetWet() + value);
10614 }
10615 //----------------------------------------------------------------
10616 override void SetWetMax()
10617 {
10619 }
10620 //----------------------------------------------------------------
10621 override float GetWet()
10622 {
10623 return m_VarWet;
10624 }
10625 //----------------------------------------------------------------
10626 override float GetWetMax()
10627 {
10628 return m_VarWetMax;
10629 }
10630 //----------------------------------------------------------------
10631 override float GetWetMin()
10632 {
10633 return m_VarWetMin;
10634 }
10635 //----------------------------------------------------------------
10636 override float GetWetInit()
10637 {
10638 return m_VarWetInit;
10639 }
10640 //----------------------------------------------------------------
10641 override void OnWetChanged(float newVal, float oldVal)
10642 {
10643 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
10644 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
10645 if (newLevel != oldLevel)
10646 {
10647 OnWetLevelChanged(newLevel,oldLevel);
10648 }
10649 }
10650
10651 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
10652 {
10653 SetWeightDirty();
10654 }
10655
10656 override EWetnessLevel GetWetLevel()
10657 {
10658 return GetWetLevelInternal(m_VarWet);
10659 }
10660
10661 //----------------------------------------------------------------
10662
10663 override void SetStoreLoad(bool value)
10664 {
10665 m_IsStoreLoad = value;
10666 }
10667
10668 override bool IsStoreLoad()
10669 {
10670 return m_IsStoreLoad;
10671 }
10672
10673 override void SetStoreLoadedQuantity(float value)
10674 {
10675 m_StoreLoadedQuantity = value;
10676 }
10677
10678 override float GetStoreLoadedQuantity()
10679 {
10680 return m_StoreLoadedQuantity;
10681 }
10682
10683 //----------------------------------------------------------------
10684
10685 float GetItemModelLength()
10686 {
10687 if (ConfigIsExisting("itemModelLength"))
10688 {
10689 return ConfigGetFloat("itemModelLength");
10690 }
10691 return 0;
10692 }
10693
10694 float GetItemAttachOffset()
10695 {
10696 if (ConfigIsExisting("itemAttachOffset"))
10697 {
10698 return ConfigGetFloat("itemAttachOffset");
10699 }
10700 return 0;
10701 }
10702
10703 override void SetCleanness(int value, bool allow_client = false)
10704 {
10705 if (!IsServerCheck(allow_client))
10706 return;
10707
10708 int previousValue = m_Cleanness;
10709
10710 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
10711
10712 if (previousValue != m_Cleanness)
10713 SetVariableMask(VARIABLE_CLEANNESS);
10714 }
10715
10716 override int GetCleanness()
10717 {
10718 return m_Cleanness;
10719 }
10720
10722 {
10723 return true;
10724 }
10725
10726 //----------------------------------------------------------------
10727 // ATTACHMENT LOCKING
10728 // Getters relevant to generic ActionLockAttachment
10729 int GetLockType()
10730 {
10731 return m_LockType;
10732 }
10733
10734 string GetLockSoundSet()
10735 {
10736 return m_LockSoundSet;
10737 }
10738
10739 //----------------------------------------------------------------
10740 //------------------------- Color
10741 // sets items color variable given color components
10742 override void SetColor(int r, int g, int b, int a)
10743 {
10748 SetVariableMask(VARIABLE_COLOR);
10749 }
10751 override void GetColor(out int r,out int g,out int b,out int a)
10752 {
10757 }
10758
10759 bool IsColorSet()
10760 {
10761 return IsVariableSet(VARIABLE_COLOR);
10762 }
10763
10765 string GetColorString()
10766 {
10767 int r,g,b,a;
10768 GetColor(r,g,b,a);
10769 r = r/255;
10770 g = g/255;
10771 b = b/255;
10772 a = a/255;
10773 return MiscGameplayFunctions.GetColorString(r, g, b, a);
10774 }
10775 //----------------------------------------------------------------
10776 //------------------------- LiquidType
10777
10778 override void SetLiquidType(int value, bool allow_client = false)
10779 {
10780 if (!IsServerCheck(allow_client))
10781 return;
10782
10783 int old = m_VarLiquidType;
10784 m_VarLiquidType = value;
10785 OnLiquidTypeChanged(old,value);
10786 SetVariableMask(VARIABLE_LIQUIDTYPE);
10787 }
10788
10789 int GetLiquidTypeInit()
10790 {
10791 return ConfigGetInt("varLiquidTypeInit");
10792 }
10793
10794 override int GetLiquidType()
10795 {
10796 return m_VarLiquidType;
10797 }
10798
10799 protected void OnLiquidTypeChanged(int oldType, int newType)
10800 {
10801 if (newType == LIQUID_NONE && GetIsFrozen())
10802 SetFrozen(false);
10803 }
10804
10806 void UpdateQuickbarShortcutVisibility(PlayerBase player)
10807 {
10808 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10809 }
10810
10811 // -------------------------------------------------------------------------
10813 void OnInventoryEnter(Man player)
10814 {
10815 PlayerBase nplayer;
10816 if (PlayerBase.CastTo(nplayer, player))
10817 {
10818 m_CanPlayImpactSound = true;
10819 //nplayer.OnItemInventoryEnter(this);
10820 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
10821 }
10822 }
10823
10824 // -------------------------------------------------------------------------
10826 void OnInventoryExit(Man player)
10827 {
10828 PlayerBase nplayer;
10829 if (PlayerBase.CastTo(nplayer,player))
10830 {
10831 //nplayer.OnItemInventoryExit(this);
10832 nplayer.SetEnableQuickBarEntityShortcut(this,false);
10833
10834 }
10835
10836 //if (!GetGame().IsDedicatedServer())
10837 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
10838
10839
10840 if (HasEnergyManager())
10841 {
10842 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
10843 }
10844 }
10845
10846 // ADVANCED PLACEMENT EVENTS
10847 override void OnPlacementStarted(Man player)
10848 {
10849 super.OnPlacementStarted(player);
10850
10851 SetTakeable(false);
10852 }
10853
10854 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
10855 {
10856 if (m_AdminLog)
10857 {
10858 m_AdminLog.OnPlacementComplete(player, this);
10859 }
10860
10861 super.OnPlacementComplete(player, position, orientation);
10862 }
10863
10864 //-----------------------------
10865 // AGENT SYSTEM
10866 //-----------------------------
10867 //--------------------------------------------------------------------------
10868 bool ContainsAgent(int agent_id)
10869 {
10870 if (agent_id & m_AttachedAgents)
10871 {
10872 return true;
10873 }
10874 else
10875 {
10876 return false;
10877 }
10878 }
10879
10880 //--------------------------------------------------------------------------
10881 override void RemoveAgent(int agent_id)
10882 {
10883 if (ContainsAgent(agent_id))
10884 {
10885 m_AttachedAgents = ~agent_id & m_AttachedAgents;
10886 }
10887 }
10888
10889 //--------------------------------------------------------------------------
10890 override void RemoveAllAgents()
10891 {
10892 m_AttachedAgents = 0;
10893 }
10894 //--------------------------------------------------------------------------
10895 override void RemoveAllAgentsExcept(int agent_to_keep)
10896 {
10897 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
10898 }
10899 // -------------------------------------------------------------------------
10900 override void InsertAgent(int agent, float count = 1)
10901 {
10902 if (count < 1)
10903 return;
10904 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
10906 }
10907
10909 void TransferAgents(int agents)
10910 {
10912 }
10913
10914 // -------------------------------------------------------------------------
10915 override int GetAgents()
10916 {
10917 return m_AttachedAgents;
10918 }
10919 //----------------------------------------------------------------------
10920
10921 /*int GetContaminationType()
10922 {
10923 int contamination_type;
10924
10925 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
10926 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
10927 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
10928 const int DIRTY_MASK = eAgents.WOUND_AGENT;
10929
10930 Edible_Base edible = Edible_Base.Cast(this);
10931 int agents = GetAgents();
10932 if (edible)
10933 {
10934 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
10935 if (profile)
10936 {
10937 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
10938 }
10939 }
10940 if (agents & CONTAMINATED_MASK)
10941 {
10942 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
10943 }
10944 if (agents & POISONED_MASK)
10945 {
10946 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
10947 }
10948 if (agents & NERVE_GAS_MASK)
10949 {
10950 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
10951 }
10952 if (agents & DIRTY_MASK)
10953 {
10954 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
10955 }
10956
10957 return agents;
10958 }*/
10959
10960 // -------------------------------------------------------------------------
10961 bool LoadAgents(ParamsReadContext ctx, int version)
10962 {
10963 if (!ctx.Read(m_AttachedAgents))
10964 return false;
10965 return true;
10966 }
10967 // -------------------------------------------------------------------------
10969 {
10970
10972 }
10973 // -------------------------------------------------------------------------
10974
10976 override void CheckForRoofLimited(float timeTresholdMS = 3000)
10977 {
10978 super.CheckForRoofLimited(timeTresholdMS);
10979
10980 float time = GetGame().GetTime();
10981 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
10982 {
10983 m_PreviousRoofTestTime = time;
10984 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
10985 }
10986 }
10987
10988 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
10989 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
10990 {
10991 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
10992 {
10993 return 0;
10994 }
10995
10996 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
10997 {
10998 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
10999 if (filter)
11000 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11001 else
11002 return 0;//otherwise return 0 when no filter attached
11003 }
11004
11005 string subclassPath, entryName;
11006
11007 switch (type)
11008 {
11009 case DEF_BIOLOGICAL:
11010 entryName = "biological";
11011 break;
11012 case DEF_CHEMICAL:
11013 entryName = "chemical";
11014 break;
11015 default:
11016 entryName = "biological";
11017 break;
11018 }
11019
11020 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
11021
11022 return GetGame().ConfigGetFloat(subclassPath + entryName);
11023 }
11024
11025
11026
11028 override void EEOnCECreate()
11029 {
11030 if (!IsMagazine())
11032
11034 }
11035
11036
11037 //-------------------------
11038 // OPEN/CLOSE USER ACTIONS
11039 //-------------------------
11041 void Open();
11042 void Close();
11043 bool IsOpen()
11044 {
11045 return true;
11046 }
11047
11048 override bool CanDisplayCargo()
11049 {
11050 return IsOpen();
11051 }
11052
11053
11054 // ------------------------------------------------------------
11055 // CONDITIONS
11056 // ------------------------------------------------------------
11057 override bool CanPutInCargo(EntityAI parent)
11058 {
11059 if (parent)
11060 {
11061 if (parent.IsInherited(DayZInfected))
11062 return true;
11063
11064 if (!parent.IsRuined())
11065 return true;
11066 }
11067
11068 return true;
11069 }
11070
11071 override bool CanPutAsAttachment(EntityAI parent)
11072 {
11073 if (!super.CanPutAsAttachment(parent))
11074 {
11075 return false;
11076 }
11077
11078 if (!IsRuined() && !parent.IsRuined())
11079 {
11080 return true;
11081 }
11082
11083 return false;
11084 }
11085
11086 override bool CanReceiveItemIntoCargo(EntityAI item)
11087 {
11088 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11089 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11090 // return false;
11091
11092 return super.CanReceiveItemIntoCargo(item);
11093 }
11094
11095 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
11096 {
11097 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11098 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11099 // return false;
11100
11101 GameInventory attachmentInv = attachment.GetInventory();
11102 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11103 {
11104 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11105 return false;
11106 }
11107
11108 InventoryLocation loc = new InventoryLocation();
11109 attachment.GetInventory().GetCurrentInventoryLocation(loc);
11110 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
11111 return false;
11112
11113 return super.CanReceiveAttachment(attachment, slotId);
11114 }
11115
11116 override bool CanReleaseAttachment(EntityAI attachment)
11117 {
11118 if (!super.CanReleaseAttachment(attachment))
11119 return false;
11120
11121 return GetInventory().AreChildrenAccessible();
11122 }
11123
11124 /*override bool CanLoadAttachment(EntityAI attachment)
11125 {
11126 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
11127 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
11128 // return false;
11129
11130 GameInventory attachmentInv = attachment.GetInventory();
11131 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
11132 {
11133 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
11134 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
11135
11136 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
11137 return false;
11138 }
11139
11140 return super.CanLoadAttachment(attachment);
11141 }*/
11142
11143 // Plays muzzle flash particle effects
11144 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11145 {
11146 int id = muzzle_owner.GetMuzzleID();
11147 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
11148
11149 if (WPOF_array)
11150 {
11151 for (int i = 0; i < WPOF_array.Count(); i++)
11152 {
11153 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
11154
11155 if (WPOF)
11156 {
11157 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
11158 }
11159 }
11160 }
11161 }
11162
11163 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
11164 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11165 {
11166 int id = muzzle_owner.GetMuzzleID();
11167 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
11168
11169 if (WPOBE_array)
11170 {
11171 for (int i = 0; i < WPOBE_array.Count(); i++)
11172 {
11173 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
11174
11175 if (WPOBE)
11176 {
11177 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11178 }
11179 }
11180 }
11181 }
11182
11183 // Plays all weapon overheating particles
11184 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11185 {
11186 int id = muzzle_owner.GetMuzzleID();
11187 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11188
11189 if (WPOOH_array)
11190 {
11191 for (int i = 0; i < WPOOH_array.Count(); i++)
11192 {
11193 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11194
11195 if (WPOOH)
11196 {
11197 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
11198 }
11199 }
11200 }
11201 }
11202
11203 // Updates all weapon overheating particles
11204 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11205 {
11206 int id = muzzle_owner.GetMuzzleID();
11207 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11208
11209 if (WPOOH_array)
11210 {
11211 for (int i = 0; i < WPOOH_array.Count(); i++)
11212 {
11213 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11214
11215 if (WPOOH)
11216 {
11217 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11218 }
11219 }
11220 }
11221 }
11222
11223 // Stops overheating particles
11224 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
11225 {
11226 int id = muzzle_owner.GetMuzzleID();
11227 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
11228
11229 if (WPOOH_array)
11230 {
11231 for (int i = 0; i < WPOOH_array.Count(); i++)
11232 {
11233 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
11234
11235 if (WPOOH)
11236 {
11237 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
11238 }
11239 }
11240 }
11241 }
11242
11243 //----------------------------------------------------------------
11244 //Item Behaviour - unified approach
11245 override bool IsHeavyBehaviour()
11246 {
11247 if (m_ItemBehaviour == 0)
11248 {
11249 return true;
11250 }
11251
11252 return false;
11253 }
11254
11255 override bool IsOneHandedBehaviour()
11256 {
11257 if (m_ItemBehaviour == 1)
11258 {
11259 return true;
11260 }
11261
11262 return false;
11263 }
11264
11265 override bool IsTwoHandedBehaviour()
11266 {
11267 if (m_ItemBehaviour == 2)
11268 {
11269 return true;
11270 }
11271
11272 return false;
11273 }
11274
11275 bool IsDeployable()
11276 {
11277 return false;
11278 }
11279
11281 float GetDeployTime()
11282 {
11283 return UATimeSpent.DEFAULT_DEPLOY;
11284 }
11285
11286
11287 //----------------------------------------------------------------
11288 // Item Targeting (User Actions)
11289 override void SetTakeable(bool pState)
11290 {
11291 m_IsTakeable = pState;
11292 SetSynchDirty();
11293 }
11294
11295 override bool IsTakeable()
11296 {
11297 return m_IsTakeable;
11298 }
11299
11300 // For cases where we want to show object widget which cant be taken to hands
11302 {
11303 return false;
11304 }
11305
11307 protected void PreLoadSoundAttachmentType()
11308 {
11309 string att_type = "None";
11310
11311 if (ConfigIsExisting("soundAttType"))
11312 {
11313 att_type = ConfigGetString("soundAttType");
11314 }
11315
11316 m_SoundAttType = att_type;
11317 }
11318
11319 override string GetAttachmentSoundType()
11320 {
11321 return m_SoundAttType;
11322 }
11323
11324 //----------------------------------------------------------------
11325 //SOUNDS - ItemSoundHandler
11326 //----------------------------------------------------------------
11327
11328 string GetPlaceSoundset(); // played when deploy starts
11329 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
11330 string GetDeploySoundset(); // played when deploy sucessfully finishes
11331
11333 {
11334 if (!m_ItemSoundHandler)
11336
11337 return m_ItemSoundHandler;
11338 }
11339
11340 // override to initialize sounds
11341 protected void InitItemSounds()
11342 {
11343 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
11344 return;
11345
11347
11348 if (GetPlaceSoundset() != string.Empty)
11349 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
11350
11351 if (GetDeploySoundset() != string.Empty)
11352 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
11353
11354 SoundParameters params = new SoundParameters();
11355 params.m_Loop = true;
11356 if (GetLoopDeploySoundset() != string.Empty)
11357 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
11358 }
11359
11360 // Start sound using ItemSoundHandler
11361 void StartItemSoundServer(int id)
11362 {
11363 if (!GetGame().IsServer())
11364 return;
11365
11366 m_SoundSyncPlay = id;
11367 SetSynchDirty();
11368
11369 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
11371 }
11372
11373 // Stop sound using ItemSoundHandler
11374 void StopItemSoundServer(int id)
11375 {
11376 if (!GetGame().IsServer())
11377 return;
11378
11379 m_SoundSyncStop = id;
11380 SetSynchDirty();
11381
11382 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
11384 }
11385
11386 protected void ClearStartItemSoundServer()
11387 {
11388 m_SoundSyncPlay = 0;
11389 }
11390
11391 protected void ClearStopItemSoundServer()
11392 {
11393 m_SoundSyncStop = 0;
11394 }
11395
11397 void PlayAttachSound(string slot_type)
11398 {
11399 if (!GetGame().IsDedicatedServer())
11400 {
11401 if (ConfigIsExisting("attachSoundSet"))
11402 {
11403 string cfg_path = "";
11404 string soundset = "";
11405 string type_name = GetType();
11406
11407 TStringArray cfg_soundset_array = new TStringArray;
11408 TStringArray cfg_slot_array = new TStringArray;
11409 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
11410 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
11411
11412 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
11413 {
11414 for (int i = 0; i < cfg_soundset_array.Count(); i++)
11415 {
11416 if (cfg_slot_array[i] == slot_type)
11417 {
11418 soundset = cfg_soundset_array[i];
11419 break;
11420 }
11421 }
11422 }
11423
11424 if (soundset != "")
11425 {
11426 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
11427 sound.SetAutodestroy(true);
11428 }
11429 }
11430 }
11431 }
11432
11433 void PlayDetachSound(string slot_type)
11434 {
11435 //TODO - evaluate if needed and devise universal config structure if so
11436 }
11437
11438 void OnApply(PlayerBase player);
11439
11441 {
11442 return 1.0;
11443 };
11444 //returns applicable selection
11445 array<string> GetHeadHidingSelection()
11446 {
11448 }
11449
11451 {
11453 }
11454
11455 WrittenNoteData GetWrittenNoteData() {};
11456
11458 {
11459 SetDynamicPhysicsLifeTime(0.01);
11460 m_ItemBeingDroppedPhys = false;
11461 }
11462
11464 {
11465 array<string> zone_names = new array<string>;
11466 GetDamageZones(zone_names);
11467 for (int i = 0; i < zone_names.Count(); i++)
11468 {
11469 SetHealthMax(zone_names.Get(i),"Health");
11470 }
11471 SetHealthMax("","Health");
11472 }
11473
11475 void SetZoneDamageCEInit()
11476 {
11477 float global_health = GetHealth01("","Health");
11478 array<string> zones = new array<string>;
11479 GetDamageZones(zones);
11480 //set damage of all zones to match global health level
11481 for (int i = 0; i < zones.Count(); i++)
11482 {
11483 SetHealth01(zones.Get(i),"Health",global_health);
11484 }
11485 }
11486
11488 bool IsCoverFaceForShave(string slot_name)
11489 {
11490 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
11491 }
11492
11493 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11494 {
11495 if (!hasRootAsPlayer)
11496 {
11497 if (refParentIB)
11498 {
11499 // parent is wet
11500 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
11501 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
11502 // parent has liquid inside
11503 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
11504 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
11505 // drying
11506 else if (m_VarWet > m_VarWetMin)
11507 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
11508 }
11509 else
11510 {
11511 // drying on ground or inside non-itembase (car, ...)
11512 if (m_VarWet > m_VarWetMin)
11513 AddWet(-1 * delta * GetDryingIncrement("ground"));
11514 }
11515 }
11516 }
11517
11518 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11519 {
11521 {
11522 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
11523 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
11524 {
11525 float heatPermCoef = 1.0;
11526 EntityAI ent = this;
11527 while (ent)
11528 {
11529 heatPermCoef *= ent.GetHeatPermeabilityCoef();
11530 ent = ent.GetHierarchyParent();
11531 }
11532
11533 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
11534 }
11535 }
11536 }
11537
11538 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
11539 {
11540 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
11541 EntityAI parent = GetHierarchyParent();
11542 if (!parent)
11543 {
11544 hasParent = false;
11545 hasRootAsPlayer = false;
11546 }
11547 else
11548 {
11549 hasParent = true;
11550 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
11551 refParentIB = ItemBase.Cast(parent);
11552 }
11553 }
11554
11555 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
11556 {
11557 // this is stub, implemented on Edible_Base
11558 }
11559
11560 bool CanDecay()
11561 {
11562 // return true used on selected food clases so they can decay
11563 return false;
11564 }
11565
11566 protected bool CanProcessDecay()
11567 {
11568 // this is stub, implemented on Edible_Base class
11569 // used to determine whether it is still necessary for the food to decay
11570 return false;
11571 }
11572
11573 protected bool CanHaveWetness()
11574 {
11575 // return true used on selected items that have a wetness effect
11576 return false;
11577 }
11578
11580 bool CanBeConsumed(ConsumeConditionData data = null)
11581 {
11582 return !GetIsFrozen() && IsOpen();
11583 }
11584
11585 override void ProcessVariables()
11586 {
11587 bool hasParent = false, hasRootAsPlayer = false;
11588 ItemBase refParentIB;
11589
11590 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
11591 bool foodDecay = g_Game.IsFoodDecayEnabled();
11592
11593 if (wwtu || foodDecay)
11594 {
11595 bool processWetness = wwtu && CanHaveWetness();
11596 bool processTemperature = wwtu && CanHaveTemperature();
11597 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
11598
11599 if (processWetness || processTemperature || processDecay)
11600 {
11601 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
11602
11603 if (processWetness)
11604 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11605
11606 if (processTemperature)
11607 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
11608
11609 if (processDecay)
11610 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
11611 }
11612 }
11613 }
11614
11617 {
11618 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
11619 }
11620
11621 override float GetTemperatureFreezeThreshold()
11622 {
11624 return Liquid.GetFreezeThreshold(GetLiquidType());
11625
11626 return super.GetTemperatureFreezeThreshold();
11627 }
11628
11629 override float GetTemperatureThawThreshold()
11630 {
11632 return Liquid.GetThawThreshold(GetLiquidType());
11633
11634 return super.GetTemperatureThawThreshold();
11635 }
11636
11637 override float GetItemOverheatThreshold()
11638 {
11640 return Liquid.GetBoilThreshold(GetLiquidType());
11641
11642 return super.GetItemOverheatThreshold();
11643 }
11644
11645 override float GetTemperatureFreezeTime()
11646 {
11647 if (HasQuantity())
11648 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
11649
11650 return super.GetTemperatureFreezeTime();
11651 }
11652
11653 override float GetTemperatureThawTime()
11654 {
11655 if (HasQuantity())
11656 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
11657
11658 return super.GetTemperatureThawTime();
11659 }
11660
11662 void AffectLiquidContainerOnFill(int liquid_type, float amount);
11664 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
11665
11666 bool IsCargoException4x3(EntityAI item)
11667 {
11668 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
11669 }
11670
11672 {
11673 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
11674 }
11675
11677 void AddLightSourceItem(ItemBase lightsource)
11678 {
11679 m_LightSourceItem = lightsource;
11680 }
11681
11683 {
11684 m_LightSourceItem = null;
11685 }
11686
11688 {
11689 return m_LightSourceItem;
11690 }
11691
11693 array<int> GetValidFinishers()
11694 {
11695 return null;
11696 }
11697
11699 bool GetActionWidgetOverride(out typename name)
11700 {
11701 return false;
11702 }
11703
11704 bool PairWithDevice(notnull ItemBase otherDevice)
11705 {
11706 if (GetGame().IsServer())
11707 {
11708 ItemBase explosive = otherDevice;
11710 if (!trg)
11711 {
11712 trg = RemoteDetonatorTrigger.Cast(otherDevice);
11713 explosive = this;
11714 }
11715
11716 explosive.PairRemote(trg);
11717 trg.SetControlledDevice(explosive);
11718
11719 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
11720 trg.SetPersistentPairID(persistentID);
11721 explosive.SetPersistentPairID(persistentID);
11722
11723 return true;
11724 }
11725 return false;
11726 }
11727
11729 float GetBaitEffectivity()
11730 {
11731 float ret = 1.0;
11732 if (HasQuantity())
11733 ret *= GetQuantityNormalized();
11734 ret *= GetHealth01();
11735
11736 return ret;
11737 }
11738
11739 #ifdef DEVELOPER
11740 override void SetDebugItem()
11741 {
11742 super.SetDebugItem();
11743 _itemBase = this;
11744 }
11745
11746 override string GetDebugText()
11747 {
11748 string text = super.GetDebugText();
11749
11750 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
11751 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
11752
11753 return text;
11754 }
11755 #endif
11756
11757 bool CanBeUsedForSuicide()
11758 {
11759 return true;
11760 }
11761
11763 //DEPRECATED BELOW
11765 // Backwards compatibility
11766 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
11767 {
11768 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
11769 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
11770 }
11771
11772 // replaced by ItemSoundHandler
11773 protected EffectSound m_SoundDeployFinish;
11774 protected EffectSound m_SoundPlace;
11775 protected EffectSound m_DeployLoopSoundEx;
11776 protected EffectSound m_SoundDeploy;
11777 bool m_IsPlaceSound;
11778 bool m_IsDeploySound;
11780
11781 string GetDeployFinishSoundset();
11782 void PlayDeploySound();
11783 void PlayDeployFinishSound();
11784 void PlayPlaceSound();
11785 void PlayDeployLoopSoundEx();
11786 void StopDeployLoopSoundEx();
11787 void SoundSynchRemoteReset();
11788 void SoundSynchRemote();
11789 bool UsesGlobalDeploy(){return false;}
11790 bool CanPlayDeployLoopSound(){return false;}
11792 bool IsPlaceSound(){return m_IsPlaceSound;}
11793 bool IsDeploySound(){return m_IsDeploySound;}
11794 void SetIsPlaceSound(bool is_place_sound);
11795 void SetIsDeploySound(bool is_deploy_sound);
11796}
11797
11798EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
11799{
11800 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
11801 if (entity)
11802 {
11803 bool is_item = entity.IsInherited(ItemBase);
11804 if (is_item && full_quantity)
11805 {
11806 ItemBase item = ItemBase.Cast(entity);
11807 item.SetQuantity(item.GetQuantityInit());
11808 }
11809 }
11810 else
11811 {
11812 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
11813 return NULL;
11814 }
11815 return entity;
11816}
11817
11818void SetupSpawnedItem(ItemBase item, float health, float quantity)
11819{
11820 if (item)
11821 {
11822 if (health > 0)
11823 item.SetHealth("", "", health);
11824
11825 if (item.CanHaveTemperature())
11826 {
11827 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
11828 if (item.CanFreeze())
11829 item.SetFrozen(false);
11830 }
11831
11832 if (item.HasEnergyManager())
11833 {
11834 if (quantity >= 0)
11835 {
11836 item.GetCompEM().SetEnergy0To1(quantity);
11837 }
11838 else
11839 {
11840 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
11841 }
11842 }
11843 else if (item.IsMagazine())
11844 {
11845 Magazine mag = Magazine.Cast(item);
11846 if (quantity >= 0)
11847 {
11848 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
11849 }
11850 else
11851 {
11852 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
11853 }
11854
11855 }
11856 else
11857 {
11858 if (quantity >= 0)
11859 {
11860 item.SetQuantityNormalized(quantity, false);
11861 }
11862 else
11863 {
11864 item.SetQuantity(Math.AbsFloat(quantity));
11865 }
11866
11867 }
11868 }
11869}
11870
11871#ifdef DEVELOPER
11872ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
11873#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения EntityAI.c:2
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
const int INPUT_UDT_ITEM_MANIPULATION
Определения _constants.c:8
class LogManager EntityAI
eBleedingSourceType GetType()
Определения BleedingSource.c:63
ItemSuppressor SuppressorBase
Определения InventoryItem.c:7
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
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
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
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:557
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:6308
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5548
bool HidesSelectionBySlot()
Определения ItemBase.c:9203
float m_VarWetMin
Определения ItemBase.c:4809
void SplitItem(PlayerBase player)
Определения ItemBase.c:6739
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9424
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8653
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:8087
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5553
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8796
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6706
override bool IsHeavyBehaviour()
Определения ItemBase.c:8998
override void SetWetMax()
Определения ItemBase.c:8369
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9241
void ClearStartItemSoundServer()
Определения ItemBase.c:9139
float m_VarWet
Определения ItemBase.c:4806
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9271
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8648
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4869
bool CanBeMovedOverride()
Определения ItemBase.c:7380
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8345
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4855
override void ProcessVariables()
Определения ItemBase.c:9338
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4883
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8179
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8714
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8559
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5139
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4881
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9374
bool m_IsSoundSynchRemote
Определения ItemBase.c:9532
float m_OverheatingShots
Определения ItemBase.c:4876
void StopItemSoundServer(int id)
Определения ItemBase.c:9127
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5568
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5292
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9398
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4893
bool CanBeCooked()
Определения ItemBase.c:7336
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5635
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4905
bool m_RecipesInitialized
Определения ItemBase.c:4791
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6382
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9382
override void OnEnergyConsumed()
Определения ItemBase.c:8289
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:8078
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:8218
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8409
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8174
ref TIntArray m_InteractActions
Определения ItemBase.c:4857
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7400
float m_VarQuantity
Определения ItemBase.c:4797
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9543
override float GetWetMax()
Определения ItemBase.c:8379
bool CanBeUsedForSuicide()
Определения ItemBase.c:9510
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7011
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5773
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7554
void StartItemSoundServer(int id)
Определения ItemBase.c:9114
void DoAmmoExplosion()
Определения ItemBase.c:6243
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4868
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6557
int GetItemSize()
Определения ItemBase.c:7365
bool m_CanBeMovedOverride
Определения ItemBase.c:4834
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6167
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5360
bool CanDecay()
Определения ItemBase.c:9313
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:8060
void SetQuantityMax()
Определения ItemBase.c:8065
override float GetQuantity()
Определения ItemBase.c:8154
int m_ColorComponentR
Определения ItemBase.c:4846
int m_ShotsToStartOverheating
Определения ItemBase.c:4878
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8394
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5367
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8897
void OnOverheatingDecay()
Определения ItemBase.c:5330
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8327
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4812
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5468
bool UsesGlobalDeploy()
Определения ItemBase.c:9542
int m_ItemBehaviour
Определения ItemBase.c:4827
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:8869
float m_HeatIsolation
Определения ItemBase.c:4822
float m_VarWetInit
Определения ItemBase.c:4808
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5813
void SetCEBasedQuantity()
Определения ItemBase.c:5581
bool m_CanPlayImpactSound
Определения ItemBase.c:4818
override string GetAttachmentSoundType()
Определения ItemBase.c:9072
float GetOverheatingCoef()
Определения ItemBase.c:5387
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9198
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9150
override bool IsStoreLoad()
Определения ItemBase.c:8421
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:6987
bool IsLightSource()
Определения ItemBase.c:5709
bool m_HasQuantityBar
Определения ItemBase.c:4840
void SetResultOfSplit(bool value)
Определения ItemBase.c:6982
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6624
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6797
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5395
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8336
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8977
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8431
int m_LockType
Определения ItemBase.c:4894
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4899
bool m_CanBeDigged
Определения ItemBase.c:4841
float m_ItemAttachOffset
Определения ItemBase.c:4824
float GetItemModelLength()
Определения ItemBase.c:8438
bool m_ThrowItemOnDrop
Определения ItemBase.c:4832
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7699
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8729
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8322
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7016
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9369
bool CanHaveWetness()
Определения ItemBase.c:9326
int m_CleannessMin
Определения ItemBase.c:4814
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8662
string IDToName(int id)
Определения ItemBase.c:7547
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9333
float GetHeatIsolationInit()
Определения ItemBase.c:8317
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7387
override bool HasQuantity()
Определения ItemBase.c:8149
float m_VarWetPrev
Определения ItemBase.c:4807
int m_SoundSyncStop
Определения ItemBase.c:4901
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9419
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4856
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5477
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5162
int m_VarLiquidType
Определения ItemBase.c:4826
int m_QuickBarBonus
Определения ItemBase.c:4828
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9060
override float GetWetInit()
Определения ItemBase.c:8389
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4820
int m_SoundSyncPlay
Определения ItemBase.c:4900
int m_MaxOverheatingValue
Определения ItemBase.c:4879
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4803
bool m_IsTakeable
Определения ItemBase.c:4831
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4871
string GetLockSoundSet()
Определения ItemBase.c:8487
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8518
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9446
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6803
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4783
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9085
override int GetQuantityMin()
Определения ItemBase.c:8138
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6533
override int GetQuickBarBonus()
Определения ItemBase.c:5047
override void SetTakeable(bool pState)
Определения ItemBase.c:9042
float m_OverheatingDecayInterval
Определения ItemBase.c:4880
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6356
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9291
bool CanProcessDecay()
Определения ItemBase.c:9319
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5558
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9435
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7351
bool can_this_be_combined
Определения ItemBase.c:4836
EffectSound m_SoundDeploy
Определения ItemBase.c:9529
int m_Count
Определения ItemBase.c:4802
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9482
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9034
override bool IsSplitable()
Определения ItemBase.c:6343
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6327
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7663
void ConvertEnergyToQuantity()
Определения ItemBase.c:8304
override void RemoveAllAgents()
Определения ItemBase.c:8643
override void SetQuantityToMinimum()
Определения ItemBase.c:8071
bool m_WantPlayImpactSound
Определения ItemBase.c:4817
override float GetTemperatureThawTime()
Определения ItemBase.c:9406
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4870
int m_ColorComponentG
Определения ItemBase.c:4847
float m_StoreLoadedQuantity
Определения ItemBase.c:4804
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7418
int m_ColorComponentA
Определения ItemBase.c:4849
int m_VarQuantityInit
Определения ItemBase.c:4799
float GetFilterDamageRatio()
Определения ItemBase.c:5462
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8531
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6773
void OnApply(PlayerBase player)
bool m_HideSelectionsBySlot
Определения ItemBase.c:4884
bool IsOverheatingEffectActive()
Определения ItemBase.c:5325
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5742
int GetLiquidContainerMask()
Определения ItemBase.c:5679
ref Timer m_CheckOverheating
Определения ItemBase.c:4877
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:5373
float GetEnergy()
Определения ItemBase.c:8278
bool CanBeDigged()
Определения ItemBase.c:5758
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9452
bool IsNVG()
Определения ItemBase.c:5690
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8238
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9228
bool m_IsDeploySound
Определения ItemBase.c:9531
bool CanEat()
Определения ItemBase.c:7311
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8937
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9008
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9430
bool IsLiquidContainer()
Определения ItemBase.c:5674
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7331
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8165
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8721
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8119
int m_CleannessInit
Определения ItemBase.c:4813
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5457
override int GetAgents()
Определения ItemBase.c:8668
int m_VarQuantityMax
Определения ItemBase.c:4801
override bool IsHologram()
Определения ItemBase.c:5753
float GetItemAttachOffset()
Определения ItemBase.c:8447
bool IsPlaceSound()
Определения ItemBase.c:9545
static int GetDebugActionsMask()
Определения ItemBase.c:5543
override int GetLiquidType()
Определения ItemBase.c:8547
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9308
override bool IsItemBase()
Определения ItemBase.c:7464
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9018
void ExplodeAmmo()
Определения ItemBase.c:6230
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:6972
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8742
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8917
override void OnEnergyAdded()
Определения ItemBase.c:8296
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:5702
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9528
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7604
void StopItemDynamicPhysics()
Определения ItemBase.c:9210
bool HasFoodStage()
Определения ItemBase.c:7324
override void SetStoreLoad(bool value)
Определения ItemBase.c:8416
float GetOverheatingValue()
Определения ItemBase.c:5287
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8621
override void AddWet(float value)
Определения ItemBase.c:8364
bool IsLiquidPresent()
Определения ItemBase.c:5669
bool IsFullQuantity()
Определения ItemBase.c:8159
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:5943
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6678
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6651
int m_CleannessMax
Определения ItemBase.c:4815
float m_VarStackMax
Определения ItemBase.c:4803
ref Timer m_PhysDropTimer
Определения ItemBase.c:4890
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7436
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8426
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4844
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5308
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5623
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7358
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8552
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5354
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8474
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4875
int m_LiquidContainerMask
Определения ItemBase.c:4825
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9246
override int GetCleanness()
Определения ItemBase.c:8469
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9457
bool IsDeploySound()
Определения ItemBase.c:9546
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5563
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8957
int m_VarQuantityMin
Определения ItemBase.c:4800
void PerformDamageSystemReinit()
Определения ItemBase.c:9216
override void ClearInventory()
Определения ItemBase.c:8257
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4872
ItemBase GetLightSourceItem()
Определения ItemBase.c:9440
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7454
override float GetItemOverheatThreshold()
Определения ItemBase.c:9390
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4837
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7568
void Open()
Implementations only.
Определения CannedFood.c:100
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6590
float m_ItemModelLength
Определения ItemBase.c:4823
bool m_IsHologram
Определения ItemBase.c:4830
static int m_DebugActionsMask
Определения ItemBase.c:4790
void KillAllOverheatingParticles()
Определения ItemBase.c:5423
bool CanBeCookedOnStick()
Определения ItemBase.c:7341
override int GetQuantityMax()
Определения ItemBase.c:8106
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7050
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8512
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8634
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4833
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8824
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9186
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4784
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9519
override bool IsBeingPlaced()
Определения ItemBase.c:5737
int GetQuantityInit()
Определения ItemBase.c:8143
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:6992
bool IsResultOfSplit()
Определения ItemBase.c:6977
bool m_FixDamageSystemInit
Определения ItemBase.c:4835
float m_ImpactSpeed
Определения ItemBase.c:4819
bool m_IsStoreLoad
Определения ItemBase.c:4838
int GetLiquidTypeInit()
Определения ItemBase.c:8542
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4853
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5610
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6462
int m_AttachedAgents
Определения ItemBase.c:4861
string m_LockSoundSet
Определения ItemBase.c:4896
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5231
float m_VarQuantityPrev
Определения ItemBase.c:4798
bool IsSoundSynchRemote()
Определения ItemBase.c:9544
bool m_CanShowQuantity
Определения ItemBase.c:4839
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Определения ItemBase.c:8781
override void OnRightClick()
Определения ItemBase.c:6846
int m_ColorComponentB
Определения ItemBase.c:4848
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4786
bool IsActionTargetVisible()
Определения ItemBase.c:9054
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:5978
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6267
bool m_IsBeingPlaced
Определения ItemBase.c:4829
int NameToID(string name)
Определения ItemBase.c:7541
void ~ItemBase()
Определения ItemBase.c:5508
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8404
void ClearStopItemSoundServer()
Определения ItemBase.c:9144
override string ChangeIntoOnDetach()
Определения ItemBase.c:6191
float m_VarWetMax
Определения ItemBase.c:4810
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6585
int GetLockType()
Определения ItemBase.c:8482
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9526
override float GetWet()
Определения ItemBase.c:8374
EffectSound m_SoundPlace
Определения ItemBase.c:9527
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8092
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8456
bool m_IsPlaceSound
Определения ItemBase.c:9530
override float GetWetMin()
Определения ItemBase.c:8384
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4902
override bool KindOf(string tag)
Определения ItemBase.c:7470
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:1321
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:962
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 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 int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Game.c:1513
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()
Определения Man.c:44
Определения Building.c:6
Определения constants.c:659
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
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
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 bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:149
override void OnWasDetached(EntityAI parent, int slot_id)
Определения InventoryItem.c:920
override void EEOnAfterLoad()
Определения GardenBase.c:187
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()
Определения InventoryItem.c:732
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:1218
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:465
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:472
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:206
override void AfterStoreLoad()
Определения GardenBase.c:182
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1017
override void OnVariablesSynchronized()
Определения GardenBase.c:68
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
Определения InventoryItem.c:912
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:962
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:269
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:988
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1150
override void InitItemSounds()
Определения TentBase.c:810
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:1012
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()
Определения InventoryItem.c:840
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:341
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
Определения InventoryItem.c:731
Определения 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)
Определения 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
Определения constants.c:510
const int DEF_CHEMICAL
Определения constants.c:511
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:685
array< int > TIntArray
Определения EnScript.c:687
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения constants.c:806
const int VARIABLE_LIQUIDTYPE
Определения constants.c:630
const int VARIABLE_CLEANNESS
Определения constants.c:633
const int VARIABLE_COLOR
Определения constants.c:632
const int VARIABLE_TEMPERATURE
Определения constants.c:628
const int VARIABLE_QUANTITY
Определения constants.c:626
const int VARIABLE_WET
Определения constants.c:629
const int LIQUID_NONE
Определения constants.c:527
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения constants.c:451
const int SAT_DEBUG_ACTION
Определения constants.c:452
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
Определения tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
proto native int GetColor()

Используется в InventoryItem::CombineItemsClient() и InventoryItem::CombineItemsEx().