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

◆ CheckForRoofLimited()

override void SpawnItemOnLocation::CheckForRoofLimited ( float timeTresholdMS = 3000)
protected

Roof check for entity, limited by time (anti-spam solution)

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

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

Используется в Cooling(), Heating(), FireplaceBase::IsThisIgnitionSuccessful(), OnItemLocationChanged(), StartFire() и StopFire().