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

◆ IsOpen()

override bool IsOpen ( )
protected

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

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

Используется в InventoryItem::CanBeConsumed(), FireplaceBase::CanBeIgnitedBy(), FireplaceBase::CanDisplayAttachmentCategory(), FireplaceBase::CanDisplayCargo(), InventoryItem::CanDisplayCargo(), FireplaceBase::CanExtinguishFire(), FireplaceBase::CanIgniteItem(), FireplaceBase::CanPutInCargo(), FireplaceBase::CanPutIntoHands(), FireplaceBase::CanReceiveAttachment(), FireplaceBase::CanReceiveItemIntoCargo(), FireplaceBase::CanReleaseCargo(), FireplaceBase::CanShowSmoke(), FireplaceBase::IsThisIgnitionSuccessful() и FireplaceBase::UpdateVisualState().