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

◆ ContainsAgent()

bool SpawnItemOnLocation::ContainsAgent ( int agent_id)
protected

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

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

Используется в InventoryItem::RemoveAgent().