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

◆ InsertAgent()

override void SpawnItemOnLocation::InsertAgent ( int agent,
float count = 1 )
protected

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

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

Используется в Bottle_Base::EEOnCECreate(), Edible_Base::HumanSteakMeat(), InventoryItem::OnAction(), Bottle_Base::OnDebugSpawn(), Edible_Base::ProcessDecay() и ManBase::SetBloodyHandsPenalty().