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

◆ OnMovedInsideCargo()

override void SpawnItemOnLocation::OnMovedInsideCargo ( EntityAI container)
private

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

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