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

◆ EEOnCECreate()

override void SpawnItemOnLocation::EEOnCECreate ( )
protected

Called when entity is being created as new by CE/ Debug.

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

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