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

◆ OnItemAttachmentSlotChanged()

override void SpawnItemOnLocation::OnItemAttachmentSlotChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
private

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

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