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

◆ SetLiquidType()

override void SpawnItemOnLocation::SetLiquidType ( int value,
bool allow_client = false )
protected

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

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