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

◆ LoadAgents()

bool SpawnItemOnLocation::LoadAgents ( ParamsReadContext ctx,
int version )
protected

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

8860{
8861 override bool CanPutAsAttachment(EntityAI parent)
8862 {
8863 return true;
8864 }
8865};
8866
8867//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8868
8869class ItemBase extends InventoryItem
8870{
8874
8876
8877 static int m_DebugActionsMask;
8879 // ============================================
8880 // Variable Manipulation System
8881 // ============================================
8882 // Quantity
8883
8884 float m_VarQuantity;
8885 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8887 int m_VarQuantityMin;
8888 int m_VarQuantityMax;
8889 int m_Count;
8890 float m_VarStackMax;
8891 float m_StoreLoadedQuantity = float.LOWEST;
8892 // Wet
8893 float m_VarWet;
8894 float m_VarWetPrev;//for client to know wetness changed during synchronization
8895 float m_VarWetInit;
8896 float m_VarWetMin;
8897 float m_VarWetMax;
8898 // Cleanness
8899 int m_Cleanness;
8900 int m_CleannessInit;
8901 int m_CleannessMin;
8902 int m_CleannessMax;
8903 // impact sounds
8905 bool m_CanPlayImpactSound = true;
8906 float m_ImpactSpeed;
8908 //
8909 float m_HeatIsolation;
8910 float m_ItemModelLength;
8911 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8913 int m_VarLiquidType;
8914 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8915 int m_QuickBarBonus;
8916 bool m_IsBeingPlaced;
8917 bool m_IsHologram;
8918 bool m_IsTakeable;
8919 bool m_ThrowItemOnDrop;
8922 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8923 bool can_this_be_combined; //Check if item can be combined
8924 bool m_CanThisBeSplit; //Check if item can be split
8925 bool m_IsStoreLoad = false;
8926 bool m_CanShowQuantity;
8927 bool m_HasQuantityBar;
8928 protected bool m_CanBeDigged;
8929 protected bool m_IsResultOfSplit
8930
8931 string m_SoundAttType;
8932 // items color variables
8937 //-------------------------------------------------------
8938
8939 // light source managing
8941
8945
8946 //==============================================
8947 // agent system
8948 private int m_AttachedAgents;
8949
8951 void TransferModifiers(PlayerBase reciever);
8952
8953
8954 // Weapons & suppressors particle effects
8959 static int m_LastRegisteredWeaponID = 0;
8960
8961 // Overheating effects
8963 float m_OverheatingShots;
8964 ref Timer m_CheckOverheating;
8965 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8966 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8967 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8968 ref array <ref OverheatingParticle> m_OverheatingParticles;
8969
8971 protected bool m_HideSelectionsBySlot;
8972
8973 // Admin Log
8974 PluginAdminLog m_AdminLog;
8975
8976 // misc
8977 ref Timer m_PhysDropTimer;
8978
8979 // Attachment Locking variables
8980 ref array<int> m_CompatibleLocks;
8981 protected int m_LockType;
8982 protected ref EffectSound m_LockingSound;
8983 protected string m_LockSoundSet;
8984
8985 // ItemSoundHandler
8986 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8987 protected int m_SoundSyncPlay; // id for sound to play
8988 protected int m_SoundSyncStop; // id for sound to stop
8990
8991 //temperature
8992 private float m_TemperaturePerQuantityWeight;
8993
8994 // -------------------------------------------------------------------------
8995 void ItemBase()
8996 {
8997 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
9001
9002 if (!GetGame().IsDedicatedServer())
9003 {
9004 if (HasMuzzle())
9005 {
9007
9009 {
9011 }
9012 }
9013
9015 m_ActionsInitialize = false;
9016 }
9017
9018 m_OldLocation = null;
9019
9020 if (GetGame().IsServer())
9021 {
9022 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
9023 }
9024
9025 if (ConfigIsExisting("headSelectionsToHide"))
9026 {
9028 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
9029 }
9030
9031 m_HideSelectionsBySlot = false;
9032 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
9033 {
9034 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
9035 }
9036
9037 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
9038
9039 m_IsResultOfSplit = false;
9040
9042 }
9043
9044 override void InitItemVariables()
9045 {
9046 super.InitItemVariables();
9047
9048 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
9049 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
9050 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
9051 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
9052 m_VarStackMax = ConfigGetFloat("varStackMax");
9053 m_Count = ConfigGetInt("count");
9054
9055 m_CanShowQuantity = ConfigGetBool("quantityShow");
9056 m_HasQuantityBar = ConfigGetBool("quantityBar");
9057
9058 m_CleannessInit = ConfigGetInt("varCleannessInit");
9060 m_CleannessMin = ConfigGetInt("varCleannessMin");
9061 m_CleannessMax = ConfigGetInt("varCleannessMax");
9062
9063 m_WantPlayImpactSound = false;
9064 m_ImpactSpeed = 0.0;
9065
9066 m_VarWetInit = ConfigGetFloat("varWetInit");
9068 m_VarWetMin = ConfigGetFloat("varWetMin");
9069 m_VarWetMax = ConfigGetFloat("varWetMax");
9070
9071 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
9072 if (IsLiquidContainer() && GetQuantity() != 0)
9074 m_IsBeingPlaced = false;
9075 m_IsHologram = false;
9076 m_IsTakeable = true;
9077 m_CanBeMovedOverride = false;
9081 m_CanBeDigged = ConfigGetBool("canBeDigged");
9082
9083 m_CompatibleLocks = new array<int>();
9084 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
9085 m_LockType = ConfigGetInt("lockType");
9086
9087 //Define if item can be split and set ability to be combined accordingly
9088 m_CanThisBeSplit = false;
9089 can_this_be_combined = false;
9090 if (ConfigIsExisting("canBeSplit"))
9091 {
9092 can_this_be_combined = ConfigGetBool("canBeSplit");
9094 }
9095
9096 m_ItemBehaviour = -1;
9097 if (ConfigIsExisting("itemBehaviour"))
9098 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
9099
9100 //RegisterNetSyncVariableInt("m_VariablesMask");
9101 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9102 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
9103 RegisterNetSyncVariableInt("m_VarLiquidType");
9104 RegisterNetSyncVariableInt("m_Cleanness",0,1);
9105
9106 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
9107 RegisterNetSyncVariableFloat("m_ImpactSpeed");
9108 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
9109
9110 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
9111 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
9112 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
9113 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
9114
9115 RegisterNetSyncVariableBool("m_IsBeingPlaced");
9116 RegisterNetSyncVariableBool("m_IsTakeable");
9117 RegisterNetSyncVariableBool("m_IsHologram");
9118
9119 InitItemSounds();
9121 {
9122 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
9123 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
9124 }
9125
9126 m_LockSoundSet = ConfigGetString("lockSoundSet");
9127
9129 if (ConfigIsExisting("temperaturePerQuantityWeight"))
9130 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
9131
9132 }
9133
9134 override int GetQuickBarBonus()
9135 {
9136 return m_QuickBarBonus;
9137 }
9138
9139 void InitializeActions()
9140 {
9142 if (!m_InputActionMap)
9143 {
9145 m_InputActionMap = iam;
9146 SetActions();
9148 }
9149 }
9150
9151 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
9152 {
9154 {
9155 m_ActionsInitialize = true;
9157 }
9158
9159 actions = m_InputActionMap.Get(action_input_type);
9160 }
9161
9162 void SetActions()
9163 {
9164 AddAction(ActionTakeItem);
9165 AddAction(ActionTakeItemToHands);
9166 AddAction(ActionWorldCraft);
9168 AddAction(ActionAttachWithSwitch);
9169 }
9170
9171 void SetActionAnimOverrides(); // Override action animation for specific item
9172
9173 void AddAction(typename actionName)
9174 {
9175 ActionBase action = ActionManagerBase.GetAction(actionName);
9176
9177 if (!action)
9178 {
9179 Debug.LogError("Action " + actionName + " dosn't exist!");
9180 return;
9181 }
9182
9183 typename ai = action.GetInputType();
9184 if (!ai)
9185 {
9186 m_ActionsInitialize = false;
9187 return;
9188 }
9189
9190 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9191 if (!action_array)
9192 {
9193 action_array = new array<ActionBase_Basic>;
9194 m_InputActionMap.Insert(ai, action_array);
9195 }
9196 if (LogManager.IsActionLogEnable())
9197 {
9198 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
9199 }
9200
9201 if (action_array.Find(action) != -1)
9202 {
9203 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
9204 }
9205 else
9206 {
9207 action_array.Insert(action);
9208 }
9209 }
9210
9211 void RemoveAction(typename actionName)
9212 {
9213 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9214 ActionBase action = player.GetActionManager().GetAction(actionName);
9215 typename ai = action.GetInputType();
9216 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
9217
9218 if (action_array)
9219 {
9220 action_array.RemoveItem(action);
9221 }
9222 }
9223
9224 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
9225 // Set -1 for params which should stay in default state
9226 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
9227 {
9228 ActionOverrideData overrideData = new ActionOverrideData();
9229 overrideData.m_CommandUID = commandUID;
9230 overrideData.m_CommandUIDProne = commandUIDProne;
9231 overrideData.m_StanceMask = stanceMask;
9232
9233 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
9234 if (!actionMap) // create new map of action > overidables map
9235 {
9236 actionMap = new TActionAnimOverrideMap();
9237 m_ItemActionOverrides.Insert(action, actionMap);
9238 }
9239
9240 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
9241
9242 }
9243
9244 void OnItemInHandsPlayerSwimStart(PlayerBase player);
9245
9246 ScriptedLightBase GetLight();
9247
9248 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9249 void LoadParticleConfigOnFire(int id)
9250 {
9251 if (!m_OnFireEffect)
9253
9256
9257 string config_to_search = "CfgVehicles";
9258 string muzzle_owner_config;
9259
9260 if (!m_OnFireEffect.Contains(id))
9261 {
9262 if (IsInherited(Weapon))
9263 config_to_search = "CfgWeapons";
9264
9265 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9266
9267 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
9268
9269 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
9270
9271 if (config_OnFire_subclass_count > 0)
9272 {
9273 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
9274
9275 for (int i = 0; i < config_OnFire_subclass_count; i++)
9276 {
9277 string particle_class = "";
9278 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
9279 string config_OnFire_entry = config_OnFire_class + particle_class;
9280 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
9281 WPOF_array.Insert(WPOF);
9282 }
9283
9284
9285 m_OnFireEffect.Insert(id, WPOF_array);
9286 }
9287 }
9288
9289 if (!m_OnBulletCasingEjectEffect.Contains(id))
9290 {
9291 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
9292 muzzle_owner_config = config_to_search + " " + GetType() + " ";
9293
9294 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
9295
9296 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
9297
9298 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
9299 {
9300 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
9301
9302 for (i = 0; i < config_OnBulletCasingEject_count; i++)
9303 {
9304 string particle_class2 = "";
9305 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
9306 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
9307 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
9308 WPOBE_array.Insert(WPOBE);
9309 }
9310
9311
9312 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
9313 }
9314 }
9315 }
9316
9317 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
9319 {
9322
9323 if (!m_OnOverheatingEffect.Contains(id))
9324 {
9325 string config_to_search = "CfgVehicles";
9326
9327 if (IsInherited(Weapon))
9328 config_to_search = "CfgWeapons";
9329
9330 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
9331 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
9332
9333 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
9334 {
9335
9336 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
9337
9339 {
9340 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
9341 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
9342 Error(error);
9343 return;
9344 }
9345
9346 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
9347 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
9348
9349
9350
9351 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
9352 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
9353
9354 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
9355 {
9356 string particle_class = "";
9357 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
9358 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
9359 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
9360
9361 if (entry_type == CT_CLASS)
9362 {
9363 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
9364 WPOOH_array.Insert(WPOF);
9365 }
9366 }
9367
9368
9369 m_OnOverheatingEffect.Insert(id, WPOOH_array);
9370 }
9371 }
9372 }
9373
9374 float GetOverheatingValue()
9375 {
9376 return m_OverheatingShots;
9377 }
9378
9379 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9380 {
9381 if (m_MaxOverheatingValue > 0)
9382 {
9384
9385 if (!m_CheckOverheating)
9387
9389 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9390
9391 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9392 }
9393 }
9394
9395 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9396 {
9398 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9399
9401 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9402
9404 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9405
9407 {
9409 }
9410 }
9411
9413 {
9415 }
9416
9417 void OnOverheatingDecay()
9418 {
9419 if (m_MaxOverheatingValue > 0)
9420 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
9421 else
9423
9424 if (m_OverheatingShots <= 0)
9425 {
9428 }
9429 else
9430 {
9431 if (!m_CheckOverheating)
9433
9435 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
9436 }
9437
9438 CheckOverheating(this, "", this);
9439 }
9440
9441 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9442 {
9444 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9445 }
9446
9447 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9448 {
9450 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
9452 }
9453
9454 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
9455 {
9457 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9458 }
9459
9460 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
9461 {
9463 m_OverheatingParticles = new array<ref OverheatingParticle>;
9464
9465 OverheatingParticle OP = new OverheatingParticle();
9466 OP.RegisterParticle(p);
9467 OP.SetOverheatingLimitMin(min_heat_coef);
9468 OP.SetOverheatingLimitMax(max_heat_coef);
9469 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
9470
9471 m_OverheatingParticles.Insert(OP);
9472 }
9473
9474 float GetOverheatingCoef()
9475 {
9476 if (m_MaxOverheatingValue > 0)
9478
9479 return -1;
9480 }
9481
9483 {
9485 {
9486 float overheat_coef = GetOverheatingCoef();
9487 int count = m_OverheatingParticles.Count();
9488
9489 for (int i = count; i > 0; --i)
9490 {
9491 int id = i - 1;
9492 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9493 Particle p = OP.GetParticle();
9494
9495 float overheat_min = OP.GetOverheatingLimitMin();
9496 float overheat_max = OP.GetOverheatingLimitMax();
9497
9498 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
9499 {
9500 if (p)
9501 {
9502 p.Stop();
9503 OP.RegisterParticle(null);
9504 }
9505 }
9506 }
9507 }
9508 }
9509
9511 {
9513 {
9514 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
9515 {
9516 int id = i - 1;
9517 OverheatingParticle OP = m_OverheatingParticles.Get(id);
9518
9519 if (OP)
9520 {
9521 Particle p = OP.GetParticle();
9522
9523 if (p)
9524 {
9525 p.Stop();
9526 }
9527
9528 delete OP;
9529 }
9530 }
9531
9532 m_OverheatingParticles.Clear();
9534 }
9535 }
9536
9538 float GetInfectionChance(int system = 0, Param param = null)
9539 {
9540 return 0.0;
9541 }
9542
9543
9544 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9545 {
9546 return 250;//default value
9547 }
9548
9549 float GetFilterDamageRatio()
9550 {
9551 return 0;
9552 }
9553
9555 bool HasMuzzle()
9556 {
9557 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9558 return true;
9559
9560 return false;
9561 }
9562
9564 int GetMuzzleID()
9565 {
9566 if (!m_WeaponTypeToID)
9568
9569 if (m_WeaponTypeToID.Contains(GetType()))
9570 {
9571 return m_WeaponTypeToID.Get(GetType());
9572 }
9573 else
9574 {
9575 // Register new weapon ID
9577 }
9578
9580 }
9581
9588 {
9589 return -1;
9590 }
9591
9592
9593
9594 // -------------------------------------------------------------------------
9595 void ~ItemBase()
9596 {
9597 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
9598 {
9599 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
9600 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9601
9602 if (r_index >= 0)
9603 {
9604 InventoryLocation r_il = new InventoryLocation;
9605 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9606
9607 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9608 int r_type = r_il.GetType();
9609 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9610 {
9611 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9612 }
9613 else if (r_type == InventoryLocationType.ATTACHMENT)
9614 {
9615 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9616 }
9617
9618 }
9619
9620 player.GetHumanInventory().ClearUserReservedLocation(this);
9621 }
9622
9623 if (m_LockingSound)
9624 SEffectManager.DestroyEffect(m_LockingSound);
9625 }
9626
9627
9628
9629 // -------------------------------------------------------------------------
9630 static int GetDebugActionsMask()
9631 {
9632 return ItemBase.m_DebugActionsMask;
9633 }
9634
9635 static bool HasDebugActionsMask(int mask)
9636 {
9637 return ItemBase.m_DebugActionsMask & mask;
9638 }
9639
9640 static void SetDebugActionsMask(int mask)
9641 {
9642 ItemBase.m_DebugActionsMask = mask;
9643 }
9644
9645 static void AddDebugActionsMask(int mask)
9646 {
9647 ItemBase.m_DebugActionsMask |= mask;
9648 }
9649
9650 static void RemoveDebugActionsMask(int mask)
9651 {
9652 ItemBase.m_DebugActionsMask &= ~mask;
9653 }
9654
9655 static void ToggleDebugActionsMask(int mask)
9656 {
9657 if (HasDebugActionsMask(mask))
9658 {
9660 }
9661 else
9662 {
9663 AddDebugActionsMask(mask);
9664 }
9665 }
9666
9667 // -------------------------------------------------------------------------
9668 void SetCEBasedQuantity()
9669 {
9670 if (GetEconomyProfile())
9671 {
9672 float q_max = GetEconomyProfile().GetQuantityMax();
9673 if (q_max > 0)
9674 {
9675 float q_min = GetEconomyProfile().GetQuantityMin();
9676 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9677
9678 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9679 {
9680 ComponentEnergyManager comp = GetCompEM();
9681 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
9682 {
9683 comp.SetEnergy0To1(quantity_randomized);
9684 }
9685 }
9686 else if (HasQuantity())
9687 {
9688 SetQuantityNormalized(quantity_randomized, false);
9689 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9690 }
9691
9692 }
9693 }
9694 }
9695
9697 void LockToParent()
9698 {
9699 EntityAI parent = GetHierarchyParent();
9700
9701 if (parent)
9702 {
9703 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9704 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9705 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9706 }
9707 }
9708
9710 void UnlockFromParent()
9711 {
9712 EntityAI parent = GetHierarchyParent();
9713
9714 if (parent)
9715 {
9716 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9717 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9718 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9719 }
9720 }
9721
9722 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9723 {
9724 /*
9725 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9726 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
9727 */
9728 ItemBase item2 = ItemBase.Cast(entity2);
9729
9730 if (GetGame().IsClient())
9731 {
9732 if (ScriptInputUserData.CanStoreInputUserData())
9733 {
9734 ScriptInputUserData ctx = new ScriptInputUserData;
9736 ctx.Write(-1);
9737 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9738 ctx.Write(i1);
9739 ctx.Write(item2);
9740 ctx.Write(use_stack_max);
9741 ctx.Write(-1);
9742 ctx.Send();
9743
9744 if (IsCombineAll(item2, use_stack_max))
9745 {
9746 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9747 }
9748 }
9749 }
9750 else if (!GetGame().IsMultiplayer())
9751 {
9752 CombineItems(item2, use_stack_max);
9753 }
9754 }
9755
9756 bool IsLiquidPresent()
9757 {
9758 return (GetLiquidType() != 0 && HasQuantity());
9759 }
9760
9761 bool IsLiquidContainer()
9762 {
9763 return m_LiquidContainerMask != 0;
9764 }
9765
9767 {
9768 return m_LiquidContainerMask;
9769 }
9770
9771 bool IsBloodContainer()
9772 {
9773 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9774 return false;
9775 }
9776
9777 bool IsNVG()
9778 {
9779 return false;
9780 }
9781
9784 bool IsExplosive()
9785 {
9786 return false;
9787 }
9788
9790 {
9791 return "";
9792 }
9793
9795
9796 bool IsLightSource()
9797 {
9798 return false;
9799 }
9800
9802 {
9803 return true;
9804 }
9805
9806 //--- ACTION CONDITIONS
9807 //direction
9808 bool IsFacingPlayer(PlayerBase player, string selection)
9809 {
9810 return true;
9811 }
9812
9813 bool IsPlayerInside(PlayerBase player, string selection)
9814 {
9815 return true;
9816 }
9817
9818 override bool CanObstruct()
9819 {
9820 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9821 return !player || !IsPlayerInside(player, "");
9822 }
9823
9824 override bool IsBeingPlaced()
9825 {
9826 return m_IsBeingPlaced;
9827 }
9828
9829 void SetIsBeingPlaced(bool is_being_placed)
9830 {
9831 m_IsBeingPlaced = is_being_placed;
9832 if (!is_being_placed)
9834 SetSynchDirty();
9835 }
9836
9837 //server-side
9838 void OnEndPlacement() {}
9839
9840 override bool IsHologram()
9841 {
9842 return m_IsHologram;
9843 }
9844
9845 bool CanBeDigged()
9846 {
9847 return m_CanBeDigged;
9848 }
9849
9851 {
9852 return 1;
9853 }
9854
9855 bool CanMakeGardenplot()
9856 {
9857 return false;
9858 }
9859
9860 void SetIsHologram(bool is_hologram)
9861 {
9862 m_IsHologram = is_hologram;
9863 SetSynchDirty();
9864 }
9865 /*
9866 protected float GetNutritionalEnergy()
9867 {
9868 Edible_Base edible = Edible_Base.Cast(this);
9869 return edible.GetFoodEnergy();
9870 }
9871
9872 protected float GetNutritionalWaterContent()
9873 {
9874 Edible_Base edible = Edible_Base.Cast(this);
9875 return edible.GetFoodWater();
9876 }
9877
9878 protected float GetNutritionalIndex()
9879 {
9880 Edible_Base edible = Edible_Base.Cast(this);
9881 return edible.GetFoodNutritionalIndex();
9882 }
9883
9884 protected float GetNutritionalFullnessIndex()
9885 {
9886 Edible_Base edible = Edible_Base.Cast(this);
9887 return edible.GetFoodTotalVolume();
9888 }
9889
9890 protected float GetNutritionalToxicity()
9891 {
9892 Edible_Base edible = Edible_Base.Cast(this);
9893 return edible.GetFoodToxicity();
9894
9895 }
9896 */
9897
9898
9899 // -------------------------------------------------------------------------
9900 override void OnMovedInsideCargo(EntityAI container)
9901 {
9902 super.OnMovedInsideCargo(container);
9903
9904 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9905 }
9906
9907 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9908 {
9909 super.EEItemLocationChanged(oldLoc,newLoc);
9910
9911 PlayerBase new_player = null;
9912 PlayerBase old_player = null;
9913
9914 if (newLoc.GetParent())
9915 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9916
9917 if (oldLoc.GetParent())
9918 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9919
9920 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
9921 {
9922 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
9923
9924 if (r_index >= 0)
9925 {
9926 InventoryLocation r_il = new InventoryLocation;
9927 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9928
9929 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9930 int r_type = r_il.GetType();
9931 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9932 {
9933 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9934 }
9935 else if (r_type == InventoryLocationType.ATTACHMENT)
9936 {
9937 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9938 }
9939
9940 }
9941 }
9942
9943 if (newLoc.GetType() == InventoryLocationType.HANDS)
9944 {
9945 if (new_player)
9946 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
9947
9948 if (new_player == old_player)
9949 {
9950
9951 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9952 {
9953 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9954 {
9955 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9956 {
9957 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9958 }
9959 }
9960 else
9961 {
9962 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9963 }
9964 }
9965
9966 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9967 {
9968 int type = oldLoc.GetType();
9969 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9970 {
9971 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9972 }
9973 else if (type == InventoryLocationType.ATTACHMENT)
9974 {
9975 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9976 }
9977 }
9978 if (!m_OldLocation)
9979 {
9980 m_OldLocation = new InventoryLocation;
9981 }
9982 m_OldLocation.Copy(oldLoc);
9983 }
9984 else
9985 {
9986 if (m_OldLocation)
9987 {
9988 m_OldLocation.Reset();
9989 }
9990 }
9991
9993 }
9994 else
9995 {
9996 if (new_player)
9997 {
9998 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9999 if (res_index >= 0)
10000 {
10001 InventoryLocation il = new InventoryLocation;
10002 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
10003 ItemBase it = ItemBase.Cast(il.GetItem());
10004 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
10005 int rel_type = il.GetType();
10006 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
10007 {
10008 il.GetParent().GetOnReleaseLock().Invoke(it);
10009 }
10010 else if (rel_type == InventoryLocationType.ATTACHMENT)
10011 {
10012 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
10013 }
10014 //it.GetOnReleaseLock().Invoke(it);
10015 }
10016 }
10017 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
10018 {
10019 //ThrowPhysically(old_player, vector.Zero);
10020 m_ThrowItemOnDrop = false;
10021 }
10022
10023 if (m_OldLocation)
10024 {
10025 m_OldLocation.Reset();
10026 }
10027 }
10028 }
10029
10030 override void EOnContact(IEntity other, Contact extra)
10031 {
10033 {
10034 int liquidType = -1;
10035 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
10036 if (impactSpeed > 0.0)
10037 {
10038 m_ImpactSpeed = impactSpeed;
10039 #ifndef SERVER
10040 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
10041 #else
10042 m_WantPlayImpactSound = true;
10043 SetSynchDirty();
10044 #endif
10045 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
10046 }
10047 }
10048
10049 #ifdef SERVER
10050 if (GetCompEM() && GetCompEM().IsPlugged())
10051 {
10052 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
10053 GetCompEM().UnplugThis();
10054 }
10055 #endif
10056 }
10057
10058 void RefreshPhysics();
10059
10060 override void OnCreatePhysics()
10061 {
10063 }
10064
10065 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
10066 {
10067
10068 }
10069 // -------------------------------------------------------------------------
10070 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
10071 {
10072 super.OnItemLocationChanged(old_owner, new_owner);
10073
10074 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
10075 PlayerBase playerNew = PlayerBase.Cast(new_owner);
10076
10077 if (!relatedPlayer && playerNew)
10078 relatedPlayer = playerNew;
10079
10080 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
10081 {
10082 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
10083 if (actionMgr)
10084 {
10085 ActionBase currentAction = actionMgr.GetRunningAction();
10086 if (currentAction)
10087 currentAction.OnItemLocationChanged(this);
10088 }
10089 }
10090
10091 Man ownerPlayerOld = null;
10092 Man ownerPlayerNew = null;
10093
10094 if (old_owner)
10095 {
10096 if (old_owner.IsMan())
10097 {
10098 ownerPlayerOld = Man.Cast(old_owner);
10099 }
10100 else
10101 {
10102 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
10103 }
10104 }
10105 else
10106 {
10107 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
10108 {
10109 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
10110
10111 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
10112 {
10113 GetCompEM().UnplugThis();
10114 }
10115 }
10116 }
10117
10118 if (new_owner)
10119 {
10120 if (new_owner.IsMan())
10121 {
10122 ownerPlayerNew = Man.Cast(new_owner);
10123 }
10124 else
10125 {
10126 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
10127 }
10128 }
10129
10130 if (ownerPlayerOld != ownerPlayerNew)
10131 {
10132 if (ownerPlayerOld)
10133 {
10134 array<EntityAI> subItemsExit = new array<EntityAI>;
10135 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
10136 for (int i = 0; i < subItemsExit.Count(); i++)
10137 {
10138 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
10139 itemExit.OnInventoryExit(ownerPlayerOld);
10140 }
10141 }
10142
10143 if (ownerPlayerNew)
10144 {
10145 array<EntityAI> subItemsEnter = new array<EntityAI>;
10146 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
10147 for (int j = 0; j < subItemsEnter.Count(); j++)
10148 {
10149 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
10150 itemEnter.OnInventoryEnter(ownerPlayerNew);
10151 }
10152 }
10153 }
10154 else if (ownerPlayerNew != null)
10155 {
10156 PlayerBase nplayer;
10157 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
10158 {
10159 array<EntityAI> subItemsUpdate = new array<EntityAI>;
10160 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
10161 for (int k = 0; k < subItemsUpdate.Count(); k++)
10162 {
10163 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
10164 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
10165 }
10166 }
10167 }
10168
10169 if (old_owner)
10170 old_owner.OnChildItemRemoved(this);
10171 if (new_owner)
10172 new_owner.OnChildItemReceived(this);
10173 }
10174
10175 // -------------------------------------------------------------------------------
10176 override void EEDelete(EntityAI parent)
10177 {
10178 super.EEDelete(parent);
10179 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
10180 if (player)
10181 {
10182 OnInventoryExit(player);
10183
10184 if (player.IsAlive())
10185 {
10186 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
10187 if (r_index >= 0)
10188 {
10189 InventoryLocation r_il = new InventoryLocation;
10190 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
10191
10192 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
10193 int r_type = r_il.GetType();
10194 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
10195 {
10196 r_il.GetParent().GetOnReleaseLock().Invoke(this);
10197 }
10198 else if (r_type == InventoryLocationType.ATTACHMENT)
10199 {
10200 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
10201 }
10202
10203 }
10204
10205 player.RemoveQuickBarEntityShortcut(this);
10206 }
10207 }
10208 }
10209 // -------------------------------------------------------------------------------
10210 override void EEKilled(Object killer)
10211 {
10212 super.EEKilled(killer);
10213
10215 if (killer && killer.IsFireplace() && CanExplodeInFire())
10216 {
10217 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
10218 {
10219 if (IsMagazine())
10220 {
10221 if (Magazine.Cast(this).GetAmmoCount() > 0)
10222 {
10223 ExplodeAmmo();
10224 }
10225 }
10226 else
10227 {
10228 Explode(DamageType.EXPLOSION);
10229 }
10230 }
10231 }
10232 }
10233
10234 override void OnWasAttached(EntityAI parent, int slot_id)
10235 {
10236 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
10237
10238 super.OnWasAttached(parent, slot_id);
10239
10240 if (HasQuantity())
10241 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10242
10243 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
10244 }
10245
10246 override void OnWasDetached(EntityAI parent, int slot_id)
10247 {
10248 super.OnWasDetached(parent, slot_id);
10249
10250 if (HasQuantity())
10251 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
10252 }
10253
10254 override string ChangeIntoOnAttach(string slot)
10255 {
10256 int idx;
10257 TStringArray inventory_slots = new TStringArray;
10258 TStringArray attach_types = new TStringArray;
10259
10260 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10261 if (inventory_slots.Count() < 1) //is string
10262 {
10263 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
10264 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
10265 }
10266 else //is array
10267 {
10268 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
10269 }
10270
10271 idx = inventory_slots.Find(slot);
10272 if (idx < 0)
10273 return "";
10274
10275 return attach_types.Get(idx);
10276 }
10277
10278 override string ChangeIntoOnDetach()
10279 {
10280 int idx = -1;
10281 string slot;
10282
10283 TStringArray inventory_slots = new TStringArray;
10284 TStringArray detach_types = new TStringArray;
10285
10286 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
10287 if (inventory_slots.Count() < 1) //is string
10288 {
10289 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
10290 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10291 }
10292 else //is array
10293 {
10294 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
10295 if (detach_types.Count() < 1)
10296 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
10297 }
10298
10299 for (int i = 0; i < inventory_slots.Count(); i++)
10300 {
10301 slot = inventory_slots.Get(i);
10302 }
10303
10304 if (slot != "")
10305 {
10306 if (detach_types.Count() == 1)
10307 idx = 0;
10308 else
10309 idx = inventory_slots.Find(slot);
10310 }
10311 if (idx < 0)
10312 return "";
10313
10314 return detach_types.Get(idx);
10315 }
10316
10317 void ExplodeAmmo()
10318 {
10319 //timer
10320 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
10321
10322 //min/max time
10323 float min_time = 1;
10324 float max_time = 3;
10325 float delay = Math.RandomFloat(min_time, max_time);
10326
10327 explode_timer.Run(delay, this, "DoAmmoExplosion");
10328 }
10329
10330 void DoAmmoExplosion()
10331 {
10332 Magazine magazine = Magazine.Cast(this);
10333 int pop_sounds_count = 6;
10334 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
10335
10336 //play sound
10337 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
10338 string sound_name = pop_sounds[ sound_idx ];
10339 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
10340
10341 //remove ammo count
10342 magazine.ServerAddAmmoCount(-1);
10343
10344 //if condition then repeat -> ExplodeAmmo
10345 float min_temp_to_explode = 100; //min temperature for item to explode
10346
10347 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
10348 {
10349 ExplodeAmmo();
10350 }
10351 }
10352
10353 // -------------------------------------------------------------------------------
10354 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
10355 {
10356 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
10357
10358 const int CHANCE_DAMAGE_CARGO = 4;
10359 const int CHANCE_DAMAGE_ATTACHMENT = 1;
10360 const int CHANCE_DAMAGE_NOTHING = 2;
10361
10362 if (IsClothing() || IsContainer() || IsItemTent())
10363 {
10364 float dmg = damageResult.GetDamage("","Health") * -0.5;
10365 int chances;
10366 int rnd;
10367
10368 if (GetInventory().GetCargo())
10369 {
10370 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10371 rnd = Math.RandomInt(0,chances);
10372
10373 if (rnd < CHANCE_DAMAGE_CARGO)
10374 {
10375 DamageItemInCargo(dmg);
10376 }
10377 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
10378 {
10380 }
10381 }
10382 else
10383 {
10384 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
10385 rnd = Math.RandomInt(0,chances);
10386
10387 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
10388 {
10390 }
10391 }
10392 }
10393 }
10394
10395 bool DamageItemInCargo(float damage)
10396 {
10397 if (GetInventory().GetCargo())
10398 {
10399 int item_count = GetInventory().GetCargo().GetItemCount();
10400 if (item_count > 0)
10401 {
10402 int random_pick = Math.RandomInt(0, item_count);
10403 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
10404 if (!item.IsExplosive())
10405 {
10406 item.AddHealth("","",damage);
10407 return true;
10408 }
10409 }
10410 }
10411 return false;
10412 }
10413
10414 bool DamageItemAttachments(float damage)
10415 {
10416 int attachment_count = GetInventory().AttachmentCount();
10417 if (attachment_count > 0)
10418 {
10419 int random_pick = Math.RandomInt(0, attachment_count);
10420 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
10421 if (!attachment.IsExplosive())
10422 {
10423 attachment.AddHealth("","",damage);
10424 return true;
10425 }
10426 }
10427 return false;
10428 }
10429
10430 override bool IsSplitable()
10431 {
10432 return m_CanThisBeSplit;
10433 }
10434 //----------------
10435 override bool CanBeSplit()
10436 {
10437 if (IsSplitable() && (GetQuantity() > 1))
10438 return GetInventory().CanRemoveEntity();
10439
10440 return false;
10441 }
10442
10443 protected bool ShouldSplitQuantity(float quantity)
10444 {
10445 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
10446 if (!IsSplitable())
10447 return false;
10448
10449 // nothing to split?
10450 if (GetQuantity() <= 1)
10451 return false;
10452
10453 // check if we should re-use the item instead of creating a new copy?
10454 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
10455 int delta = GetQuantity() - quantity;
10456 if (delta == 0)
10457 return false;
10458
10459 // valid to split
10460 return true;
10461 }
10462
10463 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
10464 {
10465 if (GetGame().IsClient())
10466 {
10467 if (ScriptInputUserData.CanStoreInputUserData())
10468 {
10469 ScriptInputUserData ctx = new ScriptInputUserData;
10471 ctx.Write(1);
10472 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10473 ctx.Write(i1);
10474 ctx.Write(destination_entity);
10475 ctx.Write(true);
10476 ctx.Write(slot_id);
10477 ctx.Send();
10478 }
10479 }
10480 else if (!GetGame().IsMultiplayer())
10481 {
10482 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
10483 }
10484 }
10485
10486 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
10487 {
10488 float split_quantity_new;
10489 ItemBase new_item;
10490 float quantity = GetQuantity();
10491 float stack_max = GetTargetQuantityMax(slot_id);
10492 InventoryLocation loc = new InventoryLocation;
10493
10494 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10495 {
10496 if (stack_max <= GetQuantity())
10497 split_quantity_new = stack_max;
10498 else
10499 split_quantity_new = GetQuantity();
10500
10501 if (ShouldSplitQuantity(split_quantity_new))
10502 {
10503 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10504 if (new_item)
10505 {
10506 new_item.SetResultOfSplit(true);
10507 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10508 AddQuantity(-split_quantity_new, false, true);
10509 new_item.SetQuantity(split_quantity_new, false, true);
10510 }
10511 }
10512 }
10513 else if (destination_entity && slot_id == -1)
10514 {
10515 if (quantity > stack_max)
10516 split_quantity_new = stack_max;
10517 else
10518 split_quantity_new = quantity;
10519
10520 if (ShouldSplitQuantity(split_quantity_new))
10521 {
10522 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10523 {
10524 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10525 new_item = ItemBase.Cast(o);
10526 }
10527
10528 if (new_item)
10529 {
10530 new_item.SetResultOfSplit(true);
10531 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10532 AddQuantity(-split_quantity_new, false, true);
10533 new_item.SetQuantity(split_quantity_new, false, true);
10534 }
10535 }
10536 }
10537 else
10538 {
10539 if (stack_max != 0)
10540 {
10541 if (stack_max < GetQuantity())
10542 {
10543 split_quantity_new = GetQuantity() - stack_max;
10544 }
10545
10546 if (split_quantity_new == 0)
10547 {
10548 if (!GetGame().IsMultiplayer())
10549 player.PhysicalPredictiveDropItem(this);
10550 else
10551 player.ServerDropEntity(this);
10552 return;
10553 }
10554
10555 if (ShouldSplitQuantity(split_quantity_new))
10556 {
10557 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10558
10559 if (new_item)
10560 {
10561 new_item.SetResultOfSplit(true);
10562 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10563 SetQuantity(split_quantity_new, false, true);
10564 new_item.SetQuantity(stack_max, false, true);
10565 new_item.PlaceOnSurface();
10566 }
10567 }
10568 }
10569 }
10570 }
10571
10572 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10573 {
10574 float split_quantity_new;
10575 ItemBase new_item;
10576 float quantity = GetQuantity();
10577 float stack_max = GetTargetQuantityMax(slot_id);
10578 InventoryLocation loc = new InventoryLocation;
10579
10580 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10581 {
10582 if (stack_max <= GetQuantity())
10583 split_quantity_new = stack_max;
10584 else
10585 split_quantity_new = GetQuantity();
10586
10587 if (ShouldSplitQuantity(split_quantity_new))
10588 {
10589 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10590 if (new_item)
10591 {
10592 new_item.SetResultOfSplit(true);
10593 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10594 AddQuantity(-split_quantity_new, false, true);
10595 new_item.SetQuantity(split_quantity_new, false, true);
10596 }
10597 }
10598 }
10599 else if (destination_entity && slot_id == -1)
10600 {
10601 if (quantity > stack_max)
10602 split_quantity_new = stack_max;
10603 else
10604 split_quantity_new = quantity;
10605
10606 if (ShouldSplitQuantity(split_quantity_new))
10607 {
10608 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10609 {
10610 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10611 new_item = ItemBase.Cast(o);
10612 }
10613
10614 if (new_item)
10615 {
10616 new_item.SetResultOfSplit(true);
10617 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10618 AddQuantity(-split_quantity_new, false, true);
10619 new_item.SetQuantity(split_quantity_new, false, true);
10620 }
10621 }
10622 }
10623 else
10624 {
10625 if (stack_max != 0)
10626 {
10627 if (stack_max < GetQuantity())
10628 {
10629 split_quantity_new = GetQuantity() - stack_max;
10630 }
10631
10632 if (ShouldSplitQuantity(split_quantity_new))
10633 {
10634 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10635
10636 if (new_item)
10637 {
10638 new_item.SetResultOfSplit(true);
10639 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10640 SetQuantity(split_quantity_new, false, true);
10641 new_item.SetQuantity(stack_max, false, true);
10642 new_item.PlaceOnSurface();
10643 }
10644 }
10645 }
10646 }
10647 }
10648
10649 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10650 {
10651 if (GetGame().IsClient())
10652 {
10653 if (ScriptInputUserData.CanStoreInputUserData())
10654 {
10655 ScriptInputUserData ctx = new ScriptInputUserData;
10657 ctx.Write(4);
10658 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10659 ctx.Write(thiz);
10660 dst.WriteToContext(ctx);
10661 ctx.Send();
10662 }
10663 }
10664 else if (!GetGame().IsMultiplayer())
10665 {
10667 }
10668 }
10669
10670 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10671 {
10672 if (GetGame().IsClient())
10673 {
10674 if (ScriptInputUserData.CanStoreInputUserData())
10675 {
10676 ScriptInputUserData ctx = new ScriptInputUserData;
10678 ctx.Write(2);
10679 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10680 ctx.Write(dummy);
10681 ctx.Write(destination_entity);
10682 ctx.Write(true);
10683 ctx.Write(idx);
10684 ctx.Write(row);
10685 ctx.Write(col);
10686 ctx.Send();
10687 }
10688 }
10689 else if (!GetGame().IsMultiplayer())
10690 {
10691 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10692 }
10693 }
10694
10695 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10696 {
10698 }
10699
10700 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10701 {
10702 float quantity = GetQuantity();
10703 float split_quantity_new;
10704 ItemBase new_item;
10705 if (dst.IsValid())
10706 {
10707 int slot_id = dst.GetSlot();
10708 float stack_max = GetTargetQuantityMax(slot_id);
10709
10710 if (quantity > stack_max)
10711 split_quantity_new = stack_max;
10712 else
10713 split_quantity_new = quantity;
10714
10715 if (ShouldSplitQuantity(split_quantity_new))
10716 {
10717 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10718
10719 if (new_item)
10720 {
10721 new_item.SetResultOfSplit(true);
10722 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10723 AddQuantity(-split_quantity_new, false, true);
10724 new_item.SetQuantity(split_quantity_new, false, true);
10725 }
10726
10727 return new_item;
10728 }
10729 }
10730
10731 return null;
10732 }
10733
10734 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10735 {
10736 float quantity = GetQuantity();
10737 float split_quantity_new;
10738 ItemBase new_item;
10739 if (destination_entity)
10740 {
10741 float stackable = GetTargetQuantityMax();
10742 if (quantity > stackable)
10743 split_quantity_new = stackable;
10744 else
10745 split_quantity_new = quantity;
10746
10747 if (ShouldSplitQuantity(split_quantity_new))
10748 {
10749 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10750 if (new_item)
10751 {
10752 new_item.SetResultOfSplit(true);
10753 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10754 AddQuantity(-split_quantity_new, false, true);
10755 new_item.SetQuantity(split_quantity_new, false, true);
10756 }
10757 }
10758 }
10759 }
10760
10761 void SplitIntoStackMaxHandsClient(PlayerBase player)
10762 {
10763 if (GetGame().IsClient())
10764 {
10765 if (ScriptInputUserData.CanStoreInputUserData())
10766 {
10767 ScriptInputUserData ctx = new ScriptInputUserData;
10769 ctx.Write(3);
10770 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10771 ctx.Write(i1);
10772 ItemBase destination_entity = this;
10773 ctx.Write(destination_entity);
10774 ctx.Write(true);
10775 ctx.Write(0);
10776 ctx.Send();
10777 }
10778 }
10779 else if (!GetGame().IsMultiplayer())
10780 {
10781 SplitIntoStackMaxHands(player);
10782 }
10783 }
10784
10785 void SplitIntoStackMaxHands(PlayerBase player)
10786 {
10787 float quantity = GetQuantity();
10788 float split_quantity_new;
10789 ref ItemBase new_item;
10790 if (player)
10791 {
10792 float stackable = GetTargetQuantityMax();
10793 if (quantity > stackable)
10794 split_quantity_new = stackable;
10795 else
10796 split_quantity_new = quantity;
10797
10798 if (ShouldSplitQuantity(split_quantity_new))
10799 {
10800 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10801 new_item = ItemBase.Cast(in_hands);
10802 if (new_item)
10803 {
10804 new_item.SetResultOfSplit(true);
10805 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10806 AddQuantity(-split_quantity_new, false, true);
10807 new_item.SetQuantity(split_quantity_new, false, true);
10808 }
10809 }
10810 }
10811 }
10812
10813 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10814 {
10815 float quantity = GetQuantity();
10816 float split_quantity_new = Math.Floor(quantity * 0.5);
10817
10818 if (!ShouldSplitQuantity(split_quantity_new))
10819 return;
10820
10821 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10822
10823 if (new_item)
10824 {
10825 if (new_item.GetQuantityMax() < split_quantity_new)
10826 {
10827 split_quantity_new = new_item.GetQuantityMax();
10828 }
10829
10830 new_item.SetResultOfSplit(true);
10831 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10832
10833 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10834 {
10835 AddQuantity(-1, false, true);
10836 new_item.SetQuantity(1, false, true);
10837 }
10838 else
10839 {
10840 AddQuantity(-split_quantity_new, false, true);
10841 new_item.SetQuantity(split_quantity_new, false, true);
10842 }
10843 }
10844 }
10845
10846 void SplitItem(PlayerBase player)
10847 {
10848 float quantity = GetQuantity();
10849 float split_quantity_new = Math.Floor(quantity / 2);
10850
10851 if (!ShouldSplitQuantity(split_quantity_new))
10852 return;
10853
10854 InventoryLocation invloc = new InventoryLocation;
10855 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10856
10857 ItemBase new_item;
10858 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10859
10860 if (new_item)
10861 {
10862 if (new_item.GetQuantityMax() < split_quantity_new)
10863 {
10864 split_quantity_new = new_item.GetQuantityMax();
10865 }
10866 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10867 {
10868 AddQuantity(-1, false, true);
10869 new_item.SetQuantity(1, false, true);
10870 }
10871 else if (split_quantity_new > 1)
10872 {
10873 AddQuantity(-split_quantity_new, false, true);
10874 new_item.SetQuantity(split_quantity_new, false, true);
10875 }
10876 }
10877 }
10878
10880 void OnQuantityChanged(float delta)
10881 {
10882 SetWeightDirty();
10883 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10884
10885 if (parent)
10886 parent.OnAttachmentQuantityChangedEx(this, delta);
10887
10888 if (IsLiquidContainer())
10889 {
10890 if (GetQuantityNormalized() <= 0.0)
10891 {
10893 }
10894 else if (GetLiquidType() == LIQUID_NONE)
10895 {
10896 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10898 }
10899 }
10900
10901 }
10902
10905 {
10906 // insert code here
10907 }
10908
10910 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10911 {
10913 }
10914
10915 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10916 {
10917 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10918
10919 if (GetGame().IsServer())
10920 {
10921 if (newLevel == GameConstants.STATE_RUINED)
10922 {
10924 EntityAI parent = GetHierarchyParent();
10925 if (parent && parent.IsFireplace())
10926 {
10927 CargoBase cargo = GetInventory().GetCargo();
10928 if (cargo)
10929 {
10930 for (int i = 0; i < cargo.GetItemCount(); ++i)
10931 {
10932 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10933 }
10934 }
10935 }
10936 }
10937
10938 if (IsResultOfSplit())
10939 {
10940 // reset the splitting result flag, return to normal item behavior
10941 SetResultOfSplit(false);
10942 return;
10943 }
10944
10945 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10946 {
10947 SetCleanness(0);//unclean the item upon damage dealt
10948 }
10949 }
10950 }
10951
10952 // just the split? TODO: verify
10953 override void OnRightClick()
10954 {
10955 super.OnRightClick();
10956
10957 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
10958 {
10959 if (GetGame().IsClient())
10960 {
10961 if (ScriptInputUserData.CanStoreInputUserData())
10962 {
10963 EntityAI root = GetHierarchyRoot();
10964 Man playerOwner = GetHierarchyRootPlayer();
10965 InventoryLocation dst = new InventoryLocation;
10966
10967 // 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
10968 if (!playerOwner && root && root == this)
10969 {
10971 }
10972 else
10973 {
10974 // 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
10975 GetInventory().GetCurrentInventoryLocation(dst);
10976 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10977 {
10978 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
10979 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10980 {
10982 }
10983 else
10984 {
10985 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10986 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10987 this shouldnt cause issues within this scope*/
10988 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10989 {
10991 }
10992 else
10993 {
10994 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10995 }
10996 }
10997 }
10998 }
10999
11000 ScriptInputUserData ctx = new ScriptInputUserData;
11002 ctx.Write(4);
11003 ItemBase thiz = this; // @NOTE: workaround for correct serialization
11004 ctx.Write(thiz);
11005 dst.WriteToContext(ctx);
11006 ctx.Write(true); // dummy
11007 ctx.Send();
11008 }
11009 }
11010 else if (!GetGame().IsMultiplayer())
11011 {
11012 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
11013 }
11014 }
11015 }
11016
11017 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
11018 {
11019 if (root)
11020 {
11021 vector m4[4];
11022 root.GetTransform(m4);
11023 dst.SetGround(this, m4);
11024 }
11025 else
11026 {
11027 GetInventory().GetCurrentInventoryLocation(dst);
11028 }
11029 }
11030
11031 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
11032 {
11033 //TODO: delete check zero quantity check after fix double posts hands fsm events
11034 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
11035 return false;
11036
11037 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
11038 return false;
11039
11040 //can_this_be_combined = ConfigGetBool("canBeSplit");
11042 return false;
11043
11044
11045 Magazine mag = Magazine.Cast(this);
11046 if (mag)
11047 {
11048 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
11049 return false;
11050
11051 if (stack_max_limit)
11052 {
11053 Magazine other_mag = Magazine.Cast(other_item);
11054 if (other_item)
11055 {
11056 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
11057 return false;
11058 }
11059
11060 }
11061 }
11062 else
11063 {
11064 //TODO: delete check zero quantity check after fix double posts hands fsm events
11065 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
11066 return false;
11067
11068 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
11069 return false;
11070 }
11071
11072 PlayerBase player = null;
11073 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
11074 {
11075 if (player.GetInventory().HasAttachment(this))
11076 return false;
11077
11078 if (player.IsItemsToDelete())
11079 return false;
11080 }
11081
11082 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
11083 return false;
11084
11085 int slotID;
11086 string slotName;
11087 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
11088 return false;
11089
11090 return true;
11091 }
11092
11093 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
11094 {
11095 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
11096 }
11097
11098 bool IsResultOfSplit()
11099 {
11100 return m_IsResultOfSplit;
11101 }
11102
11103 void SetResultOfSplit(bool value)
11104 {
11105 m_IsResultOfSplit = value;
11106 }
11107
11108 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
11109 {
11110 return ComputeQuantityUsedEx(other_item, use_stack_max);
11111 }
11112
11113 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
11114 {
11115 float other_item_quantity = other_item.GetQuantity();
11116 float this_free_space;
11117
11118 float stack_max = GetQuantityMax();
11119
11120 this_free_space = stack_max - GetQuantity();
11121
11122 if (other_item_quantity > this_free_space)
11123 {
11124 return this_free_space;
11125 }
11126 else
11127 {
11128 return other_item_quantity;
11129 }
11130 }
11131
11132 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
11133 {
11134 CombineItems(ItemBase.Cast(entity2),use_stack_max);
11135 }
11136
11137 void CombineItems(ItemBase other_item, bool use_stack_max = true)
11138 {
11139 if (!CanBeCombined(other_item, false))
11140 return;
11141
11142 if (!IsMagazine() && other_item)
11143 {
11144 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
11145 if (quantity_used != 0)
11146 {
11147 float hp1 = GetHealth01("","");
11148 float hp2 = other_item.GetHealth01("","");
11149 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
11150 hpResult = hpResult / (GetQuantity() + quantity_used);
11151
11152 hpResult *= GetMaxHealth();
11153 Math.Round(hpResult);
11154 SetHealth("", "Health", hpResult);
11155
11156 AddQuantity(quantity_used);
11157 other_item.AddQuantity(-quantity_used);
11158 }
11159 }
11160 OnCombine(other_item);
11161 }
11162
11163 void OnCombine(ItemBase other_item)
11164 {
11165 #ifdef SERVER
11166 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
11167 GetHierarchyParent().IncreaseLifetimeUp();
11168 #endif
11169 };
11170
11171 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
11172 {
11173 PlayerBase p = PlayerBase.Cast(player);
11174
11175 array<int> recipesIds = p.m_Recipes;
11176 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11177 if (moduleRecipesManager)
11178 {
11179 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
11180 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
11181 }
11182
11183 for (int i = 0;i < recipesIds.Count(); i++)
11184 {
11185 int key = recipesIds.Get(i);
11186 string recipeName = moduleRecipesManager.GetRecipeName(key);
11187 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
11188 }
11189 }
11190
11191 // -------------------------------------------------------------------------
11192 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
11193 {
11194 super.GetDebugActions(outputList);
11195
11196 //quantity
11197 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
11198 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
11199 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
11200 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
11201 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11202
11203 //health
11204 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
11205 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
11206 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
11207 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11208 //temperature
11209 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
11210 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
11211 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
11212 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11213
11214 //wet
11215 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
11216 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
11217 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11218
11219 //liquidtype
11220 if (IsLiquidContainer())
11221 {
11222 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
11223 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
11224 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11225 }
11226
11227 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
11228 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11229
11230 // watch
11231 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
11232 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
11233 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11234
11235 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
11236
11237 InventoryLocation loc = new InventoryLocation();
11238 GetInventory().GetCurrentInventoryLocation(loc);
11239 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
11240 {
11241 if (Gizmo_IsSupported())
11242 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
11243 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
11244 }
11245
11246 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
11247 }
11248
11249 // -------------------------------------------------------------------------
11250 // -------------------------------------------------------------------------
11251 // -------------------------------------------------------------------------
11252 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
11253 {
11254 super.OnAction(action_id, player, ctx);
11255
11256 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
11257 {
11258 switch (action_id)
11259 {
11260 case EActions.GIZMO_OBJECT:
11261 GetGame().GizmoSelectObject(this);
11262 return true;
11263 case EActions.GIZMO_PHYSICS:
11264 GetGame().GizmoSelectPhysics(GetPhysics());
11265 return true;
11266 }
11267 }
11268
11269 if (GetGame().IsServer())
11270 {
11271 switch (action_id)
11272 {
11273 case EActions.DELETE:
11274 Delete();
11275 return true;
11276 }
11277 }
11278
11279 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
11280 {
11281 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
11282 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
11283 PlayerBase p = PlayerBase.Cast(player);
11284 if (EActions.RECIPES_RANGE_START < 1000)
11285 {
11286 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
11287 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
11288 }
11289 }
11290 #ifndef SERVER
11291 else if (action_id == EActions.WATCH_PLAYER)
11292 {
11293 PluginDeveloper.SetDeveloperItemClientEx(player);
11294 }
11295 #endif
11296 if (GetGame().IsServer())
11297 {
11298 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
11299 {
11300 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
11301 OnDebugButtonPressServer(id + 1);
11302 }
11303
11304 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
11305 {
11306 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
11307 InsertAgent(agent_id,100);
11308 }
11309
11310 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
11311 {
11312 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
11313 RemoveAgent(agent_id2);
11314 }
11315
11316 else if (action_id == EActions.ADD_QUANTITY)
11317 {
11318 if (IsMagazine())
11319 {
11320 Magazine mag = Magazine.Cast(this);
11321 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
11322 }
11323 else
11324 {
11325 AddQuantity(GetQuantityMax() * 0.2);
11326 }
11327
11328 if (m_EM)
11329 {
11330 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
11331 }
11332 //PrintVariables();
11333 }
11334
11335 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
11336 {
11337 if (IsMagazine())
11338 {
11339 Magazine mag2 = Magazine.Cast(this);
11340 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
11341 }
11342 else
11343 {
11344 AddQuantity(- GetQuantityMax() * 0.2);
11345 }
11346 if (m_EM)
11347 {
11348 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
11349 }
11350 //PrintVariables();
11351 }
11352
11353 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
11354 {
11355 SetQuantity(0);
11356
11357 if (m_EM)
11358 {
11359 m_EM.SetEnergy(0);
11360 }
11361 }
11362
11363 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
11364 {
11366
11367 if (m_EM)
11368 {
11369 m_EM.SetEnergy(m_EM.GetEnergyMax());
11370 }
11371 }
11372
11373 else if (action_id == EActions.ADD_HEALTH)
11374 {
11375 AddHealth("","",GetMaxHealth("","Health")/5);
11376 }
11377 else if (action_id == EActions.REMOVE_HEALTH)
11378 {
11379 AddHealth("","",-GetMaxHealth("","Health")/5);
11380 }
11381 else if (action_id == EActions.DESTROY_HEALTH)
11382 {
11383 SetHealth01("","",0);
11384 }
11385 else if (action_id == EActions.WATCH_ITEM)
11386 {
11388 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
11389 #ifdef DEVELOPER
11390 SetDebugDeveloper_item(this);
11391 #endif
11392 }
11393
11394 else if (action_id == EActions.ADD_TEMPERATURE)
11395 {
11396 AddTemperature(20);
11397 //PrintVariables();
11398 }
11399
11400 else if (action_id == EActions.REMOVE_TEMPERATURE)
11401 {
11402 AddTemperature(-20);
11403 //PrintVariables();
11404 }
11405
11406 else if (action_id == EActions.FLIP_FROZEN)
11407 {
11408 SetFrozen(!GetIsFrozen());
11409 //PrintVariables();
11410 }
11411
11412 else if (action_id == EActions.ADD_WETNESS)
11413 {
11414 AddWet(GetWetMax()/5);
11415 //PrintVariables();
11416 }
11417
11418 else if (action_id == EActions.REMOVE_WETNESS)
11419 {
11420 AddWet(-GetWetMax()/5);
11421 //PrintVariables();
11422 }
11423
11424 else if (action_id == EActions.LIQUIDTYPE_UP)
11425 {
11426 int curr_type = GetLiquidType();
11427 SetLiquidType(curr_type * 2);
11428 //AddWet(1);
11429 //PrintVariables();
11430 }
11431
11432 else if (action_id == EActions.LIQUIDTYPE_DOWN)
11433 {
11434 int curr_type2 = GetLiquidType();
11435 SetLiquidType(curr_type2 / 2);
11436 }
11437
11438 else if (action_id == EActions.MAKE_SPECIAL)
11439 {
11440 auto debugParams = DebugSpawnParams.WithPlayer(player);
11441 OnDebugSpawnEx(debugParams);
11442 }
11443
11444 }
11445
11446
11447 return false;
11448 }
11449
11450 // -------------------------------------------------------------------------
11451
11452
11455 void OnActivatedByTripWire();
11456
11458 void OnActivatedByItem(notnull ItemBase item);
11459
11460 //----------------------------------------------------------------
11461 //returns true if item is able to explode when put in fire
11462 bool CanExplodeInFire()
11463 {
11464 return false;
11465 }
11466
11467 //----------------------------------------------------------------
11468 bool CanEat()
11469 {
11470 return true;
11471 }
11472
11473 //----------------------------------------------------------------
11474 override bool IsIgnoredByConstruction()
11475 {
11476 return true;
11477 }
11478
11479 //----------------------------------------------------------------
11480 //has FoodStages in config?
11481 bool HasFoodStage()
11482 {
11483 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
11484 return GetGame().ConfigIsExisting(config_path);
11485 }
11486
11488 FoodStage GetFoodStage()
11489 {
11490 return null;
11491 }
11492
11493 bool CanBeCooked()
11494 {
11495 return false;
11496 }
11497
11498 bool CanBeCookedOnStick()
11499 {
11500 return false;
11501 }
11502
11504 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
11506
11507 //----------------------------------------------------------------
11508 bool CanRepair(ItemBase item_repair_kit)
11509 {
11510 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11511 return module_repairing.CanRepair(this, item_repair_kit);
11512 }
11513
11514 //----------------------------------------------------------------
11515 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11516 {
11517 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11518 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11519 }
11520
11521 //----------------------------------------------------------------
11522 int GetItemSize()
11523 {
11524 /*
11525 vector v_size = this.ConfigGetVector("itemSize");
11526 int v_size_x = v_size[0];
11527 int v_size_y = v_size[1];
11528 int size = v_size_x * v_size_y;
11529 return size;
11530 */
11531
11532 return 1;
11533 }
11534
11535 //----------------------------------------------------------------
11536 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11537 bool CanBeMovedOverride()
11538 {
11539 return m_CanBeMovedOverride;
11540 }
11541
11542 //----------------------------------------------------------------
11543 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11544 void SetCanBeMovedOverride(bool setting)
11545 {
11546 m_CanBeMovedOverride = setting;
11547 }
11548
11549 //----------------------------------------------------------------
11557 void MessageToOwnerStatus(string text)
11558 {
11559 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11560
11561 if (player)
11562 {
11563 player.MessageStatus(text);
11564 }
11565 }
11566
11567 //----------------------------------------------------------------
11575 void MessageToOwnerAction(string text)
11576 {
11577 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11578
11579 if (player)
11580 {
11581 player.MessageAction(text);
11582 }
11583 }
11584
11585 //----------------------------------------------------------------
11593 void MessageToOwnerFriendly(string text)
11594 {
11595 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11596
11597 if (player)
11598 {
11599 player.MessageFriendly(text);
11600 }
11601 }
11602
11603 //----------------------------------------------------------------
11611 void MessageToOwnerImportant(string text)
11612 {
11613 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11614
11615 if (player)
11616 {
11617 player.MessageImportant(text);
11618 }
11619 }
11620
11621 override bool IsItemBase()
11622 {
11623 return true;
11624 }
11625
11626 // Checks if item is of questioned kind
11627 override bool KindOf(string tag)
11628 {
11629 bool found = false;
11630 string item_name = this.GetType();
11631 ref TStringArray item_tag_array = new TStringArray;
11632 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11633
11634 int array_size = item_tag_array.Count();
11635 for (int i = 0; i < array_size; i++)
11636 {
11637 if (item_tag_array.Get(i) == tag)
11638 {
11639 found = true;
11640 break;
11641 }
11642 }
11643 return found;
11644 }
11645
11646
11647 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11648 {
11649 //Debug.Log("OnRPC called");
11650 super.OnRPC(sender, rpc_type,ctx);
11651
11652 //Play soundset for attachment locking (ActionLockAttachment.c)
11653 switch (rpc_type)
11654 {
11655 #ifndef SERVER
11656 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11657 Param2<bool, string> p = new Param2<bool, string>(false, "");
11658
11659 if (!ctx.Read(p))
11660 return;
11661
11662 bool play = p.param1;
11663 string soundSet = p.param2;
11664
11665 if (play)
11666 {
11667 if (m_LockingSound)
11668 {
11670 {
11671 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11672 }
11673 }
11674 else
11675 {
11676 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11677 }
11678 }
11679 else
11680 {
11681 SEffectManager.DestroyEffect(m_LockingSound);
11682 }
11683
11684 break;
11685 #endif
11686
11687 }
11688
11689 if (GetWrittenNoteData())
11690 {
11691 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11692 }
11693 }
11694
11695 //-----------------------------
11696 // VARIABLE MANIPULATION SYSTEM
11697 //-----------------------------
11698 int NameToID(string name)
11699 {
11700 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11701 return plugin.GetID(name);
11702 }
11703
11704 string IDToName(int id)
11705 {
11706 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11707 return plugin.GetName(id);
11708 }
11709
11711 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11712 {
11713 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11714 //read the flags
11715 int varFlags;
11716 if (!ctx.Read(varFlags))
11717 return;
11718
11719 if (varFlags & ItemVariableFlags.FLOAT)
11720 {
11721 ReadVarsFromCTX(ctx);
11722 }
11723 }
11724
11725 override void SerializeNumericalVars(array<float> floats_out)
11726 {
11727 //some variables handled on EntityAI level already!
11728 super.SerializeNumericalVars(floats_out);
11729
11730 // the order of serialization must be the same as the order of de-serialization
11731 //--------------------------------------------
11732 if (IsVariableSet(VARIABLE_QUANTITY))
11733 {
11734 floats_out.Insert(m_VarQuantity);
11735 }
11736 //--------------------------------------------
11737 if (IsVariableSet(VARIABLE_WET))
11738 {
11739 floats_out.Insert(m_VarWet);
11740 }
11741 //--------------------------------------------
11742 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11743 {
11744 floats_out.Insert(m_VarLiquidType);
11745 }
11746 //--------------------------------------------
11747 if (IsVariableSet(VARIABLE_COLOR))
11748 {
11749 floats_out.Insert(m_ColorComponentR);
11750 floats_out.Insert(m_ColorComponentG);
11751 floats_out.Insert(m_ColorComponentB);
11752 floats_out.Insert(m_ColorComponentA);
11753 }
11754 //--------------------------------------------
11755 if (IsVariableSet(VARIABLE_CLEANNESS))
11756 {
11757 floats_out.Insert(m_Cleanness);
11758 }
11759 }
11760
11761 override void DeSerializeNumericalVars(array<float> floats)
11762 {
11763 //some variables handled on EntityAI level already!
11764 super.DeSerializeNumericalVars(floats);
11765
11766 // the order of serialization must be the same as the order of de-serialization
11767 int index = 0;
11768 int mask = Math.Round(floats.Get(index));
11769
11770 index++;
11771 //--------------------------------------------
11772 if (mask & VARIABLE_QUANTITY)
11773 {
11774 if (m_IsStoreLoad)
11775 {
11776 SetStoreLoadedQuantity(floats.Get(index));
11777 }
11778 else
11779 {
11780 float quantity = floats.Get(index);
11781 SetQuantity(quantity, true, false, false, false);
11782 }
11783 index++;
11784 }
11785 //--------------------------------------------
11786 if (mask & VARIABLE_WET)
11787 {
11788 float wet = floats.Get(index);
11789 SetWet(wet);
11790 index++;
11791 }
11792 //--------------------------------------------
11793 if (mask & VARIABLE_LIQUIDTYPE)
11794 {
11795 int liquidtype = Math.Round(floats.Get(index));
11796 SetLiquidType(liquidtype);
11797 index++;
11798 }
11799 //--------------------------------------------
11800 if (mask & VARIABLE_COLOR)
11801 {
11802 m_ColorComponentR = Math.Round(floats.Get(index));
11803 index++;
11804 m_ColorComponentG = Math.Round(floats.Get(index));
11805 index++;
11806 m_ColorComponentB = Math.Round(floats.Get(index));
11807 index++;
11808 m_ColorComponentA = Math.Round(floats.Get(index));
11809 index++;
11810 }
11811 //--------------------------------------------
11812 if (mask & VARIABLE_CLEANNESS)
11813 {
11814 int cleanness = Math.Round(floats.Get(index));
11815 SetCleanness(cleanness);
11816 index++;
11817 }
11818 }
11819
11820 override void WriteVarsToCTX(ParamsWriteContext ctx)
11821 {
11822 super.WriteVarsToCTX(ctx);
11823
11824 //--------------------------------------------
11825 if (IsVariableSet(VARIABLE_QUANTITY))
11826 {
11827 ctx.Write(GetQuantity());
11828 }
11829 //--------------------------------------------
11830 if (IsVariableSet(VARIABLE_WET))
11831 {
11832 ctx.Write(GetWet());
11833 }
11834 //--------------------------------------------
11835 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11836 {
11837 ctx.Write(GetLiquidType());
11838 }
11839 //--------------------------------------------
11840 if (IsVariableSet(VARIABLE_COLOR))
11841 {
11842 int r,g,b,a;
11843 GetColor(r,g,b,a);
11844 ctx.Write(r);
11845 ctx.Write(g);
11846 ctx.Write(b);
11847 ctx.Write(a);
11848 }
11849 //--------------------------------------------
11850 if (IsVariableSet(VARIABLE_CLEANNESS))
11851 {
11852 ctx.Write(GetCleanness());
11853 }
11854 }
11855
11856 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11857 {
11858 if (!super.ReadVarsFromCTX(ctx,version))
11859 return false;
11860
11861 int intValue;
11862 float value;
11863
11864 if (version < 140)
11865 {
11866 if (!ctx.Read(intValue))
11867 return false;
11868
11869 m_VariablesMask = intValue;
11870 }
11871
11872 if (m_VariablesMask & VARIABLE_QUANTITY)
11873 {
11874 if (!ctx.Read(value))
11875 return false;
11876
11877 if (IsStoreLoad())
11878 {
11880 }
11881 else
11882 {
11883 SetQuantity(value, true, false, false, false);
11884 }
11885 }
11886 //--------------------------------------------
11887 if (version < 140)
11888 {
11889 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11890 {
11891 if (!ctx.Read(value))
11892 return false;
11893 SetTemperatureDirect(value);
11894 }
11895 }
11896 //--------------------------------------------
11897 if (m_VariablesMask & VARIABLE_WET)
11898 {
11899 if (!ctx.Read(value))
11900 return false;
11901 SetWet(value);
11902 }
11903 //--------------------------------------------
11904 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11905 {
11906 if (!ctx.Read(intValue))
11907 return false;
11908 SetLiquidType(intValue);
11909 }
11910 //--------------------------------------------
11911 if (m_VariablesMask & VARIABLE_COLOR)
11912 {
11913 int r,g,b,a;
11914 if (!ctx.Read(r))
11915 return false;
11916 if (!ctx.Read(g))
11917 return false;
11918 if (!ctx.Read(b))
11919 return false;
11920 if (!ctx.Read(a))
11921 return false;
11922
11923 SetColor(r,g,b,a);
11924 }
11925 //--------------------------------------------
11926 if (m_VariablesMask & VARIABLE_CLEANNESS)
11927 {
11928 if (!ctx.Read(intValue))
11929 return false;
11930 SetCleanness(intValue);
11931 }
11932 //--------------------------------------------
11933 if (version >= 138 && version < 140)
11934 {
11935 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11936 {
11937 if (!ctx.Read(intValue))
11938 return false;
11939 SetFrozen(intValue);
11940 }
11941 }
11942
11943 return true;
11944 }
11945
11946 //----------------------------------------------------------------
11947 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11948 {
11949 m_IsStoreLoad = true;
11951 {
11952 m_FixDamageSystemInit = true;
11953 }
11954
11955 if (!super.OnStoreLoad(ctx, version))
11956 {
11957 m_IsStoreLoad = false;
11958 return false;
11959 }
11960
11961 if (version >= 114)
11962 {
11963 bool hasQuickBarIndexSaved;
11964
11965 if (!ctx.Read(hasQuickBarIndexSaved))
11966 {
11967 m_IsStoreLoad = false;
11968 return false;
11969 }
11970
11971 if (hasQuickBarIndexSaved)
11972 {
11973 int itmQBIndex;
11974
11975 //Load quickbar item bind
11976 if (!ctx.Read(itmQBIndex))
11977 {
11978 m_IsStoreLoad = false;
11979 return false;
11980 }
11981
11982 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11983 if (itmQBIndex != -1 && parentPlayer)
11984 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11985 }
11986 }
11987 else
11988 {
11989 // Backup of how it used to be
11990 PlayerBase player;
11991 int itemQBIndex;
11992 if (version == int.MAX)
11993 {
11994 if (!ctx.Read(itemQBIndex))
11995 {
11996 m_IsStoreLoad = false;
11997 return false;
11998 }
11999 }
12000 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
12001 {
12002 //Load quickbar item bind
12003 if (!ctx.Read(itemQBIndex))
12004 {
12005 m_IsStoreLoad = false;
12006 return false;
12007 }
12008 if (itemQBIndex != -1 && player)
12009 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
12010 }
12011 }
12012
12013 if (version < 140)
12014 {
12015 // variable management system
12016 if (!LoadVariables(ctx, version))
12017 {
12018 m_IsStoreLoad = false;
12019 return false;
12020 }
12021 }
12022
12023 //agent trasmission system
12024 if (!LoadAgents(ctx, version))
12025 {
12026 m_IsStoreLoad = false;
12027 return false;
12028 }
12029 if (version >= 132)
12030 {
12031 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12032 if (raib)
12033 {
12034 if (!raib.OnStoreLoad(ctx,version))
12035 {
12036 m_IsStoreLoad = false;
12037 return false;
12038 }
12039 }
12040 }
12041
12042 m_IsStoreLoad = false;
12043 return true;
12044 }
12045
12046 //----------------------------------------------------------------
12047
12048 override void OnStoreSave(ParamsWriteContext ctx)
12049 {
12050 super.OnStoreSave(ctx);
12051
12052 PlayerBase player;
12053 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
12054 {
12055 ctx.Write(true); // Keep track of if we should actually read this in or not
12056 //Save quickbar item bind
12057 int itemQBIndex = -1;
12058 itemQBIndex = player.FindQuickBarEntityIndex(this);
12059 ctx.Write(itemQBIndex);
12060 }
12061 else
12062 {
12063 ctx.Write(false); // Keep track of if we should actually read this in or not
12064 }
12065
12066 SaveAgents(ctx);//agent trasmission system
12067
12068 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
12069 if (raib)
12070 {
12071 raib.OnStoreSave(ctx);
12072 }
12073 }
12074 //----------------------------------------------------------------
12075
12076 override void AfterStoreLoad()
12077 {
12078 super.AfterStoreLoad();
12079
12081 {
12083 }
12084
12085 if (GetStoreLoadedQuantity() != float.LOWEST)
12086 {
12088 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
12089 }
12090 }
12091
12092 override void EEOnAfterLoad()
12093 {
12094 super.EEOnAfterLoad();
12095
12097 {
12098 m_FixDamageSystemInit = false;
12099 }
12100
12103 }
12104
12105 bool CanBeDisinfected()
12106 {
12107 return false;
12108 }
12109
12110
12111 //----------------------------------------------------------------
12112 override void OnVariablesSynchronized()
12113 {
12114 if (m_Initialized)
12115 {
12116 #ifdef PLATFORM_CONSOLE
12117 //bruteforce it is
12118 if (IsSplitable())
12119 {
12120 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
12121 if (menu)
12122 {
12123 menu.Refresh();
12124 }
12125 }
12126 #endif
12127 }
12128
12130 {
12131 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
12132 m_WantPlayImpactSound = false;
12133 }
12134
12136 {
12137 SetWeightDirty();
12139 }
12140 if (m_VarWet != m_VarWetPrev)
12141 {
12144 }
12145
12146 if (m_SoundSyncPlay != 0)
12147 {
12148 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
12149 m_SoundSyncPlay = 0;
12150 }
12151 if (m_SoundSyncStop != 0)
12152 {
12153 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
12154 m_SoundSyncStop = 0;
12155 }
12156
12157 super.OnVariablesSynchronized();
12158 }
12159
12160 //------------------------- Quantity
12161 //----------------------------------------------------------------
12163 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
12164 {
12165 if (!IsServerCheck(allow_client))
12166 return false;
12167
12168 if (!HasQuantity())
12169 return false;
12170
12171 float min = GetQuantityMin();
12172 float max = GetQuantityMax();
12173
12174 if (value <= (min + 0.001))
12175 value = min;
12176
12177 if (value == min)
12178 {
12179 if (destroy_config)
12180 {
12181 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
12182 if (dstr)
12183 {
12184 m_VarQuantity = Math.Clamp(value, min, max);
12185 this.Delete();
12186 return true;
12187 }
12188 }
12189 else if (destroy_forced)
12190 {
12191 m_VarQuantity = Math.Clamp(value, min, max);
12192 this.Delete();
12193 return true;
12194 }
12195 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
12196 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
12197 }
12198
12199 float delta = m_VarQuantity;
12200 m_VarQuantity = Math.Clamp(value, min, max);
12201
12202 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
12203 {
12204 delta = m_VarQuantity - delta;
12205
12206 if (delta)
12207 OnQuantityChanged(delta);
12208 }
12209
12210 SetVariableMask(VARIABLE_QUANTITY);
12211
12212 return false;
12213 }
12214
12215 //----------------------------------------------------------------
12217 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
12218 {
12219 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
12220 }
12221 //----------------------------------------------------------------
12222 void SetQuantityMax()
12223 {
12224 float max = GetQuantityMax();
12225 SetQuantity(max);
12226 }
12227
12228 override void SetQuantityToMinimum()
12229 {
12230 float min = GetQuantityMin();
12231 SetQuantity(min);
12232 }
12233 //----------------------------------------------------------------
12235 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
12236 {
12237 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
12238 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
12239 SetQuantity(result, destroy_config, destroy_forced);
12240 }
12241
12242 //----------------------------------------------------------------
12244 override float GetQuantityNormalized()
12245 {
12246 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
12247 }
12248
12250 {
12251 return GetQuantityNormalized();
12252 }
12253
12254 /*void SetAmmoNormalized(float value)
12255 {
12256 float value_clamped = Math.Clamp(value, 0, 1);
12257 Magazine this_mag = Magazine.Cast(this);
12258 int max_rounds = this_mag.GetAmmoMax();
12259 int result = value * max_rounds;//can the rounded if higher precision is required
12260 this_mag.SetAmmoCount(result);
12261 }*/
12262 //----------------------------------------------------------------
12263 override int GetQuantityMax()
12264 {
12265 int slot = -1;
12266 if (GetInventory())
12267 {
12268 InventoryLocation il = new InventoryLocation;
12269 GetInventory().GetCurrentInventoryLocation(il);
12270 slot = il.GetSlot();
12271 }
12272
12273 return GetTargetQuantityMax(slot);
12274 }
12275
12276 override int GetTargetQuantityMax(int attSlotID = -1)
12277 {
12278 float quantity_max = 0;
12279
12280 if (IsSplitable()) //only stackable/splitable items can check for stack size
12281 {
12282 if (attSlotID != -1)
12283 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
12284
12285 if (quantity_max <= 0)
12286 quantity_max = m_VarStackMax;
12287 }
12288
12289 if (quantity_max <= 0)
12290 quantity_max = m_VarQuantityMax;
12291
12292 return quantity_max;
12293 }
12294 //----------------------------------------------------------------
12295 override int GetQuantityMin()
12296 {
12297 return m_VarQuantityMin;
12298 }
12299 //----------------------------------------------------------------
12300 int GetQuantityInit()
12301 {
12302 return m_VarQuantityInit;
12303 }
12304
12305 //----------------------------------------------------------------
12306 override bool HasQuantity()
12307 {
12308 return !(GetQuantityMax() - GetQuantityMin() == 0);
12309 }
12310
12311 override float GetQuantity()
12312 {
12313 return m_VarQuantity;
12314 }
12315
12316 bool IsFullQuantity()
12317 {
12318 return GetQuantity() >= GetQuantityMax();
12319 }
12320
12321 //Calculates weight of single item without attachments and cargo
12322 override float GetSingleInventoryItemWeightEx()
12323 {
12324 //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
12325 float weightEx = GetWeightEx();//overall weight of the item
12326 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
12327 return weightEx - special;
12328 }
12329
12330 // Obsolete, use GetSingleInventoryItemWeightEx() instead
12332 {
12334 }
12335
12336 override protected float GetWeightSpecialized(bool forceRecalc = false)
12337 {
12338 if (IsSplitable()) //quantity determines size of the stack
12339 {
12340 #ifdef DEVELOPER
12341 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12342 {
12343 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
12344 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
12345 }
12346 #endif
12347
12348 return GetQuantity() * GetConfigWeightModified();
12349 }
12350 else if (HasEnergyManager())// items with energy manager
12351 {
12352 #ifdef DEVELOPER
12353 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12354 {
12355 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
12356 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
12357 }
12358 #endif
12359 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12360 }
12361 else//everything else
12362 {
12363 #ifdef DEVELOPER
12364 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
12365 {
12366 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
12367 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
12368 }
12369 #endif
12370 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
12371 }
12372 }
12373
12375 int GetNumberOfItems()
12376 {
12377 int item_count = 0;
12378 ItemBase item;
12379
12380 if (GetInventory().GetCargo() != NULL)
12381 {
12382 item_count = GetInventory().GetCargo().GetItemCount();
12383 }
12384
12385 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
12386 {
12387 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
12388 if (item)
12389 item_count += item.GetNumberOfItems();
12390 }
12391 return item_count;
12392 }
12393
12395 float GetUnitWeight(bool include_wetness = true)
12396 {
12397 float weight = 0;
12398 float wetness = 1;
12399 if (include_wetness)
12400 wetness += GetWet();
12401 if (IsSplitable()) //quantity determines size of the stack
12402 {
12403 weight = wetness * m_ConfigWeight;
12404 }
12405 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
12406 {
12407 weight = 1;
12408 }
12409 return weight;
12410 }
12411
12412 //-----------------------------------------------------------------
12413
12414 override void ClearInventory()
12415 {
12416 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
12417 {
12418 GameInventory inv = GetInventory();
12419 array<EntityAI> items = new array<EntityAI>;
12420 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
12421 for (int i = 0; i < items.Count(); i++)
12422 {
12423 ItemBase item = ItemBase.Cast(items.Get(i));
12424 if (item)
12425 {
12426 GetGame().ObjectDelete(item);
12427 }
12428 }
12429 }
12430 }
12431
12432 //------------------------- Energy
12433
12434 //----------------------------------------------------------------
12435 float GetEnergy()
12436 {
12437 float energy = 0;
12438 if (HasEnergyManager())
12439 {
12440 energy = GetCompEM().GetEnergy();
12441 }
12442 return energy;
12443 }
12444
12445
12446 override void OnEnergyConsumed()
12447 {
12448 super.OnEnergyConsumed();
12449
12451 }
12452
12453 override void OnEnergyAdded()
12454 {
12455 super.OnEnergyAdded();
12456
12458 }
12459
12460 // Converts energy (from Energy Manager) to quantity, if enabled.
12462 {
12463 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
12464 {
12465 if (HasQuantity())
12466 {
12467 float energy_0to1 = GetCompEM().GetEnergy0To1();
12468 SetQuantityNormalized(energy_0to1);
12469 }
12470 }
12471 }
12472
12473 //----------------------------------------------------------------
12474 float GetHeatIsolationInit()
12475 {
12476 return ConfigGetFloat("heatIsolation");
12477 }
12478
12479 float GetHeatIsolation()
12480 {
12481 return m_HeatIsolation;
12482 }
12483
12484 float GetDryingIncrement(string pIncrementName)
12485 {
12486 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12487 if (GetGame().ConfigIsExisting(paramPath))
12488 return GetGame().ConfigGetFloat(paramPath);
12489
12490 return 0.0;
12491 }
12492
12493 float GetSoakingIncrement(string pIncrementName)
12494 {
12495 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12496 if (GetGame().ConfigIsExisting(paramPath))
12497 return GetGame().ConfigGetFloat(paramPath);
12498
12499 return 0.0;
12500 }
12501 //----------------------------------------------------------------
12502 override void SetWet(float value, bool allow_client = false)
12503 {
12504 if (!IsServerCheck(allow_client))
12505 return;
12506
12507 float min = GetWetMin();
12508 float max = GetWetMax();
12509
12510 float previousValue = m_VarWet;
12511
12512 m_VarWet = Math.Clamp(value, min, max);
12513
12514 if (previousValue != m_VarWet)
12515 {
12516 SetVariableMask(VARIABLE_WET);
12517 OnWetChanged(m_VarWet, previousValue);
12518 }
12519 }
12520 //----------------------------------------------------------------
12521 override void AddWet(float value)
12522 {
12523 SetWet(GetWet() + value);
12524 }
12525 //----------------------------------------------------------------
12526 override void SetWetMax()
12527 {
12529 }
12530 //----------------------------------------------------------------
12531 override float GetWet()
12532 {
12533 return m_VarWet;
12534 }
12535 //----------------------------------------------------------------
12536 override float GetWetMax()
12537 {
12538 return m_VarWetMax;
12539 }
12540 //----------------------------------------------------------------
12541 override float GetWetMin()
12542 {
12543 return m_VarWetMin;
12544 }
12545 //----------------------------------------------------------------
12546 override float GetWetInit()
12547 {
12548 return m_VarWetInit;
12549 }
12550 //----------------------------------------------------------------
12551 override void OnWetChanged(float newVal, float oldVal)
12552 {
12553 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12554 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12555 if (newLevel != oldLevel)
12556 {
12557 OnWetLevelChanged(newLevel,oldLevel);
12558 }
12559 }
12560
12561 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12562 {
12563 SetWeightDirty();
12564 }
12565
12566 override EWetnessLevel GetWetLevel()
12567 {
12568 return GetWetLevelInternal(m_VarWet);
12569 }
12570
12571 //----------------------------------------------------------------
12572
12573 override void SetStoreLoad(bool value)
12574 {
12575 m_IsStoreLoad = value;
12576 }
12577
12578 override bool IsStoreLoad()
12579 {
12580 return m_IsStoreLoad;
12581 }
12582
12583 override void SetStoreLoadedQuantity(float value)
12584 {
12585 m_StoreLoadedQuantity = value;
12586 }
12587
12588 override float GetStoreLoadedQuantity()
12589 {
12590 return m_StoreLoadedQuantity;
12591 }
12592
12593 //----------------------------------------------------------------
12594
12595 float GetItemModelLength()
12596 {
12597 if (ConfigIsExisting("itemModelLength"))
12598 {
12599 return ConfigGetFloat("itemModelLength");
12600 }
12601 return 0;
12602 }
12603
12604 float GetItemAttachOffset()
12605 {
12606 if (ConfigIsExisting("itemAttachOffset"))
12607 {
12608 return ConfigGetFloat("itemAttachOffset");
12609 }
12610 return 0;
12611 }
12612
12613 override void SetCleanness(int value, bool allow_client = false)
12614 {
12615 if (!IsServerCheck(allow_client))
12616 return;
12617
12618 int previousValue = m_Cleanness;
12619
12620 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12621
12622 if (previousValue != m_Cleanness)
12623 SetVariableMask(VARIABLE_CLEANNESS);
12624 }
12625
12626 override int GetCleanness()
12627 {
12628 return m_Cleanness;
12629 }
12630
12632 {
12633 return true;
12634 }
12635
12636 //----------------------------------------------------------------
12637 // ATTACHMENT LOCKING
12638 // Getters relevant to generic ActionLockAttachment
12639 int GetLockType()
12640 {
12641 return m_LockType;
12642 }
12643
12644 string GetLockSoundSet()
12645 {
12646 return m_LockSoundSet;
12647 }
12648
12649 //----------------------------------------------------------------
12650 //------------------------- Color
12651 // sets items color variable given color components
12652 override void SetColor(int r, int g, int b, int a)
12653 {
12658 SetVariableMask(VARIABLE_COLOR);
12659 }
12661 override void GetColor(out int r,out int g,out int b,out int a)
12662 {
12667 }
12668
12669 bool IsColorSet()
12670 {
12671 return IsVariableSet(VARIABLE_COLOR);
12672 }
12673
12675 string GetColorString()
12676 {
12677 int r,g,b,a;
12678 GetColor(r,g,b,a);
12679 r = r/255;
12680 g = g/255;
12681 b = b/255;
12682 a = a/255;
12683 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12684 }
12685 //----------------------------------------------------------------
12686 //------------------------- LiquidType
12687
12688 override void SetLiquidType(int value, bool allow_client = false)
12689 {
12690 if (!IsServerCheck(allow_client))
12691 return;
12692
12693 int old = m_VarLiquidType;
12694 m_VarLiquidType = value;
12695 OnLiquidTypeChanged(old,value);
12696 SetVariableMask(VARIABLE_LIQUIDTYPE);
12697 }
12698
12699 int GetLiquidTypeInit()
12700 {
12701 return ConfigGetInt("varLiquidTypeInit");
12702 }
12703
12704 override int GetLiquidType()
12705 {
12706 return m_VarLiquidType;
12707 }
12708
12709 protected void OnLiquidTypeChanged(int oldType, int newType)
12710 {
12711 if (newType == LIQUID_NONE && GetIsFrozen())
12712 SetFrozen(false);
12713 }
12714
12716 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12717 {
12718 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12719 }
12720
12721 // -------------------------------------------------------------------------
12723 void OnInventoryEnter(Man player)
12724 {
12725 PlayerBase nplayer;
12726 if (PlayerBase.CastTo(nplayer, player))
12727 {
12728 m_CanPlayImpactSound = true;
12729 //nplayer.OnItemInventoryEnter(this);
12730 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12731 }
12732 }
12733
12734 // -------------------------------------------------------------------------
12736 void OnInventoryExit(Man player)
12737 {
12738 PlayerBase nplayer;
12739 if (PlayerBase.CastTo(nplayer,player))
12740 {
12741 //nplayer.OnItemInventoryExit(this);
12742 nplayer.SetEnableQuickBarEntityShortcut(this,false);
12743
12744 }
12745
12746 //if (!GetGame().IsDedicatedServer())
12747 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12748
12749
12750 if (HasEnergyManager())
12751 {
12752 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12753 }
12754 }
12755
12756 // ADVANCED PLACEMENT EVENTS
12757 override void OnPlacementStarted(Man player)
12758 {
12759 super.OnPlacementStarted(player);
12760
12761 SetTakeable(false);
12762 }
12763
12764 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12765 {
12766 if (m_AdminLog)
12767 {
12768 m_AdminLog.OnPlacementComplete(player, this);
12769 }
12770
12771 super.OnPlacementComplete(player, position, orientation);
12772 }
12773
12774 //-----------------------------
12775 // AGENT SYSTEM
12776 //-----------------------------
12777 //--------------------------------------------------------------------------
12778 bool ContainsAgent(int agent_id)
12779 {
12780 if (agent_id & m_AttachedAgents)
12781 {
12782 return true;
12783 }
12784 else
12785 {
12786 return false;
12787 }
12788 }
12789
12790 //--------------------------------------------------------------------------
12791 override void RemoveAgent(int agent_id)
12792 {
12793 if (ContainsAgent(agent_id))
12794 {
12795 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12796 }
12797 }
12798
12799 //--------------------------------------------------------------------------
12800 override void RemoveAllAgents()
12801 {
12802 m_AttachedAgents = 0;
12803 }
12804 //--------------------------------------------------------------------------
12805 override void RemoveAllAgentsExcept(int agent_to_keep)
12806 {
12807 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12808 }
12809 // -------------------------------------------------------------------------
12810 override void InsertAgent(int agent, float count = 1)
12811 {
12812 if (count < 1)
12813 return;
12814 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12816 }
12817
12819 void TransferAgents(int agents)
12820 {
12822 }
12823
12824 // -------------------------------------------------------------------------
12825 override int GetAgents()
12826 {
12827 return m_AttachedAgents;
12828 }
12829 //----------------------------------------------------------------------
12830
12831 /*int GetContaminationType()
12832 {
12833 int contamination_type;
12834
12835 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12836 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12837 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12838 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12839
12840 Edible_Base edible = Edible_Base.Cast(this);
12841 int agents = GetAgents();
12842 if (edible)
12843 {
12844 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12845 if (profile)
12846 {
12847 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12848 }
12849 }
12850 if (agents & CONTAMINATED_MASK)
12851 {
12852 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12853 }
12854 if (agents & POISONED_MASK)
12855 {
12856 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12857 }
12858 if (agents & NERVE_GAS_MASK)
12859 {
12860 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12861 }
12862 if (agents & DIRTY_MASK)
12863 {
12864 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12865 }
12866
12867 return agents;
12868 }*/
12869
12870 // -------------------------------------------------------------------------
12871 bool LoadAgents(ParamsReadContext ctx, int version)
12872 {
12873 if (!ctx.Read(m_AttachedAgents))
12874 return false;
12875 return true;
12876 }
12877 // -------------------------------------------------------------------------
12879 {
12880
12882 }
12883 // -------------------------------------------------------------------------
12884
12886 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12887 {
12888 super.CheckForRoofLimited(timeTresholdMS);
12889
12890 float time = GetGame().GetTime();
12891 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12892 {
12893 m_PreviousRoofTestTime = time;
12894 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12895 }
12896 }
12897
12898 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12899 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12900 {
12901 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12902 {
12903 return 0;
12904 }
12905
12906 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12907 {
12908 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12909 if (filter)
12910 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12911 else
12912 return 0;//otherwise return 0 when no filter attached
12913 }
12914
12915 string subclassPath, entryName;
12916
12917 switch (type)
12918 {
12919 case DEF_BIOLOGICAL:
12920 entryName = "biological";
12921 break;
12922 case DEF_CHEMICAL:
12923 entryName = "chemical";
12924 break;
12925 default:
12926 entryName = "biological";
12927 break;
12928 }
12929
12930 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12931
12932 return GetGame().ConfigGetFloat(subclassPath + entryName);
12933 }
12934
12935
12936
12938 override void EEOnCECreate()
12939 {
12940 if (!IsMagazine())
12942
12944 }
12945
12946
12947 //-------------------------
12948 // OPEN/CLOSE USER ACTIONS
12949 //-------------------------
12951 void Open();
12952 void Close();
12953 bool IsOpen()
12954 {
12955 return true;
12956 }
12957
12958 override bool CanDisplayCargo()
12959 {
12960 return IsOpen();
12961 }
12962
12963
12964 // ------------------------------------------------------------
12965 // CONDITIONS
12966 // ------------------------------------------------------------
12967 override bool CanPutInCargo(EntityAI parent)
12968 {
12969 if (parent)
12970 {
12971 if (parent.IsInherited(DayZInfected))
12972 return true;
12973
12974 if (!parent.IsRuined())
12975 return true;
12976 }
12977
12978 return true;
12979 }
12980
12981 override bool CanPutAsAttachment(EntityAI parent)
12982 {
12983 if (!super.CanPutAsAttachment(parent))
12984 {
12985 return false;
12986 }
12987
12988 if (!IsRuined() && !parent.IsRuined())
12989 {
12990 return true;
12991 }
12992
12993 return false;
12994 }
12995
12996 override bool CanReceiveItemIntoCargo(EntityAI item)
12997 {
12998 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12999 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13000 // return false;
13001
13002 return super.CanReceiveItemIntoCargo(item);
13003 }
13004
13005 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
13006 {
13007 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13008 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13009 // return false;
13010
13011 GameInventory attachmentInv = attachment.GetInventory();
13012 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13013 {
13014 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13015 return false;
13016 }
13017
13018 InventoryLocation loc = new InventoryLocation();
13019 attachment.GetInventory().GetCurrentInventoryLocation(loc);
13020 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
13021 return false;
13022
13023 return super.CanReceiveAttachment(attachment, slotId);
13024 }
13025
13026 override bool CanReleaseAttachment(EntityAI attachment)
13027 {
13028 if (!super.CanReleaseAttachment(attachment))
13029 return false;
13030
13031 return GetInventory().AreChildrenAccessible();
13032 }
13033
13034 /*override bool CanLoadAttachment(EntityAI attachment)
13035 {
13036 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
13037 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
13038 // return false;
13039
13040 GameInventory attachmentInv = attachment.GetInventory();
13041 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
13042 {
13043 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
13044 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
13045
13046 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
13047 return false;
13048 }
13049
13050 return super.CanLoadAttachment(attachment);
13051 }*/
13052
13053 // Plays muzzle flash particle effects
13054 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13055 {
13056 int id = muzzle_owner.GetMuzzleID();
13057 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
13058
13059 if (WPOF_array)
13060 {
13061 for (int i = 0; i < WPOF_array.Count(); i++)
13062 {
13063 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
13064
13065 if (WPOF)
13066 {
13067 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
13068 }
13069 }
13070 }
13071 }
13072
13073 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
13074 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13075 {
13076 int id = muzzle_owner.GetMuzzleID();
13077 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
13078
13079 if (WPOBE_array)
13080 {
13081 for (int i = 0; i < WPOBE_array.Count(); i++)
13082 {
13083 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
13084
13085 if (WPOBE)
13086 {
13087 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13088 }
13089 }
13090 }
13091 }
13092
13093 // Plays all weapon overheating particles
13094 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13095 {
13096 int id = muzzle_owner.GetMuzzleID();
13097 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13098
13099 if (WPOOH_array)
13100 {
13101 for (int i = 0; i < WPOOH_array.Count(); i++)
13102 {
13103 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13104
13105 if (WPOOH)
13106 {
13107 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
13108 }
13109 }
13110 }
13111 }
13112
13113 // Updates all weapon overheating particles
13114 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13115 {
13116 int id = muzzle_owner.GetMuzzleID();
13117 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13118
13119 if (WPOOH_array)
13120 {
13121 for (int i = 0; i < WPOOH_array.Count(); i++)
13122 {
13123 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13124
13125 if (WPOOH)
13126 {
13127 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13128 }
13129 }
13130 }
13131 }
13132
13133 // Stops overheating particles
13134 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
13135 {
13136 int id = muzzle_owner.GetMuzzleID();
13137 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
13138
13139 if (WPOOH_array)
13140 {
13141 for (int i = 0; i < WPOOH_array.Count(); i++)
13142 {
13143 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
13144
13145 if (WPOOH)
13146 {
13147 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
13148 }
13149 }
13150 }
13151 }
13152
13153 //----------------------------------------------------------------
13154 //Item Behaviour - unified approach
13155 override bool IsHeavyBehaviour()
13156 {
13157 if (m_ItemBehaviour == 0)
13158 {
13159 return true;
13160 }
13161
13162 return false;
13163 }
13164
13165 override bool IsOneHandedBehaviour()
13166 {
13167 if (m_ItemBehaviour == 1)
13168 {
13169 return true;
13170 }
13171
13172 return false;
13173 }
13174
13175 override bool IsTwoHandedBehaviour()
13176 {
13177 if (m_ItemBehaviour == 2)
13178 {
13179 return true;
13180 }
13181
13182 return false;
13183 }
13184
13185 bool IsDeployable()
13186 {
13187 return false;
13188 }
13189
13191 float GetDeployTime()
13192 {
13193 return UATimeSpent.DEFAULT_DEPLOY;
13194 }
13195
13196
13197 //----------------------------------------------------------------
13198 // Item Targeting (User Actions)
13199 override void SetTakeable(bool pState)
13200 {
13201 m_IsTakeable = pState;
13202 SetSynchDirty();
13203 }
13204
13205 override bool IsTakeable()
13206 {
13207 return m_IsTakeable;
13208 }
13209
13210 // For cases where we want to show object widget which cant be taken to hands
13212 {
13213 return false;
13214 }
13215
13217 protected void PreLoadSoundAttachmentType()
13218 {
13219 string att_type = "None";
13220
13221 if (ConfigIsExisting("soundAttType"))
13222 {
13223 att_type = ConfigGetString("soundAttType");
13224 }
13225
13226 m_SoundAttType = att_type;
13227 }
13228
13229 override string GetAttachmentSoundType()
13230 {
13231 return m_SoundAttType;
13232 }
13233
13234 //----------------------------------------------------------------
13235 //SOUNDS - ItemSoundHandler
13236 //----------------------------------------------------------------
13237
13238 string GetPlaceSoundset(); // played when deploy starts
13239 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
13240 string GetDeploySoundset(); // played when deploy sucessfully finishes
13241 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
13242 string GetFoldSoundset(); // played when fold sucessfully finishes
13243
13245 {
13246 if (!m_ItemSoundHandler)
13248
13249 return m_ItemSoundHandler;
13250 }
13251
13252 // override to initialize sounds
13253 protected void InitItemSounds()
13254 {
13255 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
13256 return;
13257
13259
13260 if (GetPlaceSoundset() != string.Empty)
13261 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
13262
13263 if (GetDeploySoundset() != string.Empty)
13264 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
13265
13266 SoundParameters params = new SoundParameters();
13267 params.m_Loop = true;
13268 if (GetLoopDeploySoundset() != string.Empty)
13269 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
13270 }
13271
13272 // Start sound using ItemSoundHandler
13273 void StartItemSoundServer(int id)
13274 {
13275 if (!GetGame().IsServer())
13276 return;
13277
13278 m_SoundSyncPlay = id;
13279 SetSynchDirty();
13280
13281 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
13283 }
13284
13285 // Stop sound using ItemSoundHandler
13286 void StopItemSoundServer(int id)
13287 {
13288 if (!GetGame().IsServer())
13289 return;
13290
13291 m_SoundSyncStop = id;
13292 SetSynchDirty();
13293
13294 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
13296 }
13297
13298 protected void ClearStartItemSoundServer()
13299 {
13300 m_SoundSyncPlay = 0;
13301 }
13302
13303 protected void ClearStopItemSoundServer()
13304 {
13305 m_SoundSyncStop = 0;
13306 }
13307
13309 void PlayAttachSound(string slot_type)
13310 {
13311 if (!GetGame().IsDedicatedServer())
13312 {
13313 if (ConfigIsExisting("attachSoundSet"))
13314 {
13315 string cfg_path = "";
13316 string soundset = "";
13317 string type_name = GetType();
13318
13319 TStringArray cfg_soundset_array = new TStringArray;
13320 TStringArray cfg_slot_array = new TStringArray;
13321 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13322 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13323
13324 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13325 {
13326 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13327 {
13328 if (cfg_slot_array[i] == slot_type)
13329 {
13330 soundset = cfg_soundset_array[i];
13331 break;
13332 }
13333 }
13334 }
13335
13336 if (soundset != "")
13337 {
13338 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13339 sound.SetAutodestroy(true);
13340 }
13341 }
13342 }
13343 }
13344
13345 void PlayDetachSound(string slot_type)
13346 {
13347 //TODO - evaluate if needed and devise universal config structure if so
13348 }
13349
13350 void OnApply(PlayerBase player);
13351
13353 {
13354 return 1.0;
13355 };
13356 //returns applicable selection
13357 array<string> GetHeadHidingSelection()
13358 {
13360 }
13361
13363 {
13365 }
13366
13367 WrittenNoteData GetWrittenNoteData() {};
13368
13370 {
13371 SetDynamicPhysicsLifeTime(0.01);
13372 m_ItemBeingDroppedPhys = false;
13373 }
13374
13376 {
13377 array<string> zone_names = new array<string>;
13378 GetDamageZones(zone_names);
13379 for (int i = 0; i < zone_names.Count(); i++)
13380 {
13381 SetHealthMax(zone_names.Get(i),"Health");
13382 }
13383 SetHealthMax("","Health");
13384 }
13385
13387 void SetZoneDamageCEInit()
13388 {
13389 float global_health = GetHealth01("","Health");
13390 array<string> zones = new array<string>;
13391 GetDamageZones(zones);
13392 //set damage of all zones to match global health level
13393 for (int i = 0; i < zones.Count(); i++)
13394 {
13395 SetHealth01(zones.Get(i),"Health",global_health);
13396 }
13397 }
13398
13400 bool IsCoverFaceForShave(string slot_name)
13401 {
13402 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
13403 }
13404
13405 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13406 {
13407 if (!hasRootAsPlayer)
13408 {
13409 if (refParentIB)
13410 {
13411 // parent is wet
13412 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
13413 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
13414 // parent has liquid inside
13415 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
13416 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
13417 // drying
13418 else if (m_VarWet > m_VarWetMin)
13419 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
13420 }
13421 else
13422 {
13423 // drying on ground or inside non-itembase (car, ...)
13424 if (m_VarWet > m_VarWetMin)
13425 AddWet(-1 * delta * GetDryingIncrement("ground"));
13426 }
13427 }
13428 }
13429
13430 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13431 {
13433 {
13434 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
13435 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
13436 {
13437 float heatPermCoef = 1.0;
13438 EntityAI ent = this;
13439 while (ent)
13440 {
13441 heatPermCoef *= ent.GetHeatPermeabilityCoef();
13442 ent = ent.GetHierarchyParent();
13443 }
13444
13445 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
13446 }
13447 }
13448 }
13449
13450 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
13451 {
13452 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
13453 EntityAI parent = GetHierarchyParent();
13454 if (!parent)
13455 {
13456 hasParent = false;
13457 hasRootAsPlayer = false;
13458 }
13459 else
13460 {
13461 hasParent = true;
13462 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
13463 refParentIB = ItemBase.Cast(parent);
13464 }
13465 }
13466
13467 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
13468 {
13469 // this is stub, implemented on Edible_Base
13470 }
13471
13472 bool CanDecay()
13473 {
13474 // return true used on selected food clases so they can decay
13475 return false;
13476 }
13477
13478 protected bool CanProcessDecay()
13479 {
13480 // this is stub, implemented on Edible_Base class
13481 // used to determine whether it is still necessary for the food to decay
13482 return false;
13483 }
13484
13485 protected bool CanHaveWetness()
13486 {
13487 // return true used on selected items that have a wetness effect
13488 return false;
13489 }
13490
13492 bool CanBeConsumed(ConsumeConditionData data = null)
13493 {
13494 return !GetIsFrozen() && IsOpen();
13495 }
13496
13497 override void ProcessVariables()
13498 {
13499 bool hasParent = false, hasRootAsPlayer = false;
13500 ItemBase refParentIB;
13501
13502 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
13503 bool foodDecay = g_Game.IsFoodDecayEnabled();
13504
13505 if (wwtu || foodDecay)
13506 {
13507 bool processWetness = wwtu && CanHaveWetness();
13508 bool processTemperature = wwtu && CanHaveTemperature();
13509 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
13510
13511 if (processWetness || processTemperature || processDecay)
13512 {
13513 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
13514
13515 if (processWetness)
13516 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13517
13518 if (processTemperature)
13519 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
13520
13521 if (processDecay)
13522 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
13523 }
13524 }
13525 }
13526
13529 {
13530 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13531 }
13532
13533 override float GetTemperatureFreezeThreshold()
13534 {
13536 return Liquid.GetFreezeThreshold(GetLiquidType());
13537
13538 return super.GetTemperatureFreezeThreshold();
13539 }
13540
13541 override float GetTemperatureThawThreshold()
13542 {
13544 return Liquid.GetThawThreshold(GetLiquidType());
13545
13546 return super.GetTemperatureThawThreshold();
13547 }
13548
13549 override float GetItemOverheatThreshold()
13550 {
13552 return Liquid.GetBoilThreshold(GetLiquidType());
13553
13554 return super.GetItemOverheatThreshold();
13555 }
13556
13557 override float GetTemperatureFreezeTime()
13558 {
13559 if (HasQuantity())
13560 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13561
13562 return super.GetTemperatureFreezeTime();
13563 }
13564
13565 override float GetTemperatureThawTime()
13566 {
13567 if (HasQuantity())
13568 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13569
13570 return super.GetTemperatureThawTime();
13571 }
13572
13574 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13576 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13577
13578 bool IsCargoException4x3(EntityAI item)
13579 {
13580 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13581 }
13582
13584 {
13585 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13586 }
13587
13589 void AddLightSourceItem(ItemBase lightsource)
13590 {
13591 m_LightSourceItem = lightsource;
13592 }
13593
13595 {
13596 m_LightSourceItem = null;
13597 }
13598
13600 {
13601 return m_LightSourceItem;
13602 }
13603
13605 array<int> GetValidFinishers()
13606 {
13607 return null;
13608 }
13609
13611 bool GetActionWidgetOverride(out typename name)
13612 {
13613 return false;
13614 }
13615
13616 bool PairWithDevice(notnull ItemBase otherDevice)
13617 {
13618 if (GetGame().IsServer())
13619 {
13620 ItemBase explosive = otherDevice;
13622 if (!trg)
13623 {
13624 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13625 explosive = this;
13626 }
13627
13628 explosive.PairRemote(trg);
13629 trg.SetControlledDevice(explosive);
13630
13631 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13632 trg.SetPersistentPairID(persistentID);
13633 explosive.SetPersistentPairID(persistentID);
13634
13635 return true;
13636 }
13637 return false;
13638 }
13639
13641 float GetBaitEffectivity()
13642 {
13643 float ret = 1.0;
13644 if (HasQuantity())
13645 ret *= GetQuantityNormalized();
13646 ret *= GetHealth01();
13647
13648 return ret;
13649 }
13650
13651 #ifdef DEVELOPER
13652 override void SetDebugItem()
13653 {
13654 super.SetDebugItem();
13655 _itemBase = this;
13656 }
13657
13658 override string GetDebugText()
13659 {
13660 string text = super.GetDebugText();
13661
13662 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13663 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13664
13665 return text;
13666 }
13667 #endif
13668
13669 bool CanBeUsedForSuicide()
13670 {
13671 return true;
13672 }
13673
13675 //DEPRECATED BELOW
13677 // Backwards compatibility
13678 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13679 {
13680 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13681 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13682 }
13683
13684 // replaced by ItemSoundHandler
13685 protected EffectSound m_SoundDeployFinish;
13686 protected EffectSound m_SoundPlace;
13687 protected EffectSound m_DeployLoopSoundEx;
13688 protected EffectSound m_SoundDeploy;
13689 bool m_IsPlaceSound;
13690 bool m_IsDeploySound;
13692
13693 string GetDeployFinishSoundset();
13694 void PlayDeploySound();
13695 void PlayDeployFinishSound();
13696 void PlayPlaceSound();
13697 void PlayDeployLoopSoundEx();
13698 void StopDeployLoopSoundEx();
13699 void SoundSynchRemoteReset();
13700 void SoundSynchRemote();
13701 bool UsesGlobalDeploy(){return false;}
13702 bool CanPlayDeployLoopSound(){return false;}
13704 bool IsPlaceSound(){return m_IsPlaceSound;}
13705 bool IsDeploySound(){return m_IsDeploySound;}
13706 void SetIsPlaceSound(bool is_place_sound);
13707 void SetIsDeploySound(bool is_deploy_sound);
13708}
13709
13710EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13711{
13712 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13713 if (entity)
13714 {
13715 bool is_item = entity.IsInherited(ItemBase);
13716 if (is_item && full_quantity)
13717 {
13718 ItemBase item = ItemBase.Cast(entity);
13719 item.SetQuantity(item.GetQuantityInit());
13720 }
13721 }
13722 else
13723 {
13724 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13725 return NULL;
13726 }
13727 return entity;
13728}
13729
13730void SetupSpawnedItem(ItemBase item, float health, float quantity)
13731{
13732 if (item)
13733 {
13734 if (health > 0)
13735 item.SetHealth("", "", health);
13736
13737 if (item.CanHaveTemperature())
13738 {
13739 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13740 if (item.CanFreeze())
13741 item.SetFrozen(false);
13742 }
13743
13744 if (item.HasEnergyManager())
13745 {
13746 if (quantity >= 0)
13747 {
13748 item.GetCompEM().SetEnergy0To1(quantity);
13749 }
13750 else
13751 {
13752 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13753 }
13754 }
13755 else if (item.IsMagazine())
13756 {
13757 Magazine mag = Magazine.Cast(item);
13758 if (quantity >= 0)
13759 {
13760 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13761 }
13762 else
13763 {
13764 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13765 }
13766
13767 }
13768 else
13769 {
13770 if (quantity >= 0)
13771 {
13772 item.SetQuantityNormalized(quantity, false);
13773 }
13774 else
13775 {
13776 item.SetQuantity(Math.AbsFloat(quantity));
13777 }
13778
13779 }
13780 }
13781}
13782
13783#ifdef DEVELOPER
13784ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13785#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/Entities/EntityAI.c:2
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:14
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
int GetLiquidType()
Определения CCTWaterSurface.c:129
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:142
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:497
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6380
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5620
bool HidesSelectionBySlot()
Определения ItemBase.c:9347
float m_VarWetMin
Определения ItemBase.c:4881
void SplitItem(PlayerBase player)
Определения ItemBase.c:6831
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9568
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8229
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5625
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8938
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6798
override bool IsHeavyBehaviour()
Определения ItemBase.c:9140
override void SetWetMax()
Определения ItemBase.c:8511
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9385
void ClearStartItemSoundServer()
Определения ItemBase.c:9283
float m_VarWet
Определения ItemBase.c:4878
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9415
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4941
bool CanBeMovedOverride()
Определения ItemBase.c:7522
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8487
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4927
override void ProcessVariables()
Определения ItemBase.c:9482
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4955
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8321
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8856
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8701
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5211
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4953
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9518
bool m_IsSoundSynchRemote
Определения ItemBase.c:9676
float m_OverheatingShots
Определения ItemBase.c:4948
void StopItemSoundServer(int id)
Определения ItemBase.c:9271
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5640
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5364
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9542
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4965
bool CanBeCooked()
Определения ItemBase.c:7478
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5707
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4977
bool m_RecipesInitialized
Определения ItemBase.c:4863
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6471
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9526
override void OnEnergyConsumed()
Определения ItemBase.c:8431
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8360
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8551
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8316
ref TIntArray m_InteractActions
Определения ItemBase.c:4929
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7542
float m_VarQuantity
Определения ItemBase.c:4869
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9687
override float GetWetMax()
Определения ItemBase.c:8521
bool CanBeUsedForSuicide()
Определения ItemBase.c:9654
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7117
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5845
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7696
void StartItemSoundServer(int id)
Определения ItemBase.c:9258
void DoAmmoExplosion()
Определения ItemBase.c:6315
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4940
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6655
int GetItemSize()
Определения ItemBase.c:7507
bool m_CanBeMovedOverride
Определения ItemBase.c:4906
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6239
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5432
bool CanDecay()
Определения ItemBase.c:9457
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8202
void SetQuantityMax()
Определения ItemBase.c:8207
override float GetQuantity()
Определения ItemBase.c:8296
int m_ColorComponentR
Определения ItemBase.c:4918
int m_ShotsToStartOverheating
Определения ItemBase.c:4950
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8536
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5439
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9039
void OnOverheatingDecay()
Определения ItemBase.c:5402
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8469
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4884
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5540
bool UsesGlobalDeploy()
Определения ItemBase.c:9686
int m_ItemBehaviour
Определения ItemBase.c:4899
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9011
float m_HeatIsolation
Определения ItemBase.c:4894
float m_VarWetInit
Определения ItemBase.c:4880
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5885
void SetCEBasedQuantity()
Определения ItemBase.c:5653
bool m_CanPlayImpactSound
Определения ItemBase.c:4890
override string GetAttachmentSoundType()
Определения ItemBase.c:9214
float GetOverheatingCoef()
Определения ItemBase.c:5459
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9342
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9294
override bool IsStoreLoad()
Определения ItemBase.c:8563
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7093
bool IsLightSource()
Определения ItemBase.c:5781
bool m_HasQuantityBar
Определения ItemBase.c:4912
void SetResultOfSplit(bool value)
Определения ItemBase.c:7088
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6719
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6889
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5467
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8478
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9119
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8573
int m_LockType
Определения ItemBase.c:4966
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4971
bool m_CanBeDigged
Определения ItemBase.c:4913
float m_ItemAttachOffset
Определения ItemBase.c:4896
float GetItemModelLength()
Определения ItemBase.c:8580
bool m_ThrowItemOnDrop
Определения ItemBase.c:4904
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7841
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8871
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8464
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7122
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9513
bool CanHaveWetness()
Определения ItemBase.c:9470
int m_CleannessMin
Определения ItemBase.c:4886
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8804
string IDToName(int id)
Определения ItemBase.c:7689
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9477
float GetHeatIsolationInit()
Определения ItemBase.c:8459
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7529
override bool HasQuantity()
Определения ItemBase.c:8291
float m_VarWetPrev
Определения ItemBase.c:4879
int m_SoundSyncStop
Определения ItemBase.c:4973
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9563
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4928
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5549
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5234
int m_VarLiquidType
Определения ItemBase.c:4898
int m_QuickBarBonus
Определения ItemBase.c:4900
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9202
override float GetWetInit()
Определения ItemBase.c:8531
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4892
int m_SoundSyncPlay
Определения ItemBase.c:4972
int m_MaxOverheatingValue
Определения ItemBase.c:4951
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4875
bool m_IsTakeable
Определения ItemBase.c:4903
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6428
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4943
string GetLockSoundSet()
Определения ItemBase.c:8629
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8660
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9590
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6895
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4855
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9229
override int GetQuantityMin()
Определения ItemBase.c:8280
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6634
override int GetQuickBarBonus()
Определения ItemBase.c:5119
override void SetTakeable(bool pState)
Определения ItemBase.c:9184
float m_OverheatingDecayInterval
Определения ItemBase.c:4952
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6448
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9435
bool CanProcessDecay()
Определения ItemBase.c:9463
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5630
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9579
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7493
bool can_this_be_combined
Определения ItemBase.c:4908
EffectSound m_SoundDeploy
Определения ItemBase.c:9673
int m_Count
Определения ItemBase.c:4874
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9626
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9176
override bool IsSplitable()
Определения ItemBase.c:6415
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6399
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7805
void ConvertEnergyToQuantity()
Определения ItemBase.c:8446
override void RemoveAllAgents()
Определения ItemBase.c:8785
override void SetQuantityToMinimum()
Определения ItemBase.c:8213
bool m_WantPlayImpactSound
Определения ItemBase.c:4889
override float GetTemperatureThawTime()
Определения ItemBase.c:9550
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4942
int m_ColorComponentG
Определения ItemBase.c:4919
float m_StoreLoadedQuantity
Определения ItemBase.c:4876
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7560
int m_ColorComponentA
Определения ItemBase.c:4921
int m_VarQuantityInit
Определения ItemBase.c:4871
float GetFilterDamageRatio()
Определения ItemBase.c:5534
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8673
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6865
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8220
bool m_HideSelectionsBySlot
Определения ItemBase.c:4956
bool IsOverheatingEffectActive()
Определения ItemBase.c:5397
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5814
int GetLiquidContainerMask()
Определения ItemBase.c:5751
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7002
ref Timer m_CheckOverheating
Определения ItemBase.c:4949
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5445
float GetEnergy()
Определения ItemBase.c:8420
bool CanBeDigged()
Определения ItemBase.c:5830
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9596
bool IsNVG()
Определения ItemBase.c:5762
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8380
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9372
bool m_IsDeploySound
Определения ItemBase.c:9675
bool CanEat()
Определения ItemBase.c:7453
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9079
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9150
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9574
bool IsLiquidContainer()
Определения ItemBase.c:5746
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7473
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8307
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8863
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8261
int m_CleannessInit
Определения ItemBase.c:4885
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5529
override int GetAgents()
Определения ItemBase.c:8810
int m_VarQuantityMax
Определения ItemBase.c:4873
override bool IsHologram()
Определения ItemBase.c:5825
float GetItemAttachOffset()
Определения ItemBase.c:8589
bool IsPlaceSound()
Определения ItemBase.c:9689
static int GetDebugActionsMask()
Определения ItemBase.c:5615
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9452
override bool IsItemBase()
Определения ItemBase.c:7606
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9160
void ExplodeAmmo()
Определения ItemBase.c:6302
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7078
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8884
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9059
override void OnEnergyAdded()
Определения ItemBase.c:8438
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5774
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9672
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7746
void StopItemDynamicPhysics()
Определения ItemBase.c:9354
bool HasFoodStage()
Определения ItemBase.c:7466
override void SetStoreLoad(bool value)
Определения ItemBase.c:8558
float GetOverheatingValue()
Определения ItemBase.c:5359
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8763
override void AddWet(float value)
Определения ItemBase.c:8506
bool IsLiquidPresent()
Определения ItemBase.c:5741
bool IsFullQuantity()
Определения ItemBase.c:8301
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6015
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6770
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6746
int m_CleannessMax
Определения ItemBase.c:4887
float m_VarStackMax
Определения ItemBase.c:4875
ref Timer m_PhysDropTimer
Определения ItemBase.c:4962
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7578
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8568
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4916
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5380
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5695
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7500
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8694
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5426
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8616
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4947
int m_LiquidContainerMask
Определения ItemBase.c:4897
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9390
override int GetCleanness()
Определения ItemBase.c:8611
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9601
bool IsDeploySound()
Определения ItemBase.c:9690
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5635
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9099
int m_VarQuantityMin
Определения ItemBase.c:4872
void PerformDamageSystemReinit()
Определения ItemBase.c:9360
override void ClearInventory()
Определения ItemBase.c:8399
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4944
ItemBase GetLightSourceItem()
Определения ItemBase.c:9584
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7596
override float GetItemOverheatThreshold()
Определения ItemBase.c:9534
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4909
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7710
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6685
float m_ItemModelLength
Определения ItemBase.c:4895
bool m_IsHologram
Определения ItemBase.c:4902
static int m_DebugActionsMask
Определения ItemBase.c:4862
void KillAllOverheatingParticles()
Определения ItemBase.c:5495
bool CanBeCookedOnStick()
Определения ItemBase.c:7483
override int GetQuantityMax()
Определения ItemBase.c:8248
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7156
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8654
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8776
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4905
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8966
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9330
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4856
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9663
override bool IsBeingPlaced()
Определения ItemBase.c:5809
int GetQuantityInit()
Определения ItemBase.c:8285
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7098
bool IsResultOfSplit()
Определения ItemBase.c:7083
bool m_FixDamageSystemInit
Определения ItemBase.c:4907
float m_ImpactSpeed
Определения ItemBase.c:4891
bool m_IsStoreLoad
Определения ItemBase.c:4910
int GetLiquidTypeInit()
Определения ItemBase.c:8684
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4925
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5682
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6557
int m_AttachedAgents
Определения ItemBase.c:4933
string m_LockSoundSet
Определения ItemBase.c:4968
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5303
float m_VarQuantityPrev
Определения ItemBase.c:4870
bool IsSoundSynchRemote()
Определения ItemBase.c:9688
bool m_CanShowQuantity
Определения ItemBase.c:4911
override void OnRightClick()
Определения ItemBase.c:6938
int m_ColorComponentB
Определения ItemBase.c:4920
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4858
bool IsActionTargetVisible()
Определения ItemBase.c:9196
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6050
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6339
bool m_IsBeingPlaced
Определения ItemBase.c:4901
int NameToID(string name)
Определения ItemBase.c:7683
void ~ItemBase()
Определения ItemBase.c:5580
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8546
void ClearStopItemSoundServer()
Определения ItemBase.c:9288
override string ChangeIntoOnDetach()
Определения ItemBase.c:6263
float m_VarWetMax
Определения ItemBase.c:4882
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6680
int GetLockType()
Определения ItemBase.c:8624
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9670
override float GetWet()
Определения ItemBase.c:8516
EffectSound m_SoundPlace
Определения ItemBase.c:9671
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8234
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8598
bool m_IsPlaceSound
Определения ItemBase.c:9674
override float GetWetMin()
Определения ItemBase.c:8526
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4974
override bool KindOf(string tag)
Определения ItemBase.c:7612
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:321
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
EntityAI GetItem()
Определения RadialQuickbarMenu.c:37
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
void Debug()
Определения UniversalTemperatureSource.c:349
int GetID()
Определения ActionBase.c:1360
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:998
GetInputType()
Определения ActionBase.c:215
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
Определения AnalyticsManagerClient.c:77
proto native UIManager GetUIManager()
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void GizmoSelectObject(Object object)
proto native bool ConfigIsExisting(string path)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native DayZPlayer GetPlayer()
proto native void GizmoSelectPhysics(Physics physics)
proto int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Global/game.c:1568
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ObjectDelete(Object obj)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1280
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:541
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1275
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/Entities/Man.c:44
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:469
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
override bool CanDisplayCargo()
Определения UndergroundStash.c:24
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override void SetActions()
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:412
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:424
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool IsClothing()
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:64
proto native float GetDamage(string zoneName, string healthType)
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Определения UIManager.c:160
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/tools/Debug.c:816
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:100
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/constants.c:512
const int DEF_CHEMICAL
Определения 3_Game/constants.c:513
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:709
array< int > TIntArray
Определения EnScript.c:711
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/constants.c:808
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/constants.c:632
const int VARIABLE_CLEANNESS
Определения 3_Game/constants.c:635
const int VARIABLE_COLOR
Определения 3_Game/constants.c:634
const int VARIABLE_TEMPERATURE
Определения 3_Game/constants.c:630
const int VARIABLE_QUANTITY
Определения 3_Game/constants.c:628
const int VARIABLE_WET
Определения 3_Game/constants.c:631
const int LIQUID_NONE
Определения 3_Game/constants.c:529
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/constants.c:453
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/tools/tools.c:8
proto native int GetColor()

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