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

◆ GetProtectionLevel()

float SpawnItemOnLocation::GetProtectionLevel ( int type,
bool consider_filter = false,
int system = 0 )
protected

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

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