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

◆ GetLockType()

int SpawnItemOnLocation::GetLockType ( )
protected

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

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