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

◆ GetLockSoundSet()

string SpawnItemOnLocation::GetLockSoundSet ( )
protected

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

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