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

◆ WriteVarsToCTX()

override void SpawnItemOnLocation::WriteVarsToCTX ( ParamsWriteContext ctx)
protected

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

7888{
7889 override bool CanPutAsAttachment(EntityAI parent)
7890 {
7891 return true;
7892 }
7893};
7894
7896{
7897
7898};
7899
7900//const bool QUANTITY_DEBUG_REMOVE_ME = false;
7901
7902class ItemBase extends InventoryItem
7903{
7907
7909
7910 static int m_DebugActionsMask;
7912 // ============================================
7913 // Variable Manipulation System
7914 // ============================================
7915 // Quantity
7916
7917 float m_VarQuantity;
7918 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
7920 int m_VarQuantityMin;
7921 int m_VarQuantityMax;
7922 int m_Count;
7923 float m_VarStackMax;
7924 float m_StoreLoadedQuantity = float.LOWEST;
7925 // Wet
7926 float m_VarWet;
7927 float m_VarWetPrev;//for client to know wetness changed during synchronization
7928 float m_VarWetInit;
7929 float m_VarWetMin;
7930 float m_VarWetMax;
7931 // Cleanness
7932 int m_Cleanness;
7933 int m_CleannessInit;
7934 int m_CleannessMin;
7935 int m_CleannessMax;
7936 // impact sounds
7938 bool m_CanPlayImpactSound = true;
7939 float m_ImpactSpeed;
7941 //
7942 float m_HeatIsolation;
7943 float m_ItemModelLength;
7944 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
7946 int m_VarLiquidType;
7947 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
7948 int m_QuickBarBonus;
7949 bool m_IsBeingPlaced;
7950 bool m_IsHologram;
7951 bool m_IsTakeable;
7952 bool m_ThrowItemOnDrop;
7955 bool m_FixDamageSystemInit = false; //can be changed on storage version check
7956 bool can_this_be_combined; //Check if item can be combined
7957 bool m_CanThisBeSplit; //Check if item can be split
7958 bool m_IsStoreLoad = false;
7959 bool m_CanShowQuantity;
7960 bool m_HasQuantityBar;
7961 protected bool m_CanBeDigged;
7962 protected bool m_IsResultOfSplit
7963
7964 string m_SoundAttType;
7965 // items color variables
7970 //-------------------------------------------------------
7971
7972 // light source managing
7974
7978
7979 //==============================================
7980 // agent system
7981 private int m_AttachedAgents;
7982
7984 void TransferModifiers(PlayerBase reciever);
7985
7986
7987 // Weapons & suppressors particle effects
7991 ref static map<string, int> m_WeaponTypeToID;
7992 static int m_LastRegisteredWeaponID = 0;
7993
7994 // Overheating effects
7996 float m_OverheatingShots;
7997 ref Timer m_CheckOverheating;
7998 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
7999 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8000 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8001 ref array <ref OverheatingParticle> m_OverheatingParticles;
8002
8004 protected bool m_HideSelectionsBySlot;
8005
8006 // Admin Log
8007 PluginAdminLog m_AdminLog;
8008
8009 // misc
8010 ref Timer m_PhysDropTimer;
8011
8012 // Attachment Locking variables
8013 ref array<int> m_CompatibleLocks;
8014 protected int m_LockType;
8015 protected ref EffectSound m_LockingSound;
8016 protected string m_LockSoundSet;
8017
8018 // ItemSoundHandler variables
8019 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8020 protected int m_SoundSyncPlay; // id for sound to play
8021 protected int m_SoundSyncStop; // id for sound to stop
8022 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8023
8025
8026 //temperature
8027 private float m_TemperaturePerQuantityWeight;
8028
8029 // -------------------------------------------------------------------------
8030 void ItemBase()
8031 {
8032 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8036
8037 if (!g_Game.IsDedicatedServer())
8038 {
8039 if (HasMuzzle())
8040 {
8042
8044 {
8046 }
8047 }
8048
8050 m_ActionsInitialize = false;
8051 }
8052
8053 m_OldLocation = null;
8054
8055 if (g_Game.IsServer())
8056 {
8057 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8058 }
8059
8060 if (ConfigIsExisting("headSelectionsToHide"))
8061 {
8063 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8064 }
8065
8066 m_HideSelectionsBySlot = false;
8067 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8068 {
8069 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8070 }
8071
8072 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8073
8074 m_IsResultOfSplit = false;
8075
8077 }
8078
8079 override void InitItemVariables()
8080 {
8081 super.InitItemVariables();
8082
8083 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8084 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8085 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8086 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8087 m_VarStackMax = ConfigGetFloat("varStackMax");
8088 m_Count = ConfigGetInt("count");
8089
8090 m_CanShowQuantity = ConfigGetBool("quantityShow");
8091 m_HasQuantityBar = ConfigGetBool("quantityBar");
8092
8093 m_CleannessInit = ConfigGetInt("varCleannessInit");
8095 m_CleannessMin = ConfigGetInt("varCleannessMin");
8096 m_CleannessMax = ConfigGetInt("varCleannessMax");
8097
8098 m_WantPlayImpactSound = false;
8099 m_ImpactSpeed = 0.0;
8100
8101 m_VarWetInit = ConfigGetFloat("varWetInit");
8103 m_VarWetMin = ConfigGetFloat("varWetMin");
8104 m_VarWetMax = ConfigGetFloat("varWetMax");
8105
8106 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8107 if (IsLiquidContainer() && GetQuantity() != 0)
8109 m_IsBeingPlaced = false;
8110 m_IsHologram = false;
8111 m_IsTakeable = true;
8112 m_CanBeMovedOverride = false;
8116 m_CanBeDigged = ConfigGetBool("canBeDigged");
8117
8118 m_CompatibleLocks = new array<int>();
8119 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8120 m_LockType = ConfigGetInt("lockType");
8121
8122 //Define if item can be split and set ability to be combined accordingly
8123 m_CanThisBeSplit = false;
8124 can_this_be_combined = false;
8125 if (ConfigIsExisting("canBeSplit"))
8126 {
8127 can_this_be_combined = ConfigGetBool("canBeSplit");
8129 }
8130
8131 m_ItemBehaviour = -1;
8132 if (ConfigIsExisting("itemBehaviour"))
8133 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8134
8135 //RegisterNetSyncVariableInt("m_VariablesMask");
8136 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8137 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8138 RegisterNetSyncVariableInt("m_VarLiquidType");
8139 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8140
8141 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8142 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8143 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8144
8145 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8146 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8147 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8148 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8149
8150 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8151 RegisterNetSyncVariableBool("m_IsTakeable");
8152 RegisterNetSyncVariableBool("m_IsHologram");
8153
8156 {
8157 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8158 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8159 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8160 }
8161
8162 m_LockSoundSet = ConfigGetString("lockSoundSet");
8163
8165 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8166 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8167
8168 m_SoundSyncSlotID = -1;
8169 }
8170
8171 override int GetQuickBarBonus()
8172 {
8173 return m_QuickBarBonus;
8174 }
8175
8176 void InitializeActions()
8177 {
8179 if (!m_InputActionMap)
8180 {
8182 m_InputActionMap = iam;
8183 SetActions();
8185 }
8186 }
8187
8188 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8189 {
8191 {
8192 m_ActionsInitialize = true;
8194 }
8195
8196 actions = m_InputActionMap.Get(action_input_type);
8197 }
8198
8199 void SetActions()
8200 {
8201 AddAction(ActionTakeItem);
8202 AddAction(ActionTakeItemToHands);
8203 AddAction(ActionWorldCraft);
8205 AddAction(ActionAttachWithSwitch);
8206 }
8207
8208 void SetActionAnimOverrides(); // Override action animation for specific item
8209
8210 void AddAction(typename actionName)
8211 {
8212 ActionBase action = ActionManagerBase.GetAction(actionName);
8213
8214 if (!action)
8215 {
8216 Debug.LogError("Action " + actionName + " dosn't exist!");
8217 return;
8218 }
8219
8220 typename ai = action.GetInputType();
8221 if (!ai)
8222 {
8223 m_ActionsInitialize = false;
8224 return;
8225 }
8226
8227 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8228 if (!action_array)
8229 {
8230 action_array = new array<ActionBase_Basic>;
8231 m_InputActionMap.Insert(ai, action_array);
8232 }
8233 if (LogManager.IsActionLogEnable())
8234 {
8235 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8236 }
8237
8238 if (action_array.Find(action) != -1)
8239 {
8240 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8241 }
8242 else
8243 {
8244 action_array.Insert(action);
8245 }
8246 }
8247
8248 void RemoveAction(typename actionName)
8249 {
8250 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8251 ActionBase action = player.GetActionManager().GetAction(actionName);
8252 typename ai = action.GetInputType();
8253 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8254
8255 if (action_array)
8256 {
8257 action_array.RemoveItem(action);
8258 }
8259 }
8260
8261 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8262 // Set -1 for params which should stay in default state
8263 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8264 {
8265 ActionOverrideData overrideData = new ActionOverrideData();
8266 overrideData.m_CommandUID = commandUID;
8267 overrideData.m_CommandUIDProne = commandUIDProne;
8268 overrideData.m_StanceMask = stanceMask;
8269
8270 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8271 if (!actionMap) // create new map of action > overidables map
8272 {
8273 actionMap = new TActionAnimOverrideMap();
8274 m_ItemActionOverrides.Insert(action, actionMap);
8275 }
8276
8277 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8278
8279 }
8280
8281 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8282
8283 ScriptedLightBase GetLight();
8284
8285 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8286 void LoadParticleConfigOnFire(int id)
8287 {
8288 if (!m_OnFireEffect)
8290
8293
8294 string config_to_search = "CfgVehicles";
8295 string muzzle_owner_config;
8296
8297 if (!m_OnFireEffect.Contains(id))
8298 {
8299 if (IsInherited(Weapon))
8300 config_to_search = "CfgWeapons";
8301
8302 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8303
8304 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8305
8306 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
8307
8308 if (config_OnFire_subclass_count > 0)
8309 {
8310 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8311
8312 for (int i = 0; i < config_OnFire_subclass_count; i++)
8313 {
8314 string particle_class = "";
8315 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
8316 string config_OnFire_entry = config_OnFire_class + particle_class;
8317 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8318 WPOF_array.Insert(WPOF);
8319 }
8320
8321
8322 m_OnFireEffect.Insert(id, WPOF_array);
8323 }
8324 }
8325
8326 if (!m_OnBulletCasingEjectEffect.Contains(id))
8327 {
8328 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8329 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8330
8331 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8332
8333 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8334
8335 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8336 {
8337 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8338
8339 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8340 {
8341 string particle_class2 = "";
8342 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8343 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8344 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8345 WPOBE_array.Insert(WPOBE);
8346 }
8347
8348
8349 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8350 }
8351 }
8352 }
8353
8354 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8356 {
8359
8360 if (!m_OnOverheatingEffect.Contains(id))
8361 {
8362 string config_to_search = "CfgVehicles";
8363
8364 if (IsInherited(Weapon))
8365 config_to_search = "CfgWeapons";
8366
8367 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8368 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8369
8370 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8371 {
8372
8373 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8374
8376 {
8377 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8378 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8379 Error(error);
8380 return;
8381 }
8382
8383 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8384 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8385
8386
8387
8388 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8389 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8390
8391 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8392 {
8393 string particle_class = "";
8394 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8395 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8396 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8397
8398 if (entry_type == CT_CLASS)
8399 {
8400 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8401 WPOOH_array.Insert(WPOF);
8402 }
8403 }
8404
8405
8406 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8407 }
8408 }
8409 }
8410
8411 float GetOverheatingValue()
8412 {
8413 return m_OverheatingShots;
8414 }
8415
8416 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8417 {
8418 if (m_MaxOverheatingValue > 0)
8419 {
8421
8422 if (!m_CheckOverheating)
8424
8426 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8427
8428 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8429 }
8430 }
8431
8432 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8433 {
8435 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8436
8438 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8439
8441 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8442
8444 {
8446 }
8447 }
8448
8450 {
8452 }
8453
8454 void OnOverheatingDecay()
8455 {
8456 if (m_MaxOverheatingValue > 0)
8457 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8458 else
8460
8461 if (m_OverheatingShots <= 0)
8462 {
8465 }
8466 else
8467 {
8468 if (!m_CheckOverheating)
8470
8472 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8473 }
8474
8475 CheckOverheating(this, "", this);
8476 }
8477
8478 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8479 {
8481 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8482 }
8483
8484 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8485 {
8487 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8489 }
8490
8491 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8492 {
8494 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8495 }
8496
8497 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8498 {
8500 m_OverheatingParticles = new array<ref OverheatingParticle>;
8501
8502 OverheatingParticle OP = new OverheatingParticle();
8503 OP.RegisterParticle(p);
8504 OP.SetOverheatingLimitMin(min_heat_coef);
8505 OP.SetOverheatingLimitMax(max_heat_coef);
8506 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8507
8508 m_OverheatingParticles.Insert(OP);
8509 }
8510
8511 float GetOverheatingCoef()
8512 {
8513 if (m_MaxOverheatingValue > 0)
8515
8516 return -1;
8517 }
8518
8520 {
8522 {
8523 float overheat_coef = GetOverheatingCoef();
8524 int count = m_OverheatingParticles.Count();
8525
8526 for (int i = count; i > 0; --i)
8527 {
8528 int id = i - 1;
8529 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8530 Particle p = OP.GetParticle();
8531
8532 float overheat_min = OP.GetOverheatingLimitMin();
8533 float overheat_max = OP.GetOverheatingLimitMax();
8534
8535 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8536 {
8537 if (p)
8538 {
8539 p.Stop();
8540 OP.RegisterParticle(null);
8541 }
8542 }
8543 }
8544 }
8545 }
8546
8548 {
8550 {
8551 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8552 {
8553 int id = i - 1;
8554 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8555
8556 if (OP)
8557 {
8558 Particle p = OP.GetParticle();
8559
8560 if (p)
8561 {
8562 p.Stop();
8563 }
8564
8565 delete OP;
8566 }
8567 }
8568
8569 m_OverheatingParticles.Clear();
8571 }
8572 }
8573
8575 float GetInfectionChance(int system = 0, Param param = null)
8576 {
8577 return 0.0;
8578 }
8579
8580
8581 float GetDisinfectQuantity(int system = 0, Param param1 = null)
8582 {
8583 return 250;//default value
8584 }
8585
8586 float GetFilterDamageRatio()
8587 {
8588 return 0;
8589 }
8590
8592 bool HasMuzzle()
8593 {
8594 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
8595 return true;
8596
8597 return false;
8598 }
8599
8601 int GetMuzzleID()
8602 {
8603 if (!m_WeaponTypeToID)
8604 m_WeaponTypeToID = new map<string, int>;
8605
8606 if (m_WeaponTypeToID.Contains(GetType()))
8607 {
8608 return m_WeaponTypeToID.Get(GetType());
8609 }
8610 else
8611 {
8612 // Register new weapon ID
8614 }
8615
8617 }
8618
8625 {
8626 return -1;
8627 }
8628
8629
8630
8631 // -------------------------------------------------------------------------
8632 void ~ItemBase()
8633 {
8634 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
8635 {
8636 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8637 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
8638
8639 if (r_index >= 0)
8640 {
8641 InventoryLocation r_il = new InventoryLocation;
8642 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
8643
8644 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
8645 int r_type = r_il.GetType();
8646 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
8647 {
8648 r_il.GetParent().GetOnReleaseLock().Invoke(this);
8649 }
8650 else if (r_type == InventoryLocationType.ATTACHMENT)
8651 {
8652 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
8653 }
8654
8655 }
8656
8657 player.GetHumanInventory().ClearUserReservedLocation(this);
8658 }
8659
8660 if (m_LockingSound)
8661 SEffectManager.DestroyEffect(m_LockingSound);
8662 }
8663
8664
8665
8666 // -------------------------------------------------------------------------
8667 static int GetDebugActionsMask()
8668 {
8669 return ItemBase.m_DebugActionsMask;
8670 }
8671
8672 static bool HasDebugActionsMask(int mask)
8673 {
8674 return ItemBase.m_DebugActionsMask & mask;
8675 }
8676
8677 static void SetDebugActionsMask(int mask)
8678 {
8679 ItemBase.m_DebugActionsMask = mask;
8680 }
8681
8682 static void AddDebugActionsMask(int mask)
8683 {
8684 ItemBase.m_DebugActionsMask |= mask;
8685 }
8686
8687 static void RemoveDebugActionsMask(int mask)
8688 {
8689 ItemBase.m_DebugActionsMask &= ~mask;
8690 }
8691
8692 static void ToggleDebugActionsMask(int mask)
8693 {
8694 if (HasDebugActionsMask(mask))
8695 {
8697 }
8698 else
8699 {
8700 AddDebugActionsMask(mask);
8701 }
8702 }
8703
8704 // -------------------------------------------------------------------------
8705 void SetCEBasedQuantity()
8706 {
8707 if (GetEconomyProfile())
8708 {
8709 float q_max = GetEconomyProfile().GetQuantityMax();
8710 if (q_max > 0)
8711 {
8712 float q_min = GetEconomyProfile().GetQuantityMin();
8713 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
8714
8715 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
8716 {
8717 ComponentEnergyManager comp = GetCompEM();
8718 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
8719 {
8720 comp.SetEnergy0To1(quantity_randomized);
8721 }
8722 }
8723 else if (HasQuantity())
8724 {
8725 SetQuantityNormalized(quantity_randomized, false);
8726 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
8727 }
8728
8729 }
8730 }
8731 }
8732
8734 void LockToParent()
8735 {
8736 EntityAI parent = GetHierarchyParent();
8737
8738 if (parent)
8739 {
8740 InventoryLocation inventory_location_to_lock = new InventoryLocation;
8741 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
8742 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
8743 }
8744 }
8745
8747 void UnlockFromParent()
8748 {
8749 EntityAI parent = GetHierarchyParent();
8750
8751 if (parent)
8752 {
8753 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
8754 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
8755 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
8756 }
8757 }
8758
8759 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
8760 {
8761 /*
8762 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
8763 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
8764 */
8765 ItemBase item2 = ItemBase.Cast(entity2);
8766
8767 if (g_Game.IsClient())
8768 {
8769 if (ScriptInputUserData.CanStoreInputUserData())
8770 {
8771 ScriptInputUserData ctx = new ScriptInputUserData;
8773 ctx.Write(-1);
8774 ItemBase i1 = this; // @NOTE: workaround for correct serialization
8775 ctx.Write(i1);
8776 ctx.Write(item2);
8777 ctx.Write(use_stack_max);
8778 ctx.Write(-1);
8779 ctx.Send();
8780
8781 if (IsCombineAll(item2, use_stack_max))
8782 {
8783 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
8784 }
8785 }
8786 }
8787 else if (!g_Game.IsMultiplayer())
8788 {
8789 CombineItems(item2, use_stack_max);
8790 }
8791 }
8792
8793 bool IsLiquidPresent()
8794 {
8795 return (GetLiquidType() != 0 && HasQuantity());
8796 }
8797
8798 bool IsLiquidContainer()
8799 {
8800 return m_LiquidContainerMask != 0;
8801 }
8802
8804 {
8805 return m_LiquidContainerMask;
8806 }
8807
8808 bool IsBloodContainer()
8809 {
8810 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
8811 return false;
8812 }
8813
8814 bool IsNVG()
8815 {
8816 return false;
8817 }
8818
8821 bool IsExplosive()
8822 {
8823 return false;
8824 }
8825
8827 {
8828 return "";
8829 }
8830
8832
8833 bool IsLightSource()
8834 {
8835 return false;
8836 }
8837
8839 {
8840 return true;
8841 }
8842
8843 //--- ACTION CONDITIONS
8844 //direction
8845 bool IsFacingPlayer(PlayerBase player, string selection)
8846 {
8847 return true;
8848 }
8849
8850 bool IsPlayerInside(PlayerBase player, string selection)
8851 {
8852 return true;
8853 }
8854
8855 override bool CanObstruct()
8856 {
8857 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8858 return !player || !IsPlayerInside(player, "");
8859 }
8860
8861 override bool IsBeingPlaced()
8862 {
8863 return m_IsBeingPlaced;
8864 }
8865
8866 void SetIsBeingPlaced(bool is_being_placed)
8867 {
8868 m_IsBeingPlaced = is_being_placed;
8869 if (!is_being_placed)
8871 SetSynchDirty();
8872 }
8873
8874 //server-side
8875 void OnEndPlacement() {}
8876
8877 override bool IsHologram()
8878 {
8879 return m_IsHologram;
8880 }
8881
8882 bool CanBeDigged()
8883 {
8884 return m_CanBeDigged;
8885 }
8886
8888 {
8889 return 1;
8890 }
8891
8892 bool CanMakeGardenplot()
8893 {
8894 return false;
8895 }
8896
8897 void SetIsHologram(bool is_hologram)
8898 {
8899 m_IsHologram = is_hologram;
8900 SetSynchDirty();
8901 }
8902 /*
8903 protected float GetNutritionalEnergy()
8904 {
8905 Edible_Base edible = Edible_Base.Cast(this);
8906 return edible.GetFoodEnergy();
8907 }
8908
8909 protected float GetNutritionalWaterContent()
8910 {
8911 Edible_Base edible = Edible_Base.Cast(this);
8912 return edible.GetFoodWater();
8913 }
8914
8915 protected float GetNutritionalIndex()
8916 {
8917 Edible_Base edible = Edible_Base.Cast(this);
8918 return edible.GetFoodNutritionalIndex();
8919 }
8920
8921 protected float GetNutritionalFullnessIndex()
8922 {
8923 Edible_Base edible = Edible_Base.Cast(this);
8924 return edible.GetFoodTotalVolume();
8925 }
8926
8927 protected float GetNutritionalToxicity()
8928 {
8929 Edible_Base edible = Edible_Base.Cast(this);
8930 return edible.GetFoodToxicity();
8931
8932 }
8933 */
8934
8935
8936 // -------------------------------------------------------------------------
8937 override void OnMovedInsideCargo(EntityAI container)
8938 {
8939 super.OnMovedInsideCargo(container);
8940
8941 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
8942 }
8943
8944 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
8945 {
8946 super.EEItemLocationChanged(oldLoc, newLoc);
8947
8948 PlayerBase newPlayer = null;
8949 PlayerBase oldPlayer = null;
8950
8951 if (newLoc.GetParent())
8952 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
8953
8954 if (oldLoc.GetParent())
8955 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
8956
8957 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
8958 {
8959 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
8960
8961 if (rIndex >= 0)
8962 {
8963 InventoryLocation rIl = new InventoryLocation;
8964 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
8965
8966 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
8967 int rType = rIl.GetType();
8968 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
8969 {
8970 rIl.GetParent().GetOnReleaseLock().Invoke(this);
8971 }
8972 else if (rType == InventoryLocationType.ATTACHMENT)
8973 {
8974 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
8975 }
8976
8977 }
8978 }
8979
8980 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
8981 {
8982 if (newPlayer)
8983 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
8984
8985 if (newPlayer == oldPlayer)
8986 {
8987 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
8988 {
8989 if (oldLoc.GetType() == InventoryLocationType.CARGO)
8990 {
8991 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
8992 {
8993 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8994 }
8995 }
8996 else
8997 {
8998 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
8999 }
9000 }
9001
9002 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9003 {
9004 int type = oldLoc.GetType();
9005 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9006 {
9007 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9008 }
9009 else if (type == InventoryLocationType.ATTACHMENT)
9010 {
9011 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9012 }
9013 }
9014 if (!m_OldLocation)
9015 {
9016 m_OldLocation = new InventoryLocation;
9017 }
9018 m_OldLocation.Copy(oldLoc);
9019 }
9020 else
9021 {
9022 if (m_OldLocation)
9023 {
9024 m_OldLocation.Reset();
9025 }
9026 }
9027
9028 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9029 }
9030 else
9031 {
9032 if (newPlayer)
9033 {
9034 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9035 if (resIndex >= 0)
9036 {
9037 InventoryLocation il = new InventoryLocation;
9038 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9039 ItemBase it = ItemBase.Cast(il.GetItem());
9040 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9041 int rel_type = il.GetType();
9042 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9043 {
9044 il.GetParent().GetOnReleaseLock().Invoke(it);
9045 }
9046 else if (rel_type == InventoryLocationType.ATTACHMENT)
9047 {
9048 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9049 }
9050 //it.GetOnReleaseLock().Invoke(it);
9051 }
9052 }
9053 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9054 {
9055 //ThrowPhysically(oldPlayer, vector.Zero);
9056 m_ThrowItemOnDrop = false;
9057 }
9058
9059 if (m_OldLocation)
9060 {
9061 m_OldLocation.Reset();
9062 }
9063 }
9064
9065 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9066 {
9067 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9068 }
9069
9070 if (newLoc.GetType() == InventoryLocationType.TEMP)
9071 {
9072 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9073 }
9074 }
9075
9076 override void EOnContact(IEntity other, Contact extra)
9077 {
9079 {
9080 int liquidType = -1;
9081 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9082 if (impactSpeed > 0.0)
9083 {
9084 m_ImpactSpeed = impactSpeed;
9085 #ifndef SERVER
9086 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9087 #else
9088 m_WantPlayImpactSound = true;
9089 SetSynchDirty();
9090 #endif
9091 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9092 }
9093 }
9094
9095 #ifdef SERVER
9096 if (GetCompEM() && GetCompEM().IsPlugged())
9097 {
9098 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9099 GetCompEM().UnplugThis();
9100 }
9101 #endif
9102 }
9103
9104 void RefreshPhysics();
9105
9106 override void OnCreatePhysics()
9107 {
9109 }
9110
9111 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9112 {
9113
9114 }
9115 // -------------------------------------------------------------------------
9116 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9117 {
9118 super.OnItemLocationChanged(old_owner, new_owner);
9119
9120 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9121 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9122
9123 if (!relatedPlayer && playerNew)
9124 relatedPlayer = playerNew;
9125
9126 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9127 {
9128 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9129 if (actionMgr)
9130 {
9131 ActionBase currentAction = actionMgr.GetRunningAction();
9132 if (currentAction)
9133 currentAction.OnItemLocationChanged(this);
9134 }
9135 }
9136
9137 Man ownerPlayerOld = null;
9138 Man ownerPlayerNew = null;
9139
9140 if (old_owner)
9141 {
9142 if (old_owner.IsMan())
9143 {
9144 ownerPlayerOld = Man.Cast(old_owner);
9145 }
9146 else
9147 {
9148 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9149 }
9150 }
9151 else
9152 {
9153 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9154 {
9155 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9156
9157 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9158 {
9159 GetCompEM().UnplugThis();
9160 }
9161 }
9162 }
9163
9164 if (new_owner)
9165 {
9166 if (new_owner.IsMan())
9167 {
9168 ownerPlayerNew = Man.Cast(new_owner);
9169 }
9170 else
9171 {
9172 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9173 }
9174 }
9175
9176 if (ownerPlayerOld != ownerPlayerNew)
9177 {
9178 if (ownerPlayerOld)
9179 {
9180 array<EntityAI> subItemsExit = new array<EntityAI>;
9181 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9182 for (int i = 0; i < subItemsExit.Count(); i++)
9183 {
9184 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9185 itemExit.OnInventoryExit(ownerPlayerOld);
9186 }
9187 }
9188
9189 if (ownerPlayerNew)
9190 {
9191 array<EntityAI> subItemsEnter = new array<EntityAI>;
9192 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9193 for (int j = 0; j < subItemsEnter.Count(); j++)
9194 {
9195 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9196 itemEnter.OnInventoryEnter(ownerPlayerNew);
9197 }
9198 }
9199 }
9200 else if (ownerPlayerNew != null)
9201 {
9202 PlayerBase nplayer;
9203 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9204 {
9205 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9206 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9207 for (int k = 0; k < subItemsUpdate.Count(); k++)
9208 {
9209 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9210 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9211 }
9212 }
9213 }
9214
9215 if (old_owner)
9216 old_owner.OnChildItemRemoved(this);
9217 if (new_owner)
9218 new_owner.OnChildItemReceived(this);
9219 }
9220
9221 // -------------------------------------------------------------------------------
9222 override void EEDelete(EntityAI parent)
9223 {
9224 super.EEDelete(parent);
9225 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9226 if (player)
9227 {
9228 OnInventoryExit(player);
9229
9230 if (player.IsAlive())
9231 {
9232 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9233 if (r_index >= 0)
9234 {
9235 InventoryLocation r_il = new InventoryLocation;
9236 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9237
9238 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9239 int r_type = r_il.GetType();
9240 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9241 {
9242 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9243 }
9244 else if (r_type == InventoryLocationType.ATTACHMENT)
9245 {
9246 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9247 }
9248
9249 }
9250
9251 player.RemoveQuickBarEntityShortcut(this);
9252 }
9253 }
9254 }
9255 // -------------------------------------------------------------------------------
9256 override void EEKilled(Object killer)
9257 {
9258 super.EEKilled(killer);
9259
9261 if (killer && killer.IsFireplace() && CanExplodeInFire())
9262 {
9263 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9264 {
9265 if (IsMagazine())
9266 {
9267 if (Magazine.Cast(this).GetAmmoCount() > 0)
9268 {
9269 ExplodeAmmo();
9270 }
9271 }
9272 else
9273 {
9274 Explode(DamageType.EXPLOSION);
9275 }
9276 }
9277 }
9278 }
9279
9280 override void OnWasAttached(EntityAI parent, int slot_id)
9281 {
9282 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9283
9284 super.OnWasAttached(parent, slot_id);
9285
9286 if (HasQuantity())
9287 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9288
9289 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9290 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
9291 }
9292
9293 override void OnWasDetached(EntityAI parent, int slot_id)
9294 {
9295 super.OnWasDetached(parent, slot_id);
9296
9297 if (HasQuantity())
9298 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9299
9300 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9301 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
9302 }
9303
9304 override string ChangeIntoOnAttach(string slot)
9305 {
9306 int idx;
9307 TStringArray inventory_slots = new TStringArray;
9308 TStringArray attach_types = new TStringArray;
9309
9310 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9311 if (inventory_slots.Count() < 1) //is string
9312 {
9313 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9314 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9315 }
9316 else //is array
9317 {
9318 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9319 }
9320
9321 idx = inventory_slots.Find(slot);
9322 if (idx < 0)
9323 return "";
9324
9325 return attach_types.Get(idx);
9326 }
9327
9328 override string ChangeIntoOnDetach()
9329 {
9330 int idx = -1;
9331 string slot;
9332
9333 TStringArray inventory_slots = new TStringArray;
9334 TStringArray detach_types = new TStringArray;
9335
9336 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9337 if (inventory_slots.Count() < 1) //is string
9338 {
9339 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9340 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9341 }
9342 else //is array
9343 {
9344 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9345 if (detach_types.Count() < 1)
9346 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9347 }
9348
9349 for (int i = 0; i < inventory_slots.Count(); i++)
9350 {
9351 slot = inventory_slots.Get(i);
9352 }
9353
9354 if (slot != "")
9355 {
9356 if (detach_types.Count() == 1)
9357 idx = 0;
9358 else
9359 idx = inventory_slots.Find(slot);
9360 }
9361 if (idx < 0)
9362 return "";
9363
9364 return detach_types.Get(idx);
9365 }
9366
9367 void ExplodeAmmo()
9368 {
9369 //timer
9370 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9371
9372 //min/max time
9373 float min_time = 1;
9374 float max_time = 3;
9375 float delay = Math.RandomFloat(min_time, max_time);
9376
9377 explode_timer.Run(delay, this, "DoAmmoExplosion");
9378 }
9379
9380 void DoAmmoExplosion()
9381 {
9382 Magazine magazine = Magazine.Cast(this);
9383 int pop_sounds_count = 6;
9384 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9385
9386 //play sound
9387 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9388 string sound_name = pop_sounds[ sound_idx ];
9389 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9390
9391 //remove ammo count
9392 magazine.ServerAddAmmoCount(-1);
9393
9394 //if condition then repeat -> ExplodeAmmo
9395 float min_temp_to_explode = 100; //min temperature for item to explode
9396
9397 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9398 {
9399 ExplodeAmmo();
9400 }
9401 }
9402
9403 // -------------------------------------------------------------------------------
9404 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9405 {
9406 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9407
9408 const int CHANCE_DAMAGE_CARGO = 4;
9409 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9410 const int CHANCE_DAMAGE_NOTHING = 2;
9411
9412 if (IsClothing() || IsContainer() || IsItemTent())
9413 {
9414 float dmg = damageResult.GetDamage("","Health") * -0.5;
9415 int chances;
9416 int rnd;
9417
9418 if (GetInventory().GetCargo())
9419 {
9420 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9421 rnd = Math.RandomInt(0,chances);
9422
9423 if (rnd < CHANCE_DAMAGE_CARGO)
9424 {
9425 DamageItemInCargo(dmg);
9426 }
9427 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9428 {
9430 }
9431 }
9432 else
9433 {
9434 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9435 rnd = Math.RandomInt(0,chances);
9436
9437 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9438 {
9440 }
9441 }
9442 }
9443 }
9444
9445 bool DamageItemInCargo(float damage)
9446 {
9447 CargoBase cargo = GetInventory().GetCargo();
9448 if (cargo)
9449 {
9450 int item_count = cargo.GetItemCount();
9451 if (item_count > 0)
9452 {
9453 int random_pick = Math.RandomInt(0, item_count);
9454 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9455 if (!item.IsExplosive())
9456 {
9457 item.AddHealth("","",damage);
9458 return true;
9459 }
9460 }
9461 }
9462 return false;
9463 }
9464
9465 bool DamageItemAttachments(float damage)
9466 {
9467 GameInventory inventory = GetInventory();
9468 int attachment_count = inventory.AttachmentCount();
9469 if (attachment_count > 0)
9470 {
9471 int random_pick = Math.RandomInt(0, attachment_count);
9472 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
9473 if (!attachment.IsExplosive())
9474 {
9475 attachment.AddHealth("","",damage);
9476 return true;
9477 }
9478 }
9479 return false;
9480 }
9481
9482 override bool IsSplitable()
9483 {
9484 return m_CanThisBeSplit;
9485 }
9486 //----------------
9487 override bool CanBeSplit()
9488 {
9489 if (IsSplitable() && (GetQuantity() > 1))
9490 return GetInventory().CanRemoveEntity();
9491
9492 return false;
9493 }
9494
9495 protected bool ShouldSplitQuantity(float quantity)
9496 {
9497 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9498 if (!IsSplitable())
9499 return false;
9500
9501 // nothing to split?
9502 if (GetQuantity() <= 1)
9503 return false;
9504
9505 // check if we should re-use the item instead of creating a new copy?
9506 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9507 int delta = GetQuantity() - quantity;
9508 if (delta == 0)
9509 return false;
9510
9511 // valid to split
9512 return true;
9513 }
9514
9515 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9516 {
9517 if (g_Game.IsClient())
9518 {
9519 if (ScriptInputUserData.CanStoreInputUserData())
9520 {
9521 ScriptInputUserData ctx = new ScriptInputUserData;
9523 ctx.Write(1);
9524 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9525 ctx.Write(i1);
9526 ctx.Write(destination_entity);
9527 ctx.Write(true);
9528 ctx.Write(slot_id);
9529 ctx.Send();
9530 }
9531 }
9532 else if (!g_Game.IsMultiplayer())
9533 {
9534 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
9535 }
9536 }
9537
9538 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9539 {
9540 float split_quantity_new;
9541 ItemBase new_item;
9542 float quantity = GetQuantity();
9543 float stack_max = GetTargetQuantityMax(slot_id);
9544 InventoryLocation loc = new InventoryLocation;
9545
9546 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9547 {
9548 if (stack_max <= GetQuantity())
9549 split_quantity_new = stack_max;
9550 else
9551 split_quantity_new = GetQuantity();
9552
9553 if (ShouldSplitQuantity(split_quantity_new))
9554 {
9555 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9556 if (new_item)
9557 {
9558 new_item.SetResultOfSplit(true);
9559 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9560 AddQuantity(-split_quantity_new, false, true);
9561 new_item.SetQuantity(split_quantity_new, false, true);
9562 }
9563 }
9564 }
9565 else if (destination_entity && slot_id == -1)
9566 {
9567 if (quantity > stack_max)
9568 split_quantity_new = stack_max;
9569 else
9570 split_quantity_new = quantity;
9571
9572 if (ShouldSplitQuantity(split_quantity_new))
9573 {
9574 GameInventory destinationInventory = destination_entity.GetInventory();
9575 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9576 {
9577 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9578 new_item = ItemBase.Cast(o);
9579 }
9580
9581 if (new_item)
9582 {
9583 new_item.SetResultOfSplit(true);
9584 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9585 AddQuantity(-split_quantity_new, false, true);
9586 new_item.SetQuantity(split_quantity_new, false, true);
9587 }
9588 }
9589 }
9590 else
9591 {
9592 if (stack_max != 0)
9593 {
9594 if (stack_max < GetQuantity())
9595 {
9596 split_quantity_new = GetQuantity() - stack_max;
9597 }
9598
9599 if (split_quantity_new == 0)
9600 {
9601 if (!g_Game.IsMultiplayer())
9602 player.PhysicalPredictiveDropItem(this);
9603 else
9604 player.ServerDropEntity(this);
9605 return;
9606 }
9607
9608 if (ShouldSplitQuantity(split_quantity_new))
9609 {
9610 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9611
9612 if (new_item)
9613 {
9614 new_item.SetResultOfSplit(true);
9615 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9616 SetQuantity(split_quantity_new, false, true);
9617 new_item.SetQuantity(stack_max, false, true);
9618 new_item.PlaceOnSurface();
9619 }
9620 }
9621 }
9622 }
9623 }
9624
9625 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
9626 {
9627 float split_quantity_new;
9628 ItemBase new_item;
9629 float quantity = GetQuantity();
9630 float stack_max = GetTargetQuantityMax(slot_id);
9631 InventoryLocation loc = new InventoryLocation;
9632
9633 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9634 {
9635 if (stack_max <= GetQuantity())
9636 split_quantity_new = stack_max;
9637 else
9638 split_quantity_new = GetQuantity();
9639
9640 if (ShouldSplitQuantity(split_quantity_new))
9641 {
9642 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9643 if (new_item)
9644 {
9645 new_item.SetResultOfSplit(true);
9646 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9647 AddQuantity(-split_quantity_new, false, true);
9648 new_item.SetQuantity(split_quantity_new, false, true);
9649 }
9650 }
9651 }
9652 else if (destination_entity && slot_id == -1)
9653 {
9654 if (quantity > stack_max)
9655 split_quantity_new = stack_max;
9656 else
9657 split_quantity_new = quantity;
9658
9659 if (ShouldSplitQuantity(split_quantity_new))
9660 {
9661 GameInventory destinationInventory = destination_entity.GetInventory();
9662 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
9663 {
9664 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
9665 new_item = ItemBase.Cast(o);
9666 }
9667
9668 if (new_item)
9669 {
9670 new_item.SetResultOfSplit(true);
9671 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9672 AddQuantity(-split_quantity_new, false, true);
9673 new_item.SetQuantity(split_quantity_new, false, true);
9674 }
9675 }
9676 }
9677 else
9678 {
9679 if (stack_max != 0)
9680 {
9681 if (stack_max < GetQuantity())
9682 {
9683 split_quantity_new = GetQuantity() - stack_max;
9684 }
9685
9686 if (ShouldSplitQuantity(split_quantity_new))
9687 {
9688 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
9689
9690 if (new_item)
9691 {
9692 new_item.SetResultOfSplit(true);
9693 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9694 SetQuantity(split_quantity_new, false, true);
9695 new_item.SetQuantity(stack_max, false, true);
9696 new_item.PlaceOnSurface();
9697 }
9698 }
9699 }
9700 }
9701 }
9702
9703 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
9704 {
9705 if (g_Game.IsClient())
9706 {
9707 if (ScriptInputUserData.CanStoreInputUserData())
9708 {
9709 ScriptInputUserData ctx = new ScriptInputUserData;
9711 ctx.Write(4);
9712 ItemBase thiz = this; // @NOTE: workaround for correct serialization
9713 ctx.Write(thiz);
9714 dst.WriteToContext(ctx);
9715 ctx.Send();
9716 }
9717 }
9718 else if (!g_Game.IsMultiplayer())
9719 {
9721 }
9722 }
9723
9724 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
9725 {
9726 if (g_Game.IsClient())
9727 {
9728 if (ScriptInputUserData.CanStoreInputUserData())
9729 {
9730 ScriptInputUserData ctx = new ScriptInputUserData;
9732 ctx.Write(2);
9733 ItemBase dummy = this; // @NOTE: workaround for correct serialization
9734 ctx.Write(dummy);
9735 ctx.Write(destination_entity);
9736 ctx.Write(true);
9737 ctx.Write(idx);
9738 ctx.Write(row);
9739 ctx.Write(col);
9740 ctx.Send();
9741 }
9742 }
9743 else if (!g_Game.IsMultiplayer())
9744 {
9745 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
9746 }
9747 }
9748
9749 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
9750 {
9752 }
9753
9754 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
9755 {
9756 float quantity = GetQuantity();
9757 float split_quantity_new;
9758 ItemBase new_item;
9759 if (dst.IsValid())
9760 {
9761 int slot_id = dst.GetSlot();
9762 float stack_max = GetTargetQuantityMax(slot_id);
9763
9764 if (quantity > stack_max)
9765 split_quantity_new = stack_max;
9766 else
9767 split_quantity_new = quantity;
9768
9769 if (ShouldSplitQuantity(split_quantity_new))
9770 {
9771 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9772
9773 if (new_item)
9774 {
9775 new_item.SetResultOfSplit(true);
9776 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9777 AddQuantity(-split_quantity_new, false, true);
9778 new_item.SetQuantity(split_quantity_new, false, true);
9779 }
9780
9781 return new_item;
9782 }
9783 }
9784
9785 return null;
9786 }
9787
9788 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
9789 {
9790 float quantity = GetQuantity();
9791 float split_quantity_new;
9792 ItemBase new_item;
9793 if (destination_entity)
9794 {
9795 float stackable = GetTargetQuantityMax();
9796 if (quantity > stackable)
9797 split_quantity_new = stackable;
9798 else
9799 split_quantity_new = quantity;
9800
9801 if (ShouldSplitQuantity(split_quantity_new))
9802 {
9803 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
9804 if (new_item)
9805 {
9806 new_item.SetResultOfSplit(true);
9807 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9808 AddQuantity(-split_quantity_new, false, true);
9809 new_item.SetQuantity(split_quantity_new, false, true);
9810 }
9811 }
9812 }
9813 }
9814
9815 void SplitIntoStackMaxHandsClient(PlayerBase player)
9816 {
9817 if (g_Game.IsClient())
9818 {
9819 if (ScriptInputUserData.CanStoreInputUserData())
9820 {
9821 ScriptInputUserData ctx = new ScriptInputUserData;
9823 ctx.Write(3);
9824 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9825 ctx.Write(i1);
9826 ItemBase destination_entity = this;
9827 ctx.Write(destination_entity);
9828 ctx.Write(true);
9829 ctx.Write(0);
9830 ctx.Send();
9831 }
9832 }
9833 else if (!g_Game.IsMultiplayer())
9834 {
9835 SplitIntoStackMaxHands(player);
9836 }
9837 }
9838
9839 void SplitIntoStackMaxHands(PlayerBase player)
9840 {
9841 float quantity = GetQuantity();
9842 float split_quantity_new;
9843 ref ItemBase new_item;
9844 if (player)
9845 {
9846 float stackable = GetTargetQuantityMax();
9847 if (quantity > stackable)
9848 split_quantity_new = stackable;
9849 else
9850 split_quantity_new = quantity;
9851
9852 if (ShouldSplitQuantity(split_quantity_new))
9853 {
9854 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
9855 new_item = ItemBase.Cast(in_hands);
9856 if (new_item)
9857 {
9858 new_item.SetResultOfSplit(true);
9859 MiscGameplayFunctions.TransferItemProperties(this,new_item);
9860 AddQuantity(-split_quantity_new, false, true);
9861 new_item.SetQuantity(split_quantity_new, false, true);
9862 }
9863 }
9864 }
9865 }
9866
9867 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
9868 {
9869 float quantity = GetQuantity();
9870 float split_quantity_new = Math.Floor(quantity * 0.5);
9871
9872 if (!ShouldSplitQuantity(split_quantity_new))
9873 return;
9874
9875 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
9876
9877 if (new_item)
9878 {
9879 if (new_item.GetQuantityMax() < split_quantity_new)
9880 {
9881 split_quantity_new = new_item.GetQuantityMax();
9882 }
9883
9884 new_item.SetResultOfSplit(true);
9885 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9886
9887 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9888 {
9889 AddQuantity(-1, false, true);
9890 new_item.SetQuantity(1, false, true);
9891 }
9892 else
9893 {
9894 AddQuantity(-split_quantity_new, false, true);
9895 new_item.SetQuantity(split_quantity_new, false, true);
9896 }
9897 }
9898 }
9899
9900 void SplitItem(PlayerBase player)
9901 {
9902 float quantity = GetQuantity();
9903 float split_quantity_new = Math.Floor(quantity / 2);
9904
9905 if (!ShouldSplitQuantity(split_quantity_new))
9906 return;
9907
9908 InventoryLocation invloc = new InventoryLocation;
9909 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
9910
9911 ItemBase new_item;
9912 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
9913
9914 if (new_item)
9915 {
9916 if (new_item.GetQuantityMax() < split_quantity_new)
9917 {
9918 split_quantity_new = new_item.GetQuantityMax();
9919 }
9920 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
9921 {
9922 AddQuantity(-1, false, true);
9923 new_item.SetQuantity(1, false, true);
9924 }
9925 else if (split_quantity_new > 1)
9926 {
9927 AddQuantity(-split_quantity_new, false, true);
9928 new_item.SetQuantity(split_quantity_new, false, true);
9929 }
9930 }
9931 }
9932
9934 void OnQuantityChanged(float delta)
9935 {
9936 SetWeightDirty();
9937 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
9938
9939 if (parent)
9940 parent.OnAttachmentQuantityChangedEx(this, delta);
9941
9942 if (IsLiquidContainer())
9943 {
9944 if (GetQuantityNormalized() <= 0.0)
9945 {
9947 }
9948 else if (GetLiquidType() == LIQUID_NONE)
9949 {
9950 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
9952 }
9953 }
9954 }
9955
9958 {
9959 // insert code here
9960 }
9961
9963 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
9964 {
9966 }
9967
9968 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
9969 {
9970 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
9971
9972 if (g_Game.IsServer())
9973 {
9974 if (newLevel == GameConstants.STATE_RUINED)
9975 {
9977 EntityAI parent = GetHierarchyParent();
9978 if (parent && parent.IsFireplace())
9979 {
9980 CargoBase cargo = GetInventory().GetCargo();
9981 if (cargo)
9982 {
9983 for (int i = 0; i < cargo.GetItemCount(); ++i)
9984 {
9985 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
9986 }
9987 }
9988 }
9989 }
9990
9991 if (IsResultOfSplit())
9992 {
9993 // reset the splitting result flag, return to normal item behavior
9994 SetResultOfSplit(false);
9995 return;
9996 }
9997
9998 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
9999 {
10000 SetCleanness(0);//unclean the item upon damage dealt
10001 }
10002 }
10003 }
10004
10005 // just the split? TODO: verify
10006 override void OnRightClick()
10007 {
10008 super.OnRightClick();
10009
10010 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10011 {
10012 if (g_Game.IsClient())
10013 {
10014 if (ScriptInputUserData.CanStoreInputUserData())
10015 {
10016 EntityAI root = GetHierarchyRoot();
10017 Man playerOwner = GetHierarchyRootPlayer();
10018 InventoryLocation dst = new InventoryLocation;
10019
10020 // 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
10021 if (!playerOwner && root && root == this)
10022 {
10024 }
10025 else
10026 {
10027 // 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
10028 GetInventory().GetCurrentInventoryLocation(dst);
10029 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10030 {
10031 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10032 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10033 {
10035 }
10036 else
10037 {
10038 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10039 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10040 this shouldnt cause issues within this scope*/
10041 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10042 {
10044 }
10045 else
10046 {
10047 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10048 }
10049 }
10050 }
10051 }
10052
10053 ScriptInputUserData ctx = new ScriptInputUserData;
10055 ctx.Write(4);
10056 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10057 ctx.Write(thiz);
10058 dst.WriteToContext(ctx);
10059 ctx.Write(true); // dummy
10060 ctx.Send();
10061 }
10062 }
10063 else if (!g_Game.IsMultiplayer())
10064 {
10065 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10066 }
10067 }
10068 }
10069
10070 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10071 {
10072 if (root)
10073 {
10074 vector m4[4];
10075 root.GetTransform(m4);
10076 dst.SetGround(this, m4);
10077 }
10078 else
10079 {
10080 GetInventory().GetCurrentInventoryLocation(dst);
10081 }
10082 }
10083
10084 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10085 {
10086 //TODO: delete check zero quantity check after fix double posts hands fsm events
10087 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10088 return false;
10089
10090 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10091 return false;
10092
10093 //can_this_be_combined = ConfigGetBool("canBeSplit");
10095 return false;
10096
10097
10098 Magazine mag = Magazine.Cast(this);
10099 if (mag)
10100 {
10101 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10102 return false;
10103
10104 if (stack_max_limit)
10105 {
10106 Magazine other_mag = Magazine.Cast(other_item);
10107 if (other_item)
10108 {
10109 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10110 return false;
10111 }
10112
10113 }
10114 }
10115 else
10116 {
10117 //TODO: delete check zero quantity check after fix double posts hands fsm events
10118 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10119 return false;
10120
10121 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10122 return false;
10123 }
10124
10125 PlayerBase player = null;
10126 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10127 {
10128 if (player.GetInventory().HasAttachment(this))
10129 return false;
10130
10131 if (player.IsItemsToDelete())
10132 return false;
10133 }
10134
10135 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10136 return false;
10137
10138 int slotID;
10139 string slotName;
10140 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10141 return false;
10142
10143 return true;
10144 }
10145
10146 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10147 {
10148 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10149 }
10150
10151 bool IsResultOfSplit()
10152 {
10153 return m_IsResultOfSplit;
10154 }
10155
10156 void SetResultOfSplit(bool value)
10157 {
10158 m_IsResultOfSplit = value;
10159 }
10160
10161 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10162 {
10163 return ComputeQuantityUsedEx(other_item, use_stack_max);
10164 }
10165
10166 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10167 {
10168 float other_item_quantity = other_item.GetQuantity();
10169 float this_free_space;
10170
10171 float stack_max = GetQuantityMax();
10172
10173 this_free_space = stack_max - GetQuantity();
10174
10175 if (other_item_quantity > this_free_space)
10176 {
10177 return this_free_space;
10178 }
10179 else
10180 {
10181 return other_item_quantity;
10182 }
10183 }
10184
10185 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10186 {
10187 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10188 }
10189
10190 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10191 {
10192 if (!CanBeCombined(other_item, false))
10193 return;
10194
10195 if (!IsMagazine() && other_item)
10196 {
10197 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10198 if (quantity_used != 0)
10199 {
10200 float hp1 = GetHealth01("","");
10201 float hp2 = other_item.GetHealth01("","");
10202 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10203 hpResult = hpResult / (GetQuantity() + quantity_used);
10204
10205 hpResult *= GetMaxHealth();
10206 Math.Round(hpResult);
10207 SetHealth("", "Health", hpResult);
10208
10209 AddQuantity(quantity_used);
10210 other_item.AddQuantity(-quantity_used);
10211 }
10212 }
10213 OnCombine(other_item);
10214 }
10215
10216 void OnCombine(ItemBase other_item)
10217 {
10218 #ifdef SERVER
10219 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10220 GetHierarchyParent().IncreaseLifetimeUp();
10221 #endif
10222 };
10223
10224 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10225 {
10226 PlayerBase p = PlayerBase.Cast(player);
10227
10228 array<int> recipesIds = p.m_Recipes;
10229 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10230 if (moduleRecipesManager)
10231 {
10232 EntityAI itemInHands = player.GetEntityInHands();
10233 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10234 }
10235
10236 for (int i = 0;i < recipesIds.Count(); i++)
10237 {
10238 int key = recipesIds.Get(i);
10239 string recipeName = moduleRecipesManager.GetRecipeName(key);
10240 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10241 }
10242 }
10243
10244 // -------------------------------------------------------------------------
10245 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10246 {
10247 super.GetDebugActions(outputList);
10248
10249 //quantity
10250 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10251 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10252 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10253 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10254 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10255
10256 //health
10257 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10258 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10259 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10260 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10261 //temperature
10262 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10263 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10264 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10265 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10266
10267 //wet
10268 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10269 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10270 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10271
10272 //liquidtype
10273 if (IsLiquidContainer())
10274 {
10275 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10276 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10277 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10278 }
10279
10280 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10281 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10282
10283 // watch
10284 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10285 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10286 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10287
10288 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10289
10290 InventoryLocation loc = new InventoryLocation();
10291 GetInventory().GetCurrentInventoryLocation(loc);
10292 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10293 {
10294 if (Gizmo_IsSupported())
10295 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10296 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10297 }
10298
10299 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10300 }
10301
10302 // -------------------------------------------------------------------------
10303 // -------------------------------------------------------------------------
10304 // -------------------------------------------------------------------------
10305 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10306 {
10307 super.OnAction(action_id, player, ctx);
10308
10309 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
10310 {
10311 switch (action_id)
10312 {
10313 case EActions.GIZMO_OBJECT:
10314 if (GetGizmoApi())
10315 GetGizmoApi().SelectObject(this);
10316 return true;
10317 case EActions.GIZMO_PHYSICS:
10318 if (GetGizmoApi())
10319 GetGizmoApi().SelectPhysics(GetPhysics());
10320 return true;
10321 }
10322 }
10323
10324 if (g_Game.IsServer())
10325 {
10326 switch (action_id)
10327 {
10328 case EActions.DELETE:
10329 Delete();
10330 return true;
10331 }
10332 }
10333
10334 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10335 {
10336 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10337 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10338 PlayerBase p = PlayerBase.Cast(player);
10339 if (EActions.RECIPES_RANGE_START < 1000)
10340 {
10341 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10342 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10343 }
10344 }
10345 #ifndef SERVER
10346 else if (action_id == EActions.WATCH_PLAYER)
10347 {
10348 PluginDeveloper.SetDeveloperItemClientEx(player);
10349 }
10350 #endif
10351 if (g_Game.IsServer())
10352 {
10353 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10354 {
10355 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10356 OnDebugButtonPressServer(id + 1);
10357 }
10358
10359 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10360 {
10361 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10362 InsertAgent(agent_id,100);
10363 }
10364
10365 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10366 {
10367 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10368 RemoveAgent(agent_id2);
10369 }
10370
10371 else if (action_id == EActions.ADD_QUANTITY)
10372 {
10373 if (IsMagazine())
10374 {
10375 Magazine mag = Magazine.Cast(this);
10376 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10377 }
10378 else
10379 {
10380 AddQuantity(GetQuantityMax() * 0.2);
10381 }
10382
10383 if (m_EM)
10384 {
10385 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10386 }
10387 //PrintVariables();
10388 }
10389
10390 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10391 {
10392 if (IsMagazine())
10393 {
10394 Magazine mag2 = Magazine.Cast(this);
10395 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10396 }
10397 else
10398 {
10399 AddQuantity(- GetQuantityMax() * 0.2);
10400 }
10401 if (m_EM)
10402 {
10403 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10404 }
10405 //PrintVariables();
10406 }
10407
10408 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10409 {
10410 SetQuantity(0);
10411
10412 if (m_EM)
10413 {
10414 m_EM.SetEnergy(0);
10415 }
10416 }
10417
10418 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10419 {
10421
10422 if (m_EM)
10423 {
10424 m_EM.SetEnergy(m_EM.GetEnergyMax());
10425 }
10426 }
10427
10428 else if (action_id == EActions.ADD_HEALTH)
10429 {
10430 AddHealth("","",GetMaxHealth("","Health")/5);
10431 }
10432 else if (action_id == EActions.REMOVE_HEALTH)
10433 {
10434 AddHealth("","",-GetMaxHealth("","Health")/5);
10435 }
10436 else if (action_id == EActions.DESTROY_HEALTH)
10437 {
10438 SetHealth01("","",0);
10439 }
10440 else if (action_id == EActions.WATCH_ITEM)
10441 {
10443 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10444 #ifdef DEVELOPER
10445 SetDebugDeveloper_item(this);
10446 #endif
10447 }
10448
10449 else if (action_id == EActions.ADD_TEMPERATURE)
10450 {
10451 AddTemperature(20);
10452 //PrintVariables();
10453 }
10454
10455 else if (action_id == EActions.REMOVE_TEMPERATURE)
10456 {
10457 AddTemperature(-20);
10458 //PrintVariables();
10459 }
10460
10461 else if (action_id == EActions.FLIP_FROZEN)
10462 {
10463 SetFrozen(!GetIsFrozen());
10464 //PrintVariables();
10465 }
10466
10467 else if (action_id == EActions.ADD_WETNESS)
10468 {
10469 AddWet(GetWetMax()/5);
10470 //PrintVariables();
10471 }
10472
10473 else if (action_id == EActions.REMOVE_WETNESS)
10474 {
10475 AddWet(-GetWetMax()/5);
10476 //PrintVariables();
10477 }
10478
10479 else if (action_id == EActions.LIQUIDTYPE_UP)
10480 {
10481 int curr_type = GetLiquidType();
10482 SetLiquidType(curr_type * 2);
10483 //AddWet(1);
10484 //PrintVariables();
10485 }
10486
10487 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10488 {
10489 int curr_type2 = GetLiquidType();
10490 SetLiquidType(curr_type2 / 2);
10491 }
10492
10493 else if (action_id == EActions.MAKE_SPECIAL)
10494 {
10495 auto debugParams = DebugSpawnParams.WithPlayer(player);
10496 OnDebugSpawnEx(debugParams);
10497 }
10498
10499 }
10500
10501
10502 return false;
10503 }
10504
10505 // -------------------------------------------------------------------------
10506
10507
10510 void OnActivatedByTripWire();
10511
10513 void OnActivatedByItem(notnull ItemBase item);
10514
10515 //----------------------------------------------------------------
10516 //returns true if item is able to explode when put in fire
10517 bool CanExplodeInFire()
10518 {
10519 return false;
10520 }
10521
10522 //----------------------------------------------------------------
10523 bool CanEat()
10524 {
10525 return true;
10526 }
10527
10528 //----------------------------------------------------------------
10529 override bool IsIgnoredByConstruction()
10530 {
10531 return true;
10532 }
10533
10534 //----------------------------------------------------------------
10535 //has FoodStages in config?
10536 bool HasFoodStage()
10537 {
10538 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10539 return g_Game.ConfigIsExisting(config_path);
10540 }
10541
10543 FoodStage GetFoodStage()
10544 {
10545 return null;
10546 }
10547
10548 bool CanBeCooked()
10549 {
10550 return false;
10551 }
10552
10553 bool CanBeCookedOnStick()
10554 {
10555 return false;
10556 }
10557
10559 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10561
10562 //----------------------------------------------------------------
10563 bool CanRepair(ItemBase item_repair_kit)
10564 {
10565 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10566 return module_repairing.CanRepair(this, item_repair_kit);
10567 }
10568
10569 //----------------------------------------------------------------
10570 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
10571 {
10572 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10573 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
10574 }
10575
10576 //----------------------------------------------------------------
10577 int GetItemSize()
10578 {
10579 /*
10580 vector v_size = this.ConfigGetVector("itemSize");
10581 int v_size_x = v_size[0];
10582 int v_size_y = v_size[1];
10583 int size = v_size_x * v_size_y;
10584 return size;
10585 */
10586
10587 return 1;
10588 }
10589
10590 //----------------------------------------------------------------
10591 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10592 bool CanBeMovedOverride()
10593 {
10594 return m_CanBeMovedOverride;
10595 }
10596
10597 //----------------------------------------------------------------
10598 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
10599 void SetCanBeMovedOverride(bool setting)
10600 {
10601 m_CanBeMovedOverride = setting;
10602 }
10603
10604 //----------------------------------------------------------------
10612 void MessageToOwnerStatus(string text)
10613 {
10614 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10615
10616 if (player)
10617 {
10618 player.MessageStatus(text);
10619 }
10620 }
10621
10622 //----------------------------------------------------------------
10630 void MessageToOwnerAction(string text)
10631 {
10632 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10633
10634 if (player)
10635 {
10636 player.MessageAction(text);
10637 }
10638 }
10639
10640 //----------------------------------------------------------------
10648 void MessageToOwnerFriendly(string text)
10649 {
10650 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10651
10652 if (player)
10653 {
10654 player.MessageFriendly(text);
10655 }
10656 }
10657
10658 //----------------------------------------------------------------
10666 void MessageToOwnerImportant(string text)
10667 {
10668 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
10669
10670 if (player)
10671 {
10672 player.MessageImportant(text);
10673 }
10674 }
10675
10676 override bool IsItemBase()
10677 {
10678 return true;
10679 }
10680
10681 // Checks if item is of questioned kind
10682 override bool KindOf(string tag)
10683 {
10684 bool found = false;
10685 string item_name = this.GetType();
10686 ref TStringArray item_tag_array = new TStringArray;
10687 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
10688
10689 int array_size = item_tag_array.Count();
10690 for (int i = 0; i < array_size; i++)
10691 {
10692 if (item_tag_array.Get(i) == tag)
10693 {
10694 found = true;
10695 break;
10696 }
10697 }
10698 return found;
10699 }
10700
10701
10702 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
10703 {
10704 //Debug.Log("OnRPC called");
10705 super.OnRPC(sender, rpc_type,ctx);
10706
10707 //Play soundset for attachment locking (ActionLockAttachment.c)
10708 switch (rpc_type)
10709 {
10710 #ifndef SERVER
10711 case ERPCs.RPC_SOUND_LOCK_ATTACH:
10712 Param2<bool, string> p = new Param2<bool, string>(false, "");
10713
10714 if (!ctx.Read(p))
10715 return;
10716
10717 bool play = p.param1;
10718 string soundSet = p.param2;
10719
10720 if (play)
10721 {
10722 if (m_LockingSound)
10723 {
10725 {
10726 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10727 }
10728 }
10729 else
10730 {
10731 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
10732 }
10733 }
10734 else
10735 {
10736 SEffectManager.DestroyEffect(m_LockingSound);
10737 }
10738
10739 break;
10740 #endif
10741
10742 }
10743
10744 if (GetWrittenNoteData())
10745 {
10746 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
10747 }
10748 }
10749
10750 //-----------------------------
10751 // VARIABLE MANIPULATION SYSTEM
10752 //-----------------------------
10753 int NameToID(string name)
10754 {
10755 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10756 return plugin.GetID(name);
10757 }
10758
10759 string IDToName(int id)
10760 {
10761 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
10762 return plugin.GetName(id);
10763 }
10764
10766 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
10767 {
10768 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
10769 //read the flags
10770 int varFlags;
10771 if (!ctx.Read(varFlags))
10772 return;
10773
10774 if (varFlags & ItemVariableFlags.FLOAT)
10775 {
10776 ReadVarsFromCTX(ctx);
10777 }
10778 }
10779
10780 override void SerializeNumericalVars(array<float> floats_out)
10781 {
10782 //some variables handled on EntityAI level already!
10783 super.SerializeNumericalVars(floats_out);
10784
10785 // the order of serialization must be the same as the order of de-serialization
10786 //--------------------------------------------
10787 if (IsVariableSet(VARIABLE_QUANTITY))
10788 {
10789 floats_out.Insert(m_VarQuantity);
10790 }
10791 //--------------------------------------------
10792 if (IsVariableSet(VARIABLE_WET))
10793 {
10794 floats_out.Insert(m_VarWet);
10795 }
10796 //--------------------------------------------
10797 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10798 {
10799 floats_out.Insert(m_VarLiquidType);
10800 }
10801 //--------------------------------------------
10802 if (IsVariableSet(VARIABLE_COLOR))
10803 {
10804 floats_out.Insert(m_ColorComponentR);
10805 floats_out.Insert(m_ColorComponentG);
10806 floats_out.Insert(m_ColorComponentB);
10807 floats_out.Insert(m_ColorComponentA);
10808 }
10809 //--------------------------------------------
10810 if (IsVariableSet(VARIABLE_CLEANNESS))
10811 {
10812 floats_out.Insert(m_Cleanness);
10813 }
10814 }
10815
10816 override void DeSerializeNumericalVars(array<float> floats)
10817 {
10818 //some variables handled on EntityAI level already!
10819 super.DeSerializeNumericalVars(floats);
10820
10821 // the order of serialization must be the same as the order of de-serialization
10822 int index = 0;
10823 int mask = Math.Round(floats.Get(index));
10824
10825 index++;
10826 //--------------------------------------------
10827 if (mask & VARIABLE_QUANTITY)
10828 {
10829 if (m_IsStoreLoad)
10830 {
10831 SetStoreLoadedQuantity(floats.Get(index));
10832 }
10833 else
10834 {
10835 float quantity = floats.Get(index);
10836 SetQuantity(quantity, true, false, false, false);
10837 }
10838 index++;
10839 }
10840 //--------------------------------------------
10841 if (mask & VARIABLE_WET)
10842 {
10843 float wet = floats.Get(index);
10844 SetWet(wet);
10845 index++;
10846 }
10847 //--------------------------------------------
10848 if (mask & VARIABLE_LIQUIDTYPE)
10849 {
10850 int liquidtype = Math.Round(floats.Get(index));
10851 SetLiquidType(liquidtype);
10852 index++;
10853 }
10854 //--------------------------------------------
10855 if (mask & VARIABLE_COLOR)
10856 {
10857 m_ColorComponentR = Math.Round(floats.Get(index));
10858 index++;
10859 m_ColorComponentG = Math.Round(floats.Get(index));
10860 index++;
10861 m_ColorComponentB = Math.Round(floats.Get(index));
10862 index++;
10863 m_ColorComponentA = Math.Round(floats.Get(index));
10864 index++;
10865 }
10866 //--------------------------------------------
10867 if (mask & VARIABLE_CLEANNESS)
10868 {
10869 int cleanness = Math.Round(floats.Get(index));
10870 SetCleanness(cleanness);
10871 index++;
10872 }
10873 }
10874
10875 override void WriteVarsToCTX(ParamsWriteContext ctx)
10876 {
10877 super.WriteVarsToCTX(ctx);
10878
10879 //--------------------------------------------
10880 if (IsVariableSet(VARIABLE_QUANTITY))
10881 {
10882 ctx.Write(GetQuantity());
10883 }
10884 //--------------------------------------------
10885 if (IsVariableSet(VARIABLE_WET))
10886 {
10887 ctx.Write(GetWet());
10888 }
10889 //--------------------------------------------
10890 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
10891 {
10892 ctx.Write(GetLiquidType());
10893 }
10894 //--------------------------------------------
10895 if (IsVariableSet(VARIABLE_COLOR))
10896 {
10897 int r,g,b,a;
10898 GetColor(r,g,b,a);
10899 ctx.Write(r);
10900 ctx.Write(g);
10901 ctx.Write(b);
10902 ctx.Write(a);
10903 }
10904 //--------------------------------------------
10905 if (IsVariableSet(VARIABLE_CLEANNESS))
10906 {
10907 ctx.Write(GetCleanness());
10908 }
10909 }
10910
10911 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
10912 {
10913 if (!super.ReadVarsFromCTX(ctx,version))
10914 return false;
10915
10916 int intValue;
10917 float value;
10918
10919 if (version < 140)
10920 {
10921 if (!ctx.Read(intValue))
10922 return false;
10923
10924 m_VariablesMask = intValue;
10925 }
10926
10927 if (m_VariablesMask & VARIABLE_QUANTITY)
10928 {
10929 if (!ctx.Read(value))
10930 return false;
10931
10932 if (IsStoreLoad())
10933 {
10935 }
10936 else
10937 {
10938 SetQuantity(value, true, false, false, false);
10939 }
10940 }
10941 //--------------------------------------------
10942 if (version < 140)
10943 {
10944 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10945 {
10946 if (!ctx.Read(value))
10947 return false;
10948 SetTemperatureDirect(value);
10949 }
10950 }
10951 //--------------------------------------------
10952 if (m_VariablesMask & VARIABLE_WET)
10953 {
10954 if (!ctx.Read(value))
10955 return false;
10956 SetWet(value);
10957 }
10958 //--------------------------------------------
10959 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
10960 {
10961 if (!ctx.Read(intValue))
10962 return false;
10963 SetLiquidType(intValue);
10964 }
10965 //--------------------------------------------
10966 if (m_VariablesMask & VARIABLE_COLOR)
10967 {
10968 int r,g,b,a;
10969 if (!ctx.Read(r))
10970 return false;
10971 if (!ctx.Read(g))
10972 return false;
10973 if (!ctx.Read(b))
10974 return false;
10975 if (!ctx.Read(a))
10976 return false;
10977
10978 SetColor(r,g,b,a);
10979 }
10980 //--------------------------------------------
10981 if (m_VariablesMask & VARIABLE_CLEANNESS)
10982 {
10983 if (!ctx.Read(intValue))
10984 return false;
10985 SetCleanness(intValue);
10986 }
10987 //--------------------------------------------
10988 if (version >= 138 && version < 140)
10989 {
10990 if (m_VariablesMask & VARIABLE_TEMPERATURE)
10991 {
10992 if (!ctx.Read(intValue))
10993 return false;
10994 SetFrozen(intValue);
10995 }
10996 }
10997
10998 return true;
10999 }
11000
11001 //----------------------------------------------------------------
11002 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11003 {
11004 m_IsStoreLoad = true;
11006 {
11007 m_FixDamageSystemInit = true;
11008 }
11009
11010 if (!super.OnStoreLoad(ctx, version))
11011 {
11012 m_IsStoreLoad = false;
11013 return false;
11014 }
11015
11016 if (version >= 114)
11017 {
11018 bool hasQuickBarIndexSaved;
11019
11020 if (!ctx.Read(hasQuickBarIndexSaved))
11021 {
11022 m_IsStoreLoad = false;
11023 return false;
11024 }
11025
11026 if (hasQuickBarIndexSaved)
11027 {
11028 int itmQBIndex;
11029
11030 //Load quickbar item bind
11031 if (!ctx.Read(itmQBIndex))
11032 {
11033 m_IsStoreLoad = false;
11034 return false;
11035 }
11036
11037 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11038 if (itmQBIndex != -1 && parentPlayer)
11039 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11040 }
11041 }
11042 else
11043 {
11044 // Backup of how it used to be
11045 PlayerBase player;
11046 int itemQBIndex;
11047 if (version == int.MAX)
11048 {
11049 if (!ctx.Read(itemQBIndex))
11050 {
11051 m_IsStoreLoad = false;
11052 return false;
11053 }
11054 }
11055 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11056 {
11057 //Load quickbar item bind
11058 if (!ctx.Read(itemQBIndex))
11059 {
11060 m_IsStoreLoad = false;
11061 return false;
11062 }
11063 if (itemQBIndex != -1 && player)
11064 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11065 }
11066 }
11067
11068 if (version < 140)
11069 {
11070 // variable management system
11071 if (!LoadVariables(ctx, version))
11072 {
11073 m_IsStoreLoad = false;
11074 return false;
11075 }
11076 }
11077
11078 //agent trasmission system
11079 if (!LoadAgents(ctx, version))
11080 {
11081 m_IsStoreLoad = false;
11082 return false;
11083 }
11084 if (version >= 132)
11085 {
11086 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11087 if (raib)
11088 {
11089 if (!raib.OnStoreLoad(ctx,version))
11090 {
11091 m_IsStoreLoad = false;
11092 return false;
11093 }
11094 }
11095 }
11096
11097 m_IsStoreLoad = false;
11098 return true;
11099 }
11100
11101 //----------------------------------------------------------------
11102
11103 override void OnStoreSave(ParamsWriteContext ctx)
11104 {
11105 super.OnStoreSave(ctx);
11106
11107 PlayerBase player;
11108 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11109 {
11110 ctx.Write(true); // Keep track of if we should actually read this in or not
11111 //Save quickbar item bind
11112 int itemQBIndex = -1;
11113 itemQBIndex = player.FindQuickBarEntityIndex(this);
11114 ctx.Write(itemQBIndex);
11115 }
11116 else
11117 {
11118 ctx.Write(false); // Keep track of if we should actually read this in or not
11119 }
11120
11121 SaveAgents(ctx);//agent trasmission system
11122
11123 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11124 if (raib)
11125 {
11126 raib.OnStoreSave(ctx);
11127 }
11128 }
11129 //----------------------------------------------------------------
11130
11131 override void AfterStoreLoad()
11132 {
11133 super.AfterStoreLoad();
11134
11136 {
11138 }
11139
11140 if (GetStoreLoadedQuantity() != float.LOWEST)
11141 {
11143 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
11144 }
11145 }
11146
11147 override void EEOnAfterLoad()
11148 {
11149 super.EEOnAfterLoad();
11150
11152 {
11153 m_FixDamageSystemInit = false;
11154 }
11155
11158 }
11159
11160 bool CanBeDisinfected()
11161 {
11162 return false;
11163 }
11164
11165
11166 //----------------------------------------------------------------
11167 override void OnVariablesSynchronized()
11168 {
11169 if (m_Initialized)
11170 {
11171 #ifdef PLATFORM_CONSOLE
11172 //bruteforce it is
11173 if (IsSplitable())
11174 {
11175 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11176 if (menu)
11177 {
11178 menu.Refresh();
11179 }
11180 }
11181 #endif
11182 }
11183
11185 {
11186 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11187 m_WantPlayImpactSound = false;
11188 }
11189
11191 {
11192 SetWeightDirty();
11194 }
11195 if (m_VarWet != m_VarWetPrev)
11196 {
11199 }
11200
11201 if (m_SoundSyncPlay != 0)
11202 {
11205
11206 m_SoundSyncPlay = 0;
11207 m_SoundSyncSlotID = -1;
11208 }
11209 if (m_SoundSyncStop != 0)
11210 {
11212 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11213 m_SoundSyncStop = 0;
11214 }
11215
11216 super.OnVariablesSynchronized();
11217 }
11218
11219 //------------------------- Quantity
11220 //----------------------------------------------------------------
11222 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11223 {
11224 if (!IsServerCheck(allow_client))
11225 return false;
11226
11227 if (!HasQuantity())
11228 return false;
11229
11230 float min = GetQuantityMin();
11231 float max = GetQuantityMax();
11232
11233 if (value <= (min + 0.001))
11234 value = min;
11235
11236 if (value == min)
11237 {
11238 if (destroy_config)
11239 {
11240 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11241 if (dstr)
11242 {
11243 m_VarQuantity = Math.Clamp(value, min, max);
11244 this.Delete();
11245 return true;
11246 }
11247 }
11248 else if (destroy_forced)
11249 {
11250 m_VarQuantity = Math.Clamp(value, min, max);
11251 this.Delete();
11252 return true;
11253 }
11254 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11255 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11256 }
11257
11258 float delta = m_VarQuantity;
11259 m_VarQuantity = Math.Clamp(value, min, max);
11260
11261 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11262 {
11263 EntityAI parent = GetHierarchyRoot();
11264 InventoryLocation iLoc = new InventoryLocation();
11265 GetInventory().GetCurrentInventoryLocation(iLoc);
11266 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
11267 {
11268 int iLocSlot = iLoc.GetSlot();
11269 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
11270 {
11271 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
11272 }
11273 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
11274 {
11275 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
11276 }
11277 }
11278 }
11279
11280 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11281 {
11282 delta = m_VarQuantity - delta;
11283
11284 if (delta)
11285 OnQuantityChanged(delta);
11286 }
11287
11288 SetVariableMask(VARIABLE_QUANTITY);
11289
11290 return false;
11291 }
11292
11293 //----------------------------------------------------------------
11295 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11296 {
11297 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11298 }
11299 //----------------------------------------------------------------
11300 void SetQuantityMax()
11301 {
11302 float max = GetQuantityMax();
11303 SetQuantity(max);
11304 }
11305
11306 override void SetQuantityToMinimum()
11307 {
11308 float min = GetQuantityMin();
11309 SetQuantity(min);
11310 }
11311 //----------------------------------------------------------------
11313 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11314 {
11315 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11316 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11317 SetQuantity(result, destroy_config, destroy_forced);
11318 }
11319
11320 //----------------------------------------------------------------
11322 override float GetQuantityNormalized()
11323 {
11324 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11325 }
11326
11328 {
11329 return GetQuantityNormalized();
11330 }
11331
11332 /*void SetAmmoNormalized(float value)
11333 {
11334 float value_clamped = Math.Clamp(value, 0, 1);
11335 Magazine this_mag = Magazine.Cast(this);
11336 int max_rounds = this_mag.GetAmmoMax();
11337 int result = value * max_rounds;//can the rounded if higher precision is required
11338 this_mag.SetAmmoCount(result);
11339 }*/
11340 //----------------------------------------------------------------
11341 override int GetQuantityMax()
11342 {
11343 int slot = -1;
11344 GameInventory inventory = GetInventory();
11345 if (inventory)
11346 {
11347 InventoryLocation il = new InventoryLocation;
11348 inventory.GetCurrentInventoryLocation(il);
11349 slot = il.GetSlot();
11350 }
11351
11352 return GetTargetQuantityMax(slot);
11353 }
11354
11355 override int GetTargetQuantityMax(int attSlotID = -1)
11356 {
11357 float quantity_max = 0;
11358
11359 if (IsSplitable()) //only stackable/splitable items can check for stack size
11360 {
11361 if (attSlotID != -1)
11362 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11363
11364 if (quantity_max <= 0)
11365 quantity_max = m_VarStackMax;
11366 }
11367
11368 if (quantity_max <= 0)
11369 quantity_max = m_VarQuantityMax;
11370
11371 return quantity_max;
11372 }
11373 //----------------------------------------------------------------
11374 override int GetQuantityMin()
11375 {
11376 return m_VarQuantityMin;
11377 }
11378 //----------------------------------------------------------------
11379 int GetQuantityInit()
11380 {
11381 return m_VarQuantityInit;
11382 }
11383
11384 //----------------------------------------------------------------
11385 override bool HasQuantity()
11386 {
11387 return !(GetQuantityMax() - GetQuantityMin() == 0);
11388 }
11389
11390 override float GetQuantity()
11391 {
11392 return m_VarQuantity;
11393 }
11394
11395 bool IsFullQuantity()
11396 {
11397 return GetQuantity() >= GetQuantityMax();
11398 }
11399
11400 //Calculates weight of single item without attachments and cargo
11401 override float GetSingleInventoryItemWeightEx()
11402 {
11403 //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
11404 float weightEx = GetWeightEx();//overall weight of the item
11405 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11406 return weightEx - special;
11407 }
11408
11409 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11411 {
11413 }
11414
11415 override protected float GetWeightSpecialized(bool forceRecalc = false)
11416 {
11417 if (IsSplitable()) //quantity determines size of the stack
11418 {
11419 #ifdef DEVELOPER
11420 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11421 {
11422 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11423 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11424 }
11425 #endif
11426
11427 return GetQuantity() * GetConfigWeightModified();
11428 }
11429 else if (HasEnergyManager())// items with energy manager
11430 {
11431 #ifdef DEVELOPER
11432 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11433 {
11434 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11435 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11436 }
11437 #endif
11438 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11439 }
11440 else//everything else
11441 {
11442 #ifdef DEVELOPER
11443 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11444 {
11445 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11446 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11447 }
11448 #endif
11449 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11450 }
11451 }
11452
11454 int GetNumberOfItems()
11455 {
11456 int item_count = 0;
11457 ItemBase item;
11458
11459 GameInventory inventory = GetInventory();
11460 CargoBase cargo = inventory.GetCargo();
11461 if (cargo != NULL)
11462 {
11463 item_count = cargo.GetItemCount();
11464 }
11465
11466 int nAttachments = inventory.AttachmentCount();
11467 for (int i = 0; i < nAttachments; ++i)
11468 {
11469 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
11470 if (item)
11471 item_count += item.GetNumberOfItems();
11472 }
11473 return item_count;
11474 }
11475
11477 float GetUnitWeight(bool include_wetness = true)
11478 {
11479 float weight = 0;
11480 float wetness = 1;
11481 if (include_wetness)
11482 wetness += GetWet();
11483 if (IsSplitable()) //quantity determines size of the stack
11484 {
11485 weight = wetness * m_ConfigWeight;
11486 }
11487 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11488 {
11489 weight = 1;
11490 }
11491 return weight;
11492 }
11493
11494 //-----------------------------------------------------------------
11495
11496 override void ClearInventory()
11497 {
11498 GameInventory inventory = GetInventory();
11499 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
11500 {
11501 array<EntityAI> items = new array<EntityAI>;
11502 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
11503 for (int i = 0; i < items.Count(); ++i)
11504 {
11505 ItemBase item = ItemBase.Cast(items.Get(i));
11506 if (item)
11507 {
11508 g_Game.ObjectDelete(item);
11509 }
11510 }
11511 }
11512 }
11513
11514 //------------------------- Energy
11515
11516 //----------------------------------------------------------------
11517 float GetEnergy()
11518 {
11519 float energy = 0;
11520 if (HasEnergyManager())
11521 {
11522 energy = GetCompEM().GetEnergy();
11523 }
11524 return energy;
11525 }
11526
11527
11528 override void OnEnergyConsumed()
11529 {
11530 super.OnEnergyConsumed();
11531
11533 }
11534
11535 override void OnEnergyAdded()
11536 {
11537 super.OnEnergyAdded();
11538
11540 }
11541
11542 // Converts energy (from Energy Manager) to quantity, if enabled.
11544 {
11545 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11546 {
11547 if (HasQuantity())
11548 {
11549 float energy_0to1 = GetCompEM().GetEnergy0To1();
11550 SetQuantityNormalized(energy_0to1);
11551 }
11552 }
11553 }
11554
11555 //----------------------------------------------------------------
11556 float GetHeatIsolationInit()
11557 {
11558 return ConfigGetFloat("heatIsolation");
11559 }
11560
11561 float GetHeatIsolation()
11562 {
11563 return m_HeatIsolation;
11564 }
11565
11566 float GetDryingIncrement(string pIncrementName)
11567 {
11568 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
11569 if (g_Game.ConfigIsExisting(paramPath))
11570 return g_Game.ConfigGetFloat(paramPath);
11571
11572 return 0.0;
11573 }
11574
11575 float GetSoakingIncrement(string pIncrementName)
11576 {
11577 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
11578 if (g_Game.ConfigIsExisting(paramPath))
11579 return g_Game.ConfigGetFloat(paramPath);
11580
11581 return 0.0;
11582 }
11583 //----------------------------------------------------------------
11584 override void SetWet(float value, bool allow_client = false)
11585 {
11586 if (!IsServerCheck(allow_client))
11587 return;
11588
11589 float min = GetWetMin();
11590 float max = GetWetMax();
11591
11592 float previousValue = m_VarWet;
11593
11594 m_VarWet = Math.Clamp(value, min, max);
11595
11596 if (previousValue != m_VarWet)
11597 {
11598 SetVariableMask(VARIABLE_WET);
11599 OnWetChanged(m_VarWet, previousValue);
11600 }
11601 }
11602 //----------------------------------------------------------------
11603 override void AddWet(float value)
11604 {
11605 SetWet(GetWet() + value);
11606 }
11607 //----------------------------------------------------------------
11608 override void SetWetMax()
11609 {
11611 }
11612 //----------------------------------------------------------------
11613 override float GetWet()
11614 {
11615 return m_VarWet;
11616 }
11617 //----------------------------------------------------------------
11618 override float GetWetMax()
11619 {
11620 return m_VarWetMax;
11621 }
11622 //----------------------------------------------------------------
11623 override float GetWetMin()
11624 {
11625 return m_VarWetMin;
11626 }
11627 //----------------------------------------------------------------
11628 override float GetWetInit()
11629 {
11630 return m_VarWetInit;
11631 }
11632 //----------------------------------------------------------------
11633 override void OnWetChanged(float newVal, float oldVal)
11634 {
11635 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
11636 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
11637 if (newLevel != oldLevel)
11638 {
11639 OnWetLevelChanged(newLevel,oldLevel);
11640 }
11641 }
11642
11643 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
11644 {
11645 SetWeightDirty();
11646 }
11647
11648 override EWetnessLevel GetWetLevel()
11649 {
11650 return GetWetLevelInternal(m_VarWet);
11651 }
11652
11653 //----------------------------------------------------------------
11654
11655 override void SetStoreLoad(bool value)
11656 {
11657 m_IsStoreLoad = value;
11658 }
11659
11660 override bool IsStoreLoad()
11661 {
11662 return m_IsStoreLoad;
11663 }
11664
11665 override void SetStoreLoadedQuantity(float value)
11666 {
11667 m_StoreLoadedQuantity = value;
11668 }
11669
11670 override float GetStoreLoadedQuantity()
11671 {
11672 return m_StoreLoadedQuantity;
11673 }
11674
11675 //----------------------------------------------------------------
11676
11677 float GetItemModelLength()
11678 {
11679 if (ConfigIsExisting("itemModelLength"))
11680 {
11681 return ConfigGetFloat("itemModelLength");
11682 }
11683 return 0;
11684 }
11685
11686 float GetItemAttachOffset()
11687 {
11688 if (ConfigIsExisting("itemAttachOffset"))
11689 {
11690 return ConfigGetFloat("itemAttachOffset");
11691 }
11692 return 0;
11693 }
11694
11695 override void SetCleanness(int value, bool allow_client = false)
11696 {
11697 if (!IsServerCheck(allow_client))
11698 return;
11699
11700 int previousValue = m_Cleanness;
11701
11702 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
11703
11704 if (previousValue != m_Cleanness)
11705 SetVariableMask(VARIABLE_CLEANNESS);
11706 }
11707
11708 override int GetCleanness()
11709 {
11710 return m_Cleanness;
11711 }
11712
11714 {
11715 return true;
11716 }
11717
11718 //----------------------------------------------------------------
11719 // ATTACHMENT LOCKING
11720 // Getters relevant to generic ActionLockAttachment
11721 int GetLockType()
11722 {
11723 return m_LockType;
11724 }
11725
11726 string GetLockSoundSet()
11727 {
11728 return m_LockSoundSet;
11729 }
11730
11731 //----------------------------------------------------------------
11732 //------------------------- Color
11733 // sets items color variable given color components
11734 override void SetColor(int r, int g, int b, int a)
11735 {
11740 SetVariableMask(VARIABLE_COLOR);
11741 }
11743 override void GetColor(out int r,out int g,out int b,out int a)
11744 {
11749 }
11750
11751 bool IsColorSet()
11752 {
11753 return IsVariableSet(VARIABLE_COLOR);
11754 }
11755
11757 string GetColorString()
11758 {
11759 int r,g,b,a;
11760 GetColor(r,g,b,a);
11761 r = r/255;
11762 g = g/255;
11763 b = b/255;
11764 a = a/255;
11765 return MiscGameplayFunctions.GetColorString(r, g, b, a);
11766 }
11767 //----------------------------------------------------------------
11768 //------------------------- LiquidType
11769
11770 override void SetLiquidType(int value, bool allow_client = false)
11771 {
11772 if (!IsServerCheck(allow_client))
11773 return;
11774
11775 int old = m_VarLiquidType;
11776 m_VarLiquidType = value;
11777 OnLiquidTypeChanged(old,value);
11778 SetVariableMask(VARIABLE_LIQUIDTYPE);
11779 }
11780
11781 int GetLiquidTypeInit()
11782 {
11783 return ConfigGetInt("varLiquidTypeInit");
11784 }
11785
11786 override int GetLiquidType()
11787 {
11788 return m_VarLiquidType;
11789 }
11790
11791 protected void OnLiquidTypeChanged(int oldType, int newType)
11792 {
11793 if (newType == LIQUID_NONE && GetIsFrozen())
11794 SetFrozen(false);
11795 }
11796
11798 void UpdateQuickbarShortcutVisibility(PlayerBase player)
11799 {
11800 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11801 }
11802
11803 // -------------------------------------------------------------------------
11805 void OnInventoryEnter(Man player)
11806 {
11807 PlayerBase nplayer;
11808 if (PlayerBase.CastTo(nplayer, player))
11809 {
11810 m_CanPlayImpactSound = true;
11811 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
11812 }
11813 }
11814
11815 // -------------------------------------------------------------------------
11817 void OnInventoryExit(Man player)
11818 {
11819 PlayerBase nplayer;
11820 if (PlayerBase.CastTo(nplayer,player))
11821 {
11822 nplayer.SetEnableQuickBarEntityShortcut(this, false);
11823 }
11824
11825 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
11826
11827 if (HasEnergyManager())
11828 {
11829 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
11830 }
11831 }
11832
11833 // ADVANCED PLACEMENT EVENTS
11834 override void OnPlacementStarted(Man player)
11835 {
11836 super.OnPlacementStarted(player);
11837
11838 SetTakeable(false);
11839 }
11840
11841 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
11842 {
11843 if (m_AdminLog)
11844 {
11845 m_AdminLog.OnPlacementComplete(player, this);
11846 }
11847
11848 super.OnPlacementComplete(player, position, orientation);
11849 }
11850
11851 //-----------------------------
11852 // AGENT SYSTEM
11853 //-----------------------------
11854 //--------------------------------------------------------------------------
11855 bool ContainsAgent(int agent_id)
11856 {
11857 if (agent_id & m_AttachedAgents)
11858 {
11859 return true;
11860 }
11861 else
11862 {
11863 return false;
11864 }
11865 }
11866
11867 //--------------------------------------------------------------------------
11868 override void RemoveAgent(int agent_id)
11869 {
11870 if (ContainsAgent(agent_id))
11871 {
11872 m_AttachedAgents = ~agent_id & m_AttachedAgents;
11873 }
11874 }
11875
11876 //--------------------------------------------------------------------------
11877 override void RemoveAllAgents()
11878 {
11879 m_AttachedAgents = 0;
11880 }
11881 //--------------------------------------------------------------------------
11882 override void RemoveAllAgentsExcept(int agent_to_keep)
11883 {
11884 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
11885 }
11886 // -------------------------------------------------------------------------
11887 override void InsertAgent(int agent, float count = 1)
11888 {
11889 if (count < 1)
11890 return;
11891 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
11893 }
11894
11896 void TransferAgents(int agents)
11897 {
11899 }
11900
11901 // -------------------------------------------------------------------------
11902 override int GetAgents()
11903 {
11904 return m_AttachedAgents;
11905 }
11906 //----------------------------------------------------------------------
11907
11908 /*int GetContaminationType()
11909 {
11910 int contamination_type;
11911
11912 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
11913 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
11914 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
11915 const int DIRTY_MASK = eAgents.WOUND_AGENT;
11916
11917 Edible_Base edible = Edible_Base.Cast(this);
11918 int agents = GetAgents();
11919 if (edible)
11920 {
11921 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
11922 if (profile)
11923 {
11924 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
11925 }
11926 }
11927 if (agents & CONTAMINATED_MASK)
11928 {
11929 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
11930 }
11931 if (agents & POISONED_MASK)
11932 {
11933 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
11934 }
11935 if (agents & NERVE_GAS_MASK)
11936 {
11937 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
11938 }
11939 if (agents & DIRTY_MASK)
11940 {
11941 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
11942 }
11943
11944 return agents;
11945 }*/
11946
11947 // -------------------------------------------------------------------------
11948 bool LoadAgents(ParamsReadContext ctx, int version)
11949 {
11950 if (!ctx.Read(m_AttachedAgents))
11951 return false;
11952 return true;
11953 }
11954 // -------------------------------------------------------------------------
11956 {
11957
11959 }
11960 // -------------------------------------------------------------------------
11961
11963 override void CheckForRoofLimited(float timeTresholdMS = 3000)
11964 {
11965 super.CheckForRoofLimited(timeTresholdMS);
11966
11967 float time = g_Game.GetTime();
11968 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
11969 {
11970 m_PreviousRoofTestTime = time;
11971 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
11972 }
11973 }
11974
11975 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
11976 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
11977 {
11978 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
11979 {
11980 return 0;
11981 }
11982
11983 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
11984 {
11985 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
11986 if (filter)
11987 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
11988 else
11989 return 0;//otherwise return 0 when no filter attached
11990 }
11991
11992 string subclassPath, entryName;
11993
11994 switch (type)
11995 {
11996 case DEF_BIOLOGICAL:
11997 entryName = "biological";
11998 break;
11999 case DEF_CHEMICAL:
12000 entryName = "chemical";
12001 break;
12002 default:
12003 entryName = "biological";
12004 break;
12005 }
12006
12007 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12008
12009 return g_Game.ConfigGetFloat(subclassPath + entryName);
12010 }
12011
12012
12013
12015 override void EEOnCECreate()
12016 {
12017 if (!IsMagazine())
12019
12021 }
12022
12023
12024 //-------------------------
12025 // OPEN/CLOSE USER ACTIONS
12026 //-------------------------
12028 void Open();
12029 void Close();
12030 bool IsOpen()
12031 {
12032 return true;
12033 }
12034
12035 override bool CanDisplayCargo()
12036 {
12037 return IsOpen();
12038 }
12039
12040
12041 // ------------------------------------------------------------
12042 // CONDITIONS
12043 // ------------------------------------------------------------
12044 override bool CanPutInCargo(EntityAI parent)
12045 {
12046 if (parent)
12047 {
12048 if (parent.IsInherited(DayZInfected))
12049 return true;
12050
12051 if (!parent.IsRuined())
12052 return true;
12053 }
12054
12055 return true;
12056 }
12057
12058 override bool CanPutAsAttachment(EntityAI parent)
12059 {
12060 if (!super.CanPutAsAttachment(parent))
12061 {
12062 return false;
12063 }
12064
12065 if (!IsRuined() && !parent.IsRuined())
12066 {
12067 return true;
12068 }
12069
12070 return false;
12071 }
12072
12073 override bool CanReceiveItemIntoCargo(EntityAI item)
12074 {
12075 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12076 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12077 // return false;
12078
12079 return super.CanReceiveItemIntoCargo(item);
12080 }
12081
12082 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12083 {
12084 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12085 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12086 // return false;
12087
12088 GameInventory attachmentInv = attachment.GetInventory();
12089 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12090 {
12091 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12092 return false;
12093 }
12094
12095 InventoryLocation loc = new InventoryLocation();
12096 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12097 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12098 return false;
12099
12100 return super.CanReceiveAttachment(attachment, slotId);
12101 }
12102
12103 override bool CanReleaseAttachment(EntityAI attachment)
12104 {
12105 if (!super.CanReleaseAttachment(attachment))
12106 return false;
12107
12108 return GetInventory().AreChildrenAccessible();
12109 }
12110
12111 /*override bool CanLoadAttachment(EntityAI attachment)
12112 {
12113 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12114 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12115 // return false;
12116
12117 GameInventory attachmentInv = attachment.GetInventory();
12118 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12119 {
12120 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12121 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12122
12123 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12124 return false;
12125 }
12126
12127 return super.CanLoadAttachment(attachment);
12128 }*/
12129
12130 // Plays muzzle flash particle effects
12131 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12132 {
12133 int id = muzzle_owner.GetMuzzleID();
12134 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12135
12136 if (WPOF_array)
12137 {
12138 for (int i = 0; i < WPOF_array.Count(); i++)
12139 {
12140 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12141
12142 if (WPOF)
12143 {
12144 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12145 }
12146 }
12147 }
12148 }
12149
12150 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12151 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12152 {
12153 int id = muzzle_owner.GetMuzzleID();
12154 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12155
12156 if (WPOBE_array)
12157 {
12158 for (int i = 0; i < WPOBE_array.Count(); i++)
12159 {
12160 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12161
12162 if (WPOBE)
12163 {
12164 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12165 }
12166 }
12167 }
12168 }
12169
12170 // Plays all weapon overheating particles
12171 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12172 {
12173 int id = muzzle_owner.GetMuzzleID();
12174 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12175
12176 if (WPOOH_array)
12177 {
12178 for (int i = 0; i < WPOOH_array.Count(); i++)
12179 {
12180 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12181
12182 if (WPOOH)
12183 {
12184 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12185 }
12186 }
12187 }
12188 }
12189
12190 // Updates all weapon overheating particles
12191 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12192 {
12193 int id = muzzle_owner.GetMuzzleID();
12194 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12195
12196 if (WPOOH_array)
12197 {
12198 for (int i = 0; i < WPOOH_array.Count(); i++)
12199 {
12200 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12201
12202 if (WPOOH)
12203 {
12204 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12205 }
12206 }
12207 }
12208 }
12209
12210 // Stops overheating particles
12211 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12212 {
12213 int id = muzzle_owner.GetMuzzleID();
12214 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12215
12216 if (WPOOH_array)
12217 {
12218 for (int i = 0; i < WPOOH_array.Count(); i++)
12219 {
12220 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12221
12222 if (WPOOH)
12223 {
12224 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12225 }
12226 }
12227 }
12228 }
12229
12230 //----------------------------------------------------------------
12231 //Item Behaviour - unified approach
12232 override bool IsHeavyBehaviour()
12233 {
12234 if (m_ItemBehaviour == 0)
12235 {
12236 return true;
12237 }
12238
12239 return false;
12240 }
12241
12242 override bool IsOneHandedBehaviour()
12243 {
12244 if (m_ItemBehaviour == 1)
12245 {
12246 return true;
12247 }
12248
12249 return false;
12250 }
12251
12252 override bool IsTwoHandedBehaviour()
12253 {
12254 if (m_ItemBehaviour == 2)
12255 {
12256 return true;
12257 }
12258
12259 return false;
12260 }
12261
12262 bool IsDeployable()
12263 {
12264 return false;
12265 }
12266
12268 float GetDeployTime()
12269 {
12270 return UATimeSpent.DEFAULT_DEPLOY;
12271 }
12272
12273
12274 //----------------------------------------------------------------
12275 // Item Targeting (User Actions)
12276 override void SetTakeable(bool pState)
12277 {
12278 m_IsTakeable = pState;
12279 SetSynchDirty();
12280 }
12281
12282 override bool IsTakeable()
12283 {
12284 return m_IsTakeable;
12285 }
12286
12287 // For cases where we want to show object widget which cant be taken to hands
12289 {
12290 return false;
12291 }
12292
12294 protected void PreLoadSoundAttachmentType()
12295 {
12296 string att_type = "None";
12297
12298 if (ConfigIsExisting("soundAttType"))
12299 {
12300 att_type = ConfigGetString("soundAttType");
12301 }
12302
12303 m_SoundAttType = att_type;
12304 }
12305
12306 override string GetAttachmentSoundType()
12307 {
12308 return m_SoundAttType;
12309 }
12310
12311 //----------------------------------------------------------------
12312 //SOUNDS - ItemSoundHandler
12313 //----------------------------------------------------------------
12314
12315 string GetPlaceSoundset(); // played when deploy starts
12316 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12317 string GetDeploySoundset(); // played when deploy sucessfully finishes
12318 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12319 string GetFoldSoundset(); // played when fold sucessfully finishes
12320
12322 {
12323 if (!m_ItemSoundHandler)
12325
12326 return m_ItemSoundHandler;
12327 }
12328
12329 // override to initialize sounds
12330 protected void InitItemSounds()
12331 {
12332 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
12333 return;
12334
12336
12337 if (GetPlaceSoundset() != string.Empty)
12338 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12339
12340 if (GetDeploySoundset() != string.Empty)
12341 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12342
12343 SoundParameters params = new SoundParameters();
12344 params.m_Loop = true;
12345 if (GetLoopDeploySoundset() != string.Empty)
12346 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12347 }
12348
12349 // Start sound using ItemSoundHandler
12350 void StartItemSoundServer(int id, int slotId)
12351 {
12352 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12353 {
12354 m_SoundSyncSlotID = slotId;
12355 m_SoundSyncPlay = id;
12356
12357 SetSynchDirty();
12358
12359 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12360 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12361 }
12362 }
12363
12364 void StartItemSoundServer(int id)
12365 {
12366 StartItemSoundServer(id, InventorySlots.INVALID);
12367 }
12368
12369 // Stop sound using ItemSoundHandler
12370 void StopItemSoundServer(int id)
12371 {
12372 if (!g_Game.IsServer())
12373 return;
12374
12375 m_SoundSyncStop = id;
12376 SetSynchDirty();
12377
12378 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12379 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12380 }
12381
12382 protected void ClearStartItemSoundServer()
12383 {
12384 m_SoundSyncPlay = 0;
12385 m_SoundSyncSlotID = InventorySlots.INVALID;
12386 }
12387
12388 protected void ClearStopItemSoundServer()
12389 {
12390 m_SoundSyncStop = 0;
12391 }
12392
12393 void OnApply(PlayerBase player);
12394
12396 {
12397 return 1.0;
12398 };
12399 //returns applicable selection
12400 array<string> GetHeadHidingSelection()
12401 {
12403 }
12404
12406 {
12408 }
12409
12410 WrittenNoteData GetWrittenNoteData() {};
12411
12413 {
12414 SetDynamicPhysicsLifeTime(0.01);
12415 m_ItemBeingDroppedPhys = false;
12416 }
12417
12419 {
12420 array<string> zone_names = new array<string>;
12421 GetDamageZones(zone_names);
12422 for (int i = 0; i < zone_names.Count(); i++)
12423 {
12424 SetHealthMax(zone_names.Get(i),"Health");
12425 }
12426 SetHealthMax("","Health");
12427 }
12428
12430 void SetZoneDamageCEInit()
12431 {
12432 float global_health = GetHealth01("","Health");
12433 array<string> zones = new array<string>;
12434 GetDamageZones(zones);
12435 //set damage of all zones to match global health level
12436 for (int i = 0; i < zones.Count(); i++)
12437 {
12438 SetHealth01(zones.Get(i),"Health",global_health);
12439 }
12440 }
12441
12443 bool IsCoverFaceForShave(string slot_name)
12444 {
12445 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12446 }
12447
12448 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12449 {
12450 if (!hasRootAsPlayer)
12451 {
12452 if (refParentIB)
12453 {
12454 // parent is wet
12455 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12456 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12457 // parent has liquid inside
12458 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12459 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12460 // drying
12461 else if (m_VarWet > m_VarWetMin)
12462 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12463 }
12464 else
12465 {
12466 // drying on ground or inside non-itembase (car, ...)
12467 if (m_VarWet > m_VarWetMin)
12468 AddWet(-1 * delta * GetDryingIncrement("ground"));
12469 }
12470 }
12471 }
12472
12473 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12474 {
12476 {
12477 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12478 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12479 {
12480 float heatPermCoef = 1.0;
12481 EntityAI ent = this;
12482 while (ent)
12483 {
12484 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12485 ent = ent.GetHierarchyParent();
12486 }
12487
12488 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12489 }
12490 }
12491 }
12492
12493 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12494 {
12495 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12496 EntityAI parent = GetHierarchyParent();
12497 if (!parent)
12498 {
12499 hasParent = false;
12500 hasRootAsPlayer = false;
12501 }
12502 else
12503 {
12504 hasParent = true;
12505 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12506 refParentIB = ItemBase.Cast(parent);
12507 }
12508 }
12509
12510 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12511 {
12512 // this is stub, implemented on Edible_Base
12513 }
12514
12515 bool CanDecay()
12516 {
12517 // return true used on selected food clases so they can decay
12518 return false;
12519 }
12520
12521 protected bool CanProcessDecay()
12522 {
12523 // this is stub, implemented on Edible_Base class
12524 // used to determine whether it is still necessary for the food to decay
12525 return false;
12526 }
12527
12528 protected bool CanHaveWetness()
12529 {
12530 // return true used on selected items that have a wetness effect
12531 return false;
12532 }
12533
12535 bool CanBeConsumed(ConsumeConditionData data = null)
12536 {
12537 return !GetIsFrozen() && IsOpen();
12538 }
12539
12540 override void ProcessVariables()
12541 {
12542 bool hasParent = false, hasRootAsPlayer = false;
12543 ItemBase refParentIB;
12544
12545 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12546 bool foodDecay = g_Game.IsFoodDecayEnabled();
12547
12548 if (wwtu || foodDecay)
12549 {
12550 bool processWetness = wwtu && CanHaveWetness();
12551 bool processTemperature = wwtu && CanHaveTemperature();
12552 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12553
12554 if (processWetness || processTemperature || processDecay)
12555 {
12556 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12557
12558 if (processWetness)
12559 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12560
12561 if (processTemperature)
12562 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12563
12564 if (processDecay)
12565 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12566 }
12567 }
12568 }
12569
12572 {
12573 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
12574 }
12575
12576 override float GetTemperatureFreezeThreshold()
12577 {
12579 return Liquid.GetFreezeThreshold(GetLiquidType());
12580
12581 return super.GetTemperatureFreezeThreshold();
12582 }
12583
12584 override float GetTemperatureThawThreshold()
12585 {
12587 return Liquid.GetThawThreshold(GetLiquidType());
12588
12589 return super.GetTemperatureThawThreshold();
12590 }
12591
12592 override float GetItemOverheatThreshold()
12593 {
12595 return Liquid.GetBoilThreshold(GetLiquidType());
12596
12597 return super.GetItemOverheatThreshold();
12598 }
12599
12600 override float GetTemperatureFreezeTime()
12601 {
12602 if (HasQuantity())
12603 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
12604
12605 return super.GetTemperatureFreezeTime();
12606 }
12607
12608 override float GetTemperatureThawTime()
12609 {
12610 if (HasQuantity())
12611 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
12612
12613 return super.GetTemperatureThawTime();
12614 }
12615
12617 void AffectLiquidContainerOnFill(int liquid_type, float amount);
12619 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
12620
12621 bool IsCargoException4x3(EntityAI item)
12622 {
12623 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
12624 }
12625
12627 {
12628 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
12629 }
12630
12632 void AddLightSourceItem(ItemBase lightsource)
12633 {
12634 m_LightSourceItem = lightsource;
12635 }
12636
12638 {
12639 m_LightSourceItem = null;
12640 }
12641
12643 {
12644 return m_LightSourceItem;
12645 }
12646
12648 array<int> GetValidFinishers()
12649 {
12650 return null;
12651 }
12652
12654 bool GetActionWidgetOverride(out typename name)
12655 {
12656 return false;
12657 }
12658
12659 bool PairWithDevice(notnull ItemBase otherDevice)
12660 {
12661 if (g_Game.IsServer())
12662 {
12663 ItemBase explosive = otherDevice;
12665 if (!trg)
12666 {
12667 trg = RemoteDetonatorTrigger.Cast(otherDevice);
12668 explosive = this;
12669 }
12670
12671 explosive.PairRemote(trg);
12672 trg.SetControlledDevice(explosive);
12673
12674 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
12675 trg.SetPersistentPairID(persistentID);
12676 explosive.SetPersistentPairID(persistentID);
12677
12678 return true;
12679 }
12680 return false;
12681 }
12682
12684 float GetBaitEffectivity()
12685 {
12686 float ret = 1.0;
12687 if (HasQuantity())
12688 ret *= GetQuantityNormalized();
12689 ret *= GetHealth01();
12690
12691 return ret;
12692 }
12693
12694 #ifdef DEVELOPER
12695 override void SetDebugItem()
12696 {
12697 super.SetDebugItem();
12698 _itemBase = this;
12699 }
12700
12701 override string GetDebugText()
12702 {
12703 string text = super.GetDebugText();
12704
12705 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
12706 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
12707
12708 return text;
12709 }
12710 #endif
12711
12712 bool CanBeUsedForSuicide()
12713 {
12714 return true;
12715 }
12716
12718 //DEPRECATED BELOW
12720 // Backwards compatibility
12721 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12722 {
12723 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
12724 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
12725 }
12726
12727 // replaced by ItemSoundHandler
12728 protected EffectSound m_SoundDeployFinish;
12729 protected EffectSound m_SoundPlace;
12730 protected EffectSound m_DeployLoopSoundEx;
12731 protected EffectSound m_SoundDeploy;
12732 bool m_IsPlaceSound;
12733 bool m_IsDeploySound;
12735
12736 string GetDeployFinishSoundset();
12737 void PlayDeploySound();
12738 void PlayDeployFinishSound();
12739 void PlayPlaceSound();
12740 void PlayDeployLoopSoundEx();
12741 void StopDeployLoopSoundEx();
12742 void SoundSynchRemoteReset();
12743 void SoundSynchRemote();
12744 bool UsesGlobalDeploy(){return false;}
12745 bool CanPlayDeployLoopSound(){return false;}
12747 bool IsPlaceSound(){return m_IsPlaceSound;}
12748 bool IsDeploySound(){return m_IsDeploySound;}
12749 void SetIsPlaceSound(bool is_place_sound);
12750 void SetIsDeploySound(bool is_deploy_sound);
12751
12752 [Obsolete("Use ItemSoundHandler instead")]
12754 void PlayAttachSound(string slot_type)
12755 {
12756 if (!g_Game.IsDedicatedServer())
12757 {
12758 if (ConfigIsExisting("attachSoundSet"))
12759 {
12760 string cfg_path = "";
12761 string soundset = "";
12762 string type_name = GetType();
12763
12764 TStringArray cfg_soundset_array = new TStringArray;
12765 TStringArray cfg_slot_array = new TStringArray;
12766 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
12767 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
12768
12769 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
12770 {
12771 for (int i = 0; i < cfg_soundset_array.Count(); i++)
12772 {
12773 if (cfg_slot_array[i] == slot_type)
12774 {
12775 soundset = cfg_soundset_array[i];
12776 break;
12777 }
12778 }
12779 }
12780
12781 if (soundset != "")
12782 {
12783 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
12784 sound.SetAutodestroy(true);
12785 }
12786 }
12787 }
12788 }
12789
12790 void PlayDetachSound(string slot_type) {}
12791}
12792
12793EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
12794{
12795 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
12796 if (entity)
12797 {
12798 bool is_item = entity.IsInherited(ItemBase);
12799 if (is_item && full_quantity)
12800 {
12801 ItemBase item = ItemBase.Cast(entity);
12802 item.SetQuantity(item.GetQuantityInit());
12803 }
12804 }
12805 else
12806 {
12807 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
12808 return NULL;
12809 }
12810 return entity;
12811}
12812
12813void SetupSpawnedItem(ItemBase item, float health, float quantity)
12814{
12815 if (item)
12816 {
12817 if (health > 0)
12818 item.SetHealth("", "", health);
12819
12820 if (item.CanHaveTemperature())
12821 {
12822 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
12823 if (item.CanFreeze())
12824 item.SetFrozen(false);
12825 }
12826
12827 if (item.HasEnergyManager())
12828 {
12829 if (quantity >= 0)
12830 {
12831 item.GetCompEM().SetEnergy0To1(quantity);
12832 }
12833 else
12834 {
12835 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
12836 }
12837 }
12838 else if (item.IsMagazine())
12839 {
12840 Magazine mag = Magazine.Cast(item);
12841 if (quantity >= 0)
12842 {
12843 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
12844 }
12845 else
12846 {
12847 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
12848 }
12849
12850 }
12851 else
12852 {
12853 if (quantity >= 0)
12854 {
12855 item.SetQuantityNormalized(quantity, false);
12856 }
12857 else
12858 {
12859 item.SetQuantity(Math.AbsFloat(quantity));
12860 }
12861
12862 }
12863 }
12864}
12865
12866#ifdef DEVELOPER
12867ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
12868#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()

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