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

◆ CanReceiveAttachment()

override bool SpawnItemOnLocation::CanReceiveAttachment ( EntityAI attachment,
int slotId )
protected

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

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