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

◆ SplitItem()

void SpawnItemOnLocation::SplitItem ( PlayerBase player)
protected

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

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

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