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

◆ OnPlacementComplete()

override void SpawnItemOnLocation::OnPlacementComplete ( Man player,
vector position = "0 0 0",
vector orientation = "0 0 0" )
protected

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

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