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

◆ CheckForRoofLimited()

override void SpawnItemOnLocation::CheckForRoofLimited ( float timeTresholdMS = 3000)
protected

Roof check for entity, limited by time (anti-spam solution)

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

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

Используется в Cooling(), Heating(), FireplaceBase::IsThisIgnitionSuccessful(), OnItemLocationChanged(), StartFire() и StopFire().