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

◆ OnLiquidTypeChanged()

void SpawnItemOnLocation::OnLiquidTypeChanged ( int oldType,
int newType )
protected

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

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

Используется в InventoryItem::SetLiquidType().