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

◆ InsertAgent()

override void SpawnItemOnLocation::InsertAgent ( int agent,
float count = 1 )
protected

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

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

Используется в Bottle_Base::EEOnCECreate(), Edible_Base::HumanSteakMeat(), InventoryItem::OnAction(), Bottle_Base::OnDebugSpawn(), Edible_Base::ProcessDecay() и ManBase::SetBloodyHandsPenalty().