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

◆ CanReleaseAttachment()

override bool SpawnItemOnLocation::CanReleaseAttachment ( EntityAI attachment)
protected

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

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