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

◆ IsCombineAll()

bool SpawnItemOnLocation::IsCombineAll ( ItemBase other_item,
bool use_stack_max = false )
protected

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

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

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