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

◆ EEOnCECreate()

override void SpawnItemOnLocation::EEOnCECreate ( )
protected

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

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

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