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

◆ OnInventoryEnter()

void SpawnItemOnLocation::OnInventoryEnter ( Man player)
protected

Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter.

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

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