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

◆ OnRightClick()

override void SpawnItemOnLocation::OnRightClick ( )
protected

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

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