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

◆ ComputeQuantityUsed()

int SpawnItemOnLocation::ComputeQuantityUsed ( ItemBase other_item,
bool use_stack_max = true )
private

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

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

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