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

◆ CanPutInCargo()

override bool SpawnItemOnLocation::CanPutInCargo ( EntityAI parent)
protected

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

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