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

◆ OnPlacementStarted()

override void SpawnItemOnLocation::OnPlacementStarted ( Man player)
protected

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

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