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

◆ OnInventoryExit()

void SpawnItemOnLocation::OnInventoryExit ( Man player)
protected

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

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

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