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

◆ OnItemLocationChanged()

override void SpawnItemOnLocation::OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
private

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

5987{
5988 override bool CanPutAsAttachment(EntityAI parent)
5989 {
5990 return true;
5991 }
5992};
5993
5994//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5995
5996class ItemBase extends InventoryItem
5997{
6001
6003
6004 static int m_DebugActionsMask;
6006 // ============================================
6007 // Variable Manipulation System
6008 // ============================================
6009 // Quantity
6010
6011 float m_VarQuantity;
6012 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
6014 int m_VarQuantityMin;
6015 int m_VarQuantityMax;
6016 int m_Count;
6017 float m_VarStackMax;
6018 float m_StoreLoadedQuantity = float.LOWEST;
6019 // Wet
6020 float m_VarWet;
6021 float m_VarWetPrev;//for client to know wetness changed during synchronization
6022 float m_VarWetInit;
6023 float m_VarWetMin;
6024 float m_VarWetMax;
6025 // Cleanness
6026 int m_Cleanness;
6027 int m_CleannessInit;
6028 int m_CleannessMin;
6029 int m_CleannessMax;
6030 // impact sounds
6032 bool m_CanPlayImpactSound = true;
6033 float m_ImpactSpeed;
6035 //
6036 float m_HeatIsolation;
6037 float m_ItemModelLength;
6038 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
6040 int m_VarLiquidType;
6041 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
6042 int m_QuickBarBonus;
6043 bool m_IsBeingPlaced;
6044 bool m_IsHologram;
6045 bool m_IsTakeable;
6046 bool m_ThrowItemOnDrop;
6049 bool m_FixDamageSystemInit = false; //can be changed on storage version check
6050 bool can_this_be_combined; //Check if item can be combined
6051 bool m_CanThisBeSplit; //Check if item can be split
6052 bool m_IsStoreLoad = false;
6053 bool m_CanShowQuantity;
6054 bool m_HasQuantityBar;
6055 protected bool m_CanBeDigged;
6056 protected bool m_IsResultOfSplit
6057
6058 string m_SoundAttType;
6059 // items color variables
6064 //-------------------------------------------------------
6065
6066 // light source managing
6068
6072
6073 //==============================================
6074 // agent system
6075 private int m_AttachedAgents;
6076
6078 void TransferModifiers(PlayerBase reciever);
6079
6080
6081 // Weapons & suppressors particle effects
6086 static int m_LastRegisteredWeaponID = 0;
6087
6088 // Overheating effects
6090 float m_OverheatingShots;
6091 ref Timer m_CheckOverheating;
6092 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
6093 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
6094 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
6095 ref array <ref OverheatingParticle> m_OverheatingParticles;
6096
6098 protected bool m_HideSelectionsBySlot;
6099
6100 // Admin Log
6101 PluginAdminLog m_AdminLog;
6102
6103 // misc
6104 ref Timer m_PhysDropTimer;
6105
6106 // Attachment Locking variables
6107 ref array<int> m_CompatibleLocks;
6108 protected int m_LockType;
6109 protected ref EffectSound m_LockingSound;
6110 protected string m_LockSoundSet;
6111
6112 // ItemSoundHandler
6113 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
6114 protected int m_SoundSyncPlay; // id for sound to play
6115 protected int m_SoundSyncStop; // id for sound to stop
6117
6118 //temperature
6119 private float m_TemperaturePerQuantityWeight;
6120
6121 // -------------------------------------------------------------------------
6122 void ItemBase()
6123 {
6124 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
6128
6129 if (!GetGame().IsDedicatedServer())
6130 {
6131 if (HasMuzzle())
6132 {
6134
6136 {
6138 }
6139 }
6140
6142 m_ActionsInitialize = false;
6143 }
6144
6145 m_OldLocation = null;
6146
6147 if (GetGame().IsServer())
6148 {
6149 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
6150 }
6151
6152 if (ConfigIsExisting("headSelectionsToHide"))
6153 {
6155 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
6156 }
6157
6158 m_HideSelectionsBySlot = false;
6159 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
6160 {
6161 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
6162 }
6163
6164 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
6165
6166 m_IsResultOfSplit = false;
6167
6169 }
6170
6171 override void InitItemVariables()
6172 {
6173 super.InitItemVariables();
6174
6175 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
6176 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
6177 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
6178 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
6179 m_VarStackMax = ConfigGetFloat("varStackMax");
6180 m_Count = ConfigGetInt("count");
6181
6182 m_CanShowQuantity = ConfigGetBool("quantityShow");
6183 m_HasQuantityBar = ConfigGetBool("quantityBar");
6184
6185 m_CleannessInit = ConfigGetInt("varCleannessInit");
6187 m_CleannessMin = ConfigGetInt("varCleannessMin");
6188 m_CleannessMax = ConfigGetInt("varCleannessMax");
6189
6190 m_WantPlayImpactSound = false;
6191 m_ImpactSpeed = 0.0;
6192
6193 m_VarWetInit = ConfigGetFloat("varWetInit");
6195 m_VarWetMin = ConfigGetFloat("varWetMin");
6196 m_VarWetMax = ConfigGetFloat("varWetMax");
6197
6198 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
6199 if (IsLiquidContainer() && GetQuantity() != 0)
6201 m_IsBeingPlaced = false;
6202 m_IsHologram = false;
6203 m_IsTakeable = true;
6204 m_CanBeMovedOverride = false;
6208 m_CanBeDigged = ConfigGetBool("canBeDigged");
6209
6210 m_CompatibleLocks = new array<int>();
6211 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
6212 m_LockType = ConfigGetInt("lockType");
6213
6214 //Define if item can be split and set ability to be combined accordingly
6215 m_CanThisBeSplit = false;
6216 can_this_be_combined = false;
6217 if (ConfigIsExisting("canBeSplit"))
6218 {
6219 can_this_be_combined = ConfigGetBool("canBeSplit");
6221 }
6222
6223 m_ItemBehaviour = -1;
6224 if (ConfigIsExisting("itemBehaviour"))
6225 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
6226
6227 //RegisterNetSyncVariableInt("m_VariablesMask");
6228 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6229 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
6230 RegisterNetSyncVariableInt("m_VarLiquidType");
6231 RegisterNetSyncVariableInt("m_Cleanness",0,1);
6232
6233 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
6234 RegisterNetSyncVariableFloat("m_ImpactSpeed");
6235 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
6236
6237 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
6238 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
6239 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
6240 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
6241
6242 RegisterNetSyncVariableBool("m_IsBeingPlaced");
6243 RegisterNetSyncVariableBool("m_IsTakeable");
6244 RegisterNetSyncVariableBool("m_IsHologram");
6245
6246 InitItemSounds();
6248 {
6249 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
6250 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
6251 }
6252
6253 m_LockSoundSet = ConfigGetString("lockSoundSet");
6254
6256 if (ConfigIsExisting("temperaturePerQuantityWeight"))
6257 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
6258
6259 }
6260
6261 override int GetQuickBarBonus()
6262 {
6263 return m_QuickBarBonus;
6264 }
6265
6266 void InitializeActions()
6267 {
6269 if (!m_InputActionMap)
6270 {
6272 m_InputActionMap = iam;
6273 SetActions();
6275 }
6276 }
6277
6278 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
6279 {
6281 {
6282 m_ActionsInitialize = true;
6284 }
6285
6286 actions = m_InputActionMap.Get(action_input_type);
6287 }
6288
6289 void SetActions()
6290 {
6291 AddAction(ActionTakeItem);
6292 AddAction(ActionTakeItemToHands);
6293 AddAction(ActionWorldCraft);
6295 AddAction(ActionAttachWithSwitch);
6296 }
6297
6298 void SetActionAnimOverrides(); // Override action animation for specific item
6299
6300 void AddAction(typename actionName)
6301 {
6302 ActionBase action = ActionManagerBase.GetAction(actionName);
6303
6304 if (!action)
6305 {
6306 Debug.LogError("Action " + actionName + " dosn't exist!");
6307 return;
6308 }
6309
6310 typename ai = action.GetInputType();
6311 if (!ai)
6312 {
6313 m_ActionsInitialize = false;
6314 return;
6315 }
6316
6317 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6318 if (!action_array)
6319 {
6320 action_array = new array<ActionBase_Basic>;
6321 m_InputActionMap.Insert(ai, action_array);
6322 }
6323 if (LogManager.IsActionLogEnable())
6324 {
6325 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
6326 }
6327
6328 if (action_array.Find(action) != -1)
6329 {
6330 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
6331 }
6332 else
6333 {
6334 action_array.Insert(action);
6335 }
6336 }
6337
6338 void RemoveAction(typename actionName)
6339 {
6340 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6341 ActionBase action = player.GetActionManager().GetAction(actionName);
6342 typename ai = action.GetInputType();
6343 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
6344
6345 if (action_array)
6346 {
6347 action_array.RemoveItem(action);
6348 }
6349 }
6350
6351 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
6352 // Set -1 for params which should stay in default state
6353 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
6354 {
6355 ActionOverrideData overrideData = new ActionOverrideData();
6356 overrideData.m_CommandUID = commandUID;
6357 overrideData.m_CommandUIDProne = commandUIDProne;
6358 overrideData.m_StanceMask = stanceMask;
6359
6360 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
6361 if (!actionMap) // create new map of action > overidables map
6362 {
6363 actionMap = new TActionAnimOverrideMap();
6364 m_ItemActionOverrides.Insert(action, actionMap);
6365 }
6366
6367 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
6368
6369 }
6370
6371 void OnItemInHandsPlayerSwimStart(PlayerBase player);
6372
6373 ScriptedLightBase GetLight();
6374
6375 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6376 void LoadParticleConfigOnFire(int id)
6377 {
6378 if (!m_OnFireEffect)
6380
6383
6384 string config_to_search = "CfgVehicles";
6385 string muzzle_owner_config;
6386
6387 if (!m_OnFireEffect.Contains(id))
6388 {
6389 if (IsInherited(Weapon))
6390 config_to_search = "CfgWeapons";
6391
6392 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6393
6394 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
6395
6396 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
6397
6398 if (config_OnFire_subclass_count > 0)
6399 {
6400 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
6401
6402 for (int i = 0; i < config_OnFire_subclass_count; i++)
6403 {
6404 string particle_class = "";
6405 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
6406 string config_OnFire_entry = config_OnFire_class + particle_class;
6407 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
6408 WPOF_array.Insert(WPOF);
6409 }
6410
6411
6412 m_OnFireEffect.Insert(id, WPOF_array);
6413 }
6414 }
6415
6416 if (!m_OnBulletCasingEjectEffect.Contains(id))
6417 {
6418 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
6419 muzzle_owner_config = config_to_search + " " + GetType() + " ";
6420
6421 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
6422
6423 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
6424
6425 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
6426 {
6427 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
6428
6429 for (i = 0; i < config_OnBulletCasingEject_count; i++)
6430 {
6431 string particle_class2 = "";
6432 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
6433 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
6434 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
6435 WPOBE_array.Insert(WPOBE);
6436 }
6437
6438
6439 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
6440 }
6441 }
6442 }
6443
6444 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
6446 {
6449
6450 if (!m_OnOverheatingEffect.Contains(id))
6451 {
6452 string config_to_search = "CfgVehicles";
6453
6454 if (IsInherited(Weapon))
6455 config_to_search = "CfgWeapons";
6456
6457 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6458 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6459
6460 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
6461 {
6462
6463 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6464
6466 {
6467 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6468 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6469 Error(error);
6470 return;
6471 }
6472
6473 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6474 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6475
6476
6477
6478 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
6479 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6480
6481 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6482 {
6483 string particle_class = "";
6484 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6485 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6486 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
6487
6488 if (entry_type == CT_CLASS)
6489 {
6490 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6491 WPOOH_array.Insert(WPOF);
6492 }
6493 }
6494
6495
6496 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6497 }
6498 }
6499 }
6500
6501 float GetOverheatingValue()
6502 {
6503 return m_OverheatingShots;
6504 }
6505
6506 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6507 {
6508 if (m_MaxOverheatingValue > 0)
6509 {
6511
6512 if (!m_CheckOverheating)
6514
6516 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6517
6518 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6519 }
6520 }
6521
6522 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6523 {
6525 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6526
6528 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6529
6531 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6532
6534 {
6536 }
6537 }
6538
6540 {
6542 }
6543
6544 void OnOverheatingDecay()
6545 {
6546 if (m_MaxOverheatingValue > 0)
6547 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6548 else
6550
6551 if (m_OverheatingShots <= 0)
6552 {
6555 }
6556 else
6557 {
6558 if (!m_CheckOverheating)
6560
6562 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6563 }
6564
6565 CheckOverheating(this, "", this);
6566 }
6567
6568 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6569 {
6571 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6572 }
6573
6574 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6575 {
6577 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6579 }
6580
6581 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6582 {
6584 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6585 }
6586
6587 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6588 {
6590 m_OverheatingParticles = new array<ref OverheatingParticle>;
6591
6592 OverheatingParticle OP = new OverheatingParticle();
6593 OP.RegisterParticle(p);
6594 OP.SetOverheatingLimitMin(min_heat_coef);
6595 OP.SetOverheatingLimitMax(max_heat_coef);
6596 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6597
6598 m_OverheatingParticles.Insert(OP);
6599 }
6600
6601 float GetOverheatingCoef()
6602 {
6603 if (m_MaxOverheatingValue > 0)
6605
6606 return -1;
6607 }
6608
6610 {
6612 {
6613 float overheat_coef = GetOverheatingCoef();
6614 int count = m_OverheatingParticles.Count();
6615
6616 for (int i = count; i > 0; --i)
6617 {
6618 int id = i - 1;
6619 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6620 Particle p = OP.GetParticle();
6621
6622 float overheat_min = OP.GetOverheatingLimitMin();
6623 float overheat_max = OP.GetOverheatingLimitMax();
6624
6625 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6626 {
6627 if (p)
6628 {
6629 p.Stop();
6630 OP.RegisterParticle(null);
6631 }
6632 }
6633 }
6634 }
6635 }
6636
6638 {
6640 {
6641 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6642 {
6643 int id = i - 1;
6644 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6645
6646 if (OP)
6647 {
6648 Particle p = OP.GetParticle();
6649
6650 if (p)
6651 {
6652 p.Stop();
6653 }
6654
6655 delete OP;
6656 }
6657 }
6658
6659 m_OverheatingParticles.Clear();
6661 }
6662 }
6663
6665 float GetInfectionChance(int system = 0, Param param = null)
6666 {
6667 return 0.0;
6668 }
6669
6670
6671 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6672 {
6673 return 250;//default value
6674 }
6675
6676 float GetFilterDamageRatio()
6677 {
6678 return 0;
6679 }
6680
6682 bool HasMuzzle()
6683 {
6684 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6685 return true;
6686
6687 return false;
6688 }
6689
6691 int GetMuzzleID()
6692 {
6693 if (!m_WeaponTypeToID)
6695
6696 if (m_WeaponTypeToID.Contains(GetType()))
6697 {
6698 return m_WeaponTypeToID.Get(GetType());
6699 }
6700 else
6701 {
6702 // Register new weapon ID
6704 }
6705
6707 }
6708
6715 {
6716 return -1;
6717 }
6718
6719
6720
6721 // -------------------------------------------------------------------------
6722 void ~ItemBase()
6723 {
6724 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
6725 {
6726 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
6727 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6728
6729 if (r_index >= 0)
6730 {
6731 InventoryLocation r_il = new InventoryLocation;
6732 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6733
6734 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6735 int r_type = r_il.GetType();
6736 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6737 {
6738 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6739 }
6740 else if (r_type == InventoryLocationType.ATTACHMENT)
6741 {
6742 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6743 }
6744
6745 }
6746
6747 player.GetHumanInventory().ClearUserReservedLocation(this);
6748 }
6749
6750 if (m_LockingSound)
6751 SEffectManager.DestroyEffect(m_LockingSound);
6752 }
6753
6754
6755
6756 // -------------------------------------------------------------------------
6757 static int GetDebugActionsMask()
6758 {
6759 return ItemBase.m_DebugActionsMask;
6760 }
6761
6762 static bool HasDebugActionsMask(int mask)
6763 {
6764 return ItemBase.m_DebugActionsMask & mask;
6765 }
6766
6767 static void SetDebugActionsMask(int mask)
6768 {
6769 ItemBase.m_DebugActionsMask = mask;
6770 }
6771
6772 static void AddDebugActionsMask(int mask)
6773 {
6774 ItemBase.m_DebugActionsMask |= mask;
6775 }
6776
6777 static void RemoveDebugActionsMask(int mask)
6778 {
6779 ItemBase.m_DebugActionsMask &= ~mask;
6780 }
6781
6782 static void ToggleDebugActionsMask(int mask)
6783 {
6784 if (HasDebugActionsMask(mask))
6785 {
6787 }
6788 else
6789 {
6790 AddDebugActionsMask(mask);
6791 }
6792 }
6793
6794 // -------------------------------------------------------------------------
6795 void SetCEBasedQuantity()
6796 {
6797 if (GetEconomyProfile())
6798 {
6799 float q_max = GetEconomyProfile().GetQuantityMax();
6800 if (q_max > 0)
6801 {
6802 float q_min = GetEconomyProfile().GetQuantityMin();
6803 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6804
6805 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6806 {
6807 ComponentEnergyManager comp = GetCompEM();
6808 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
6809 {
6810 comp.SetEnergy0To1(quantity_randomized);
6811 }
6812 }
6813 else if (HasQuantity())
6814 {
6815 SetQuantityNormalized(quantity_randomized, false);
6816 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6817 }
6818
6819 }
6820 }
6821 }
6822
6824 void LockToParent()
6825 {
6826 EntityAI parent = GetHierarchyParent();
6827
6828 if (parent)
6829 {
6830 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6831 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6832 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6833 }
6834 }
6835
6837 void UnlockFromParent()
6838 {
6839 EntityAI parent = GetHierarchyParent();
6840
6841 if (parent)
6842 {
6843 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6844 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6845 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6846 }
6847 }
6848
6849 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6850 {
6851 /*
6852 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6853 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
6854 */
6855 ItemBase item2 = ItemBase.Cast(entity2);
6856
6857 if (GetGame().IsClient())
6858 {
6859 if (ScriptInputUserData.CanStoreInputUserData())
6860 {
6861 ScriptInputUserData ctx = new ScriptInputUserData;
6863 ctx.Write(-1);
6864 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6865 ctx.Write(i1);
6866 ctx.Write(item2);
6867 ctx.Write(use_stack_max);
6868 ctx.Write(-1);
6869 ctx.Send();
6870
6871 if (IsCombineAll(item2, use_stack_max))
6872 {
6873 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6874 }
6875 }
6876 }
6877 else if (!GetGame().IsMultiplayer())
6878 {
6879 CombineItems(item2, use_stack_max);
6880 }
6881 }
6882
6883 bool IsLiquidPresent()
6884 {
6885 return (GetLiquidType() != 0 && HasQuantity());
6886 }
6887
6888 bool IsLiquidContainer()
6889 {
6890 return m_LiquidContainerMask != 0;
6891 }
6892
6894 {
6895 return m_LiquidContainerMask;
6896 }
6897
6898 bool IsBloodContainer()
6899 {
6900 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6901 return false;
6902 }
6903
6904 bool IsNVG()
6905 {
6906 return false;
6907 }
6908
6911 bool IsExplosive()
6912 {
6913 return false;
6914 }
6915
6917 {
6918 return "";
6919 }
6920
6922
6923 bool IsLightSource()
6924 {
6925 return false;
6926 }
6927
6929 {
6930 return true;
6931 }
6932
6933 //--- ACTION CONDITIONS
6934 //direction
6935 bool IsFacingPlayer(PlayerBase player, string selection)
6936 {
6937 return true;
6938 }
6939
6940 bool IsPlayerInside(PlayerBase player, string selection)
6941 {
6942 return true;
6943 }
6944
6945 override bool CanObstruct()
6946 {
6947 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6948 return !player || !IsPlayerInside(player, "");
6949 }
6950
6951 override bool IsBeingPlaced()
6952 {
6953 return m_IsBeingPlaced;
6954 }
6955
6956 void SetIsBeingPlaced(bool is_being_placed)
6957 {
6958 m_IsBeingPlaced = is_being_placed;
6959 if (!is_being_placed)
6961 SetSynchDirty();
6962 }
6963
6964 //server-side
6965 void OnEndPlacement() {}
6966
6967 override bool IsHologram()
6968 {
6969 return m_IsHologram;
6970 }
6971
6972 bool CanBeDigged()
6973 {
6974 return m_CanBeDigged;
6975 }
6976
6978 {
6979 return 1;
6980 }
6981
6982 bool CanMakeGardenplot()
6983 {
6984 return false;
6985 }
6986
6987 void SetIsHologram(bool is_hologram)
6988 {
6989 m_IsHologram = is_hologram;
6990 SetSynchDirty();
6991 }
6992 /*
6993 protected float GetNutritionalEnergy()
6994 {
6995 Edible_Base edible = Edible_Base.Cast(this);
6996 return edible.GetFoodEnergy();
6997 }
6998
6999 protected float GetNutritionalWaterContent()
7000 {
7001 Edible_Base edible = Edible_Base.Cast(this);
7002 return edible.GetFoodWater();
7003 }
7004
7005 protected float GetNutritionalIndex()
7006 {
7007 Edible_Base edible = Edible_Base.Cast(this);
7008 return edible.GetFoodNutritionalIndex();
7009 }
7010
7011 protected float GetNutritionalFullnessIndex()
7012 {
7013 Edible_Base edible = Edible_Base.Cast(this);
7014 return edible.GetFoodTotalVolume();
7015 }
7016
7017 protected float GetNutritionalToxicity()
7018 {
7019 Edible_Base edible = Edible_Base.Cast(this);
7020 return edible.GetFoodToxicity();
7021
7022 }
7023 */
7024
7025
7026 // -------------------------------------------------------------------------
7027 override void OnMovedInsideCargo(EntityAI container)
7028 {
7029 super.OnMovedInsideCargo(container);
7030
7031 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7032 }
7033
7034 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7035 {
7036 super.EEItemLocationChanged(oldLoc,newLoc);
7037
7038 PlayerBase new_player = null;
7039 PlayerBase old_player = null;
7040
7041 if (newLoc.GetParent())
7042 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
7043
7044 if (oldLoc.GetParent())
7045 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
7046
7047 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
7048 {
7049 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
7050
7051 if (r_index >= 0)
7052 {
7053 InventoryLocation r_il = new InventoryLocation;
7054 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7055
7056 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7057 int r_type = r_il.GetType();
7058 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7059 {
7060 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7061 }
7062 else if (r_type == InventoryLocationType.ATTACHMENT)
7063 {
7064 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7065 }
7066
7067 }
7068 }
7069
7070 if (newLoc.GetType() == InventoryLocationType.HANDS)
7071 {
7072 if (new_player)
7073 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
7074
7075 if (new_player == old_player)
7076 {
7077
7078 if (oldLoc.GetParent() && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
7079 {
7080 if (oldLoc.GetType() == InventoryLocationType.CARGO)
7081 {
7082 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
7083 {
7084 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7085 }
7086 }
7087 else
7088 {
7089 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
7090 }
7091 }
7092
7093 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
7094 {
7095 int type = oldLoc.GetType();
7096 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
7097 {
7098 oldLoc.GetParent().GetOnSetLock().Invoke(this);
7099 }
7100 else if (type == InventoryLocationType.ATTACHMENT)
7101 {
7102 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
7103 }
7104 }
7105 if (!m_OldLocation)
7106 {
7107 m_OldLocation = new InventoryLocation;
7108 }
7109 m_OldLocation.Copy(oldLoc);
7110 }
7111 else
7112 {
7113 if (m_OldLocation)
7114 {
7115 m_OldLocation.Reset();
7116 }
7117 }
7118
7120 }
7121 else
7122 {
7123 if (new_player)
7124 {
7125 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
7126 if (res_index >= 0)
7127 {
7128 InventoryLocation il = new InventoryLocation;
7129 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
7130 ItemBase it = ItemBase.Cast(il.GetItem());
7131 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
7132 int rel_type = il.GetType();
7133 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
7134 {
7135 il.GetParent().GetOnReleaseLock().Invoke(it);
7136 }
7137 else if (rel_type == InventoryLocationType.ATTACHMENT)
7138 {
7139 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
7140 }
7141 //it.GetOnReleaseLock().Invoke(it);
7142 }
7143 }
7144 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
7145 {
7146 //ThrowPhysically(old_player, vector.Zero);
7147 m_ThrowItemOnDrop = false;
7148 }
7149
7150 if (m_OldLocation)
7151 {
7152 m_OldLocation.Reset();
7153 }
7154 }
7155 }
7156
7157 override void EOnContact(IEntity other, Contact extra)
7158 {
7160 {
7161 int liquidType = -1;
7162 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
7163 if (impactSpeed > 0.0)
7164 {
7165 m_ImpactSpeed = impactSpeed;
7166 #ifndef SERVER
7167 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
7168 #else
7169 m_WantPlayImpactSound = true;
7170 SetSynchDirty();
7171 #endif
7172 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
7173 }
7174 }
7175
7176 #ifdef SERVER
7177 if (GetCompEM() && GetCompEM().IsPlugged())
7178 {
7179 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
7180 GetCompEM().UnplugThis();
7181 }
7182 #endif
7183 }
7184
7185 void RefreshPhysics();
7186
7187 override void OnCreatePhysics()
7188 {
7190 }
7191
7192 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
7193 {
7194
7195 }
7196 // -------------------------------------------------------------------------
7197 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
7198 {
7199 super.OnItemLocationChanged(old_owner, new_owner);
7200
7201 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
7202 PlayerBase playerNew = PlayerBase.Cast(new_owner);
7203
7204 if (!relatedPlayer && playerNew)
7205 relatedPlayer = playerNew;
7206
7207 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
7208 {
7209 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
7210 if (actionMgr)
7211 {
7212 ActionBase currentAction = actionMgr.GetRunningAction();
7213 if (currentAction)
7214 currentAction.OnItemLocationChanged(this);
7215 }
7216 }
7217
7218 Man ownerPlayerOld = null;
7219 Man ownerPlayerNew = null;
7220
7221 if (old_owner)
7222 {
7223 if (old_owner.IsMan())
7224 {
7225 ownerPlayerOld = Man.Cast(old_owner);
7226 }
7227 else
7228 {
7229 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
7230 }
7231 }
7232 else
7233 {
7234 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
7235 {
7236 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
7237
7238 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
7239 {
7240 GetCompEM().UnplugThis();
7241 }
7242 }
7243 }
7244
7245 if (new_owner)
7246 {
7247 if (new_owner.IsMan())
7248 {
7249 ownerPlayerNew = Man.Cast(new_owner);
7250 }
7251 else
7252 {
7253 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
7254 }
7255 }
7256
7257 if (ownerPlayerOld != ownerPlayerNew)
7258 {
7259 if (ownerPlayerOld)
7260 {
7261 array<EntityAI> subItemsExit = new array<EntityAI>;
7262 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
7263 for (int i = 0; i < subItemsExit.Count(); i++)
7264 {
7265 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
7266 itemExit.OnInventoryExit(ownerPlayerOld);
7267 }
7268 }
7269
7270 if (ownerPlayerNew)
7271 {
7272 array<EntityAI> subItemsEnter = new array<EntityAI>;
7273 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
7274 for (int j = 0; j < subItemsEnter.Count(); j++)
7275 {
7276 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
7277 itemEnter.OnInventoryEnter(ownerPlayerNew);
7278 }
7279 }
7280 }
7281 else if (ownerPlayerNew != null)
7282 {
7283 PlayerBase nplayer;
7284 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
7285 {
7286 array<EntityAI> subItemsUpdate = new array<EntityAI>;
7287 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
7288 for (int k = 0; k < subItemsUpdate.Count(); k++)
7289 {
7290 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
7291 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
7292 }
7293 }
7294 }
7295
7296 if (old_owner)
7297 old_owner.OnChildItemRemoved(this);
7298 if (new_owner)
7299 new_owner.OnChildItemReceived(this);
7300 }
7301
7302 // -------------------------------------------------------------------------------
7303 override void EEDelete(EntityAI parent)
7304 {
7305 super.EEDelete(parent);
7306 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
7307 if (player)
7308 {
7309 OnInventoryExit(player);
7310
7311 if (player.IsAlive())
7312 {
7313 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
7314 if (r_index >= 0)
7315 {
7316 InventoryLocation r_il = new InventoryLocation;
7317 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
7318
7319 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
7320 int r_type = r_il.GetType();
7321 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
7322 {
7323 r_il.GetParent().GetOnReleaseLock().Invoke(this);
7324 }
7325 else if (r_type == InventoryLocationType.ATTACHMENT)
7326 {
7327 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
7328 }
7329
7330 }
7331
7332 player.RemoveQuickBarEntityShortcut(this);
7333 }
7334 }
7335 }
7336 // -------------------------------------------------------------------------------
7337 override void EEKilled(Object killer)
7338 {
7339 super.EEKilled(killer);
7340
7342 if (killer && killer.IsFireplace() && CanExplodeInFire())
7343 {
7344 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
7345 {
7346 if (IsMagazine())
7347 {
7348 if (Magazine.Cast(this).GetAmmoCount() > 0)
7349 {
7350 ExplodeAmmo();
7351 }
7352 }
7353 else
7354 {
7355 Explode(DamageType.EXPLOSION);
7356 }
7357 }
7358 }
7359 }
7360
7361 override void OnWasAttached(EntityAI parent, int slot_id)
7362 {
7363 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
7364
7365 super.OnWasAttached(parent, slot_id);
7366
7367 if (HasQuantity())
7368 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7369
7370 PlayAttachSound(InventorySlots.GetSlotName(slot_id));
7371 }
7372
7373 override void OnWasDetached(EntityAI parent, int slot_id)
7374 {
7375 super.OnWasDetached(parent, slot_id);
7376
7377 if (HasQuantity())
7378 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
7379 }
7380
7381 override string ChangeIntoOnAttach(string slot)
7382 {
7383 int idx;
7384 TStringArray inventory_slots = new TStringArray;
7385 TStringArray attach_types = new TStringArray;
7386
7387 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7388 if (inventory_slots.Count() < 1) //is string
7389 {
7390 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
7391 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
7392 }
7393 else //is array
7394 {
7395 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
7396 }
7397
7398 idx = inventory_slots.Find(slot);
7399 if (idx < 0)
7400 return "";
7401
7402 return attach_types.Get(idx);
7403 }
7404
7405 override string ChangeIntoOnDetach()
7406 {
7407 int idx = -1;
7408 string slot;
7409
7410 TStringArray inventory_slots = new TStringArray;
7411 TStringArray detach_types = new TStringArray;
7412
7413 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
7414 if (inventory_slots.Count() < 1) //is string
7415 {
7416 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
7417 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7418 }
7419 else //is array
7420 {
7421 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
7422 if (detach_types.Count() < 1)
7423 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
7424 }
7425
7426 for (int i = 0; i < inventory_slots.Count(); i++)
7427 {
7428 slot = inventory_slots.Get(i);
7429 }
7430
7431 if (slot != "")
7432 {
7433 if (detach_types.Count() == 1)
7434 idx = 0;
7435 else
7436 idx = inventory_slots.Find(slot);
7437 }
7438 if (idx < 0)
7439 return "";
7440
7441 return detach_types.Get(idx);
7442 }
7443
7444 void ExplodeAmmo()
7445 {
7446 //timer
7447 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7448
7449 //min/max time
7450 float min_time = 1;
7451 float max_time = 3;
7452 float delay = Math.RandomFloat(min_time, max_time);
7453
7454 explode_timer.Run(delay, this, "DoAmmoExplosion");
7455 }
7456
7457 void DoAmmoExplosion()
7458 {
7459 Magazine magazine = Magazine.Cast(this);
7460 int pop_sounds_count = 6;
7461 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7462
7463 //play sound
7464 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7465 string sound_name = pop_sounds[ sound_idx ];
7466 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
7467
7468 //remove ammo count
7469 magazine.ServerAddAmmoCount(-1);
7470
7471 //if condition then repeat -> ExplodeAmmo
7472 float min_temp_to_explode = 100; //min temperature for item to explode
7473
7474 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7475 {
7476 ExplodeAmmo();
7477 }
7478 }
7479
7480 // -------------------------------------------------------------------------------
7481 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7482 {
7483 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7484
7485 const int CHANCE_DAMAGE_CARGO = 4;
7486 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7487 const int CHANCE_DAMAGE_NOTHING = 2;
7488
7489 if (IsClothing() || IsContainer() || IsItemTent())
7490 {
7491 float dmg = damageResult.GetDamage("","Health") * -0.5;
7492 int chances;
7493 int rnd;
7494
7495 if (GetInventory().GetCargo())
7496 {
7497 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7498 rnd = Math.RandomInt(0,chances);
7499
7500 if (rnd < CHANCE_DAMAGE_CARGO)
7501 {
7502 DamageItemInCargo(dmg);
7503 }
7504 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7505 {
7507 }
7508 }
7509 else
7510 {
7511 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7512 rnd = Math.RandomInt(0,chances);
7513
7514 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7515 {
7517 }
7518 }
7519 }
7520 }
7521
7522 bool DamageItemInCargo(float damage)
7523 {
7524 if (GetInventory().GetCargo())
7525 {
7526 int item_count = GetInventory().GetCargo().GetItemCount();
7527 if (item_count > 0)
7528 {
7529 int random_pick = Math.RandomInt(0, item_count);
7530 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
7531 if (!item.IsExplosive())
7532 {
7533 item.AddHealth("","",damage);
7534 return true;
7535 }
7536 }
7537 }
7538 return false;
7539 }
7540
7541 bool DamageItemAttachments(float damage)
7542 {
7543 int attachment_count = GetInventory().AttachmentCount();
7544 if (attachment_count > 0)
7545 {
7546 int random_pick = Math.RandomInt(0, attachment_count);
7547 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
7548 if (!attachment.IsExplosive())
7549 {
7550 attachment.AddHealth("","",damage);
7551 return true;
7552 }
7553 }
7554 return false;
7555 }
7556
7557 override bool IsSplitable()
7558 {
7559 return m_CanThisBeSplit;
7560 }
7561 //----------------
7562 override bool CanBeSplit()
7563 {
7564 if (IsSplitable() && (GetQuantity() > 1))
7565 return GetInventory().CanRemoveEntity();
7566
7567 return false;
7568 }
7569
7570 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7571 {
7572 if (!CanBeSplit())
7573 return;
7574
7575 if (GetGame().IsClient())
7576 {
7577 if (ScriptInputUserData.CanStoreInputUserData())
7578 {
7579 ScriptInputUserData ctx = new ScriptInputUserData;
7581 ctx.Write(1);
7582 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7583 ctx.Write(i1);
7584 ctx.Write(destination_entity);
7585 ctx.Write(true);
7586 ctx.Write(slot_id);
7587 ctx.Send();
7588 }
7589 }
7590 else if (!GetGame().IsMultiplayer())
7591 {
7592 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
7593 }
7594 }
7595
7596 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7597 {
7598 if (!CanBeSplit())
7599 return;
7600
7601 float split_quantity_new;
7602 ref ItemBase new_item;
7603 float quantity = GetQuantity();
7604 float stack_max = GetTargetQuantityMax(slot_id);
7605 InventoryLocation loc = new InventoryLocation;
7606
7607 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7608 {
7609 if (stack_max <= GetQuantity())
7610 split_quantity_new = stack_max;
7611 else
7612 split_quantity_new = GetQuantity();
7613
7614 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7615 if (new_item)
7616 {
7617 new_item.SetResultOfSplit(true);
7618 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7619 AddQuantity(-split_quantity_new);
7620 new_item.SetQuantity(split_quantity_new);
7621 }
7622 }
7623 else if (destination_entity && slot_id == -1)
7624 {
7625 if (quantity > stack_max)
7626 split_quantity_new = stack_max;
7627 else
7628 split_quantity_new = quantity;
7629
7630 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7631 {
7632 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7633 new_item = ItemBase.Cast(o);
7634 }
7635
7636 if (new_item)
7637 {
7638 new_item.SetResultOfSplit(true);
7639 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7640 AddQuantity(-split_quantity_new);
7641 new_item.SetQuantity(split_quantity_new);
7642 }
7643 }
7644 else
7645 {
7646 if (stack_max != 0)
7647 {
7648 if (stack_max < GetQuantity())
7649 {
7650 split_quantity_new = GetQuantity() - stack_max;
7651 }
7652
7653 if (split_quantity_new == 0)
7654 {
7655 if (!GetGame().IsMultiplayer())
7656 player.PhysicalPredictiveDropItem(this);
7657 else
7658 player.ServerDropEntity(this);
7659 return;
7660 }
7661
7662 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7663
7664 if (new_item)
7665 {
7666 new_item.SetResultOfSplit(true);
7667 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7668 SetQuantity(split_quantity_new);
7669 new_item.SetQuantity(stack_max);
7670 new_item.PlaceOnSurface();
7671 }
7672 }
7673 }
7674 }
7675
7676 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7677 {
7678 if (!CanBeSplit())
7679 return;
7680
7681 float split_quantity_new;
7682 ref ItemBase new_item;
7683 float quantity = GetQuantity();
7684 float stack_max = GetTargetQuantityMax(slot_id);
7685 InventoryLocation loc = new InventoryLocation;
7686
7687 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7688 {
7689 if (stack_max <= GetQuantity())
7690 split_quantity_new = stack_max;
7691 else
7692 split_quantity_new = GetQuantity();
7693
7694 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7695 if (new_item)
7696 {
7697 new_item.SetResultOfSplit(true);
7698 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7699 AddQuantity(-split_quantity_new);
7700 new_item.SetQuantity(split_quantity_new);
7701 }
7702 }
7703 else if (destination_entity && slot_id == -1)
7704 {
7705 if (quantity > stack_max)
7706 split_quantity_new = stack_max;
7707 else
7708 split_quantity_new = quantity;
7709
7710 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7711 {
7712 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7713 new_item = ItemBase.Cast(o);
7714 }
7715
7716 if (new_item)
7717 {
7718 new_item.SetResultOfSplit(true);
7719 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7720 AddQuantity(-split_quantity_new);
7721 new_item.SetQuantity(split_quantity_new);
7722 }
7723 }
7724 else
7725 {
7726 if (stack_max != 0)
7727 {
7728 if (stack_max < GetQuantity())
7729 {
7730 split_quantity_new = GetQuantity() - stack_max;
7731 }
7732
7733 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7734
7735 if (new_item)
7736 {
7737 new_item.SetResultOfSplit(true);
7738 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7739 SetQuantity(split_quantity_new);
7740 new_item.SetQuantity(stack_max);
7741 new_item.PlaceOnSurface();
7742 }
7743 }
7744 }
7745 }
7746
7747 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7748 {
7749 if (!CanBeSplit())
7750 return;
7751
7752 if (GetGame().IsClient())
7753 {
7754 if (ScriptInputUserData.CanStoreInputUserData())
7755 {
7756 ScriptInputUserData ctx = new ScriptInputUserData;
7758 ctx.Write(4);
7759 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7760 ctx.Write(thiz);
7761 dst.WriteToContext(ctx);
7762 ctx.Send();
7763 }
7764 }
7765 else if (!GetGame().IsMultiplayer())
7766 {
7768 }
7769 }
7770
7771 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7772 {
7773 if (!CanBeSplit())
7774 return;
7775
7776 if (GetGame().IsClient())
7777 {
7778 if (ScriptInputUserData.CanStoreInputUserData())
7779 {
7780 ScriptInputUserData ctx = new ScriptInputUserData;
7782 ctx.Write(2);
7783 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7784 ctx.Write(dummy);
7785 ctx.Write(destination_entity);
7786 ctx.Write(true);
7787 ctx.Write(idx);
7788 ctx.Write(row);
7789 ctx.Write(col);
7790 ctx.Send();
7791 }
7792 }
7793 else if (!GetGame().IsMultiplayer())
7794 {
7795 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7796 }
7797 }
7798
7799 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7800 {
7802 }
7803
7804 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7805 {
7806 if (!CanBeSplit())
7807 return this;
7808
7809 float quantity = GetQuantity();
7810 float split_quantity_new;
7811 ItemBase new_item;
7812 if (dst.IsValid())
7813 {
7814 int slot_id = dst.GetSlot();
7815 float stack_max = GetTargetQuantityMax(slot_id);
7816
7817 if (quantity > stack_max)
7818 split_quantity_new = stack_max;
7819 else
7820 split_quantity_new = quantity;
7821
7822 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7823
7824 if (new_item)
7825 {
7826 new_item.SetResultOfSplit(true);
7827 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7828 AddQuantity(-split_quantity_new);
7829 new_item.SetQuantity(split_quantity_new);
7830 }
7831
7832 return new_item;
7833 }
7834
7835 return null;
7836 }
7837
7838 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7839 {
7840 if (!CanBeSplit())
7841 return;
7842
7843 float quantity = GetQuantity();
7844 float split_quantity_new;
7845 ref ItemBase new_item;
7846 if (destination_entity)
7847 {
7848 float stackable = GetTargetQuantityMax();
7849 if (quantity > stackable)
7850 split_quantity_new = stackable;
7851 else
7852 split_quantity_new = quantity;
7853
7854 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7855 if (new_item)
7856 {
7857 new_item.SetResultOfSplit(true);
7858 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7859 AddQuantity(-split_quantity_new);
7860 new_item.SetQuantity(split_quantity_new);
7861 }
7862 }
7863 }
7864
7865 void SplitIntoStackMaxHandsClient(PlayerBase player)
7866 {
7867 if (!CanBeSplit())
7868 return;
7869
7870 if (GetGame().IsClient())
7871 {
7872 if (ScriptInputUserData.CanStoreInputUserData())
7873 {
7874 ScriptInputUserData ctx = new ScriptInputUserData;
7876 ctx.Write(3);
7877 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7878 ctx.Write(i1);
7879 ItemBase destination_entity = this;
7880 ctx.Write(destination_entity);
7881 ctx.Write(true);
7882 ctx.Write(0);
7883 ctx.Send();
7884 }
7885 }
7886 else if (!GetGame().IsMultiplayer())
7887 {
7888 SplitIntoStackMaxHands(player);
7889 }
7890 }
7891
7892 void SplitIntoStackMaxHands(PlayerBase player)
7893 {
7894 if (!CanBeSplit())
7895 return;
7896
7897 float quantity = GetQuantity();
7898 float split_quantity_new;
7899 ref ItemBase new_item;
7900 if (player)
7901 {
7902 float stackable = GetTargetQuantityMax();
7903 if (quantity > stackable)
7904 split_quantity_new = stackable;
7905 else
7906 split_quantity_new = quantity;
7907
7908 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7909 new_item = ItemBase.Cast(in_hands);
7910 if (new_item)
7911 {
7912 new_item.SetResultOfSplit(true);
7913 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7914 AddQuantity(-split_quantity_new);
7915 new_item.SetQuantity(split_quantity_new);
7916 }
7917 }
7918 }
7919
7920 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7921 {
7922 if (!CanBeSplit())
7923 return;
7924
7925 float quantity = GetQuantity();
7926 float split_quantity_new = Math.Floor(quantity * 0.5);
7927
7928 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7929
7930 if (new_item)
7931 {
7932 if (new_item.GetQuantityMax() < split_quantity_new)
7933 {
7934 split_quantity_new = new_item.GetQuantityMax();
7935 }
7936
7937 new_item.SetResultOfSplit(true);
7938 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7939
7940 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7941 {
7942 AddQuantity(-1);
7943 new_item.SetQuantity(1);
7944 }
7945 else
7946 {
7947 AddQuantity(-split_quantity_new);
7948 new_item.SetQuantity(split_quantity_new);
7949 }
7950 }
7951 }
7952
7953 void SplitItem(PlayerBase player)
7954 {
7955 if (!CanBeSplit())
7956 return;
7957
7958 float quantity = GetQuantity();
7959 float split_quantity_new = Math.Floor(quantity / 2);
7960
7961 InventoryLocation invloc = new InventoryLocation;
7962 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7963
7964 ItemBase new_item;
7965 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7966
7967 if (new_item)
7968 {
7969 if (new_item.GetQuantityMax() < split_quantity_new)
7970 {
7971 split_quantity_new = new_item.GetQuantityMax();
7972 }
7973 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7974 {
7975 AddQuantity(-1);
7976 new_item.SetQuantity(1);
7977 }
7978 else
7979 {
7980 AddQuantity(-split_quantity_new);
7981 new_item.SetQuantity(split_quantity_new);
7982 }
7983 }
7984 }
7985
7987 void OnQuantityChanged(float delta)
7988 {
7989 SetWeightDirty();
7990 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7991
7992 if (parent)
7993 parent.OnAttachmentQuantityChangedEx(this, delta);
7994
7995 if (IsLiquidContainer())
7996 {
7997 if (GetQuantityNormalized() <= 0.0)
7998 {
8000 }
8001 else if (GetLiquidType() == LIQUID_NONE)
8002 {
8003 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
8005 }
8006 }
8007
8008 }
8009
8012 {
8013 // insert code here
8014 }
8015
8017 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
8018 {
8020 }
8021
8022 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
8023 {
8024 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
8025
8026 if (GetGame().IsServer())
8027 {
8028 if (newLevel == GameConstants.STATE_RUINED)
8029 {
8031 EntityAI parent = GetHierarchyParent();
8032 if (parent && parent.IsFireplace())
8033 {
8034 CargoBase cargo = GetInventory().GetCargo();
8035 if (cargo)
8036 {
8037 for (int i = 0; i < cargo.GetItemCount(); ++i)
8038 {
8039 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
8040 }
8041 }
8042 }
8043 }
8044
8045 if (IsResultOfSplit())
8046 {
8047 // reset the splitting result flag, return to normal item behavior
8048 SetResultOfSplit(false);
8049 return;
8050 }
8051
8052 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
8053 {
8054 SetCleanness(0);//unclean the item upon damage dealt
8055 }
8056 }
8057 }
8058
8059 // just the split? TODO: verify
8060 override void OnRightClick()
8061 {
8062 super.OnRightClick();
8063
8064 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
8065 {
8066 if (GetGame().IsClient())
8067 {
8068 if (ScriptInputUserData.CanStoreInputUserData())
8069 {
8070 vector m4[4];
8071 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
8072
8073 EntityAI root = GetHierarchyRoot();
8074
8075 InventoryLocation dst = new InventoryLocation;
8076 if (!player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.CARGO, dst))
8077 {
8078 if (root)
8079 {
8080 root.GetTransform(m4);
8081 dst.SetGround(this, m4);
8082 }
8083 else
8084 GetInventory().GetCurrentInventoryLocation(dst);
8085 }
8086 else
8087 {
8088 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
8089 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
8090 this shouldnt cause issues within this scope*/
8091 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(this, dst))
8092 {
8093 if (root)
8094 {
8095 root.GetTransform(m4);
8096 dst.SetGround(this, m4);
8097 }
8098 else
8099 GetInventory().GetCurrentInventoryLocation(dst);
8100 }
8101 else
8102 {
8103 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
8104 }
8105 }
8106
8107 ScriptInputUserData ctx = new ScriptInputUserData;
8109 ctx.Write(4);
8110 ItemBase thiz = this; // @NOTE: workaround for correct serialization
8111 ctx.Write(thiz);
8112 dst.WriteToContext(ctx);
8113 ctx.Write(true); // dummy
8114 ctx.Send();
8115 }
8116 }
8117 else if (!GetGame().IsMultiplayer())
8118 {
8119 SplitItem(PlayerBase.Cast(GetGame().GetPlayer()));
8120 }
8121 }
8122 }
8123
8124 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
8125 {
8126 //TODO: delete check zero quantity check after fix double posts hands fsm events
8127 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
8128 return false;
8129
8130 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
8131 return false;
8132
8133 //can_this_be_combined = ConfigGetBool("canBeSplit");
8135 return false;
8136
8137
8138 Magazine mag = Magazine.Cast(this);
8139 if (mag)
8140 {
8141 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
8142 return false;
8143
8144 if (stack_max_limit)
8145 {
8146 Magazine other_mag = Magazine.Cast(other_item);
8147 if (other_item)
8148 {
8149 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
8150 return false;
8151 }
8152
8153 }
8154 }
8155 else
8156 {
8157 //TODO: delete check zero quantity check after fix double posts hands fsm events
8158 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
8159 return false;
8160
8161 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
8162 return false;
8163 }
8164
8165 PlayerBase player = null;
8166 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
8167 {
8168 if (player.GetInventory().HasAttachment(this))
8169 return false;
8170
8171 if (player.IsItemsToDelete())
8172 return false;
8173 }
8174
8175 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
8176 return false;
8177
8178 int slotID;
8179 string slotName;
8180 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
8181 return false;
8182
8183 return true;
8184 }
8185
8186 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
8187 {
8188 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
8189 }
8190
8191 bool IsResultOfSplit()
8192 {
8193 return m_IsResultOfSplit;
8194 }
8195
8196 void SetResultOfSplit(bool value)
8197 {
8198 m_IsResultOfSplit = value;
8199 }
8200
8201 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
8202 {
8203 return ComputeQuantityUsedEx(other_item, use_stack_max);
8204 }
8205
8206 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
8207 {
8208 float other_item_quantity = other_item.GetQuantity();
8209 float this_free_space;
8210
8211 float stack_max = GetQuantityMax();
8212
8213 this_free_space = stack_max - GetQuantity();
8214
8215 if (other_item_quantity > this_free_space)
8216 {
8217 return this_free_space;
8218 }
8219 else
8220 {
8221 return other_item_quantity;
8222 }
8223 }
8224
8225 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
8226 {
8227 CombineItems(ItemBase.Cast(entity2),use_stack_max);
8228 }
8229
8230 void CombineItems(ItemBase other_item, bool use_stack_max = true)
8231 {
8232 if (!CanBeCombined(other_item, false))
8233 return;
8234
8235 if (!IsMagazine() && other_item)
8236 {
8237 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
8238 if (quantity_used != 0)
8239 {
8240 float hp1 = GetHealth01("","");
8241 float hp2 = other_item.GetHealth01("","");
8242 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
8243 hpResult = hpResult / (GetQuantity() + quantity_used);
8244
8245 hpResult *= GetMaxHealth();
8246 Math.Round(hpResult);
8247 SetHealth("", "Health", hpResult);
8248
8249 AddQuantity(quantity_used);
8250 other_item.AddQuantity(-quantity_used);
8251 }
8252 }
8253 OnCombine(other_item);
8254 }
8255
8256 void OnCombine(ItemBase other_item)
8257 {
8258 #ifdef SERVER
8259 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
8260 GetHierarchyParent().IncreaseLifetimeUp();
8261 #endif
8262 };
8263
8264 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
8265 {
8266 PlayerBase p = PlayerBase.Cast(player);
8267
8268 array<int> recipesIds = p.m_Recipes;
8269 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8270 if (moduleRecipesManager)
8271 {
8272 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
8273 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
8274 }
8275
8276 for (int i = 0;i < recipesIds.Count(); i++)
8277 {
8278 int key = recipesIds.Get(i);
8279 string recipeName = moduleRecipesManager.GetRecipeName(key);
8280 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
8281 }
8282 }
8283
8284 // -------------------------------------------------------------------------
8285 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
8286 {
8287 super.GetDebugActions(outputList);
8288
8289 //quantity
8290 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
8291 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
8292 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
8293 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
8294
8295 //health
8296 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
8297 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
8298 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
8299 //temperature
8300 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
8301 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
8302 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
8303
8304 //wet
8305 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
8306 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
8307
8308 //liquidtype
8309 if (IsLiquidContainer())
8310 {
8311 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
8312 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
8313 }
8314
8315 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
8316 // watch
8317 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
8318 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
8319
8320 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
8321 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
8322 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
8323 }
8324
8325 // -------------------------------------------------------------------------
8326 // -------------------------------------------------------------------------
8327 // -------------------------------------------------------------------------
8328 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
8329 {
8330 super.OnAction(action_id, player, ctx);
8331 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
8332 {
8333 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
8334 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
8335 PlayerBase p = PlayerBase.Cast(player);
8336 if (EActions.RECIPES_RANGE_START < 1000)
8337 {
8338 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
8339 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
8340 }
8341 }
8342 #ifndef SERVER
8343 else if (action_id == EActions.WATCH_PLAYER)
8344 {
8345 PluginDeveloper.SetDeveloperItemClientEx(player);
8346 }
8347 #endif
8348 if (GetGame().IsServer())
8349 {
8350 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
8351 {
8352 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
8353 OnDebugButtonPressServer(id + 1);
8354 }
8355
8356 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
8357 {
8358 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
8359 InsertAgent(agent_id,100);
8360 }
8361
8362 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8363 {
8364 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8365 RemoveAgent(agent_id2);
8366 }
8367
8368 else if (action_id == EActions.ADD_QUANTITY)
8369 {
8370 if (IsMagazine())
8371 {
8372 Magazine mag = Magazine.Cast(this);
8373 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8374 }
8375 else
8376 {
8377 AddQuantity(GetQuantityMax() * 0.2);
8378 }
8379
8380 if (m_EM)
8381 {
8382 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8383 }
8384 //PrintVariables();
8385 }
8386
8387 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8388 {
8389 if (IsMagazine())
8390 {
8391 Magazine mag2 = Magazine.Cast(this);
8392 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8393 }
8394 else
8395 {
8396 AddQuantity(- GetQuantityMax() * 0.2);
8397 }
8398 if (m_EM)
8399 {
8400 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8401 }
8402 //PrintVariables();
8403 }
8404
8405 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8406 {
8407 SetQuantity(0);
8408
8409 if (m_EM)
8410 {
8411 m_EM.SetEnergy(0);
8412 }
8413 }
8414
8415 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8416 {
8418
8419 if (m_EM)
8420 {
8421 m_EM.SetEnergy(m_EM.GetEnergyMax());
8422 }
8423 }
8424
8425 else if (action_id == EActions.ADD_HEALTH)
8426 {
8427 AddHealth("","",GetMaxHealth("","Health")/5);
8428 }
8429 else if (action_id == EActions.REMOVE_HEALTH)
8430 {
8431 AddHealth("","",-GetMaxHealth("","Health")/5);
8432 }
8433 else if (action_id == EActions.DESTROY_HEALTH)
8434 {
8435 SetHealth01("","",0);
8436 }
8437 else if (action_id == EActions.WATCH_ITEM)
8438 {
8440 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8441 #ifdef DEVELOPER
8442 SetDebugDeveloper_item(this);
8443 #endif
8444 }
8445
8446 else if (action_id == EActions.ADD_TEMPERATURE)
8447 {
8448 AddTemperature(20);
8449 //PrintVariables();
8450 }
8451
8452 else if (action_id == EActions.REMOVE_TEMPERATURE)
8453 {
8454 AddTemperature(-20);
8455 //PrintVariables();
8456 }
8457
8458 else if (action_id == EActions.FLIP_FROZEN)
8459 {
8460 SetFrozen(!GetIsFrozen());
8461 //PrintVariables();
8462 }
8463
8464 else if (action_id == EActions.ADD_WETNESS)
8465 {
8466 AddWet(GetWetMax()/5);
8467 //PrintVariables();
8468 }
8469
8470 else if (action_id == EActions.REMOVE_WETNESS)
8471 {
8472 AddWet(-GetWetMax()/5);
8473 //PrintVariables();
8474 }
8475
8476 else if (action_id == EActions.LIQUIDTYPE_UP)
8477 {
8478 int curr_type = GetLiquidType();
8479 SetLiquidType(curr_type * 2);
8480 //AddWet(1);
8481 //PrintVariables();
8482 }
8483
8484 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8485 {
8486 int curr_type2 = GetLiquidType();
8487 SetLiquidType(curr_type2 / 2);
8488 }
8489
8490 else if (action_id == EActions.MAKE_SPECIAL)
8491 {
8492 auto debugParams = DebugSpawnParams.WithPlayer(player);
8493 OnDebugSpawnEx(debugParams);
8494 }
8495
8496 else if (action_id == EActions.DELETE)
8497 {
8498 Delete();
8499 }
8500
8501 }
8502
8503
8504 return false;
8505 }
8506
8507 // -------------------------------------------------------------------------
8508
8509
8512 void OnActivatedByTripWire();
8513
8515 void OnActivatedByItem(notnull ItemBase item);
8516
8517 //----------------------------------------------------------------
8518 //returns true if item is able to explode when put in fire
8519 bool CanExplodeInFire()
8520 {
8521 return false;
8522 }
8523
8524 //----------------------------------------------------------------
8525 bool CanEat()
8526 {
8527 return true;
8528 }
8529
8530 //----------------------------------------------------------------
8531 override bool IsIgnoredByConstruction()
8532 {
8533 return true;
8534 }
8535
8536 //----------------------------------------------------------------
8537 //has FoodStages in config?
8538 bool HasFoodStage()
8539 {
8540 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8541 return GetGame().ConfigIsExisting(config_path);
8542 }
8543
8545 FoodStage GetFoodStage()
8546 {
8547 return null;
8548 }
8549
8550 bool CanBeCooked()
8551 {
8552 return false;
8553 }
8554
8555 bool CanBeCookedOnStick()
8556 {
8557 return false;
8558 }
8559
8561 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8563
8564 //----------------------------------------------------------------
8565 bool CanRepair(ItemBase item_repair_kit)
8566 {
8567 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8568 return module_repairing.CanRepair(this, item_repair_kit);
8569 }
8570
8571 //----------------------------------------------------------------
8572 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8573 {
8574 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8575 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8576 }
8577
8578 //----------------------------------------------------------------
8579 int GetItemSize()
8580 {
8581 /*
8582 vector v_size = this.ConfigGetVector("itemSize");
8583 int v_size_x = v_size[0];
8584 int v_size_y = v_size[1];
8585 int size = v_size_x * v_size_y;
8586 return size;
8587 */
8588
8589 return 1;
8590 }
8591
8592 //----------------------------------------------------------------
8593 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8594 bool CanBeMovedOverride()
8595 {
8596 return m_CanBeMovedOverride;
8597 }
8598
8599 //----------------------------------------------------------------
8600 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8601 void SetCanBeMovedOverride(bool setting)
8602 {
8603 m_CanBeMovedOverride = setting;
8604 }
8605
8606 //----------------------------------------------------------------
8614 void MessageToOwnerStatus(string text)
8615 {
8616 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8617
8618 if (player)
8619 {
8620 player.MessageStatus(text);
8621 }
8622 }
8623
8624 //----------------------------------------------------------------
8632 void MessageToOwnerAction(string text)
8633 {
8634 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8635
8636 if (player)
8637 {
8638 player.MessageAction(text);
8639 }
8640 }
8641
8642 //----------------------------------------------------------------
8650 void MessageToOwnerFriendly(string text)
8651 {
8652 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8653
8654 if (player)
8655 {
8656 player.MessageFriendly(text);
8657 }
8658 }
8659
8660 //----------------------------------------------------------------
8668 void MessageToOwnerImportant(string text)
8669 {
8670 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8671
8672 if (player)
8673 {
8674 player.MessageImportant(text);
8675 }
8676 }
8677
8678 override bool IsItemBase()
8679 {
8680 return true;
8681 }
8682
8683 // Checks if item is of questioned kind
8684 override bool KindOf(string tag)
8685 {
8686 bool found = false;
8687 string item_name = this.GetType();
8688 ref TStringArray item_tag_array = new TStringArray;
8689 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8690
8691 int array_size = item_tag_array.Count();
8692 for (int i = 0; i < array_size; i++)
8693 {
8694 if (item_tag_array.Get(i) == tag)
8695 {
8696 found = true;
8697 break;
8698 }
8699 }
8700 return found;
8701 }
8702
8703
8704 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8705 {
8706 //Debug.Log("OnRPC called");
8707 super.OnRPC(sender, rpc_type,ctx);
8708
8709 //Play soundset for attachment locking (ActionLockAttachment.c)
8710 switch (rpc_type)
8711 {
8712 #ifndef SERVER
8713 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8714 Param2<bool, string> p = new Param2<bool, string>(false, "");
8715
8716 if (!ctx.Read(p))
8717 return;
8718
8719 bool play = p.param1;
8720 string soundSet = p.param2;
8721
8722 if (play)
8723 {
8724 if (m_LockingSound)
8725 {
8727 {
8728 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8729 }
8730 }
8731 else
8732 {
8733 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8734 }
8735 }
8736 else
8737 {
8738 SEffectManager.DestroyEffect(m_LockingSound);
8739 }
8740
8741 break;
8742 #endif
8743
8744 }
8745
8746 if (GetWrittenNoteData())
8747 {
8748 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8749 }
8750 }
8751
8752 //-----------------------------
8753 // VARIABLE MANIPULATION SYSTEM
8754 //-----------------------------
8755 int NameToID(string name)
8756 {
8757 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8758 return plugin.GetID(name);
8759 }
8760
8761 string IDToName(int id)
8762 {
8763 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8764 return plugin.GetName(id);
8765 }
8766
8768 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8769 {
8770 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8771 //read the flags
8772 int varFlags;
8773 if (!ctx.Read(varFlags))
8774 return;
8775
8776 if (varFlags & ItemVariableFlags.FLOAT)
8777 {
8778 ReadVarsFromCTX(ctx);
8779 }
8780 }
8781
8782 override void SerializeNumericalVars(array<float> floats_out)
8783 {
8784 //some variables handled on EntityAI level already!
8785 super.SerializeNumericalVars(floats_out);
8786
8787 // the order of serialization must be the same as the order of de-serialization
8788 //--------------------------------------------
8789 if (IsVariableSet(VARIABLE_QUANTITY))
8790 {
8791 floats_out.Insert(m_VarQuantity);
8792 }
8793 //--------------------------------------------
8794 if (IsVariableSet(VARIABLE_WET))
8795 {
8796 floats_out.Insert(m_VarWet);
8797 }
8798 //--------------------------------------------
8799 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8800 {
8801 floats_out.Insert(m_VarLiquidType);
8802 }
8803 //--------------------------------------------
8804 if (IsVariableSet(VARIABLE_COLOR))
8805 {
8806 floats_out.Insert(m_ColorComponentR);
8807 floats_out.Insert(m_ColorComponentG);
8808 floats_out.Insert(m_ColorComponentB);
8809 floats_out.Insert(m_ColorComponentA);
8810 }
8811 //--------------------------------------------
8812 if (IsVariableSet(VARIABLE_CLEANNESS))
8813 {
8814 floats_out.Insert(m_Cleanness);
8815 }
8816 }
8817
8818 override void DeSerializeNumericalVars(array<float> floats)
8819 {
8820 //some variables handled on EntityAI level already!
8821 super.DeSerializeNumericalVars(floats);
8822
8823 // the order of serialization must be the same as the order of de-serialization
8824 int index = 0;
8825 int mask = Math.Round(floats.Get(index));
8826
8827 index++;
8828 //--------------------------------------------
8829 if (mask & VARIABLE_QUANTITY)
8830 {
8831 if (m_IsStoreLoad)
8832 {
8833 SetStoreLoadedQuantity(floats.Get(index));
8834 }
8835 else
8836 {
8837 float quantity = floats.Get(index);
8838 SetQuantity(quantity, true, false, false, false);
8839 }
8840 index++;
8841 }
8842 //--------------------------------------------
8843 if (mask & VARIABLE_WET)
8844 {
8845 float wet = floats.Get(index);
8846 SetWet(wet);
8847 index++;
8848 }
8849 //--------------------------------------------
8850 if (mask & VARIABLE_LIQUIDTYPE)
8851 {
8852 int liquidtype = Math.Round(floats.Get(index));
8853 SetLiquidType(liquidtype);
8854 index++;
8855 }
8856 //--------------------------------------------
8857 if (mask & VARIABLE_COLOR)
8858 {
8859 m_ColorComponentR = Math.Round(floats.Get(index));
8860 index++;
8861 m_ColorComponentG = Math.Round(floats.Get(index));
8862 index++;
8863 m_ColorComponentB = Math.Round(floats.Get(index));
8864 index++;
8865 m_ColorComponentA = Math.Round(floats.Get(index));
8866 index++;
8867 }
8868 //--------------------------------------------
8869 if (mask & VARIABLE_CLEANNESS)
8870 {
8871 int cleanness = Math.Round(floats.Get(index));
8872 SetCleanness(cleanness);
8873 index++;
8874 }
8875 }
8876
8877 override void WriteVarsToCTX(ParamsWriteContext ctx)
8878 {
8879 super.WriteVarsToCTX(ctx);
8880
8881 //--------------------------------------------
8882 if (IsVariableSet(VARIABLE_QUANTITY))
8883 {
8884 ctx.Write(GetQuantity());
8885 }
8886 //--------------------------------------------
8887 if (IsVariableSet(VARIABLE_WET))
8888 {
8889 ctx.Write(GetWet());
8890 }
8891 //--------------------------------------------
8892 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8893 {
8894 ctx.Write(GetLiquidType());
8895 }
8896 //--------------------------------------------
8897 if (IsVariableSet(VARIABLE_COLOR))
8898 {
8899 int r,g,b,a;
8900 GetColor(r,g,b,a);
8901 ctx.Write(r);
8902 ctx.Write(g);
8903 ctx.Write(b);
8904 ctx.Write(a);
8905 }
8906 //--------------------------------------------
8907 if (IsVariableSet(VARIABLE_CLEANNESS))
8908 {
8909 ctx.Write(GetCleanness());
8910 }
8911 }
8912
8913 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8914 {
8915 if (!super.ReadVarsFromCTX(ctx,version))
8916 return false;
8917
8918 int intValue;
8919 float value;
8920
8921 if (version < 140)
8922 {
8923 if (!ctx.Read(intValue))
8924 return false;
8925
8926 m_VariablesMask = intValue;
8927 }
8928
8929 if (m_VariablesMask & VARIABLE_QUANTITY)
8930 {
8931 if (!ctx.Read(value))
8932 return false;
8933
8934 if (IsStoreLoad())
8935 {
8937 }
8938 else
8939 {
8940 SetQuantity(value, true, false, false, false);
8941 }
8942 }
8943 //--------------------------------------------
8944 if (version < 140)
8945 {
8946 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8947 {
8948 if (!ctx.Read(value))
8949 return false;
8950 SetTemperatureDirect(value);
8951 }
8952 }
8953 //--------------------------------------------
8954 if (m_VariablesMask & VARIABLE_WET)
8955 {
8956 if (!ctx.Read(value))
8957 return false;
8958 SetWet(value);
8959 }
8960 //--------------------------------------------
8961 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8962 {
8963 if (!ctx.Read(intValue))
8964 return false;
8965 SetLiquidType(intValue);
8966 }
8967 //--------------------------------------------
8968 if (m_VariablesMask & VARIABLE_COLOR)
8969 {
8970 int r,g,b,a;
8971 if (!ctx.Read(r))
8972 return false;
8973 if (!ctx.Read(g))
8974 return false;
8975 if (!ctx.Read(b))
8976 return false;
8977 if (!ctx.Read(a))
8978 return false;
8979
8980 SetColor(r,g,b,a);
8981 }
8982 //--------------------------------------------
8983 if (m_VariablesMask & VARIABLE_CLEANNESS)
8984 {
8985 if (!ctx.Read(intValue))
8986 return false;
8987 SetCleanness(intValue);
8988 }
8989 //--------------------------------------------
8990 if (version >= 138 && version < 140)
8991 {
8992 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8993 {
8994 if (!ctx.Read(intValue))
8995 return false;
8996 SetFrozen(intValue);
8997 }
8998 }
8999
9000 return true;
9001 }
9002
9003 //----------------------------------------------------------------
9004 override bool OnStoreLoad(ParamsReadContext ctx, int version)
9005 {
9006 m_IsStoreLoad = true;
9008 {
9009 m_FixDamageSystemInit = true;
9010 }
9011
9012 if (!super.OnStoreLoad(ctx, version))
9013 {
9014 m_IsStoreLoad = false;
9015 return false;
9016 }
9017
9018 if (version >= 114)
9019 {
9020 bool hasQuickBarIndexSaved;
9021
9022 if (!ctx.Read(hasQuickBarIndexSaved))
9023 {
9024 m_IsStoreLoad = false;
9025 return false;
9026 }
9027
9028 if (hasQuickBarIndexSaved)
9029 {
9030 int itmQBIndex;
9031
9032 //Load quickbar item bind
9033 if (!ctx.Read(itmQBIndex))
9034 {
9035 m_IsStoreLoad = false;
9036 return false;
9037 }
9038
9039 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
9040 if (itmQBIndex != -1 && parentPlayer)
9041 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
9042 }
9043 }
9044 else
9045 {
9046 // Backup of how it used to be
9047 PlayerBase player;
9048 int itemQBIndex;
9049 if (version == int.MAX)
9050 {
9051 if (!ctx.Read(itemQBIndex))
9052 {
9053 m_IsStoreLoad = false;
9054 return false;
9055 }
9056 }
9057 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
9058 {
9059 //Load quickbar item bind
9060 if (!ctx.Read(itemQBIndex))
9061 {
9062 m_IsStoreLoad = false;
9063 return false;
9064 }
9065 if (itemQBIndex != -1 && player)
9066 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
9067 }
9068 }
9069
9070 if (version < 140)
9071 {
9072 // variable management system
9073 if (!LoadVariables(ctx, version))
9074 {
9075 m_IsStoreLoad = false;
9076 return false;
9077 }
9078 }
9079
9080 //agent trasmission system
9081 if (!LoadAgents(ctx, version))
9082 {
9083 m_IsStoreLoad = false;
9084 return false;
9085 }
9086 if (version >= 132)
9087 {
9088 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9089 if (raib)
9090 {
9091 if (!raib.OnStoreLoad(ctx,version))
9092 {
9093 m_IsStoreLoad = false;
9094 return false;
9095 }
9096 }
9097 }
9098
9099 m_IsStoreLoad = false;
9100 return true;
9101 }
9102
9103 //----------------------------------------------------------------
9104
9105 override void OnStoreSave(ParamsWriteContext ctx)
9106 {
9107 super.OnStoreSave(ctx);
9108
9109 PlayerBase player;
9110 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
9111 {
9112 ctx.Write(true); // Keep track of if we should actually read this in or not
9113 //Save quickbar item bind
9114 int itemQBIndex = -1;
9115 itemQBIndex = player.FindQuickBarEntityIndex(this);
9116 ctx.Write(itemQBIndex);
9117 }
9118 else
9119 {
9120 ctx.Write(false); // Keep track of if we should actually read this in or not
9121 }
9122
9123 SaveAgents(ctx);//agent trasmission system
9124
9125 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
9126 if (raib)
9127 {
9128 raib.OnStoreSave(ctx);
9129 }
9130 }
9131 //----------------------------------------------------------------
9132
9133 override void AfterStoreLoad()
9134 {
9135 super.AfterStoreLoad();
9136
9138 {
9140 }
9141
9142 if (GetStoreLoadedQuantity() != float.LOWEST)
9143 {
9145 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
9146 }
9147 }
9148
9149 override void EEOnAfterLoad()
9150 {
9151 super.EEOnAfterLoad();
9152
9154 {
9155 m_FixDamageSystemInit = false;
9156 }
9157
9160 }
9161
9162 bool CanBeDisinfected()
9163 {
9164 return false;
9165 }
9166
9167
9168 //----------------------------------------------------------------
9169 override void OnVariablesSynchronized()
9170 {
9171 if (m_Initialized)
9172 {
9173 #ifdef PLATFORM_CONSOLE
9174 //bruteforce it is
9175 if (IsSplitable())
9176 {
9177 UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
9178 if (menu)
9179 {
9180 menu.Refresh();
9181 }
9182 }
9183 #endif
9184 }
9185
9187 {
9188 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9189 m_WantPlayImpactSound = false;
9190 }
9191
9193 {
9194 SetWeightDirty();
9196 }
9197 if (m_VarWet != m_VarWetPrev)
9198 {
9201 }
9202
9203 if (m_SoundSyncPlay != 0)
9204 {
9205 m_ItemSoundHandler.PlayItemSoundClient(m_SoundSyncPlay);
9206 m_SoundSyncPlay = 0;
9207 }
9208 if (m_SoundSyncStop != 0)
9209 {
9210 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
9211 m_SoundSyncStop = 0;
9212 }
9213
9214 super.OnVariablesSynchronized();
9215 }
9216
9217 //------------------------- Quantity
9218 //----------------------------------------------------------------
9220 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
9221 {
9222 if (!IsServerCheck(allow_client))
9223 return false;
9224
9225 if (!HasQuantity())
9226 return false;
9227
9228 float min = GetQuantityMin();
9229 float max = GetQuantityMax();
9230
9231 if (value <= (min + 0.001))
9232 value = min;
9233
9234 if (value == min)
9235 {
9236 if (destroy_config)
9237 {
9238 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
9239 if (dstr)
9240 {
9241 m_VarQuantity = Math.Clamp(value, min, max);
9242 this.Delete();
9243 return true;
9244 }
9245 }
9246 else if (destroy_forced)
9247 {
9248 m_VarQuantity = Math.Clamp(value, min, max);
9249 this.Delete();
9250 return true;
9251 }
9252 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
9253 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
9254 }
9255
9256 float delta = m_VarQuantity;
9257 m_VarQuantity = Math.Clamp(value, min, max);
9258
9259 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
9260 {
9261 delta = m_VarQuantity - delta;
9262
9263 if (delta)
9264 OnQuantityChanged(delta);
9265 }
9266
9267 SetVariableMask(VARIABLE_QUANTITY);
9268
9269 return false;
9270 }
9271
9272 //----------------------------------------------------------------
9274 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
9275 {
9276 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
9277 }
9278 //----------------------------------------------------------------
9279 void SetQuantityMax()
9280 {
9281 float max = GetQuantityMax();
9282 SetQuantity(max);
9283 }
9284
9285 override void SetQuantityToMinimum()
9286 {
9287 float min = GetQuantityMin();
9288 SetQuantity(min);
9289 }
9290 //----------------------------------------------------------------
9292 void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
9293 {
9294 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
9295 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
9296 SetQuantity(result, destroy_config, destroy_forced);
9297 }
9298
9299 //----------------------------------------------------------------
9301 override float GetQuantityNormalized()
9302 {
9303 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
9304 }
9305
9307 {
9308 return GetQuantityNormalized();
9309 }
9310
9311 /*void SetAmmoNormalized(float value)
9312 {
9313 float value_clamped = Math.Clamp(value, 0, 1);
9314 Magazine this_mag = Magazine.Cast(this);
9315 int max_rounds = this_mag.GetAmmoMax();
9316 int result = value * max_rounds;//can the rounded if higher precision is required
9317 this_mag.SetAmmoCount(result);
9318 }*/
9319 //----------------------------------------------------------------
9320 override int GetQuantityMax()
9321 {
9322 int slot = -1;
9323 if (GetInventory())
9324 {
9325 InventoryLocation il = new InventoryLocation;
9326 GetInventory().GetCurrentInventoryLocation(il);
9327 slot = il.GetSlot();
9328 }
9329
9330 return GetTargetQuantityMax(slot);
9331 }
9332
9333 override int GetTargetQuantityMax(int attSlotID = -1)
9334 {
9335 float quantity_max = 0;
9336
9337 if (IsSplitable()) //only stackable/splitable items can check for stack size
9338 {
9339 if (attSlotID != -1)
9340 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
9341
9342 if (quantity_max <= 0)
9343 quantity_max = m_VarStackMax;
9344 }
9345
9346 if (quantity_max <= 0)
9347 quantity_max = m_VarQuantityMax;
9348
9349 return quantity_max;
9350 }
9351 //----------------------------------------------------------------
9352 override int GetQuantityMin()
9353 {
9354 return m_VarQuantityMin;
9355 }
9356 //----------------------------------------------------------------
9357 int GetQuantityInit()
9358 {
9359 return m_VarQuantityInit;
9360 }
9361
9362 //----------------------------------------------------------------
9363 override bool HasQuantity()
9364 {
9365 return !(GetQuantityMax() - GetQuantityMin() == 0);
9366 }
9367
9368 override float GetQuantity()
9369 {
9370 return m_VarQuantity;
9371 }
9372
9373 bool IsFullQuantity()
9374 {
9375 return GetQuantity() >= GetQuantityMax();
9376 }
9377
9378 //Calculates weight of single item without attachments and cargo
9379 override float GetSingleInventoryItemWeightEx()
9380 {
9381 //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
9382 float weightEx = GetWeightEx();//overall weight of the item
9383 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9384 return weightEx - special;
9385 }
9386
9387 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9389 {
9391 }
9392
9393 override protected float GetWeightSpecialized(bool forceRecalc = false)
9394 {
9395 if (IsSplitable()) //quantity determines size of the stack
9396 {
9397 #ifdef DEVELOPER
9398 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9399 {
9400 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9401 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9402 }
9403 #endif
9404
9405 return GetQuantity() * GetConfigWeightModified();
9406 }
9407 else if (HasEnergyManager())// items with energy manager
9408 {
9409 #ifdef DEVELOPER
9410 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9411 {
9412 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9413 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9414 }
9415 #endif
9416 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
9417 }
9418 else//everything else
9419 {
9420 #ifdef DEVELOPER
9421 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9422 {
9423 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9424 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9425 }
9426 #endif
9427 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
9428 }
9429 }
9430
9432 int GetNumberOfItems()
9433 {
9434 int item_count = 0;
9435 ItemBase item;
9436
9437 if (GetInventory().GetCargo() != NULL)
9438 {
9439 item_count = GetInventory().GetCargo().GetItemCount();
9440 }
9441
9442 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
9443 {
9444 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
9445 if (item)
9446 item_count += item.GetNumberOfItems();
9447 }
9448 return item_count;
9449 }
9450
9452 float GetUnitWeight(bool include_wetness = true)
9453 {
9454 float weight = 0;
9455 float wetness = 1;
9456 if (include_wetness)
9457 wetness += GetWet();
9458 if (IsSplitable()) //quantity determines size of the stack
9459 {
9460 weight = wetness * m_ConfigWeight;
9461 }
9462 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9463 {
9464 weight = 1;
9465 }
9466 return weight;
9467 }
9468
9469 //-----------------------------------------------------------------
9470
9471 override void ClearInventory()
9472 {
9473 if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
9474 {
9475 GameInventory inv = GetInventory();
9476 array<EntityAI> items = new array<EntityAI>;
9477 inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
9478 for (int i = 0; i < items.Count(); i++)
9479 {
9480 ItemBase item = ItemBase.Cast(items.Get(i));
9481 if (item)
9482 {
9483 GetGame().ObjectDelete(item);
9484 }
9485 }
9486 }
9487 }
9488
9489 //------------------------- Energy
9490
9491 //----------------------------------------------------------------
9492 float GetEnergy()
9493 {
9494 float energy = 0;
9495 if (HasEnergyManager())
9496 {
9497 energy = GetCompEM().GetEnergy();
9498 }
9499 return energy;
9500 }
9501
9502
9503 override void OnEnergyConsumed()
9504 {
9505 super.OnEnergyConsumed();
9506
9508 }
9509
9510 override void OnEnergyAdded()
9511 {
9512 super.OnEnergyAdded();
9513
9515 }
9516
9517 // Converts energy (from Energy Manager) to quantity, if enabled.
9519 {
9520 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9521 {
9522 if (HasQuantity())
9523 {
9524 float energy_0to1 = GetCompEM().GetEnergy0To1();
9525 SetQuantityNormalized(energy_0to1);
9526 }
9527 }
9528 }
9529
9530 //----------------------------------------------------------------
9531 float GetHeatIsolationInit()
9532 {
9533 return ConfigGetFloat("heatIsolation");
9534 }
9535
9536 float GetHeatIsolation()
9537 {
9538 return m_HeatIsolation;
9539 }
9540
9541 float GetDryingIncrement(string pIncrementName)
9542 {
9543 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9544 if (GetGame().ConfigIsExisting(paramPath))
9545 return GetGame().ConfigGetFloat(paramPath);
9546
9547 return 0.0;
9548 }
9549
9550 float GetSoakingIncrement(string pIncrementName)
9551 {
9552 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9553 if (GetGame().ConfigIsExisting(paramPath))
9554 return GetGame().ConfigGetFloat(paramPath);
9555
9556 return 0.0;
9557 }
9558 //----------------------------------------------------------------
9559 override void SetWet(float value, bool allow_client = false)
9560 {
9561 if (!IsServerCheck(allow_client))
9562 return;
9563
9564 float min = GetWetMin();
9565 float max = GetWetMax();
9566
9567 float previousValue = m_VarWet;
9568
9569 m_VarWet = Math.Clamp(value, min, max);
9570
9571 if (previousValue != m_VarWet)
9572 {
9573 SetVariableMask(VARIABLE_WET);
9574 OnWetChanged(m_VarWet, previousValue);
9575 }
9576 }
9577 //----------------------------------------------------------------
9578 override void AddWet(float value)
9579 {
9580 SetWet(GetWet() + value);
9581 }
9582 //----------------------------------------------------------------
9583 override void SetWetMax()
9584 {
9586 }
9587 //----------------------------------------------------------------
9588 override float GetWet()
9589 {
9590 return m_VarWet;
9591 }
9592 //----------------------------------------------------------------
9593 override float GetWetMax()
9594 {
9595 return m_VarWetMax;
9596 }
9597 //----------------------------------------------------------------
9598 override float GetWetMin()
9599 {
9600 return m_VarWetMin;
9601 }
9602 //----------------------------------------------------------------
9603 override float GetWetInit()
9604 {
9605 return m_VarWetInit;
9606 }
9607 //----------------------------------------------------------------
9608 override void OnWetChanged(float newVal, float oldVal)
9609 {
9610 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9611 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9612 if (newLevel != oldLevel)
9613 {
9614 OnWetLevelChanged(newLevel,oldLevel);
9615 }
9616 }
9617
9618 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9619 {
9620 SetWeightDirty();
9621 }
9622
9623 override EWetnessLevel GetWetLevel()
9624 {
9625 return GetWetLevelInternal(m_VarWet);
9626 }
9627
9628 //----------------------------------------------------------------
9629
9630 override void SetStoreLoad(bool value)
9631 {
9632 m_IsStoreLoad = value;
9633 }
9634
9635 override bool IsStoreLoad()
9636 {
9637 return m_IsStoreLoad;
9638 }
9639
9640 override void SetStoreLoadedQuantity(float value)
9641 {
9642 m_StoreLoadedQuantity = value;
9643 }
9644
9645 override float GetStoreLoadedQuantity()
9646 {
9647 return m_StoreLoadedQuantity;
9648 }
9649
9650 //----------------------------------------------------------------
9651
9652 float GetItemModelLength()
9653 {
9654 if (ConfigIsExisting("itemModelLength"))
9655 {
9656 return ConfigGetFloat("itemModelLength");
9657 }
9658 return 0;
9659 }
9660
9661 float GetItemAttachOffset()
9662 {
9663 if (ConfigIsExisting("itemAttachOffset"))
9664 {
9665 return ConfigGetFloat("itemAttachOffset");
9666 }
9667 return 0;
9668 }
9669
9670 override void SetCleanness(int value, bool allow_client = false)
9671 {
9672 if (!IsServerCheck(allow_client))
9673 return;
9674
9675 int previousValue = m_Cleanness;
9676
9677 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9678
9679 if (previousValue != m_Cleanness)
9680 SetVariableMask(VARIABLE_CLEANNESS);
9681 }
9682
9683 override int GetCleanness()
9684 {
9685 return m_Cleanness;
9686 }
9687
9689 {
9690 return true;
9691 }
9692
9693 //----------------------------------------------------------------
9694 // ATTACHMENT LOCKING
9695 // Getters relevant to generic ActionLockAttachment
9696 int GetLockType()
9697 {
9698 return m_LockType;
9699 }
9700
9701 string GetLockSoundSet()
9702 {
9703 return m_LockSoundSet;
9704 }
9705
9706 //----------------------------------------------------------------
9707 //------------------------- Color
9708 // sets items color variable given color components
9709 override void SetColor(int r, int g, int b, int a)
9710 {
9715 SetVariableMask(VARIABLE_COLOR);
9716 }
9718 override void GetColor(out int r,out int g,out int b,out int a)
9719 {
9724 }
9725
9726 bool IsColorSet()
9727 {
9728 return IsVariableSet(VARIABLE_COLOR);
9729 }
9730
9732 string GetColorString()
9733 {
9734 int r,g,b,a;
9735 GetColor(r,g,b,a);
9736 r = r/255;
9737 g = g/255;
9738 b = b/255;
9739 a = a/255;
9740 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9741 }
9742 //----------------------------------------------------------------
9743 //------------------------- LiquidType
9744
9745 override void SetLiquidType(int value, bool allow_client = false)
9746 {
9747 if (!IsServerCheck(allow_client))
9748 return;
9749
9750 int old = m_VarLiquidType;
9751 m_VarLiquidType = value;
9752 OnLiquidTypeChanged(old,value);
9753 SetVariableMask(VARIABLE_LIQUIDTYPE);
9754 }
9755
9756 int GetLiquidTypeInit()
9757 {
9758 return ConfigGetInt("varLiquidTypeInit");
9759 }
9760
9761 override int GetLiquidType()
9762 {
9763 return m_VarLiquidType;
9764 }
9765
9766 protected void OnLiquidTypeChanged(int oldType, int newType)
9767 {
9768 if (newType == LIQUID_NONE && GetIsFrozen())
9769 SetFrozen(false);
9770 }
9771
9773 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9774 {
9775 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9776 }
9777
9778 // -------------------------------------------------------------------------
9780 void OnInventoryEnter(Man player)
9781 {
9782 PlayerBase nplayer;
9783 if (PlayerBase.CastTo(nplayer, player))
9784 {
9785 m_CanPlayImpactSound = true;
9786 //nplayer.OnItemInventoryEnter(this);
9787 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9788 }
9789 }
9790
9791 // -------------------------------------------------------------------------
9793 void OnInventoryExit(Man player)
9794 {
9795 PlayerBase nplayer;
9796 if (PlayerBase.CastTo(nplayer,player))
9797 {
9798 //nplayer.OnItemInventoryExit(this);
9799 nplayer.SetEnableQuickBarEntityShortcut(this,false);
9800
9801 }
9802
9803 //if (!GetGame().IsDedicatedServer())
9804 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9805
9806
9807 if (HasEnergyManager())
9808 {
9809 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9810 }
9811 }
9812
9813 // ADVANCED PLACEMENT EVENTS
9814 override void OnPlacementStarted(Man player)
9815 {
9816 super.OnPlacementStarted(player);
9817
9818 SetTakeable(false);
9819 }
9820
9821 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9822 {
9823 if (m_AdminLog)
9824 {
9825 m_AdminLog.OnPlacementComplete(player, this);
9826 }
9827
9828 super.OnPlacementComplete(player, position, orientation);
9829 }
9830
9831 //-----------------------------
9832 // AGENT SYSTEM
9833 //-----------------------------
9834 //--------------------------------------------------------------------------
9835 bool ContainsAgent(int agent_id)
9836 {
9837 if (agent_id & m_AttachedAgents)
9838 {
9839 return true;
9840 }
9841 else
9842 {
9843 return false;
9844 }
9845 }
9846
9847 //--------------------------------------------------------------------------
9848 override void RemoveAgent(int agent_id)
9849 {
9850 if (ContainsAgent(agent_id))
9851 {
9852 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9853 }
9854 }
9855
9856 //--------------------------------------------------------------------------
9857 override void RemoveAllAgents()
9858 {
9859 m_AttachedAgents = 0;
9860 }
9861 //--------------------------------------------------------------------------
9862 override void RemoveAllAgentsExcept(int agent_to_keep)
9863 {
9864 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9865 }
9866 // -------------------------------------------------------------------------
9867 override void InsertAgent(int agent, float count = 1)
9868 {
9869 if (count < 1)
9870 return;
9871 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9873 }
9874
9876 void TransferAgents(int agents)
9877 {
9879 }
9880
9881 // -------------------------------------------------------------------------
9882 override int GetAgents()
9883 {
9884 return m_AttachedAgents;
9885 }
9886 //----------------------------------------------------------------------
9887
9888 /*int GetContaminationType()
9889 {
9890 int contamination_type;
9891
9892 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9893 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9894 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9895 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9896
9897 Edible_Base edible = Edible_Base.Cast(this);
9898 int agents = GetAgents();
9899 if (edible)
9900 {
9901 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9902 if (profile)
9903 {
9904 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9905 }
9906 }
9907 if (agents & CONTAMINATED_MASK)
9908 {
9909 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9910 }
9911 if (agents & POISONED_MASK)
9912 {
9913 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9914 }
9915 if (agents & NERVE_GAS_MASK)
9916 {
9917 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9918 }
9919 if (agents & DIRTY_MASK)
9920 {
9921 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9922 }
9923
9924 return agents;
9925 }*/
9926
9927 // -------------------------------------------------------------------------
9928 bool LoadAgents(ParamsReadContext ctx, int version)
9929 {
9930 if (!ctx.Read(m_AttachedAgents))
9931 return false;
9932 return true;
9933 }
9934 // -------------------------------------------------------------------------
9936 {
9937
9939 }
9940 // -------------------------------------------------------------------------
9941
9943 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9944 {
9945 super.CheckForRoofLimited(timeTresholdMS);
9946
9947 float time = GetGame().GetTime();
9948 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9949 {
9950 m_PreviousRoofTestTime = time;
9951 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9952 }
9953 }
9954
9955 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9956 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9957 {
9958 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9959 {
9960 return 0;
9961 }
9962
9963 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9964 {
9965 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9966 if (filter)
9967 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9968 else
9969 return 0;//otherwise return 0 when no filter attached
9970 }
9971
9972 string subclassPath, entryName;
9973
9974 switch (type)
9975 {
9976 case DEF_BIOLOGICAL:
9977 entryName = "biological";
9978 break;
9979 case DEF_CHEMICAL:
9980 entryName = "chemical";
9981 break;
9982 default:
9983 entryName = "biological";
9984 break;
9985 }
9986
9987 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9988
9989 return GetGame().ConfigGetFloat(subclassPath + entryName);
9990 }
9991
9992
9993
9995 override void EEOnCECreate()
9996 {
9997 if (!IsMagazine())
9999
10001 }
10002
10003
10004 //-------------------------
10005 // OPEN/CLOSE USER ACTIONS
10006 //-------------------------
10008 void Open();
10009 void Close();
10010 bool IsOpen()
10011 {
10012 return true;
10013 }
10014
10015 override bool CanDisplayCargo()
10016 {
10017 return IsOpen();
10018 }
10019
10020
10021 // ------------------------------------------------------------
10022 // CONDITIONS
10023 // ------------------------------------------------------------
10024 override bool CanPutInCargo(EntityAI parent)
10025 {
10026 if (parent)
10027 {
10028 if (parent.IsInherited(DayZInfected))
10029 return true;
10030
10031 if (!parent.IsRuined())
10032 return true;
10033 }
10034
10035 return true;
10036 }
10037
10038 override bool CanPutAsAttachment(EntityAI parent)
10039 {
10040 if (!super.CanPutAsAttachment(parent))
10041 {
10042 return false;
10043 }
10044
10045 if (!IsRuined() && !parent.IsRuined())
10046 {
10047 return true;
10048 }
10049
10050 return false;
10051 }
10052
10053 override bool CanReceiveItemIntoCargo(EntityAI item)
10054 {
10055 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10056 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10057 // return false;
10058
10059 return super.CanReceiveItemIntoCargo(item);
10060 }
10061
10062 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
10063 {
10064 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10065 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10066 // return false;
10067
10068 GameInventory attachmentInv = attachment.GetInventory();
10069 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10070 {
10071 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10072 return false;
10073 }
10074
10075 InventoryLocation loc = new InventoryLocation();
10076 attachment.GetInventory().GetCurrentInventoryLocation(loc);
10077 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
10078 return false;
10079
10080 return super.CanReceiveAttachment(attachment, slotId);
10081 }
10082
10083 override bool CanReleaseAttachment(EntityAI attachment)
10084 {
10085 if (!super.CanReleaseAttachment(attachment))
10086 return false;
10087
10088 return GetInventory().AreChildrenAccessible();
10089 }
10090
10091 /*override bool CanLoadAttachment(EntityAI attachment)
10092 {
10093 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
10094 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
10095 // return false;
10096
10097 GameInventory attachmentInv = attachment.GetInventory();
10098 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
10099 {
10100 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
10101 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
10102
10103 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
10104 return false;
10105 }
10106
10107 return super.CanLoadAttachment(attachment);
10108 }*/
10109
10110 // Plays muzzle flash particle effects
10111 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10112 {
10113 int id = muzzle_owner.GetMuzzleID();
10114 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
10115
10116 if (WPOF_array)
10117 {
10118 for (int i = 0; i < WPOF_array.Count(); i++)
10119 {
10120 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
10121
10122 if (WPOF)
10123 {
10124 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
10125 }
10126 }
10127 }
10128 }
10129
10130 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
10131 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10132 {
10133 int id = muzzle_owner.GetMuzzleID();
10134 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
10135
10136 if (WPOBE_array)
10137 {
10138 for (int i = 0; i < WPOBE_array.Count(); i++)
10139 {
10140 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
10141
10142 if (WPOBE)
10143 {
10144 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10145 }
10146 }
10147 }
10148 }
10149
10150 // Plays all weapon overheating particles
10151 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10152 {
10153 int id = muzzle_owner.GetMuzzleID();
10154 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10155
10156 if (WPOOH_array)
10157 {
10158 for (int i = 0; i < WPOOH_array.Count(); i++)
10159 {
10160 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10161
10162 if (WPOOH)
10163 {
10164 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
10165 }
10166 }
10167 }
10168 }
10169
10170 // Updates all weapon overheating particles
10171 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10172 {
10173 int id = muzzle_owner.GetMuzzleID();
10174 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10175
10176 if (WPOOH_array)
10177 {
10178 for (int i = 0; i < WPOOH_array.Count(); i++)
10179 {
10180 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10181
10182 if (WPOOH)
10183 {
10184 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10185 }
10186 }
10187 }
10188 }
10189
10190 // Stops overheating particles
10191 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
10192 {
10193 int id = muzzle_owner.GetMuzzleID();
10194 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
10195
10196 if (WPOOH_array)
10197 {
10198 for (int i = 0; i < WPOOH_array.Count(); i++)
10199 {
10200 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
10201
10202 if (WPOOH)
10203 {
10204 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
10205 }
10206 }
10207 }
10208 }
10209
10210 //----------------------------------------------------------------
10211 //Item Behaviour - unified approach
10212 override bool IsHeavyBehaviour()
10213 {
10214 if (m_ItemBehaviour == 0)
10215 {
10216 return true;
10217 }
10218
10219 return false;
10220 }
10221
10222 override bool IsOneHandedBehaviour()
10223 {
10224 if (m_ItemBehaviour == 1)
10225 {
10226 return true;
10227 }
10228
10229 return false;
10230 }
10231
10232 override bool IsTwoHandedBehaviour()
10233 {
10234 if (m_ItemBehaviour == 2)
10235 {
10236 return true;
10237 }
10238
10239 return false;
10240 }
10241
10242 bool IsDeployable()
10243 {
10244 return false;
10245 }
10246
10248 float GetDeployTime()
10249 {
10250 return UATimeSpent.DEFAULT_DEPLOY;
10251 }
10252
10253
10254 //----------------------------------------------------------------
10255 // Item Targeting (User Actions)
10256 override void SetTakeable(bool pState)
10257 {
10258 m_IsTakeable = pState;
10259 SetSynchDirty();
10260 }
10261
10262 override bool IsTakeable()
10263 {
10264 return m_IsTakeable;
10265 }
10266
10267 // For cases where we want to show object widget which cant be taken to hands
10269 {
10270 return false;
10271 }
10272
10274 protected void PreLoadSoundAttachmentType()
10275 {
10276 string att_type = "None";
10277
10278 if (ConfigIsExisting("soundAttType"))
10279 {
10280 att_type = ConfigGetString("soundAttType");
10281 }
10282
10283 m_SoundAttType = att_type;
10284 }
10285
10286 override string GetAttachmentSoundType()
10287 {
10288 return m_SoundAttType;
10289 }
10290
10291 //----------------------------------------------------------------
10292 //SOUNDS - ItemSoundHandler
10293 //----------------------------------------------------------------
10294
10295 string GetPlaceSoundset(); // played when deploy starts
10296 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
10297 string GetDeploySoundset(); // played when deploy sucessfully finishes
10298
10300 {
10301 if (!m_ItemSoundHandler)
10303
10304 return m_ItemSoundHandler;
10305 }
10306
10307 // override to initialize sounds
10308 protected void InitItemSounds()
10309 {
10310 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty)
10311 return;
10312
10314
10315 if (GetPlaceSoundset() != string.Empty)
10316 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
10317
10318 if (GetDeploySoundset() != string.Empty)
10319 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
10320
10321 SoundParameters params = new SoundParameters();
10322 params.m_Loop = true;
10323 if (GetLoopDeploySoundset() != string.Empty)
10324 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
10325 }
10326
10327 // Start sound using ItemSoundHandler
10328 void StartItemSoundServer(int id)
10329 {
10330 if (!GetGame().IsServer())
10331 return;
10332
10333 m_SoundSyncPlay = id;
10334 SetSynchDirty();
10335
10336 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
10338 }
10339
10340 // Stop sound using ItemSoundHandler
10341 void StopItemSoundServer(int id)
10342 {
10343 if (!GetGame().IsServer())
10344 return;
10345
10346 m_SoundSyncStop = id;
10347 SetSynchDirty();
10348
10349 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10351 }
10352
10353 protected void ClearStartItemSoundServer()
10354 {
10355 m_SoundSyncPlay = 0;
10356 }
10357
10358 protected void ClearStopItemSoundServer()
10359 {
10360 m_SoundSyncStop = 0;
10361 }
10362
10364 void PlayAttachSound(string slot_type)
10365 {
10366 if (!GetGame().IsDedicatedServer())
10367 {
10368 if (ConfigIsExisting("attachSoundSet"))
10369 {
10370 string cfg_path = "";
10371 string soundset = "";
10372 string type_name = GetType();
10373
10374 TStringArray cfg_soundset_array = new TStringArray;
10375 TStringArray cfg_slot_array = new TStringArray;
10376 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10377 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10378
10379 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10380 {
10381 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10382 {
10383 if (cfg_slot_array[i] == slot_type)
10384 {
10385 soundset = cfg_soundset_array[i];
10386 break;
10387 }
10388 }
10389 }
10390
10391 if (soundset != "")
10392 {
10393 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10394 sound.SetAutodestroy(true);
10395 }
10396 }
10397 }
10398 }
10399
10400 void PlayDetachSound(string slot_type)
10401 {
10402 //TODO - evaluate if needed and devise universal config structure if so
10403 }
10404
10405 void OnApply(PlayerBase player);
10406
10408 {
10409 return 1.0;
10410 };
10411 //returns applicable selection
10412 array<string> GetHeadHidingSelection()
10413 {
10415 }
10416
10418 {
10420 }
10421
10422 WrittenNoteData GetWrittenNoteData() {};
10423
10425 {
10426 SetDynamicPhysicsLifeTime(0.01);
10427 m_ItemBeingDroppedPhys = false;
10428 }
10429
10431 {
10432 array<string> zone_names = new array<string>;
10433 GetDamageZones(zone_names);
10434 for (int i = 0; i < zone_names.Count(); i++)
10435 {
10436 SetHealthMax(zone_names.Get(i),"Health");
10437 }
10438 SetHealthMax("","Health");
10439 }
10440
10442 void SetZoneDamageCEInit()
10443 {
10444 float global_health = GetHealth01("","Health");
10445 array<string> zones = new array<string>;
10446 GetDamageZones(zones);
10447 //set damage of all zones to match global health level
10448 for (int i = 0; i < zones.Count(); i++)
10449 {
10450 SetHealth01(zones.Get(i),"Health",global_health);
10451 }
10452 }
10453
10455 bool IsCoverFaceForShave(string slot_name)
10456 {
10457 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10458 }
10459
10460 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10461 {
10462 if (!hasRootAsPlayer)
10463 {
10464 if (refParentIB)
10465 {
10466 // parent is wet
10467 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10468 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10469 // parent has liquid inside
10470 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10471 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10472 // drying
10473 else if (m_VarWet > m_VarWetMin)
10474 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10475 }
10476 else
10477 {
10478 // drying on ground or inside non-itembase (car, ...)
10479 if (m_VarWet > m_VarWetMin)
10480 AddWet(-1 * delta * GetDryingIncrement("ground"));
10481 }
10482 }
10483 }
10484
10485 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10486 {
10488 {
10489 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10490 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10491 {
10492 float heatPermCoef = 1.0;
10493 EntityAI ent = this;
10494 while (ent)
10495 {
10496 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10497 ent = ent.GetHierarchyParent();
10498 }
10499
10500 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10501 }
10502 }
10503 }
10504
10505 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10506 {
10507 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10508 EntityAI parent = GetHierarchyParent();
10509 if (!parent)
10510 {
10511 hasParent = false;
10512 hasRootAsPlayer = false;
10513 }
10514 else
10515 {
10516 hasParent = true;
10517 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10518 refParentIB = ItemBase.Cast(parent);
10519 }
10520 }
10521
10522 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10523 {
10524 // this is stub, implemented on Edible_Base
10525 }
10526
10527 bool CanDecay()
10528 {
10529 // return true used on selected food clases so they can decay
10530 return false;
10531 }
10532
10533 protected bool CanProcessDecay()
10534 {
10535 // this is stub, implemented on Edible_Base class
10536 // used to determine whether it is still necessary for the food to decay
10537 return false;
10538 }
10539
10540 protected bool CanHaveWetness()
10541 {
10542 // return true used on selected items that have a wetness effect
10543 return false;
10544 }
10545
10547 bool CanBeConsumed(ConsumeConditionData data = null)
10548 {
10549 return !GetIsFrozen() && IsOpen();
10550 }
10551
10552 override void ProcessVariables()
10553 {
10554 bool hasParent = false, hasRootAsPlayer = false;
10555 ItemBase refParentIB;
10556
10557 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10558 bool foodDecay = g_Game.IsFoodDecayEnabled();
10559
10560 if (wwtu || foodDecay)
10561 {
10562 bool processWetness = wwtu && CanHaveWetness();
10563 bool processTemperature = wwtu && CanHaveTemperature();
10564 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10565
10566 if (processWetness || processTemperature || processDecay)
10567 {
10568 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10569
10570 if (processWetness)
10571 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10572
10573 if (processTemperature)
10574 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10575
10576 if (processDecay)
10577 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10578 }
10579 }
10580 }
10581
10584 {
10585 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10586 }
10587
10588 override float GetTemperatureFreezeThreshold()
10589 {
10591 return Liquid.GetFreezeThreshold(GetLiquidType());
10592
10593 return super.GetTemperatureFreezeThreshold();
10594 }
10595
10596 override float GetTemperatureThawThreshold()
10597 {
10599 return Liquid.GetThawThreshold(GetLiquidType());
10600
10601 return super.GetTemperatureThawThreshold();
10602 }
10603
10604 override float GetItemOverheatThreshold()
10605 {
10607 return Liquid.GetBoilThreshold(GetLiquidType());
10608
10609 return super.GetItemOverheatThreshold();
10610 }
10611
10612 override float GetTemperatureFreezeTime()
10613 {
10614 if (HasQuantity())
10615 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10616
10617 return super.GetTemperatureFreezeTime();
10618 }
10619
10620 override float GetTemperatureThawTime()
10621 {
10622 if (HasQuantity())
10623 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10624
10625 return super.GetTemperatureThawTime();
10626 }
10627
10629 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10631 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10632
10633 bool IsCargoException4x3(EntityAI item)
10634 {
10635 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10636 }
10637
10639 {
10640 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10641 }
10642
10644 void AddLightSourceItem(ItemBase lightsource)
10645 {
10646 m_LightSourceItem = lightsource;
10647 }
10648
10650 {
10651 m_LightSourceItem = null;
10652 }
10653
10655 {
10656 return m_LightSourceItem;
10657 }
10658
10660 array<int> GetValidFinishers()
10661 {
10662 return null;
10663 }
10664
10666 bool GetActionWidgetOverride(out typename name)
10667 {
10668 return false;
10669 }
10670
10671 bool PairWithDevice(notnull ItemBase otherDevice)
10672 {
10673 if (GetGame().IsServer())
10674 {
10675 ItemBase explosive = otherDevice;
10677 if (!trg)
10678 {
10679 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10680 explosive = this;
10681 }
10682
10683 explosive.PairRemote(trg);
10684 trg.SetControlledDevice(explosive);
10685
10686 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10687 trg.SetPersistentPairID(persistentID);
10688 explosive.SetPersistentPairID(persistentID);
10689
10690 return true;
10691 }
10692 return false;
10693 }
10694
10696 float GetBaitEffectivity()
10697 {
10698 float ret = 1.0;
10699 if (HasQuantity())
10700 ret *= GetQuantityNormalized();
10701 ret *= GetHealth01();
10702
10703 return ret;
10704 }
10705
10706 #ifdef DEVELOPER
10707 override void SetDebugItem()
10708 {
10709 super.SetDebugItem();
10710 _itemBase = this;
10711 }
10712
10713 override string GetDebugText()
10714 {
10715 string text = super.GetDebugText();
10716
10717 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10718 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10719
10720 return text;
10721 }
10722 #endif
10723
10724 bool CanBeUsedForSuicide()
10725 {
10726 return true;
10727 }
10728
10730 //DEPRECATED BELOW
10732 // Backwards compatibility
10733 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10734 {
10735 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10736 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10737 }
10738
10739 // replaced by ItemSoundHandler
10740 protected EffectSound m_SoundDeployFinish;
10741 protected EffectSound m_SoundPlace;
10742 protected EffectSound m_DeployLoopSoundEx;
10743 protected EffectSound m_SoundDeploy;
10744 bool m_IsPlaceSound;
10745 bool m_IsDeploySound;
10747
10748 string GetDeployFinishSoundset();
10749 void PlayDeploySound();
10750 void PlayDeployFinishSound();
10751 void PlayPlaceSound();
10752 void PlayDeployLoopSoundEx();
10753 void StopDeployLoopSoundEx();
10754 void SoundSynchRemoteReset();
10755 void SoundSynchRemote();
10756 bool UsesGlobalDeploy(){return false;}
10757 bool CanPlayDeployLoopSound(){return false;}
10759 bool IsPlaceSound(){return m_IsPlaceSound;}
10760 bool IsDeploySound(){return m_IsDeploySound;}
10761 void SetIsPlaceSound(bool is_place_sound);
10762 void SetIsDeploySound(bool is_deploy_sound);
10763}
10764
10765EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10766{
10767 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10768 if (entity)
10769 {
10770 bool is_item = entity.IsInherited(ItemBase);
10771 if (is_item && full_quantity)
10772 {
10773 ItemBase item = ItemBase.Cast(entity);
10774 item.SetQuantity(item.GetQuantityInit());
10775 }
10776 }
10777 else
10778 {
10779 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10780 return NULL;
10781 }
10782 return entity;
10783}
10784
10785void SetupSpawnedItem(ItemBase item, float health, float quantity)
10786{
10787 if (item)
10788 {
10789 if (health > 0)
10790 item.SetHealth("", "", health);
10791
10792 if (item.CanHaveTemperature())
10793 {
10794 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10795 if (item.CanFreeze())
10796 item.SetFrozen(false);
10797 }
10798
10799 if (item.HasEnergyManager())
10800 {
10801 if (quantity >= 0)
10802 {
10803 item.GetCompEM().SetEnergy0To1(quantity);
10804 }
10805 else
10806 {
10807 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10808 }
10809 }
10810 else if (item.IsMagazine())
10811 {
10812 Magazine mag = Magazine.Cast(item);
10813 if (quantity >= 0)
10814 {
10815 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10816 }
10817 else
10818 {
10819 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10820 }
10821
10822 }
10823 else
10824 {
10825 if (quantity >= 0)
10826 {
10827 item.SetQuantityNormalized(quantity, false);
10828 }
10829 else
10830 {
10831 item.SetQuantity(Math.AbsFloat(quantity));
10832 }
10833
10834 }
10835 }
10836}
10837
10838#ifdef DEVELOPER
10839ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10840#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
Param3 TSelectableActionInfo
EWetnessLevel
Определения EntityAI.c:2
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
const int INPUT_UDT_ITEM_MANIPULATION
Определения _constants.c:8
class LogManager EntityAI
eBleedingSourceType GetType()
Определения BleedingSource.c:63
ItemSuppressor SuppressorBase
Определения InventoryItem.c:7
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
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
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
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool CanHaveTemperature()
Определения FireplaceBase.c:557
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:6308
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5548
bool HidesSelectionBySlot()
Определения ItemBase.c:9203
float m_VarWetMin
Определения ItemBase.c:4809
void SplitItem(PlayerBase player)
Определения ItemBase.c:6739
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9424
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8653
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:8087
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5553
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:8796
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6706
override bool IsHeavyBehaviour()
Определения ItemBase.c:8998
override void SetWetMax()
Определения ItemBase.c:8369
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9241
void ClearStartItemSoundServer()
Определения ItemBase.c:9139
float m_VarWet
Определения ItemBase.c:4806
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9271
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:2
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8648
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4869
bool CanBeMovedOverride()
Определения ItemBase.c:7380
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8345
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4855
override void ProcessVariables()
Определения ItemBase.c:9338
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:4883
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8179
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8714
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8559
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5139
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:4881
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9374
bool m_IsSoundSynchRemote
Определения ItemBase.c:9532
float m_OverheatingShots
Определения ItemBase.c:4876
void StopItemSoundServer(int id)
Определения ItemBase.c:9127
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5568
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5292
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9398
ref array< int > m_CompatibleLocks
Определения ItemBase.c:4893
bool CanBeCooked()
Определения ItemBase.c:7336
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5635
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:4905
bool m_RecipesInitialized
Определения ItemBase.c:4791
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6382
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9382
override void OnEnergyConsumed()
Определения ItemBase.c:8289
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:8078
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:8218
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8409
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8174
ref TIntArray m_InteractActions
Определения ItemBase.c:4857
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7400
float m_VarQuantity
Определения ItemBase.c:4797
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9543
override float GetWetMax()
Определения ItemBase.c:8379
bool CanBeUsedForSuicide()
Определения ItemBase.c:9510
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7011
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5773
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7554
void StartItemSoundServer(int id)
Определения ItemBase.c:9114
void DoAmmoExplosion()
Определения ItemBase.c:6243
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4868
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6557
int GetItemSize()
Определения ItemBase.c:7365
bool m_CanBeMovedOverride
Определения ItemBase.c:4834
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6167
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5360
bool CanDecay()
Определения ItemBase.c:9313
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:8060
void SetQuantityMax()
Определения ItemBase.c:8065
override float GetQuantity()
Определения ItemBase.c:8154
int m_ColorComponentR
Определения ItemBase.c:4846
int m_ShotsToStartOverheating
Определения ItemBase.c:4878
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8394
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5367
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8897
void OnOverheatingDecay()
Определения ItemBase.c:5330
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8327
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4812
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5468
bool UsesGlobalDeploy()
Определения ItemBase.c:9542
int m_ItemBehaviour
Определения ItemBase.c:4827
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:8869
float m_HeatIsolation
Определения ItemBase.c:4822
float m_VarWetInit
Определения ItemBase.c:4808
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5813
void SetCEBasedQuantity()
Определения ItemBase.c:5581
bool m_CanPlayImpactSound
Определения ItemBase.c:4818
override string GetAttachmentSoundType()
Определения ItemBase.c:9072
float GetOverheatingCoef()
Определения ItemBase.c:5387
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9198
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9150
override bool IsStoreLoad()
Определения ItemBase.c:8421
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:6987
bool IsLightSource()
Определения ItemBase.c:5709
bool m_HasQuantityBar
Определения ItemBase.c:4840
void SetResultOfSplit(bool value)
Определения ItemBase.c:6982
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6624
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6797
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5395
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8336
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8977
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8431
int m_LockType
Определения ItemBase.c:4894
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:4899
bool m_CanBeDigged
Определения ItemBase.c:4841
float m_ItemAttachOffset
Определения ItemBase.c:4824
float GetItemModelLength()
Определения ItemBase.c:8438
bool m_ThrowItemOnDrop
Определения ItemBase.c:4832
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7699
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8729
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8322
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7016
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9369
bool CanHaveWetness()
Определения ItemBase.c:9326
int m_CleannessMin
Определения ItemBase.c:4814
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8662
string IDToName(int id)
Определения ItemBase.c:7547
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9333
float GetHeatIsolationInit()
Определения ItemBase.c:8317
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7387
override bool HasQuantity()
Определения ItemBase.c:8149
float m_VarWetPrev
Определения ItemBase.c:4807
int m_SoundSyncStop
Определения ItemBase.c:4901
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9419
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4856
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5477
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5162
int m_VarLiquidType
Определения ItemBase.c:4826
int m_QuickBarBonus
Определения ItemBase.c:4828
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9060
override float GetWetInit()
Определения ItemBase.c:8389
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4820
int m_SoundSyncPlay
Определения ItemBase.c:4900
int m_MaxOverheatingValue
Определения ItemBase.c:4879
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4803
bool m_IsTakeable
Определения ItemBase.c:4831
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4871
string GetLockSoundSet()
Определения ItemBase.c:8487
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8518
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9446
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6803
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4783
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9085
override int GetQuantityMin()
Определения ItemBase.c:8138
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6533
override int GetQuickBarBonus()
Определения ItemBase.c:5047
override void SetTakeable(bool pState)
Определения ItemBase.c:9042
float m_OverheatingDecayInterval
Определения ItemBase.c:4880
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6356
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9291
bool CanProcessDecay()
Определения ItemBase.c:9319
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5558
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9435
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7351
bool can_this_be_combined
Определения ItemBase.c:4836
EffectSound m_SoundDeploy
Определения ItemBase.c:9529
int m_Count
Определения ItemBase.c:4802
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9482
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9034
override bool IsSplitable()
Определения ItemBase.c:6343
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6327
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7663
void ConvertEnergyToQuantity()
Определения ItemBase.c:8304
override void RemoveAllAgents()
Определения ItemBase.c:8643
override void SetQuantityToMinimum()
Определения ItemBase.c:8071
bool m_WantPlayImpactSound
Определения ItemBase.c:4817
override float GetTemperatureThawTime()
Определения ItemBase.c:9406
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4870
int m_ColorComponentG
Определения ItemBase.c:4847
float m_StoreLoadedQuantity
Определения ItemBase.c:4804
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7418
int m_ColorComponentA
Определения ItemBase.c:4849
int m_VarQuantityInit
Определения ItemBase.c:4799
float GetFilterDamageRatio()
Определения ItemBase.c:5462
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8531
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6773
void OnApply(PlayerBase player)
bool m_HideSelectionsBySlot
Определения ItemBase.c:4884
bool IsOverheatingEffectActive()
Определения ItemBase.c:5325
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5742
int GetLiquidContainerMask()
Определения ItemBase.c:5679
ref Timer m_CheckOverheating
Определения ItemBase.c:4877
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:5373
float GetEnergy()
Определения ItemBase.c:8278
bool CanBeDigged()
Определения ItemBase.c:5758
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9452
bool IsNVG()
Определения ItemBase.c:5690
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8238
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9228
bool m_IsDeploySound
Определения ItemBase.c:9531
bool CanEat()
Определения ItemBase.c:7311
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8937
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9008
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9430
bool IsLiquidContainer()
Определения ItemBase.c:5674
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7331
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8165
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8721
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8119
int m_CleannessInit
Определения ItemBase.c:4813
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5457
override int GetAgents()
Определения ItemBase.c:8668
int m_VarQuantityMax
Определения ItemBase.c:4801
override bool IsHologram()
Определения ItemBase.c:5753
float GetItemAttachOffset()
Определения ItemBase.c:8447
bool IsPlaceSound()
Определения ItemBase.c:9545
static int GetDebugActionsMask()
Определения ItemBase.c:5543
override int GetLiquidType()
Определения ItemBase.c:8547
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9308
override bool IsItemBase()
Определения ItemBase.c:7464
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9018
void ExplodeAmmo()
Определения ItemBase.c:6230
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:6972
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8742
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8917
override void OnEnergyAdded()
Определения ItemBase.c:8296
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:5702
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9528
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7604
void StopItemDynamicPhysics()
Определения ItemBase.c:9210
bool HasFoodStage()
Определения ItemBase.c:7324
override void SetStoreLoad(bool value)
Определения ItemBase.c:8416
float GetOverheatingValue()
Определения ItemBase.c:5287
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8621
override void AddWet(float value)
Определения ItemBase.c:8364
bool IsLiquidPresent()
Определения ItemBase.c:5669
bool IsFullQuantity()
Определения ItemBase.c:8159
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:5943
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6678
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6651
int m_CleannessMax
Определения ItemBase.c:4815
float m_VarStackMax
Определения ItemBase.c:4803
ref Timer m_PhysDropTimer
Определения ItemBase.c:4890
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7436
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8426
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4844
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5308
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5623
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7358
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8552
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5354
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8474
bool m_IsOverheatingEffectActive
Определения ItemBase.c:4875
int m_LiquidContainerMask
Определения ItemBase.c:4825
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9246
override int GetCleanness()
Определения ItemBase.c:8469
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9457
bool IsDeploySound()
Определения ItemBase.c:9546
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5563
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:8957
int m_VarQuantityMin
Определения ItemBase.c:4800
void PerformDamageSystemReinit()
Определения ItemBase.c:9216
override void ClearInventory()
Определения ItemBase.c:8257
static int m_LastRegisteredWeaponID
Определения ItemBase.c:4872
ItemBase GetLightSourceItem()
Определения ItemBase.c:9440
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7454
override float GetItemOverheatThreshold()
Определения ItemBase.c:9390
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4837
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7568
void Open()
Implementations only.
Определения CannedFood.c:100
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6590
float m_ItemModelLength
Определения ItemBase.c:4823
bool m_IsHologram
Определения ItemBase.c:4830
static int m_DebugActionsMask
Определения ItemBase.c:4790
void KillAllOverheatingParticles()
Определения ItemBase.c:5423
bool CanBeCookedOnStick()
Определения ItemBase.c:7341
override int GetQuantityMax()
Определения ItemBase.c:8106
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7050
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8512
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8634
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4833
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:8824
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9186
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4784
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9519
override bool IsBeingPlaced()
Определения ItemBase.c:5737
int GetQuantityInit()
Определения ItemBase.c:8143
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:6992
bool IsResultOfSplit()
Определения ItemBase.c:6977
bool m_FixDamageSystemInit
Определения ItemBase.c:4835
float m_ImpactSpeed
Определения ItemBase.c:4819
bool m_IsStoreLoad
Определения ItemBase.c:4838
int GetLiquidTypeInit()
Определения ItemBase.c:8542
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4853
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5610
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6462
int m_AttachedAgents
Определения ItemBase.c:4861
string m_LockSoundSet
Определения ItemBase.c:4896
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5231
float m_VarQuantityPrev
Определения ItemBase.c:4798
bool IsSoundSynchRemote()
Определения ItemBase.c:9544
bool m_CanShowQuantity
Определения ItemBase.c:4839
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Определения ItemBase.c:8781
override void OnRightClick()
Определения ItemBase.c:6846
int m_ColorComponentB
Определения ItemBase.c:4848
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4786
bool IsActionTargetVisible()
Определения ItemBase.c:9054
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:5978
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6267
bool m_IsBeingPlaced
Определения ItemBase.c:4829
int NameToID(string name)
Определения ItemBase.c:7541
void ~ItemBase()
Определения ItemBase.c:5508
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8404
void ClearStopItemSoundServer()
Определения ItemBase.c:9144
override string ChangeIntoOnDetach()
Определения ItemBase.c:6191
float m_VarWetMax
Определения ItemBase.c:4810
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6585
int GetLockType()
Определения ItemBase.c:8482
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9526
override float GetWet()
Определения ItemBase.c:8374
EffectSound m_SoundPlace
Определения ItemBase.c:9527
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8092
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8456
bool m_IsPlaceSound
Определения ItemBase.c:9530
override float GetWetMin()
Определения ItemBase.c:8384
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:4902
override bool KindOf(string tag)
Определения ItemBase.c:7470
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:1321
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:962
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 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 int GetTime()
returns mission time in milliseconds
proto native int ConfigGetType(string path)
Returns type of config value.
AnalyticsManagerClient GetAnalyticsClient()
Определения Game.c:1513
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()
Определения Man.c:44
Определения Building.c:6
Определения constants.c:659
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
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
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 bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:6
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:913
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:149
override void OnWasDetached(EntityAI parent, int slot_id)
Определения InventoryItem.c:920
override void EEOnAfterLoad()
Определения GardenBase.c:187
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()
Определения InventoryItem.c:732
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:1218
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:465
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:472
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:206
override void AfterStoreLoad()
Определения GardenBase.c:182
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1017
override void OnVariablesSynchronized()
Определения GardenBase.c:68
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
Определения InventoryItem.c:912
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:962
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:269
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:988
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1150
override void InitItemSounds()
Определения TentBase.c:810
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:1012
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()
Определения InventoryItem.c:840
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:341
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
Определения InventoryItem.c:731
Определения 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)
Определения 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
Определения constants.c:510
const int DEF_CHEMICAL
Определения constants.c:511
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:685
array< int > TIntArray
Определения EnScript.c:687
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения constants.c:806
const int VARIABLE_LIQUIDTYPE
Определения constants.c:630
const int VARIABLE_CLEANNESS
Определения constants.c:633
const int VARIABLE_COLOR
Определения constants.c:632
const int VARIABLE_TEMPERATURE
Определения constants.c:628
const int VARIABLE_QUANTITY
Определения constants.c:626
const int VARIABLE_WET
Определения constants.c:629
const int LIQUID_NONE
Определения constants.c:527
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения constants.c:451
const int SAT_DEBUG_ACTION
Определения constants.c:452
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
Определения tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
proto native int GetColor()

Используется в Entity::EEItemLocationChanged().