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

◆ CanPutAsAttachment()

override bool SpawnItemOnLocation::CanPutAsAttachment ( EntityAI parent)
protected

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

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