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

◆ SaveAgents()

void SpawnItemOnLocation::SaveAgents ( ParamsWriteContext ctx)
protected

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

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

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