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

◆ UpdateQuickbarShortcutVisibility()

void SpawnItemOnLocation::UpdateQuickbarShortcutVisibility ( PlayerBase player)
protected

To be called on moving item within character's inventory; 'player' should never be null.

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

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