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

◆ GetLiquidType()

override int SpawnItemOnLocation::GetLiquidType ( )
protected

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

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

Используется в ActionFillBottleBase::ActionCondition(), InventoryItem::GetItemOverheatThreshold(), InventoryItem::GetTemperatureFreezeThreshold(), InventoryItem::GetTemperatureThawThreshold(), InventoryItem::IsLiquidPresent(), InventoryItem::OnAction(), Barrel_ColorBase::OnFreezeStateChangeServer(), OnFreezeStateChangeServer(), InventoryItem::OnQuantityChanged() и InventoryItem::WriteVarsToCTX().