DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ItemBase.c
Go to the documentation of this file.
2
3class DummyItem extends ItemBase
4{
5 override bool CanPutAsAttachment(EntityAI parent)
6 {
7 return true;
8 }
9};
10
11//const bool QUANTITY_DEBUG_REMOVE_ME = false;
12
14{
18
21 // ============================================
22 // Variable Manipulation System
23 // ============================================
24 //ref map<string,string> m_ItemVarsString;
25
26 int m_VariablesMask;//this holds information about which vars have been changed from their default values
27 // Quantity
28
30 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
37 // Temperature
42 // Wet
43 float m_VarWet;
44 float m_VarWetPrev;//for client to know wetness changed during synchronization
48 // Cleanness
53 // impact sounds
58 //
62 int m_ItemBehaviour = -1; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
73 bool m_FixDamageSystemInit = false; //can be changed on storage version check
74 bool can_this_be_combined = false; //Check if item can be combined
75 bool m_CanThisBeSplit = false; //Check if item can be split
76 bool m_IsStoreLoad = false;
79 protected bool m_CanBeDigged;
80 protected bool m_IsResultOfSplit
81
83 // items color variables
88 //-------------------------------------------------------
89
90 // light source managing
92
96
97 //==============================================
98 // agent system
99 private int m_AttachedAgents;
100
101 // Declarations
103
104
105 // Weapons & suppressors particle effects
111
112 // Overheating effects
116 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
117 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
118 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
119 ref array <ref OverheatingParticle> m_OverheatingParticles;
120
123
124 // Admin Log
125 PluginAdminLog m_AdminLog;
126
127 // misc
129
130 // Attachment Locking variables
132 protected int m_LockType;
134 protected string m_LockSoundSet = "";
135
139
140 // -------------------------------------------------------------------------
141 void ItemBase()
142 {
143 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
145
149
150 if (!GetGame().IsDedicatedServer())
151 {
152 if (HasMuzzle())
153 {
155
157 {
159 }
160 }
161
163 m_ActionsInitialize = false;
164 }
165
166 m_OldLocation = null;
167
168 if (GetGame().IsServer())
169 {
170 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
171 }
172
173 if (ConfigIsExisting("headSelectionsToHide"))
174 {
176 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
177 }
178
180 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
181 {
182 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
183 }
184
185
186
187 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
188
189 m_IsResultOfSplit = false;
190 }
191
193 {
194 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
195 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
196 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
197 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
198 m_VarStackMax = ConfigGetFloat("varStackMax");
199 m_Count = ConfigGetInt("count");
200
201 m_CanShowQuantity = ConfigGetBool("quantityShow");
202 m_HasQuantityBar = ConfigGetBool("quantityBar");
203
204 m_VarTemperatureInit = ConfigGetFloat("varTemperatureInit");
206 m_VarTemperatureMin = ConfigGetFloat("varTemperatureMin");
207 m_VarTemperatureMax = ConfigGetFloat("varTemperatureMax");
208
209
210 m_CleannessInit = ConfigGetInt("varCleannessInit");
212 m_CleannessMin = ConfigGetInt("varCleannessMin");
213 m_CleannessMax = ConfigGetInt("varCleannessMax");
214
215 m_WantPlayImpactSound = false;
216 m_ImpactSpeed = 0.0;
217
218 m_VarWetInit = ConfigGetFloat("varWetInit");
220 m_VarWetMin = ConfigGetFloat("varWetMin");
221 m_VarWetMax = ConfigGetFloat("varWetMax");
222
224 m_IsBeingPlaced = false;
225 m_IsHologram = false;
226 m_IsPlaceSound = false;
227 m_IsDeploySound = false;
228 m_IsTakeable = true;
229 m_IsSoundSynchRemote = false;
230 m_CanBeMovedOverride = false;
233 m_CanBeDigged = ConfigGetBool("canBeDigged");
234
235 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
236 m_LockType = ConfigGetInt("lockType");
237
238 //Define if item can be split and set ability to be combined accordingly
239 if (ConfigIsExisting("canBeSplit"))
240 {
241 can_this_be_combined = ConfigGetBool("canBeSplit");
243 }
244
245 if (ConfigIsExisting("itemBehaviour"))
246 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
247
248 //RegisterNetSyncVariableInt("m_VariablesMask");
249 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
250 RegisterNetSyncVariableFloat("m_VarTemperature", GetTemperatureMin(),GetTemperatureMax());
251 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
252 RegisterNetSyncVariableInt("m_VarLiquidType");
253 RegisterNetSyncVariableInt("m_Cleanness",0,1);
254
255 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
256 RegisterNetSyncVariableFloat("m_ImpactSpeed");
257 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
258
259 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
260 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
261 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
262 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
263
264 RegisterNetSyncVariableBool("m_IsBeingPlaced");
265 RegisterNetSyncVariableBool("m_IsTakeable");
266 RegisterNetSyncVariableBool("m_IsHologram");
267
268 m_LockSoundSet = ConfigGetString("lockSoundSet");
269 }
270
271 override int GetQuickBarBonus()
272 {
273 return m_QuickBarBonus;
274 }
275
277 {
279 if (!m_InputActionMap)
280 {
282 m_InputActionMap = iam;
283 SetActions();
284 m_ItemTypeActionsMap.Insert(this.Type(), m_InputActionMap);
285 }
286 }
287
288 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
289 {
291 {
292 m_ActionsInitialize = true;
294 }
295
296 actions = m_InputActionMap.Get(action_input_type);
297 }
298
300 {
304 //AddAction(ActionWorldCraftSwitch);
307 //AddAction();
308 //AddAction();
309 }
310
311 void AddAction(typename actionName)
312 {
313 ActionBase action = ActionManagerBase.GetAction(actionName);
314
315 if (!action)
316 {
317 Debug.LogError("Action " + actionName + " dosn't exist!");
318 return;
319 }
320
321 typename ai = action.GetInputType();
322 if (!ai)
323 {
324 m_ActionsInitialize = false;
325 return;
326 }
327
328 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
329 if (!action_array)
330 {
331 action_array = new array<ActionBase_Basic>;
332 m_InputActionMap.Insert(ai, action_array);
333 }
335 {
336 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
337 }
338
339 if (action_array.Find(action) != -1)
340 {
341 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
342 }
343 else
344 {
345 action_array.Insert(action);
346 }
347 }
348
349 void RemoveAction(typename actionName)
350 {
351 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
352 ActionBase action = player.GetActionManager().GetAction(actionName);
353 typename ai = action.GetInputType();
354 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
355
356 if (action_array)
357 {
358 action_array.RemoveItem(action);
359 }
360 }
361
363
365
366 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
368 {
369 if (!m_OnFireEffect)
371
374
375 string config_to_search = "CfgVehicles";
376 string muzzle_owner_config;
377
378 if (!m_OnFireEffect.Contains(id))
379 {
380 if (IsInherited(Weapon))
381 config_to_search = "CfgWeapons";
382
383 muzzle_owner_config = config_to_search + " " + GetType() + " ";
384
385 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
386
387 int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
388
389 if (config_OnFire_subclass_count > 0)
390 {
392
393 for (int i = 0; i < config_OnFire_subclass_count; i++)
394 {
395 string particle_class = "";
396 GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
397 string config_OnFire_entry = config_OnFire_class + particle_class;
398 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
399 WPOF_array.Insert(WPOF);
400 }
401
402
403 m_OnFireEffect.Insert(id, WPOF_array);
404 }
405 }
406
407 if (!m_OnBulletCasingEjectEffect.Contains(id))
408 {
409 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
410 muzzle_owner_config = config_to_search + " " + GetType() + " ";
411
412 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
413
414 int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
415
416 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
417 {
419
420 for (i = 0; i < config_OnBulletCasingEject_count; i++)
421 {
422 string particle_class2 = "";
423 GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
424 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
425 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
426 WPOBE_array.Insert(WPOBE);
427 }
428
429
430 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
431 }
432 }
433 }
434
435 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
437 {
440
441 if (!m_OnOverheatingEffect.Contains(id))
442 {
443 string config_to_search = "CfgVehicles";
444
445 if (IsInherited(Weapon))
446 config_to_search = "CfgWeapons";
447
448 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
449 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
450
451 if (GetGame().ConfigIsExisting(config_OnOverheating_class))
452 {
453
454 m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
455
457 {
458 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
459 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
460 Error(error);
461 return;
462 }
463
464 m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
465 m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
466
467
468
469 int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
471
472 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
473 {
474 string particle_class = "";
475 GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
476 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
477 int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
478
479 if (entry_type == CT_CLASS)
480 {
481 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
482 WPOOH_array.Insert(WPOF);
483 }
484 }
485
486
487 m_OnOverheatingEffect.Insert(id, WPOOH_array);
488 }
489 }
490 }
491
493 {
494 return m_OverheatingShots;
495 }
496
497 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
498 {
499 if (m_MaxOverheatingValue > 0)
500 {
502
505
507 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
508
509 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
510 }
511 }
512
513 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
514 {
516 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
517
519 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
520
522 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
523
525 {
527 }
528 }
529
531 {
533 }
534
536 {
537 if (m_MaxOverheatingValue > 0)
538 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
539 else
541
542 if (m_OverheatingShots <= 0)
543 {
546 }
547 else
548 {
551
553 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
554 }
555
556 CheckOverheating(this, "", this);
557 }
558
559 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
560 {
562 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
563 }
564
565 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
566 {
568 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
570 }
571
572 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
573 {
575 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
576 }
577
578 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
579 {
582
584 OP.RegisterParticle(p);
585 OP.SetOverheatingLimitMin(min_heat_coef);
586 OP.SetOverheatingLimitMax(max_heat_coef);
587 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
588
589 m_OverheatingParticles.Insert(OP);
590 }
591
593 {
594 if (m_MaxOverheatingValue > 0)
596
597 return -1;
598 }
599
601 {
603 {
604 float overheat_coef = GetOverheatingCoef();
605 int count = m_OverheatingParticles.Count();
606
607 for (int i = count; i > 0; --i)
608 {
609 int id = i - 1;
611 Particle p = OP.GetParticle();
612
613 float overheat_min = OP.GetOverheatingLimitMin();
614 float overheat_max = OP.GetOverheatingLimitMax();
615
616 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
617 {
618 if (p)
619 {
620 p.Stop();
621 OP.RegisterParticle(null);
622 }
623 }
624 }
625 }
626 }
627
629 {
631 {
632 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
633 {
634 int id = i - 1;
636
637 if (OP)
638 {
639 Particle p = OP.GetParticle();
640
641 if (p)
642 {
643 p.Stop();
644 }
645
646 delete OP;
647 }
648 }
649
652 }
653 }
654
656 float GetInfectionChance(int system = 0, Param param = null)
657 {
658 return 0.0;
659 }
660
661
662 float GetDisinfectQuantity(int system = 0, Param param1 = null)
663 {
664 return 250;//default value
665 }
666
668 {
669 return 0;
670 }
671
674 {
675 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
676 return true;
677
678 return false;
679 }
680
683 {
684 if (!m_WeaponTypeToID)
686
687 if (m_WeaponTypeToID.Contains(GetType()))
688 {
689 return m_WeaponTypeToID.Get(GetType());
690 }
691 else
692 {
693 // Register new weapon ID
695 }
696
698 }
699
706 {
707 return -1;
708 }
709
710 // -------------------------------------------------------------------------
712 {
713 if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
714 {
715 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
716 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
717
718 if (r_index >= 0)
719 {
721 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
722
723 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
724 int r_type = r_il.GetType();
725 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
726 {
727 r_il.GetParent().GetOnReleaseLock().Invoke(this);
728 }
729 else if (r_type == InventoryLocationType.ATTACHMENT)
730 {
731 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
732 }
733
734 }
735
736 player.GetHumanInventory().ClearUserReservedLocation(this);
737 }
738
740 }
741
742 // -------------------------------------------------------------------------
744 {
745 return ItemBase.m_DebugActionsMask;
746 }
747
748 static bool HasDebugActionsMask(int mask)
749 {
750 return ItemBase.m_DebugActionsMask & mask;
751 }
752
753 static void SetDebugActionsMask(int mask)
754 {
755 ItemBase.m_DebugActionsMask = mask;
756 }
757
758 static void AddDebugActionsMask(int mask)
759 {
760 ItemBase.m_DebugActionsMask |= mask;
761 }
762
763 static void RemoveDebugActionsMask(int mask)
764 {
765 ItemBase.m_DebugActionsMask &= ~mask;
766 }
767
768 static void ToggleDebugActionsMask(int mask)
769 {
770 if (HasDebugActionsMask(mask))
771 {
773 }
774 else
775 {
777 }
778 }
779
780 // -------------------------------------------------------------------------
782 {
783 if (GetEconomyProfile())
784 {
785 float q_min = GetEconomyProfile().GetQuantityMin();
786 float q_max = GetEconomyProfile().GetQuantityMax();
787 if (q_max > 0)
788 {
789 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
790 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
791 SetQuantityNormalized(quantity_randomized, false);
792 }
793 }
794 }
795
798 {
799 EntityAI parent = GetHierarchyParent();
800
801 if (parent)
802 {
803 InventoryLocation inventory_location_to_lock = new InventoryLocation;
804 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
805 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
806 }
807 }
808
811 {
812 EntityAI parent = GetHierarchyParent();
813
814 if (parent)
815 {
816 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
817 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
818 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
819 }
820 }
821
822 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
823 {
824 /*
825 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
826 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
827 */
828 ItemBase item2 = ItemBase.Cast(entity2);
829
830 if (GetGame().IsClient())
831 {
833 {
836 ctx.Write(-1);
837 ItemBase i1 = this; // @NOTE: workaround for correct serialization
838 ctx.Write(i1);
839 ctx.Write(item2);
840 ctx.Write(use_stack_max);
841 ctx.Write(-1);
842 ctx.Send();
843
844 if (IsCombineAll(item2, use_stack_max))
845 {
846 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
847 }
848 }
849 }
850 else if (!GetGame().IsMultiplayer())
851 {
852 CombineItems(item2, use_stack_max);
853 }
854 }
855
857 {
858
859 return (GetLiquidType() != 0 && HasQuantity());
860 }
861
863 {
864 return (ConfigGetFloat("liquidContainerType") != 0);
865 }
866
868 {
869 return false;
870 }
871
872 bool IsNVG()
873 {
874 return false;
875 }
876
880 {
881 return false;
882 }
883
885 {
886 return "";
887 }
888
890
892 {
893 return false;
894 }
895
897 {
898 return true;
899 }
900
901 //--- ACTION CONDITIONS
902 //direction
903 bool IsFacingPlayer(PlayerBase player, string selection)
904 {
905 return true;
906 }
907
908 bool IsPlayerInside(PlayerBase player, string selection)
909 {
910 return true;
911 }
912
913 override bool CanObstruct()
914 {
915 return !IsPlayerInside(PlayerBase.Cast(g_Game.GetPlayer()), "");
916 }
917
918 override bool IsBeingPlaced()
919 {
920 return m_IsBeingPlaced;
921 }
922
923 void SetIsBeingPlaced(bool is_being_placed)
924 {
925 m_IsBeingPlaced = is_being_placed;
926 if (!is_being_placed)
928 SetSynchDirty();
929 }
930
931 //server-side
933
934 override bool IsHologram()
935 {
936 return m_IsHologram;
937 }
938
940 {
941 return m_CanBeDigged;
942 }
943
945 {
946 return false;
947 }
948
949 void SetIsHologram(bool is_hologram)
950 {
951 m_IsHologram = is_hologram;
952 SetSynchDirty();
953 }
954 /*
955 protected float GetNutritionalEnergy()
956 {
957 Edible_Base edible = Edible_Base.Cast(this);
958 return edible.GetFoodEnergy();
959 }
960
961 protected float GetNutritionalWaterContent()
962 {
963 Edible_Base edible = Edible_Base.Cast(this);
964 return edible.GetFoodWater();
965 }
966
967 protected float GetNutritionalIndex()
968 {
969 Edible_Base edible = Edible_Base.Cast(this);
970 return edible.GetFoodNutritionalIndex();
971 }
972
973 protected float GetNutritionalFullnessIndex()
974 {
975 Edible_Base edible = Edible_Base.Cast(this);
976 return edible.GetFoodTotalVolume();
977 }
978
979 protected float GetNutritionalToxicity()
980 {
981 Edible_Base edible = Edible_Base.Cast(this);
982 return edible.GetFoodToxicity();
983
984 }
985*/
986
987
988 // -------------------------------------------------------------------------
989 override void EECargoIn(EntityAI item)
990 {
991 super.EECargoIn(item);
992 }
993
994 override void OnMovedInsideCargo(EntityAI container)
995 {
996 super.OnMovedInsideCargo(container);
997
998 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
999 }
1000
1001 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
1002 {
1003 super.EEItemLocationChanged(oldLoc,newLoc);
1004
1005 PlayerBase new_player = null;
1006 PlayerBase old_player = null;
1007
1008 if (newLoc.GetParent())
1009 new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
1010
1011 if (oldLoc.GetParent())
1012 old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
1013
1014 if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
1015 {
1016 int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
1017
1018 if (r_index >= 0)
1019 {
1021 old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
1022
1023 old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
1024 int r_type = r_il.GetType();
1025 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
1026 {
1027 r_il.GetParent().GetOnReleaseLock().Invoke(this);
1028 }
1029 else if (r_type == InventoryLocationType.ATTACHMENT)
1030 {
1031 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
1032 }
1033
1034 }
1035 }
1036
1037 if (newLoc.GetType() == InventoryLocationType.HANDS)
1038 {
1039 if (new_player)
1040 new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
1041
1042 if (new_player == old_player)
1043 {
1044
1045 if (oldLoc.GetParent() && !(oldLoc.GetParent() != new_player && oldLoc.GetType() == InventoryLocationType.ATTACHMENT) && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
1046 {
1047 if (oldLoc.GetType() == InventoryLocationType.CARGO)
1048 {
1049 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
1050 {
1051 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
1052 }
1053 }
1054 else
1055 {
1056 new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
1057 }
1058 }
1059
1060 if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
1061 {
1062 int type = oldLoc.GetType();
1063 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
1064 {
1065 oldLoc.GetParent().GetOnSetLock().Invoke(this);
1066 }
1067 else if (type == InventoryLocationType.ATTACHMENT)
1068 {
1069 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
1070 }
1071 }
1072 if (!m_OldLocation)
1073 {
1074 m_OldLocation = new InventoryLocation;
1075 }
1076 m_OldLocation.Copy(oldLoc);
1077 }
1078 else
1079 {
1080 if (m_OldLocation)
1081 {
1082 m_OldLocation.Reset();
1083 }
1084 }
1085
1087 }
1088 else
1089 {
1090 if (new_player)
1091 {
1092 int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
1093 if (res_index >= 0)
1094 {
1096 new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
1097 ItemBase it = ItemBase.Cast(il.GetItem());
1098 new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
1099 int rel_type = il.GetType();
1100 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
1101 {
1102 il.GetParent().GetOnReleaseLock().Invoke(it);
1103 }
1104 else if (rel_type == InventoryLocationType.ATTACHMENT)
1105 {
1106 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
1107 }
1108 //it.GetOnReleaseLock().Invoke(it);
1109 }
1110 }
1111 else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
1112 {
1113 //Print("---ThrowPhysically---");
1114 //ThrowPhysically(old_player, vector.Zero);
1115 m_ThrowItemOnDrop = false;
1116 }
1117
1118 if (m_OldLocation)
1119 {
1120 m_OldLocation.Reset();
1121 }
1122 }
1123 }
1124
1125 override void EOnContact(IEntity other, Contact extra)
1126 {
1128 {
1129 int liquidType = -1;
1130 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
1131 if (impactSpeed > 0.0)
1132 {
1133 m_ImpactSpeed = impactSpeed;
1134 #ifndef SERVER
1135 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
1136 #else
1137 m_WantPlayImpactSound = true;
1138 SetSynchDirty();
1139 #endif
1140 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
1141 }
1142 }
1143 }
1144
1146
1147 override void OnCreatePhysics()
1148 {
1150 }
1151
1152 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
1153 {
1154
1155 }
1156 // -------------------------------------------------------------------------
1157 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
1158 {
1159 super.OnItemLocationChanged(old_owner, new_owner);
1160
1161 Man ownerPlayerOld = null;
1162 Man ownerPlayerNew = null;
1163
1164 if (old_owner)
1165 {
1166 if (old_owner.IsMan())
1167 {
1168 ownerPlayerOld = Man.Cast(old_owner);
1169 }
1170 else
1171 {
1172 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
1173 }
1174 }
1175
1176 if (new_owner)
1177 {
1178 if (new_owner.IsMan())
1179 {
1180 ownerPlayerNew = Man.Cast(new_owner);
1181 }
1182 else
1183 {
1184 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
1185 }
1186 }
1187
1188 if (ownerPlayerOld != ownerPlayerNew)
1189 {
1190 if (ownerPlayerOld)
1191 {
1192 array<EntityAI> subItemsExit = new array<EntityAI>;
1193 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
1194 for (int i = 0; i < subItemsExit.Count(); i++)
1195 {
1196 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
1197 itemExit.OnInventoryExit(ownerPlayerOld);
1198 }
1199 }
1200
1201 if (ownerPlayerNew)
1202 {
1203 array<EntityAI> subItemsEnter = new array<EntityAI>;
1204 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
1205 for (int j = 0; j < subItemsEnter.Count(); j++)
1206 {
1207 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
1208 itemEnter.OnInventoryEnter(ownerPlayerNew);
1209 }
1210 }
1211 }
1212 }
1213
1214 // -------------------------------------------------------------------------------
1215 override void EEDelete(EntityAI parent)
1216 {
1217 super.EEDelete(parent);
1218 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
1219 if (player)
1220 {
1221 OnInventoryExit(player);
1222
1223 if (player.IsAlive())
1224 {
1225 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
1226 if (r_index >= 0)
1227 {
1229 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
1230
1231 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
1232 int r_type = r_il.GetType();
1233 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
1234 {
1235 r_il.GetParent().GetOnReleaseLock().Invoke(this);
1236 }
1237 else if (r_type == InventoryLocationType.ATTACHMENT)
1238 {
1239 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
1240 }
1241
1242 }
1243
1244 player.RemoveQuickBarEntityShortcut(this);
1245 }
1246 }
1247 }
1248 // -------------------------------------------------------------------------------
1249 override void EEKilled(Object killer)
1250 {
1251 super.EEKilled(killer);
1252
1254 if (killer && killer.IsFireplace() && CanExplodeInFire())
1255 {
1257 {
1258 if (IsMagazine())
1259 {
1260 if (Magazine.Cast(this).GetAmmoCount() > 0)
1261 {
1262 ExplodeAmmo();
1263 }
1264 }
1265 else
1266 {
1267 Explode(DamageType.EXPLOSION);
1268 }
1269 }
1270 }
1271 }
1272
1273 override void OnWasAttached(EntityAI parent, int slot_id)
1274 {
1275 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
1276
1277 super.OnWasAttached(parent, slot_id);
1278
1279 if (HasQuantity())
1280 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
1281
1283 }
1284
1285 override void OnWasDetached(EntityAI parent, int slot_id)
1286 {
1287 super.OnWasDetached(parent, slot_id);
1288
1289 if (HasQuantity())
1290 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
1291 }
1292
1293 override string ChangeIntoOnAttach(string slot)
1294 {
1295 int idx;
1296 TStringArray inventory_slots = new TStringArray;
1297 TStringArray attach_types = new TStringArray;
1298
1299 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
1300 if (inventory_slots.Count() < 1) //is string
1301 {
1302 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
1303 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
1304 }
1305 else //is array
1306 {
1307 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
1308 }
1309
1310 idx = inventory_slots.Find(slot);
1311 if (idx < 0)
1312 return "";
1313
1314 return attach_types.Get(idx);
1315 }
1316
1317 override string ChangeIntoOnDetach()
1318 {
1319 int idx = -1;
1320 string slot;
1321
1322 TStringArray inventory_slots = new TStringArray;
1323 TStringArray detach_types = new TStringArray;
1324
1325 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
1326 if (inventory_slots.Count() < 1) //is string
1327 {
1328 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
1329 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
1330 }
1331 else //is array
1332 {
1333 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
1334 if (detach_types.Count() < 1)
1335 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
1336 }
1337
1338 for (int i = 0; i < inventory_slots.Count(); i++)
1339 {
1340 slot = inventory_slots.Get(i);
1341 }
1342
1343 if (slot != "")
1344 {
1345 if (detach_types.Count() == 1)
1346 idx = 0;
1347 else
1348 idx = inventory_slots.Find(slot);
1349 }
1350 if (idx < 0)
1351 return "";
1352
1353 return detach_types.Get(idx);
1354 }
1355
1357 {
1358 //timer
1359 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
1360
1361 //min/max time
1362 float min_time = 1;
1363 float max_time = 3;
1364 float delay = Math.RandomFloat(min_time, max_time);
1365
1366 explode_timer.Run(delay, this, "DoAmmoExplosion");
1367 }
1368
1370 {
1371 Magazine magazine = Magazine.Cast(this);
1372 int pop_sounds_count = 6;
1373 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
1374
1375 //play sound
1376 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
1377 string sound_name = pop_sounds[ sound_idx ];
1378 GetGame().CreateSoundOnObject(this, sound_name, 20, false);
1379
1380 //remove ammo count
1381 magazine.ServerAddAmmoCount(-1);
1382
1383 //if condition then repeat -> ExplodeAmmo
1384 float min_temp_to_explode = 100; //min temperature for item to explode
1385
1386 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
1387 {
1388 ExplodeAmmo();
1389 }
1390 }
1391
1392 // -------------------------------------------------------------------------------
1393 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
1394 {
1395 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
1396
1397 const int CHANCE_DAMAGE_CARGO = 4;
1398 const int CHANCE_DAMAGE_ATTACHMENT = 1;
1399 const int CHANCE_DAMAGE_NOTHING = 2;
1400
1401 if (IsClothing() || IsContainer() || IsItemTent())
1402 {
1403 float dmg = damageResult.GetDamage("","Health") * -0.5;
1404 int chances;
1405 int rnd;
1406
1407 if (GetInventory().GetCargo())
1408 {
1409 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
1410 rnd = Math.RandomInt(0,chances);
1411
1412 if (rnd < CHANCE_DAMAGE_CARGO)
1413 {
1414 DamageItemInCargo(dmg);
1415 }
1416 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
1417 {
1419 }
1420 }
1421 else
1422 {
1423 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
1424 rnd = Math.RandomInt(0,chances);
1425
1426 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
1427 {
1429 }
1430 }
1431 }
1432 }
1433
1434 bool DamageItemInCargo(float damage)
1435 {
1436 if (GetInventory().GetCargo())
1437 {
1438 int item_count = GetInventory().GetCargo().GetItemCount();
1439 if (item_count > 0)
1440 {
1441 int random_pick = Math.RandomInt(0, item_count);
1442 ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
1443 if (!item.IsExplosive())
1444 {
1445 item.AddHealth("","",damage);
1446 return true;
1447 }
1448 }
1449 }
1450 return false;
1451 }
1452
1453 bool DamageItemAttachments(float damage)
1454 {
1455 int attachment_count = GetInventory().AttachmentCount();
1456 if (attachment_count > 0)
1457 {
1458 int random_pick = Math.RandomInt(0, attachment_count);
1459 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
1460 if (!attachment.IsExplosive())
1461 {
1462 attachment.AddHealth("","",damage);
1463 return true;
1464 }
1465 }
1466 return false;
1467 }
1468
1469 //----------------
1470 override bool CanBeSplit()
1471 {
1472 if (m_CanThisBeSplit)
1473 return (GetQuantity() > 1);
1474
1475 return false;
1476 }
1477
1478 void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
1479 {
1480 if (GetGame().IsClient())
1481 {
1483 {
1486 ctx.Write(1);
1487 ItemBase i1 = this; // @NOTE: workaround for correct serialization
1488 ctx.Write(i1);
1489 ctx.Write(destination_entity);
1490 ctx.Write(true);
1491 ctx.Write(slot_id);
1492 ctx.Send();
1493 }
1494 }
1495 else if (!GetGame().IsMultiplayer())
1496 {
1497 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
1498 }
1499 }
1500
1501 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
1502 {
1503 float split_quantity_new;
1504 ref ItemBase new_item;
1505 float quantity = GetQuantity();
1506 float stack_max = GetTargetQuantityMax(slot_id);
1508
1509 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1510 {
1511 if (stack_max <= GetQuantity())
1512 split_quantity_new = stack_max;
1513 else
1514 split_quantity_new = GetQuantity();
1515
1516 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1517 if (new_item)
1518 {
1519 new_item.SetResultOfSplit(true);
1520 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1521 AddQuantity(-split_quantity_new);
1522 new_item.SetQuantity(split_quantity_new);
1523 }
1524 }
1525 else if (destination_entity && slot_id == -1)
1526 {
1527 if (quantity > stack_max)
1528 split_quantity_new = stack_max;
1529 else
1530 split_quantity_new = quantity;
1531
1532 if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1533 {
1534 Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1535 new_item = ItemBase.Cast(o);
1536 }
1537
1538 if (new_item)
1539 {
1540 new_item.SetResultOfSplit(true);
1541 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1542 AddQuantity(-split_quantity_new);
1543 new_item.SetQuantity(split_quantity_new);
1544 }
1545 }
1546 else
1547 {
1548 if (stack_max != 0)
1549 {
1550 if (stack_max < GetQuantity())
1551 {
1552 split_quantity_new = GetQuantity() - stack_max;
1553 }
1554
1555 if (split_quantity_new == 0)
1556 {
1557 if (!GetGame().IsMultiplayer())
1558 player.PhysicalPredictiveDropItem(this);
1559 else
1560 player.ServerDropEntity(this);
1561 return;
1562 }
1563
1564 new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1565
1566 if (new_item)
1567 {
1568 new_item.SetResultOfSplit(true);
1569 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1570 SetQuantity(split_quantity_new);
1571 new_item.SetQuantity(stack_max);
1572 new_item.PlaceOnSurface();
1573 }
1574 }
1575 }
1576 }
1577
1579 {
1580 if (GetGame().IsClient())
1581 {
1583 {
1586 ctx.Write(4);
1587 ItemBase thiz = this; // @NOTE: workaround for correct serialization
1588 ctx.Write(thiz);
1589 dst.WriteToContext(ctx);
1590 ctx.Send();
1591 }
1592 }
1593 else if (!GetGame().IsMultiplayer())
1594 {
1596 }
1597 }
1598
1599 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
1600 {
1601 if (GetGame().IsClient())
1602 {
1604 {
1607 ctx.Write(2);
1608 ItemBase dummy = this; // @NOTE: workaround for correct serialization
1609 ctx.Write(dummy);
1610 ctx.Write(destination_entity);
1611 ctx.Write(true);
1612 ctx.Write(idx);
1613 ctx.Write(row);
1614 ctx.Write(col);
1615 ctx.Send();
1616 }
1617 }
1618 else if (!GetGame().IsMultiplayer())
1619 {
1620 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
1621 }
1622 }
1623
1625 {
1627 }
1628
1630 {
1631 float quantity = GetQuantity();
1632 float split_quantity_new;
1633 ItemBase new_item;
1634 if (dst.IsValid())
1635 {
1636 int slot_id = dst.GetSlot();
1637 float stack_max = GetTargetQuantityMax(slot_id);
1638
1639 if (quantity > stack_max)
1640 split_quantity_new = stack_max;
1641 else
1642 split_quantity_new = quantity;
1643
1644 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
1645
1646 if (new_item)
1647 {
1648 new_item.SetResultOfSplit(true);
1649 MiscGameplayFunctions.TransferItemProperties(this,new_item);
1650 AddQuantity(-split_quantity_new);
1651 new_item.SetQuantity(split_quantity_new);
1652 }
1653
1654 return new_item;
1655 }
1656
1657 return null;
1658 }
1659
1660 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
1661 {
1662 float quantity = GetQuantity();
1663 float split_quantity_new;
1664 ref ItemBase new_item;
1665 if (destination_entity)
1666 {
1667 float stackable = GetTargetQuantityMax();
1668 if (quantity > stackable)
1669 split_quantity_new = stackable;
1670 else
1671 split_quantity_new = quantity;
1672
1673 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
1674 if (new_item)
1675 {
1676 new_item.SetResultOfSplit(true);
1677 MiscGameplayFunctions.TransferItemProperties(this,new_item);
1678 AddQuantity(-split_quantity_new);
1679 new_item.SetQuantity(split_quantity_new);
1680 }
1681 }
1682 }
1683
1685 {
1686 if (GetGame().IsClient())
1687 {
1689 {
1692 ctx.Write(3);
1693 ItemBase i1 = this; // @NOTE: workaround for correct serialization
1694 ctx.Write(i1);
1695 ItemBase destination_entity = this;
1696 ctx.Write(destination_entity);
1697 ctx.Write(true);
1698 ctx.Write(0);
1699 ctx.Send();
1700 }
1701 }
1702 else if (!GetGame().IsMultiplayer())
1703 {
1704 SplitIntoStackMaxHands(player);
1705 }
1706 }
1707
1709 {
1710 float quantity = GetQuantity();
1711 float split_quantity_new;
1712 ref ItemBase new_item;
1713 if (player)
1714 {
1715 float stackable = GetTargetQuantityMax();
1716 if (quantity > stackable)
1717 split_quantity_new = stackable;
1718 else
1719 split_quantity_new = quantity;
1720
1721 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
1722 new_item = ItemBase.Cast(in_hands);
1723 if (new_item)
1724 {
1725 new_item.SetResultOfSplit(true);
1726 MiscGameplayFunctions.TransferItemProperties(this,new_item);
1727 AddQuantity(-split_quantity_new);
1728 new_item.SetQuantity(split_quantity_new);
1729 }
1730 }
1731 }
1732
1734 {
1735 if (!CanBeSplit())
1736 return;
1737
1738 float quantity = GetQuantity();
1739 float split_quantity_new = Math.Floor(quantity * 0.5);
1740
1742
1743 if (new_item)
1744 {
1745 if (new_item.GetQuantityMax() < split_quantity_new)
1746 {
1747 split_quantity_new = new_item.GetQuantityMax();
1748 }
1749
1750 new_item.SetResultOfSplit(true);
1751 MiscGameplayFunctions.TransferItemProperties(this, new_item);
1752
1753 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
1754 {
1755 AddQuantity(-1);
1756 new_item.SetQuantity(1);
1757 }
1758 else
1759 {
1760 AddQuantity(-split_quantity_new);
1761 new_item.SetQuantity(split_quantity_new);
1762 }
1763 }
1764 }
1765
1767 {
1768 if (!CanBeSplit())
1769 {
1770 return;
1771 }
1772
1773 float quantity = GetQuantity();
1774 float split_quantity_new = Math.Floor(quantity / 2);
1775
1777 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
1778
1779 ItemBase new_item;
1780 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
1781
1782 if (new_item)
1783 {
1784 if (new_item.GetQuantityMax() < split_quantity_new)
1785 {
1786 split_quantity_new = new_item.GetQuantityMax();
1787 }
1788 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
1789 {
1790 AddQuantity(-1);
1791 new_item.SetQuantity(1);
1792 }
1793 else
1794 {
1795 AddQuantity(-split_quantity_new);
1796 new_item.SetQuantity(split_quantity_new);
1797 }
1798 }
1799 }
1800
1802 void OnQuantityChanged(float delta)
1803 {
1804 SetWeightDirty();
1805 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
1806
1807 if (parent)
1808 {
1809 parent.OnAttachmentQuantityChangedEx(this, delta);
1810 }
1811 }
1812
1815 {
1816 // insert code here
1817 }
1818
1821 {
1823 }
1824
1825 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
1826 {
1827 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
1828
1829 if (GetGame().IsServer())
1830 {
1831 if (newLevel == GameConstants.STATE_RUINED)
1832 {
1834 EntityAI parent = GetHierarchyParent();
1835 if (parent && parent.IsFireplace())
1836 {
1837 CargoBase cargo = GetInventory().GetCargo();
1838 if (cargo)
1839 {
1840 for (int i = 0; i < cargo.GetItemCount(); ++i)
1841 {
1842 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
1843 }
1844 }
1845 }
1846 }
1847
1848 if (IsResultOfSplit())
1849 {
1850 // reset the splitting result flag, return to normal item behavior
1851 SetResultOfSplit(false);
1852 return;
1853 }
1854
1855 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
1856 {
1857 SetCleanness(0);//unclean the item upon damage dealt
1858 }
1859 }
1860 }
1861
1862 // just the split? TODO: verify
1863 override void OnRightClick()
1864 {
1865 super.OnRightClick();
1866
1867 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
1868 {
1869 if (GetGame().IsClient())
1870 {
1872 {
1873 vector m4[4];
1874 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1875
1876 EntityAI root = GetHierarchyRoot();
1877
1879 if (!player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.CARGO, dst))
1880 {
1881 if (root)
1882 {
1883 root.GetTransform(m4);
1884 dst.SetGround(this, m4);
1885 }
1886 else
1887 GetInventory().GetCurrentInventoryLocation(dst);
1888 }
1889 else
1890 {
1891 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
1892 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(null, dst))
1893 {
1894 if (root)
1895 {
1896 root.GetTransform(m4);
1897 dst.SetGround(this, m4);
1898 }
1899 else
1900 GetInventory().GetCurrentInventoryLocation(dst);
1901 }
1902 else
1903 {
1904 GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1905 }
1906 }
1907
1910 ctx.Write(4);
1911 ItemBase thiz = this; // @NOTE: workaround for correct serialization
1912 ctx.Write(thiz);
1913 dst.WriteToContext(ctx);
1914 ctx.Write(true); // dummy
1915 ctx.Send();
1916 }
1917 }
1918 else if (!GetGame().IsMultiplayer())
1919 {
1921 }
1922 }
1923 }
1924
1925 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
1926 {
1927 //Print("CanBeCombined - " + this + ": " + GetQuantity() + " + " + other_item + ": " + other_item.GetQuantity());
1928 //TODO: delete check zero quantity check after fix double posts hands fsm events
1929 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
1930 return false;
1931
1932 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
1933 return false;
1934
1935 //can_this_be_combined = ConfigGetBool("canBeSplit");
1937 return false;
1938
1939
1940 Magazine mag = Magazine.Cast(this);
1941 if (mag)
1942 {
1943 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
1944 return false;
1945
1946 if (stack_max_limit)
1947 {
1948 Magazine other_mag = Magazine.Cast(other_item);
1949 if (other_item)
1950 {
1951 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
1952 return false;
1953 }
1954
1955 }
1956 }
1957 else
1958 {
1959 //TODO: delete check zero quantity check after fix double posts hands fsm events
1960 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
1961 return false;
1962
1963 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
1964 return false;
1965 }
1966
1967 PlayerBase player = null;
1968 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
1969 {
1970 if (player.GetInventory().HasAttachment(this))
1971 return false;
1972
1973 if (player.IsItemsToDelete())
1974 return false;
1975 }
1976
1977 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
1978 return false;
1979
1980 int slotID;
1981 string slotName;
1982 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
1983 return false;
1984
1985 return true;
1986 }
1987
1988 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
1989 {
1990 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
1991 }
1992
1994 {
1995 return m_IsResultOfSplit;
1996 }
1997
1998 void SetResultOfSplit(bool value)
1999 {
2000 m_IsResultOfSplit = value;
2001 }
2002
2003 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
2004 {
2005 return ComputeQuantityUsedEx(other_item, use_stack_max);
2006 }
2007
2008 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
2009 {
2010 float other_item_quantity = other_item.GetQuantity();
2011 float this_free_space;
2012
2013 float stack_max = GetQuantityMax();
2014
2015 this_free_space = stack_max - GetQuantity();
2016
2017 if (other_item_quantity > this_free_space)
2018 {
2019 return this_free_space;
2020 }
2021 else
2022 {
2023 return other_item_quantity;
2024 }
2025 }
2026
2027 void CombineItems(ItemBase other_item, bool use_stack_max = true)
2028 {
2029 if (!CanBeCombined(other_item, false))
2030 return;
2031
2032 if (!IsMagazine() && other_item)
2033 {
2034 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
2035 if (quantity_used != 0)
2036 {
2037 float hp1 = GetHealth01("","");
2038 float hp2 = other_item.GetHealth01("","");
2039 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
2040 hpResult = hpResult / (GetQuantity() + quantity_used);
2041
2042 hpResult *= GetMaxHealth();
2043 Math.Round(hpResult);
2044 SetHealth("", "Health", hpResult);
2045
2046 AddQuantity(quantity_used);
2047 other_item.AddQuantity(-quantity_used);
2048 }
2049 }
2050 OnCombine(other_item);
2051 }
2052
2053 void OnCombine(ItemBase other_item)
2054 {
2055 #ifdef SERVER
2056 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
2057 GetHierarchyParent().IncreaseLifetimeUp();
2058 #endif
2059 };
2060
2061 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
2062 {
2063 PlayerBase p = PlayerBase.Cast(player);
2064
2065 array<int> recipesIds = p.m_Recipes;
2066 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
2067 if (moduleRecipesManager)
2068 {
2069 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
2070 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
2071 }
2072
2073 for (int i = 0;i < recipesIds.Count(); i++)
2074 {
2075 int key = recipesIds.Get(i);
2076 string recipeName = moduleRecipesManager.GetRecipeName(key);
2077 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
2078 }
2079 }
2080
2081 // -------------------------------------------------------------------------
2082 void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
2083 {
2084 //weight
2085 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT, "Print Weight", FadeColors.LIGHT_GREY));
2086 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT_RECALC, "Print Weight Verbose", FadeColors.LIGHT_GREY));
2087 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT, "Print Player Weight", FadeColors.LIGHT_GREY));
2088 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT_RECALC, "Print Player Weight Verbose", FadeColors.LIGHT_GREY));
2089
2090 //quantity
2091 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
2092 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
2093 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
2094 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
2095
2096 //health
2097 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
2098 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
2099 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
2100 //temperature
2101 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
2102 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
2103
2104 //wet
2105 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
2106 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
2107
2108 //liquidtype
2109 if (IsLiquidContainer())
2110 {
2111 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
2112 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
2113 }
2114
2115 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
2116 // watch
2117 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch", FadeColors.LIGHT_GREY));
2118 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
2119
2120 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
2121 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
2122 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
2123
2124 string button1, button2, button3, button4;
2125 GetDebugButtonNames(button1, button2, button3, button4);
2126
2127 if (button1)
2128 {
2129 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START, button1, FadeColors.LIGHT_GREY));
2130 }
2131
2132 if (button2)
2133 {
2134 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START+1, button2, FadeColors.LIGHT_GREY));
2135 }
2136
2137 if (button3)
2138 {
2139 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START+2, button3, FadeColors.LIGHT_GREY));
2140 }
2141
2142 if (button4)
2143 {
2144 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START+3, button4, FadeColors.LIGHT_GREY));
2145 }
2146 }
2147
2148 // -------------------------------------------------------------------------
2149 // -------------------------------------------------------------------------
2150 // -------------------------------------------------------------------------
2151 bool OnAction(int action_id, Man player, ParamsReadContext ctx)
2152 {
2153 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
2154 {
2155 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
2156 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
2157 PlayerBase p = PlayerBase.Cast(player);
2158 if (EActions.RECIPES_RANGE_START < 1000)
2159 {
2160 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
2161 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
2162 }
2163 }
2164 else if (action_id == EActions.GET_TOTAL_WEIGHT) //Prints total weight of item + its contents
2165 {
2166 WeightDebug.ClearWeightDebug();
2167 #ifndef SERVER
2168 Debug.Log("======================== "+ GetType() +" =================================");
2169 #endif
2170 Debug.Log("Weight:" + GetWeightEx().ToString());
2171 Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx());
2172 Debug.Log("----------------------------------------------------------------------------------------------");
2173 }
2174 else if (action_id == EActions.GET_TOTAL_WEIGHT_RECALC) //Prints total weight of item + its contents
2175 {
2176 WeightDebug.ClearWeightDebug();
2177 WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED);
2178 #ifndef SERVER
2179 Debug.Log("======================== "+ GetType() +" RECALC ===========================");
2180 #endif
2181 Debug.Log("Weight:" + GetWeightEx(true).ToString());
2182 Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx());
2183 WeightDebug.PrintAll(this);
2184 Debug.Log("----------------------------------------------------------------------------------------------");
2185 WeightDebug.SetVerbosityFlags(0);
2186 }
2187 else if (action_id == EActions.GET_PLAYER_WEIGHT) //Prints total weight of item + its contents
2188 {
2189 WeightDebug.ClearWeightDebug();
2190 #ifndef SERVER
2191 Debug.Log("======================== PLAYER: "+player+" ===========================");
2192 #endif
2193 Debug.Log("New overall weight Player:"+player.GetWeightEx().ToString());
2194
2195 Debug.Log("----------------------------------------------------------------------------------------------");
2196 }
2197 else if (action_id == EActions.GET_PLAYER_WEIGHT_RECALC) //Prints total weight of item + its contents
2198 {
2199 WeightDebug.ClearWeightDebug();
2200 WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED);
2201 #ifndef SERVER
2202 Debug.Log("======================== PLAYER RECALC: "+player+" ===========================");
2203 #endif
2204 Debug.Log("New overall weight Player:"+player.GetWeightEx(true).ToString());
2205 WeightDebug.PrintAll(player);
2206 Debug.Log("----------------------------------------------------------------------------------------------");
2207 WeightDebug.SetVerbosityFlags(0);
2208 }
2209 #ifndef SERVER
2210 else if (action_id == EActions.WATCH_PLAYER)
2211 {
2212 PluginDeveloper.SetDeveloperItemClientEx(player);
2213 }
2214 #endif
2215 if (GetGame().IsServer())
2216 {
2217 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
2218 {
2219 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
2221 }
2222
2223 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
2224 {
2225 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
2226 InsertAgent(agent_id,100);
2227 }
2228
2229 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
2230 {
2231 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
2232 RemoveAgent(agent_id2);
2233 }
2234
2235 else if (action_id == EActions.ADD_QUANTITY)
2236 {
2237 if (IsMagazine())
2238 {
2239 Magazine mag = Magazine.Cast(this);
2240 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
2241 }
2242 else
2243 {
2244 AddQuantity(GetQuantityMax() * 0.2);
2245 }
2246
2247 if (m_EM)
2248 {
2249 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
2250 }
2251 //PrintVariables();
2252 }
2253
2254 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
2255 {
2256 if (IsMagazine())
2257 {
2258 Magazine mag2 = Magazine.Cast(this);
2259 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
2260 }
2261 else
2262 {
2263 AddQuantity(- GetQuantityMax() * 0.2);
2264 }
2265 if (m_EM)
2266 {
2267 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
2268 }
2269 //PrintVariables();
2270 }
2271
2272 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
2273 {
2274 SetQuantity(0);
2275
2276 if (m_EM)
2277 {
2278 m_EM.SetEnergy(0);
2279 }
2280 }
2281
2282 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
2283 {
2285
2286 if (m_EM)
2287 {
2288 m_EM.SetEnergy(m_EM.GetEnergyMax());
2289 }
2290 }
2291
2292 else if (action_id == EActions.ADD_HEALTH)
2293 {
2294 AddHealth("","",GetMaxHealth("","Health")/5);
2295 }
2296 else if (action_id == EActions.REMOVE_HEALTH)
2297 {
2298 AddHealth("","",-GetMaxHealth("","Health")/5);
2299 }
2300 else if (action_id == EActions.DESTROY_HEALTH)
2301 {
2302 SetHealth01("","",0);
2303 }
2304 else if (action_id == EActions.WATCH_ITEM)
2305 {
2307 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
2308 #ifdef DEVELOPER
2309 SetDebugDeveloper_item(this);
2310 #endif
2311 }
2312
2313 else if (action_id == EActions.ADD_TEMPERATURE)
2314 {
2315 AddTemperature(20);
2316 //PrintVariables();
2317 }
2318
2319 else if (action_id == EActions.REMOVE_TEMPERATURE)
2320 {
2321 AddTemperature(-20);
2322 //PrintVariables();
2323 }
2324
2325 else if (action_id == EActions.ADD_WETNESS)
2326 {
2327 AddWet(GetWetMax()/5);
2328 //PrintVariables();
2329 }
2330
2331 else if (action_id == EActions.REMOVE_WETNESS)
2332 {
2333 AddWet(-GetWetMax()/5);
2334 //PrintVariables();
2335 }
2336
2337 else if (action_id == EActions.LIQUIDTYPE_UP)
2338 {
2339 int curr_type = GetLiquidType();
2340 SetLiquidType(curr_type * 2);
2341 //AddWet(1);
2342 //PrintVariables();
2343 }
2344
2345 else if (action_id == EActions.LIQUIDTYPE_DOWN)
2346 {
2347 int curr_type2 = GetLiquidType();
2348 SetLiquidType(curr_type2 / 2);
2349 }
2350
2351 else if (action_id == EActions.MAKE_SPECIAL)
2352 {
2353 OnDebugSpawn();
2354 }
2355
2356 else if (action_id == EActions.DELETE)
2357 {
2358 Delete();
2359 }
2360
2361 }
2362
2363
2364 return false;
2365 }
2366
2367 // -------------------------------------------------------------------------
2368
2369
2373
2375 void OnActivatedByItem(notnull ItemBase item);
2376
2377 //----------------------------------------------------------------
2378 //returns true if item is able to explode when put in fire
2380 {
2381 return false;
2382 }
2383
2384 //----------------------------------------------------------------
2385 bool CanEat()
2386 {
2387 return true;
2388 }
2389
2390 //----------------------------------------------------------------
2392 {
2393 return true;
2394 }
2395
2396 //----------------------------------------------------------------
2397 //has FoodStages in config?
2399 {
2400 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
2401 return GetGame().ConfigIsExisting(config_path);
2402 }
2403
2405 {
2406 return false;
2407 }
2408
2410 {
2411 return false;
2412 }
2413
2414 //----------------------------------------------------------------
2415 bool CanRepair(ItemBase item_repair_kit)
2416 {
2417 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
2418 return module_repairing.CanRepair(this, item_repair_kit);
2419 }
2420
2421 //----------------------------------------------------------------
2422 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
2423 {
2424 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
2425 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
2426 }
2427
2428 //----------------------------------------------------------------
2430 {
2431 /*
2432 vector v_size = this.ConfigGetVector("itemSize");
2433 int v_size_x = v_size[0];
2434 int v_size_y = v_size[1];
2435 int size = v_size_x * v_size_y;
2436 return size;
2437 */
2438
2439 return 1;
2440 }
2441
2442 //----------------------------------------------------------------
2443 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
2445 {
2446 return m_CanBeMovedOverride;
2447 }
2448
2449 //----------------------------------------------------------------
2450 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
2451 void SetCanBeMovedOverride(bool setting)
2452 {
2453 m_CanBeMovedOverride = setting;
2454 }
2455
2456 //----------------------------------------------------------------
2464 void MessageToOwnerStatus(string text)
2465 {
2466 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2467
2468 if (player)
2469 {
2470 player.MessageStatus(text);
2471 }
2472 }
2473
2474 //----------------------------------------------------------------
2482 void MessageToOwnerAction(string text)
2483 {
2484 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2485
2486 if (player)
2487 {
2488 player.MessageAction(text);
2489 }
2490 }
2491
2492 //----------------------------------------------------------------
2500 void MessageToOwnerFriendly(string text)
2501 {
2502 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2503
2504 if (player)
2505 {
2506 player.MessageFriendly(text);
2507 }
2508 }
2509
2510 //----------------------------------------------------------------
2518 void MessageToOwnerImportant(string text)
2519 {
2520 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2521
2522 if (player)
2523 {
2524 player.MessageImportant(text);
2525 }
2526 }
2527
2528 override bool IsItemBase()
2529 {
2530 return true;
2531 }
2532
2533 // Checks if item is of questioned kind
2534 override bool KindOf(string tag)
2535 {
2536 bool found = false;
2537 string item_name = this.GetType();
2538 ref TStringArray item_tag_array = new TStringArray;
2539 GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
2540
2541 int array_size = item_tag_array.Count();
2542 for (int i = 0; i < array_size; i++)
2543 {
2544 if (item_tag_array.Get(i) == tag)
2545 {
2546 found = true;
2547 break;
2548 }
2549 }
2550 return found;
2551 }
2552
2553
2554 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
2555 {
2556 //Debug.Log("OnRPC called");
2557 super.OnRPC(sender, rpc_type,ctx);
2558
2559 //Play soundset for attachment locking (ActionLockAttachment.c)
2560 switch (rpc_type)
2561 {
2562 #ifndef SERVER
2563 case ERPCs.RPC_SOUND_LOCK_ATTACH:
2564 Param2<bool, string> p = new Param2<bool, string>(false, "");
2565
2566 if (!ctx.Read(p))
2567 return;
2568
2569 bool play = p.param1;
2570 string soundSet = p.param2;
2571
2572 if (play)
2573 {
2574 if (m_LockingSound)
2575 {
2577 {
2578 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
2579 }
2580 }
2581 else
2582 {
2583 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
2584 }
2585 }
2586 else
2587 {
2589 }
2590
2591 break;
2592 #endif
2593
2594 }
2595
2596 if (GetWrittenNoteData())
2597 {
2598 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
2599 }
2600 }
2601
2602 //-----------------------------
2603 // VARIABLE MANIPULATION SYSTEM
2604 //-----------------------------
2605
2607 {
2608 DeSerializeNumericalVars(float_vars);
2609 }
2610
2612 {
2616 }
2617
2618 int NameToID(string name)
2619 {
2620 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
2621 return plugin.GetID(name);
2622 }
2623
2624 string IDToName(int id)
2625 {
2626 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
2627 return plugin.GetName(id);
2628 }
2629
2630 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
2631 {
2632 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
2633 //read the flags
2634 //ref Param1<int> pflags = new Param1<int>(0);
2635 int varFlags;
2636 if (!ctx.Read(varFlags))
2637 return;
2638
2639 //ctx.Read(CachedObjectsParams.PARAM1_INT);
2640
2641 //int varFlags = CachedObjectsParams.PARAM1_INT.param1;
2642 //--------------
2643
2644
2645 if (varFlags & ItemVariableFlags.FLOAT)
2646 {
2647 ReadVarsFromCTX(ctx);
2648 }
2649 /*
2650 if (varFlags & ItemVariableFlags.STRING)
2651 {
2652 OnSyncStrings(ctx);
2653 }
2654 */
2655 }
2656
2658 {
2659 // the order of serialization must be the same as the order of de-serialization
2660 floats_out.Insert(m_VariablesMask);
2661 //--------------------------------------------
2663 {
2664 floats_out.Insert(m_VarQuantity);
2665 }
2666 //--------------------------------------------
2668 {
2669 floats_out.Insert(m_VarTemperature);
2670 }
2671 //--------------------------------------------
2673 {
2674 floats_out.Insert(m_VarWet);
2675 }
2676 //--------------------------------------------
2678 {
2679 floats_out.Insert(m_VarLiquidType);
2680 }
2681 //--------------------------------------------
2683 {
2684 floats_out.Insert(m_ColorComponentR);
2685 floats_out.Insert(m_ColorComponentG);
2686 floats_out.Insert(m_ColorComponentB);
2687 floats_out.Insert(m_ColorComponentA);
2688 }
2689 //--------------------------------------------
2691 {
2692 floats_out.Insert(m_Cleanness);
2693 }
2694 //--------------------------------------------
2695 }
2696
2698 {
2699 // the order of serialization must be the same as the order of de-serialization
2700 int index = 0;
2701 int mask = Math.Round(floats.Get(index));
2702
2703 index++;
2704 //--------------------------------------------
2705 if (mask & VARIABLE_QUANTITY)
2706 {
2707 if (m_IsStoreLoad)
2708 {
2709 m_StoreLoadedQuantity = floats.Get(index);
2710 }
2711 else
2712 {
2713 float quantity = floats.Get(index);
2714 SetQuantity(quantity, true, false, false, false);
2715 }
2716 index++;
2717 }
2718 //--------------------------------------------
2719 if (mask & VARIABLE_TEMPERATURE)
2720 {
2721 float temperature = floats.Get(index);
2722 SetTemperature(temperature);
2723 index++;
2724 }
2725 //--------------------------------------------
2726 if (mask & VARIABLE_WET)
2727 {
2728 float wet = floats.Get(index);
2729 SetWet(wet);
2730 index++;
2731 }
2732 //--------------------------------------------
2733 if (mask & VARIABLE_LIQUIDTYPE)
2734 {
2735 int liquidtype = Math.Round(floats.Get(index));
2736 SetLiquidType(liquidtype);
2737 index++;
2738 }
2739 //--------------------------------------------
2740 if (mask & VARIABLE_COLOR)
2741 {
2742 m_ColorComponentR = Math.Round(floats.Get(index));
2743 index++;
2744 m_ColorComponentG = Math.Round(floats.Get(index));
2745 index++;
2746 m_ColorComponentB = Math.Round(floats.Get(index));
2747 index++;
2748 m_ColorComponentA = Math.Round(floats.Get(index));
2749 index++;
2750 }
2751 if (mask & VARIABLE_CLEANNESS)
2752 {
2753 int cleanness = Math.Round(floats.Get(index));
2754 SetCleanness(cleanness);
2755 index++;
2756 }
2757 //--------------------------------------------
2758 }
2759
2760
2762 {
2764
2765 //--------------------------------------------
2767 {
2768 ctx.Write(m_VarQuantity);
2769 }
2770 //--------------------------------------------
2772 {
2774 }
2775 //--------------------------------------------
2777 {
2778 ctx.Write(m_VarWet);
2779 }
2780 //--------------------------------------------
2782 {
2784 }
2785 //--------------------------------------------
2787 {
2792 }
2793 //--------------------------------------------
2795 {
2796 ctx.Write(m_Cleanness);
2797 }
2798 }
2799
2800 bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
2801 {
2802 int numOfItems;
2803 int intValue;
2804 float value;
2805 if (version <= 108 && version!= -1)
2806 {
2808 return false;
2809
2810 numOfItems = CachedObjectsParams.PARAM1_INT.param1;
2812
2813 for (int i = 0; i < numOfItems; i++)
2814 {
2816 return false;
2817 value = CachedObjectsParams.PARAM1_FLOAT.param1;
2818
2819 CachedObjectsArrays.ARRAY_FLOAT.Insert(value);
2820 }
2821
2823 return true;
2824 }
2825 else if (version <= 116 && version!= -1)
2826 {
2827 if (!ctx.Read(numOfItems))
2828 return false;
2829
2831
2832 for (int j = 0; j < numOfItems; j++)
2833 {
2834 if (!ctx.Read(value))
2835 return false;
2836 CachedObjectsArrays.ARRAY_FLOAT.Insert(value);
2837 }
2838
2840 return true;
2841 }
2842 else
2843 {
2844 int mask;
2845 if (!ctx.Read(mask))
2846 return false;
2847
2848 if (mask & VARIABLE_QUANTITY)
2849 {
2850 if (!ctx.Read(value))
2851 return false;
2852
2853 if (m_IsStoreLoad)
2854 {
2855 m_StoreLoadedQuantity = value;
2856 }
2857 else
2858 {
2859 SetQuantity(value, true, false, false, false);
2860 }
2861 }
2862 //--------------------------------------------
2863 if (mask & VARIABLE_TEMPERATURE)
2864 {
2865 if (!ctx.Read(value))
2866 return false;
2867 SetTemperature(value);
2868 }
2869 //--------------------------------------------
2870 if (mask & VARIABLE_WET)
2871 {
2872 if (!ctx.Read(value))
2873 return false;
2874 SetWet(value);
2875 }
2876 //--------------------------------------------
2877 if (mask & VARIABLE_LIQUIDTYPE)
2878 {
2879 if (!ctx.Read(intValue))
2880 return false;
2881 SetLiquidType(intValue);
2882 }
2883 //--------------------------------------------
2884 if (mask & VARIABLE_COLOR)
2885 {
2886 if (!ctx.Read(intValue))
2887 return false;
2888
2889 m_ColorComponentR = intValue;
2890 if (!ctx.Read(value))
2891 return false;
2892
2893 m_ColorComponentG = intValue;
2894 if (!ctx.Read(value))
2895 return false;
2896
2897 m_ColorComponentB = intValue;
2898 if (!ctx.Read(value))
2899 return false;
2900
2901 m_ColorComponentA = intValue;
2902 }
2903 //--------------------------------------------
2904 if (mask & VARIABLE_CLEANNESS)
2905 {
2906 if (!ctx.Read(intValue))
2907 return false;
2908 SetCleanness(intValue);
2909 }
2910 }
2911 return true;
2912 }
2913
2915 {
2916 //Debug.Log("Saving Item Stage 0 "+ClassName(this)+" " + ToString(this));
2917
2918 //first set the flags
2919
2920 int varFlags = 0;
2921
2922 if (m_VariablesMask)
2923 varFlags = ItemVariableFlags.FLOAT;
2924
2925 ctx.Write(varFlags);
2926 //-------------------
2927
2928 //now serialize the variables
2929
2930 //floats
2931 if (m_VariablesMask)
2932 WriteVarsToCTX(ctx);
2933 }
2934
2935
2936 //----------------------------------------------------------------
2937 bool LoadVariables(ParamsReadContext ctx, int version = -1)
2938 {
2939 int varFlags;
2940 if (version <= 108 && version != -1)
2941 {
2942 //read the flags
2944 {
2945 return false;
2946 }
2947 else
2948 {
2949 varFlags = CachedObjectsParams.PARAM1_INT.param1;
2950 //--------------
2951 if (varFlags & ItemVariableFlags.FLOAT)
2952 {
2953 if (!ReadVarsFromCTX(ctx, version))
2954 return false;
2955 }
2956 }
2957 }
2958 else
2959 {
2960 //read the flags
2961 if (!ctx.Read(varFlags))
2962 {
2963 return false;
2964 }
2965 else
2966 {
2967 //--------------
2968 if (varFlags & ItemVariableFlags.FLOAT)
2969 {
2970 if (!ReadVarsFromCTX(ctx, version))
2971 return false;
2972 }
2973 }
2974 }
2975 return true;
2976 }
2977
2978
2979 //----------------------------------------------------------------
2980 override bool OnStoreLoad(ParamsReadContext ctx, int version)
2981 {
2982 m_IsStoreLoad = true;
2983
2985 {
2986 m_FixDamageSystemInit = true;
2987 }
2988
2989 if (!super.OnStoreLoad(ctx, version))
2990 {
2991 m_IsStoreLoad = false;
2992 return false;
2993 }
2994
2995 if (version >= 114)
2996 {
2997 bool hasQuickBarIndexSaved;
2998
2999 if (!ctx.Read(hasQuickBarIndexSaved))
3000 {
3001 m_IsStoreLoad = false;
3002 return false;
3003 }
3004
3005 if (hasQuickBarIndexSaved)
3006 {
3007 int itmQBIndex;
3008
3009 //Load quickbar item bind
3010 if (!ctx.Read(itmQBIndex))
3011 {
3012 m_IsStoreLoad = false;
3013 return false;
3014 }
3015
3016 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
3017 if (itmQBIndex != -1 && parentPlayer)
3018 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
3019 }
3020 }
3021 else
3022 {
3023 // Backup of how it used to be
3024 PlayerBase player;
3025 int itemQBIndex;
3026 if (version == int.MAX)
3027 {
3028 if (!ctx.Read(itemQBIndex))
3029 {
3030 m_IsStoreLoad = false;
3031 return false;
3032 }
3033 }
3034 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
3035 {
3036 //Load quickbar item bind
3037 if (!ctx.Read(itemQBIndex))
3038 {
3039 m_IsStoreLoad = false;
3040 return false;
3041 }
3042 if (itemQBIndex != -1 && player)
3043 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
3044 }
3045 }
3046
3047 // variable management system
3048 if (!LoadVariables(ctx, version))
3049 {
3050 m_IsStoreLoad = false;
3051 return false;
3052 }
3053
3054 //agent trasmission system
3055 if (!LoadAgents(ctx, version))
3056 {
3057 m_IsStoreLoad = false;
3058 return false;
3059 }
3060 if (version >= 132)
3061 {
3063 if (raib)
3064 {
3065 if (!raib.OnStoreLoad(ctx,version))
3066 {
3067 m_IsStoreLoad = false;
3068 return false;
3069 }
3070 }
3071 }
3072
3073 m_IsStoreLoad = false;
3074 return true;
3075 }
3076
3077 //----------------------------------------------------------------
3078
3080 {
3081 super.OnStoreSave(ctx);
3082 PlayerBase player;
3083 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
3084 {
3085 ctx.Write(true); // Keep track of if we should actually read this in or not
3086 //Save quickbar item bind
3087 int itemQBIndex = -1;
3088 itemQBIndex = player.FindQuickBarEntityIndex(this);
3089 ctx.Write(itemQBIndex);
3090 }
3091 else
3092 {
3093 ctx.Write(false); // Keep track of if we should actually read this in or not
3094 }
3095
3096 SaveVariables(ctx);// variable management system
3097 SaveAgents(ctx);//agent trasmission system
3098
3100 if (raib)
3101 {
3102 raib.OnStoreSave(ctx);
3103 }
3104 }
3105 //----------------------------------------------------------------
3106
3107 override void AfterStoreLoad()
3108 {
3109 super.AfterStoreLoad();
3110
3112 {
3114 }
3115
3116 if (m_StoreLoadedQuantity != float.LOWEST)
3117 {
3119 m_StoreLoadedQuantity = float.LOWEST;//IMPORTANT to do this !! we use 'm_StoreLoadedQuantity' inside SetQuantity to distinguish between initial quantity setting and the consequent(normal gameplay) calls
3120 }
3121 }
3122
3123 override void EEOnAfterLoad()
3124 {
3125 super.EEOnAfterLoad();
3126
3128 {
3129 m_FixDamageSystemInit = false;
3130 }
3131
3134 }
3135
3137 {
3138 return false;
3139 }
3140
3141
3142 //----------------------------------------------------------------
3144 {
3145 if (m_Initialized)
3146 {
3147 #ifdef PLATFORM_CONSOLE
3148 //bruteforce it is
3149 if (m_CanThisBeSplit)
3150 {
3152 if (menu)
3153 {
3154 menu.Refresh();
3155 }
3156 }
3157 #endif
3158 }
3159
3161 {
3162 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
3163 m_WantPlayImpactSound = false;
3164 }
3165
3167 {
3168 SetWeightDirty();
3170 }
3171 if (m_VarWet != m_VarWetPrev)
3172 {
3175 }
3176
3177 super.OnVariablesSynchronized();
3178 }
3179
3180 //------------------------- Quantity
3181 //----------------------------------------------------------------
3183 bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
3184 {
3185 if (!IsServerCheck(allow_client))
3186 return false;
3187
3188 if (!HasQuantity())
3189 return false;
3190
3191 if (IsLiquidContainer() && GetLiquidType() == 0)
3192 {
3193 Debug.LogError("No LiquidType specified, try setting 'varLiquidTypeInit' to a particular liquid type");
3194 return false;
3195 }
3196
3197 float min = GetQuantityMin();
3198 float max = GetQuantityMax();
3199
3200 bool on_min_value = value <= (min + 0.001); //workaround, items with "varQuantityDestroyOnMin = true;" get destroyed
3201
3202 if (on_min_value)
3203 {
3204 if (destroy_config)
3205 {
3206 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
3207 if (dstr)
3208 {
3209 m_VarQuantity = Math.Clamp(value, min, max);
3210 this.Delete();
3211 return true;
3212 }
3213 }
3214 else if (destroy_forced)
3215 {
3216 m_VarQuantity = Math.Clamp(value, min, max);
3217 this.Delete();
3218 return true;
3219 }
3220 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
3221 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
3222 }
3223
3224 float delta = m_VarQuantity;
3225 m_VarQuantity = Math.Clamp(value, min, max);
3226
3227 if (m_StoreLoadedQuantity == float.LOWEST)//any other value means we are setting quantity from storage
3228 {
3229 delta = m_VarQuantity - delta;
3230
3231 if (delta)
3232 {
3233 OnQuantityChanged(delta);
3234 }
3235 }
3236
3238
3239 return false;
3240 }
3241
3242 //----------------------------------------------------------------
3244 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
3245 {
3246 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
3247 }
3248 //----------------------------------------------------------------
3250 {
3251 float max = GetQuantityMax();
3252 SetQuantity(max);
3253 }
3254
3255 override void SetQuantityToMinimum()
3256 {
3257 float min = GetQuantityMin();
3258 SetQuantity(min);
3259 }
3260 //----------------------------------------------------------------
3262 void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
3263 {
3264 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
3265 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
3266 SetQuantity(result, destroy_config, destroy_forced);
3267 }
3268
3269 //----------------------------------------------------------------
3272 {
3274 }
3275
3276 /*void SetAmmoNormalized(float value)
3277 {
3278 float value_clamped = Math.Clamp(value, 0, 1);
3279 Magazine this_mag = Magazine.Cast(this);
3280 int max_rounds = this_mag.GetAmmoMax();
3281 int result = value * max_rounds;//can the rounded if higher precision is required
3282 this_mag.SetAmmoCount(result);
3283 }*/
3284 //----------------------------------------------------------------
3285 override int GetQuantityMax()
3286 {
3287 float max = 0;
3288
3290 if (GetInventory())
3291 GetInventory().GetCurrentInventoryLocation(il);
3292
3293 int slot = il.GetSlot();
3294
3295 if (slot != -1)
3297
3298 if (max <= 0)
3299 max = m_VarStackMax;
3300
3301 if (max <= 0)
3302 max = m_VarQuantityMax;
3303
3304 return max;
3305 }
3306
3307 override int GetTargetQuantityMax(int attSlotID = -1)
3308 {
3309 float quantity_max = 0;
3310
3311 if (attSlotID != -1)
3312 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
3313
3314 if (quantity_max <= 0)
3315 quantity_max = m_VarStackMax;
3316
3317 if (quantity_max <= 0)
3318 quantity_max = m_VarQuantityMax;
3319
3320 return quantity_max;
3321 }
3322 //----------------------------------------------------------------
3324 {
3325 return m_VarQuantityMin;
3326 }
3327 //----------------------------------------------------------------
3329 {
3330 return m_VarQuantityInit;
3331 }
3332 //----------------------------------------------------------------
3334 {
3335 if (GetQuantityMax() - GetQuantityMin() == 0)
3336 {
3337 return false;
3338 }
3339 else
3340 {
3341 return true;
3342 }
3343 }
3344
3345 override float GetQuantity()
3346 {
3347 return m_VarQuantity;
3348 }
3349
3351 {
3352 return GetQuantity() >= GetQuantityMax();
3353 }
3354
3355 //Calculates weight of single item without attachments and cargo
3357 {
3358 //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
3359 float weightEx = GetWeightEx();//overall weight of the item
3360 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
3361 return weightEx - special;
3362 }
3363
3364 // Obsolete, use GetSingleInventoryItemWeightEx() instead
3366 {
3368 }
3369
3370 override protected float GetWeightSpecialized(bool forceRecalc = false)
3371 {
3372 if (m_CanThisBeSplit) //quantity determines size of the stack
3373 {
3374 #ifdef DEVELOPER
3375 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3376 {
3377 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
3378 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
3379 }
3380 #endif
3381
3382 return GetQuantity() * GetConfigWeightModified();
3383 }
3384 else if (HasEnergyManager())// items with energy manager
3385 {
3386 #ifdef DEVELOPER
3387 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3388 {
3389 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
3390 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
3391 }
3392 #endif
3393 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
3394 }
3395 else//everything else
3396 {
3397 #ifdef DEVELOPER
3398 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3399 {
3400 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
3401 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
3402 }
3403 #endif
3404 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
3405 }
3406 }
3407
3410 {
3411 int item_count = 0;
3412 ItemBase item;
3413
3414 if (GetInventory().GetCargo() != NULL)
3415 {
3416 item_count = GetInventory().GetCargo().GetItemCount();
3417 }
3418
3419 for (int i = 0; i < GetInventory().AttachmentCount(); i++)
3420 {
3421 Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
3422 if (item)
3423 item_count += item.GetNumberOfItems();
3424 }
3425 return item_count;
3426 }
3427
3429 float GetUnitWeight(bool include_wetness = true)
3430 {
3431 float weight = 0;
3432 float wetness = 1;
3433 if (include_wetness)
3434 wetness += GetWet();
3435 if (m_CanThisBeSplit) //quantity determines size of the stack
3436 {
3437 weight = wetness * m_ConfigWeight;
3438 }
3439 else if (ConfigGetFloat("liquidContainerType") > 0) //is a liquid container, default liquid weight is set to 1. May revisit later?
3440 {
3441 weight = 1;
3442 }
3443 return weight;
3444 }
3445
3446 void SetVariableMask(int variable)
3447 {
3448 m_VariablesMask = variable | m_VariablesMask;
3449 if (GetGame().IsServer())
3450 {
3451 SetSynchDirty();
3452 }
3453 }
3454
3456 void RemoveItemVariable(int variable)
3457 {
3458 m_VariablesMask = ~variable & m_VariablesMask;
3459 }
3460
3462 bool IsVariableSet(int variable)
3463 {
3464 return (variable & m_VariablesMask);
3465 }
3466
3467 //------------------------- Energy
3468
3469 //----------------------------------------------------------------
3471 {
3472 float energy = 0;
3473 if (this.HasEnergyManager())
3474 {
3475 energy = this.GetCompEM().GetEnergy();
3476 }
3477 return energy;
3478 }
3479
3480
3481 override void OnEnergyConsumed()
3482 {
3483 super.OnEnergyConsumed();
3484
3486 }
3487
3488 override void OnEnergyAdded()
3489 {
3490 super.OnEnergyAdded();
3491
3493 }
3494
3495 // Converts energy (from Energy Manager) to quantity, if enabled.
3497 {
3498 if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
3499 {
3500 if (HasQuantity())
3501 {
3502 float energy_0to1 = GetCompEM().GetEnergy0To1();
3503 SetQuantityNormalized(energy_0to1);
3504 }
3505 }
3506 }
3507
3508 override void SetTemperature(float value, bool allow_client = false)
3509 {
3510 if (!IsServerCheck(allow_client))
3511 return;
3512
3513 float min = GetTemperatureMin();
3514 float max = GetTemperatureMax();
3515
3516 float previousValue = m_VarTemperature;
3517
3518 m_VarTemperature = Math.Clamp(value, min, max);
3519
3520 if (previousValue != m_VarTemperature)
3522 }
3523 //----------------------------------------------------------------
3524 override void AddTemperature(float value)
3525 {
3526 SetTemperature(value + GetTemperature());
3527 }
3528 //----------------------------------------------------------------
3529 override void SetTemperatureMax()
3530 {
3532 }
3533 //----------------------------------------------------------------
3534 override float GetTemperature()
3535 {
3536 return m_VarTemperature;
3537 }
3538
3539 override float GetTemperatureInit()
3540 {
3541 return m_VarTemperatureInit;
3542 }
3543
3544 override float GetTemperatureMin()
3545 {
3546 return m_VarTemperatureMin;
3547 }
3548
3549 override float GetTemperatureMax()
3550 {
3551 return m_VarTemperatureMax;
3552 }
3553 //----------------------------------------------------------------
3555 {
3556 return ConfigGetFloat("heatIsolation");
3557 }
3558
3560 {
3561 return m_HeatIsolation;
3562 }
3563
3564 float GetDryingIncrement(string pIncrementName)
3565 {
3566 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
3567 if (GetGame().ConfigIsExisting(paramPath))
3568 return GetGame().ConfigGetFloat(paramPath);
3569
3570 return 0.0;
3571 }
3572
3573 float GetSoakingIncrement(string pIncrementName)
3574 {
3575 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
3576 if (GetGame().ConfigIsExisting(paramPath))
3577 return GetGame().ConfigGetFloat(paramPath);
3578
3579 return 0.0;
3580 }
3581 //----------------------------------------------------------------
3582 override void SetWet(float value, bool allow_client = false)
3583 {
3584 if (!IsServerCheck(allow_client))
3585 return;
3586
3587 float min = GetWetMin();
3588 float max = GetWetMax();
3589
3590 float previousValue = m_VarWet;
3591
3592 m_VarWet = Math.Clamp(value, min, max);
3593
3594 if (previousValue != m_VarWet)
3595 {
3597 OnWetChanged(m_VarWet, previousValue);
3598 }
3599 }
3600 //----------------------------------------------------------------
3601 override void AddWet(float value)
3602 {
3603 SetWet(GetWet() + value);
3604 }
3605 //----------------------------------------------------------------
3606 override void SetWetMax()
3607 {
3609 }
3610 //----------------------------------------------------------------
3611 override float GetWet()
3612 {
3613 return m_VarWet;
3614 }
3615 //----------------------------------------------------------------
3616 override float GetWetMax()
3617 {
3618 return m_VarWetMax;
3619 }
3620 //----------------------------------------------------------------
3621 override float GetWetMin()
3622 {
3623 return m_VarWetMin;
3624 }
3625 //----------------------------------------------------------------
3626 override float GetWetInit()
3627 {
3628 return m_VarWetInit;
3629 }
3630 //----------------------------------------------------------------
3631 override void OnWetChanged(float newVal, float oldVal)
3632 {
3633 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
3634 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
3635 if (newLevel != oldLevel)
3636 {
3637 OnWetLevelChanged(newLevel,oldLevel);
3638 }
3639 }
3640
3641 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
3642 {
3643 SetWeightDirty();
3644 }
3645
3647 {
3648 return GetWetLevelInternal(m_VarWet);
3649 }
3650
3651 //----------------------------------------------------------------
3652 bool IsServerCheck(bool allow_client)
3653 {
3654 if (g_Game.IsServer())
3655 return true;
3656
3657 if (allow_client) return true;
3658 if (GetGame().IsClient() && GetGame().IsMultiplayer())
3659 {
3660 Error("Attempting to change variable client side, variables are supposed to be changed on server only !!");
3661 return false;
3662 }
3663 else
3664 {
3665 return true;
3666 }
3667 }
3668
3670 {
3671 if (ConfigIsExisting("itemModelLength"))
3672 {
3673 return ConfigGetFloat("itemModelLength");
3674 }
3675 return 0;
3676 }
3677
3678 void SetCleanness(int value, bool allow_client = false)
3679 {
3680 if (!IsServerCheck(allow_client))
3681 return;
3682
3683 int previousValue = m_Cleanness;
3684
3686
3687 if (previousValue != m_Cleanness)
3689 }
3690
3691
3693 {
3694 return true;
3695 }
3696
3697 //----------------------------------------------------------------
3698 // ATTACHMENT LOCKING
3699 // Getters relevant to generic ActionLockAttachment
3701 {
3702 return m_LockType;
3703 }
3704
3706 {
3707 return m_LockSoundSet;
3708 }
3709
3710 //----------------------------------------------------------------
3711 //------------------------- Color
3712 // sets items color variable given color components
3713 void SetColor(int r, int g, int b, int a)
3714 {
3720 }
3722 void GetColor(out int r,out int g,out int b,out int a)
3723 {
3728 }
3729
3731 {
3733 }
3734
3737 {
3738 int r,g,b,a;
3739 GetColor(r,g,b,a);
3740 r = r/255;
3741 g = g/255;
3742 b = b/255;
3743 a = a/255;
3744 return MiscGameplayFunctions.GetColorString(r, g, b, a);
3745 }
3746 //----------------------------------------------------------------
3747 //------------------------- LiquidType
3748
3749 void SetLiquidType(int value, bool allow_client = false)
3750 {
3751 if (!IsServerCheck(allow_client)) return;
3752 m_VarLiquidType = value;
3754 }
3755
3757 {
3758 return ConfigGetInt("varLiquidTypeInit");
3759 }
3760
3762 {
3763 return m_VarLiquidType;
3764 }
3765
3766 // -------------------------------------------------------------------------
3768 void OnInventoryEnter(Man player)
3769 {
3770 PlayerBase nplayer;
3771 if (PlayerBase.CastTo(nplayer, player))
3772 {
3773 m_CanPlayImpactSound = true;
3774 //nplayer.OnItemInventoryEnter(this);
3775 nplayer.SetEnableQuickBarEntityShortcut(this,true);
3776 }
3777 }
3778
3779 // -------------------------------------------------------------------------
3781 void OnInventoryExit(Man player)
3782 {
3783 PlayerBase nplayer;
3784 if (PlayerBase.CastTo(nplayer,player))
3785 {
3786 //nplayer.OnItemInventoryExit(this);
3787 nplayer.SetEnableQuickBarEntityShortcut(this,false);
3788
3789 }
3790
3791 //if (!GetGame().IsDedicatedServer())
3792 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
3793
3794
3795 if (HasEnergyManager())
3796 {
3797 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
3798 }
3799 }
3800
3801 // ADVANCED PLACEMENT EVENTS
3802 override void OnPlacementStarted(Man player)
3803 {
3804 super.OnPlacementStarted(player);
3805
3806 SetTakeable(false);
3807 }
3808
3809 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
3810 {
3811 if (m_AdminLog)
3812 {
3813 m_AdminLog.OnPlacementComplete(player, this);
3814 }
3815
3816 super.OnPlacementComplete(player, position, orientation);
3817 }
3818
3819 //-----------------------------
3820 // AGENT SYSTEM
3821 //-----------------------------
3822 //--------------------------------------------------------------------------
3823 bool ContainsAgent(int agent_id)
3824 {
3825 if (agent_id & m_AttachedAgents)
3826 {
3827 return true;
3828 }
3829 else
3830 {
3831 return false;
3832 }
3833 }
3834
3835 //--------------------------------------------------------------------------
3836 override void RemoveAgent(int agent_id)
3837 {
3838 if (ContainsAgent(agent_id))
3839 {
3840 m_AttachedAgents = ~agent_id & m_AttachedAgents;
3841 }
3842 }
3843
3844 //--------------------------------------------------------------------------
3845 override void RemoveAllAgents()
3846 {
3847 m_AttachedAgents = 0;
3848 }
3849 //--------------------------------------------------------------------------
3850 override void RemoveAllAgentsExcept(int agents_to_keep_mask)
3851 {
3852 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
3853 }
3854 // -------------------------------------------------------------------------
3855 override void InsertAgent(int agent, float count = 1)
3856 {
3857 if (count < 1)
3858 return;
3859 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
3861 }
3862
3864 void TransferAgents(int agents)
3865 {
3867 }
3868
3869 // -------------------------------------------------------------------------
3870 override int GetAgents()
3871 {
3872 return m_AttachedAgents;
3873 }
3874 //----------------------------------------------------------------------
3875
3876 /*int GetContaminationType()
3877 {
3878 int contamination_type;
3879
3880 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
3881 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
3882 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
3883 const int DIRTY_MASK = eAgents.WOUND_AGENT;
3884
3885 Edible_Base edible = Edible_Base.Cast(this);
3886 int agents = GetAgents();
3887 if (edible)
3888 {
3889 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
3890 if (profile)
3891 {
3892 //Print("profile agents:" +profile.GetAgents());
3893 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
3894 }
3895 }
3896 if (agents & CONTAMINATED_MASK)
3897 {
3898 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
3899 }
3900 if (agents & POISONED_MASK)
3901 {
3902 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
3903 }
3904 if (agents & NERVE_GAS_MASK)
3905 {
3906 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
3907 }
3908 if (agents & DIRTY_MASK)
3909 {
3910 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
3911 }
3912
3913 return agents;
3914 }*/
3915
3916 // -------------------------------------------------------------------------
3917 bool LoadAgents(ParamsReadContext ctx, int version)
3918 {
3919 if (!ctx.Read(m_AttachedAgents))
3920 return false;
3921 return true;
3922 }
3923 // -------------------------------------------------------------------------
3925 {
3926
3928 }
3929 // -------------------------------------------------------------------------
3930
3931
3932 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
3933 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
3934 {
3935 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
3936 {
3937 return 0;
3938 }
3939
3940 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
3941 {
3942 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
3943 if (filter)
3944 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
3945 else
3946 return 0;//otherwise return 0 when no filter attached
3947 }
3948
3949 string subclassPath, entryName;
3950
3951 switch (type)
3952 {
3953 case DEF_BIOLOGICAL:
3954 entryName = "biological";
3955 break;
3956 case DEF_CHEMICAL:
3957 entryName = "chemical";
3958 break;
3959 default:
3960 entryName = "biological";
3961 break;
3962 }
3963
3964 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
3965
3966 return GetGame().ConfigGetFloat(subclassPath + entryName);
3967 }
3968
3969
3970
3972 override void EEOnCECreate()
3973 {
3974 //Print("EEOnCECreate");
3975 if (!IsMagazine() && HasQuantity())
3977
3979 }
3980
3981
3982 //-------------------------
3983 // OPEN/CLOSE USER ACTIONS
3984 //-------------------------
3986 void Open();
3987 void Close();
3988 bool IsOpen()
3989 {
3990 return true;
3991 }
3992
3993 override bool CanDisplayCargo()
3994 {
3995 return IsOpen();
3996 }
3997
3998
3999 // ------------------------------------------------------------
4000 // CONDITIONS
4001 // ------------------------------------------------------------
4002 override bool CanPutInCargo(EntityAI parent)
4003 {
4004 if (parent)
4005 {
4006 if (parent.IsInherited(DayZInfected))
4007 return true;
4008
4009 if (!parent.IsRuined())
4010 return true;
4011 }
4012
4013 return true;
4014 }
4015
4016 override bool CanPutAsAttachment(EntityAI parent)
4017 {
4018 if (!super.CanPutAsAttachment(parent))
4019 {
4020 return false;
4021 }
4022
4023 if (!IsRuined() && !parent.IsRuined())
4024 {
4025 return true;
4026 }
4027
4028 return false;
4029 }
4030
4032 {
4033 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
4034 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
4035 // return false;
4036
4037 return super.CanReceiveItemIntoCargo(item);
4038 }
4039
4040 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
4041 {
4042 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
4043 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
4044 // return false;
4045
4046 GameInventory attachmentInv = attachment.GetInventory();
4047 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
4048 {
4049 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
4050 return false;
4051 }
4052
4053 return super.CanReceiveAttachment(attachment, slotId);
4054 }
4055
4056 /*override bool CanLoadAttachment(EntityAI attachment)
4057 {
4058 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
4059 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
4060 // return false;
4061
4062 GameInventory attachmentInv = attachment.GetInventory();
4063 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
4064 {
4065 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
4066 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
4067
4068 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
4069 return false;
4070 }
4071
4072 return super.CanLoadAttachment(attachment);
4073 }*/
4074
4075 // Plays muzzle flash particle effects
4076 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4077 {
4078 int id = muzzle_owner.GetMuzzleID();
4080
4081 if (WPOF_array)
4082 {
4083 for (int i = 0; i < WPOF_array.Count(); i++)
4084 {
4085 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
4086
4087 if (WPOF)
4088 {
4089 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
4090 }
4091 }
4092 }
4093 }
4094
4095 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
4096 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4097 {
4098 int id = muzzle_owner.GetMuzzleID();
4100
4101 if (WPOBE_array)
4102 {
4103 for (int i = 0; i < WPOBE_array.Count(); i++)
4104 {
4105 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
4106
4107 if (WPOBE)
4108 {
4109 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
4110 }
4111 }
4112 }
4113 }
4114
4115 // Plays all weapon overheating particles
4116 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4117 {
4118 int id = muzzle_owner.GetMuzzleID();
4119 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
4120
4121 if (WPOOH_array)
4122 {
4123 for (int i = 0; i < WPOOH_array.Count(); i++)
4124 {
4125 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
4126
4127 if (WPOOH)
4128 {
4129 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
4130 }
4131 }
4132 }
4133 }
4134
4135 // Updates all weapon overheating particles
4136 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4137 {
4138 int id = muzzle_owner.GetMuzzleID();
4139 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
4140
4141 if (WPOOH_array)
4142 {
4143 for (int i = 0; i < WPOOH_array.Count(); i++)
4144 {
4145 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
4146
4147 if (WPOOH)
4148 {
4149 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
4150 }
4151 }
4152 }
4153 }
4154
4155 // Stops overheating particles
4156 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4157 {
4158 int id = muzzle_owner.GetMuzzleID();
4159 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
4160
4161 if (WPOOH_array)
4162 {
4163 for (int i = 0; i < WPOOH_array.Count(); i++)
4164 {
4165 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
4166
4167 if (WPOOH)
4168 {
4169 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
4170 }
4171 }
4172 }
4173 }
4174
4175 //----------------------------------------------------------------
4176 //Item Behaviour - unified approach
4177 override bool IsHeavyBehaviour()
4178 {
4179 if (m_ItemBehaviour == 0)
4180 {
4181 return true;
4182 }
4183
4184 return false;
4185 }
4186
4187 override bool IsOneHandedBehaviour()
4188 {
4189 if (m_ItemBehaviour == 1)
4190 {
4191 return true;
4192 }
4193
4194 return false;
4195 }
4196
4197 override bool IsTwoHandedBehaviour()
4198 {
4199 if (m_ItemBehaviour == 2)
4200 {
4201 return true;
4202 }
4203
4204 return false;
4205 }
4206
4208 {
4209 return false;
4210 }
4211
4214 {
4216 }
4217
4218
4219 //----------------------------------------------------------------
4220 // Item Targeting (User Actions)
4221 override void SetTakeable(bool pState)
4222 {
4223 m_IsTakeable = pState;
4224 SetSynchDirty();
4225 }
4226
4227 override bool IsTakeable()
4228 {
4229 return m_IsTakeable;
4230 }
4231
4234 {
4235 string att_type = "None";
4236
4237 if (ConfigIsExisting("soundAttType"))
4238 {
4239 att_type = ConfigGetString("soundAttType");
4240 }
4241
4242 m_SoundAttType = att_type;
4243 }
4244
4245 override string GetAttachmentSoundType()
4246 {
4247 return m_SoundAttType;
4248 }
4249
4250 //----------------------------------------------------------------
4251 //SOUNDS FOR ADVANCED PLACEMNT
4252 //----------------------------------------------------------------
4253
4255 {
4256 m_IsSoundSynchRemote = false;
4257
4258 SetSynchDirty();
4259 }
4260
4262 {
4263 m_IsSoundSynchRemote = true;
4264
4265 SetSynchDirty();
4266 }
4267
4269 {
4270 return m_IsSoundSynchRemote;
4271 }
4272
4277
4278 void SetIsPlaceSound(bool is_place_sound)
4279 {
4280 m_IsPlaceSound = is_place_sound;
4281 }
4282
4284 {
4285 return m_IsPlaceSound;
4286 }
4287
4288 void SetIsDeploySound(bool is_deploy_sound)
4289 {
4290 m_IsDeploySound = is_deploy_sound;
4291 }
4292
4294 {
4295 return m_IsDeploySound;
4296 }
4297
4299 {
4300 if (!GetGame().IsDedicatedServer() && !m_SoundDeploy)
4301 {
4304 }
4305 }
4306
4308 {
4309 if (!GetGame().IsDedicatedServer() && !m_SoundDeployFinish)
4310 {
4313 }
4314 }
4315
4317 {
4318 if (!GetGame().IsDedicatedServer() && !m_SoundPlace)
4319 {
4322 }
4323 }
4324
4326 {
4327 return IsBeingPlaced() && IsSoundSynchRemote();
4328 }
4329
4331 void PlayAttachSound(string slot_type)
4332 {
4333 if (!GetGame().IsDedicatedServer())
4334 {
4335 if (ConfigIsExisting("attachSoundSet"))
4336 {
4337 string cfg_path = "";
4338 string soundset = "";
4339 string type_name = GetType();
4340
4341 TStringArray cfg_soundset_array = new TStringArray;
4342 TStringArray cfg_slot_array = new TStringArray;
4343 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
4344 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
4345
4346 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
4347 {
4348 for (int i = 0; i < cfg_soundset_array.Count(); i++)
4349 {
4350 if (cfg_slot_array[i] == slot_type)
4351 {
4352 soundset = cfg_soundset_array[i];
4353 break;
4354 }
4355 }
4356 }
4357
4358 if (soundset != "")
4359 {
4360 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
4361 sound.SetAutodestroy(true);
4362 }
4363 }
4364 }
4365 }
4366
4367 void PlayDetachSound(string slot_type)
4368 {
4369 //TODO - evaluate if needed and devise universal config structure if so
4370 }
4371
4372 void OnApply(PlayerBase player);
4373
4375 {
4376 return 1.0;
4377 };
4378 //returns applicable selection
4380 {
4382 }
4383
4385 {
4387 }
4388
4390
4392 {
4393 SetDynamicPhysicsLifeTime(0.01);
4394 m_ItemBeingDroppedPhys = false;
4395 }
4396
4398 {
4399 array<string> zone_names = new array<string>;
4400 GetDamageZones(zone_names);
4401 for (int i = 0; i < zone_names.Count(); i++)
4402 {
4403 SetHealthMax(zone_names.Get(i),"Health");
4404 }
4405 SetHealthMax("","Health");
4406 }
4407
4410 {
4411 float global_health = GetHealth01("","Health");
4412 array<string> zones = new array<string>;
4413 GetDamageZones(zones);
4414 //set damage of all zones to match global health level
4415 for (int i = 0; i < zones.Count(); i++)
4416 {
4417 SetHealth01(zones.Get(i),"Health",global_health);
4418 }
4419 }
4420
4421 bool IsCoverFaceForShave(string slot_name)
4422 {
4423 if (slot_name == "Mask")
4424 {
4425 return true;
4426 }
4427
4428 if (ConfigGetBool("noMask"))
4429 {
4430 return true;
4431 }
4432
4433 return false;
4434 }
4435
4436 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
4437 {
4438 if (!hasRootAsPlayer)
4439 {
4440 if (refParentIB)
4441 {
4442 // parent is wet
4443 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
4445 // parent has liquid inside
4446 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
4448 // drying
4449 else if (m_VarWet > m_VarWetMin)
4450 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
4451 }
4452 else
4453 {
4454 // drying on ground or inside non-itembase (car, ...)
4455 if (m_VarWet > m_VarWetMin)
4456 AddWet(-1 * delta * GetDryingIncrement("ground"));
4457 }
4458 }
4459 }
4460
4461 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
4462 {
4463 if (!hasRootAsPlayer && GetTemperature() > GetTemperatureMin() && !IsFireplace())
4464 {
4465 if (refParentIB)
4466 {
4467 // cooling of an item inside other
4468 if (GetTemperature() > refParentIB.GetTemperature())
4470 }
4471 else
4472 {
4473 // cooling of an item on ground or inside non-itembase (car, ...)
4475 }
4476 }
4477 }
4478
4479 // Backwards compatibility
4480 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
4481 {
4482 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
4483 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
4484 }
4485
4486 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
4487 {
4488 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
4489 EntityAI parent = GetHierarchyParent();
4490 if (!parent)
4491 {
4492 hasParent = false;
4493 hasRootAsPlayer = false;
4494 }
4495 else
4496 {
4497 hasParent = true;
4498 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
4499 refParentIB = ItemBase.Cast(parent);
4500 }
4501 }
4502
4503 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
4504 {
4505 // this is stub, implemented on Edible_Base
4506 }
4507
4508 bool CanDecay() //Was protected, changed for access from TransferItemVariables method
4509 {
4510 // return true used on selected food clases so they can decay
4511 return false;
4512 }
4513
4514 protected bool CanProcessDecay()
4515 {
4516 // this is stub, implemented on Edible_Base class
4517 // used to determine whether it is still necessary for the food to decay
4518 return false;
4519 }
4520
4521 protected bool CanHaveWetness()
4522 {
4523 // return true used on selected items that have a wetness effect
4524 return false;
4525 }
4526
4527 protected bool CanHaveTemperature()
4528 {
4529 // return true used on selected items that have a temperature effect
4530 return false;
4531 }
4532
4533 override void OnCEUpdate()
4534 {
4535 super.OnCEUpdate();
4536
4537 bool hasParent = false, hasRootAsPlayer = false;
4538 ItemBase refParentIB;
4539
4540 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
4541 bool foodDecay = g_Game.IsFoodDecayEnabled();
4542
4543 if (wwtu || foodDecay)
4544 {
4545 bool processWetness = wwtu && CanHaveWetness();
4546 bool processTemperature = wwtu && CanHaveTemperature();
4547 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
4548
4549 if (processWetness || processTemperature || processDecay)
4550 {
4551 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
4552
4553 if (processWetness)
4554 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
4555
4556 if (processTemperature)
4557 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
4558
4559 if (processDecay)
4560 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
4561 }
4562 }
4563 }
4564
4566 {
4567 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
4568 }
4569
4571 {
4572 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
4573 }
4574
4577 {
4578 m_LightSourceItem = lightsource;
4579 }
4580
4582 {
4583 m_LightSourceItem = null;
4584 }
4585
4587 {
4588 return m_LightSourceItem;
4589 }
4590
4593 {
4594 return null;
4595 }
4596
4599 {
4600 return false;
4601 }
4602
4603 bool PairWithDevice(notnull ItemBase otherDevice)
4604 {
4605 if (GetGame().IsServer())
4606 {
4607 ItemBase explosive = otherDevice;
4609 if (!trg)
4610 {
4611 trg = RemoteDetonatorTrigger.Cast(otherDevice);
4612 explosive = this;
4613 }
4614
4615 explosive.PairRemote(trg);
4616 trg.SetControlledDevice(explosive);
4617
4619 trg.SetPersistentPairID(persistentID);
4620 explosive.SetPersistentPairID(persistentID);
4621
4622 return true;
4623 }
4624 return false;
4625 }
4626
4627 #ifdef DEVELOPER
4628 override void SetDebugItem()
4629 {
4630 super.SetDebugItem();
4631 _itemBase = this;
4632 }
4633 #endif
4634}
4635
4636EntityAI SpawnItemOnLocation (string object_name, notnull InventoryLocation loc, bool full_quantity)
4638 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
4639 if (entity)
4640 {
4641 bool is_item = entity.IsInherited(ItemBase);
4642 if (is_item && full_quantity)
4643 {
4644 ItemBase item = ItemBase.Cast(entity);
4645 item.SetQuantity(item.GetQuantityInit());
4646 }
4647 }
4648 else
4649 {
4650 Print("Cannot spawn entity: " + object_name);
4651 return NULL;
4653 return entity;
4656void SetupSpawnedItem (ItemBase item, float health, float quantity)
4658 if (item)
4659 {
4660 if (quantity == -1)
4662 if (item.HasQuantity())
4663 quantity = item.GetQuantityInit();
4664 }
4666 if (health > 0)
4667 item.SetHealth("", "", health);
4669 if (quantity > 0)
4670 {
4671 item.SetQuantity(quantity);
4675
4676#ifdef DEVELOPER
4677ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
4678#endif
EWetnessLevel
Definition EntityAI.c:2
InventoryMode
Definition Inventory.c:20
const int INPUT_UDT_ITEM_MANIPULATION
Definition _constants.c:8
eBleedingSourceType GetType()
void ActionBase()
Definition ActionBase.c:73
protected bool IsDamageDestroyed(ActionTarget target)
Definition ActionBase.c:912
void ActionDropItem()
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3< int, int, string > TSelectableActionInfo
void ActionManagerBase(PlayerBase player)
map< typename, ref array< ActionBase_Basic > > TInputActionMap
TInputActionMap m_InputActionMap
void AddAction(typename actionName)
bool m_ActionsInitialize
void InitializeActions()
const int ECE_PLACE_ON_SURFACE
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
const int RF_DEFAULT
DamageType
exposed from C++ (do not change)
DayZGame g_Game
Definition DayZGame.c:3654
DayZGame GetDayZGame()
Definition DayZGame.c:3656
EActions
Definition EActions.c:2
ERPCs
Definition ERPCs.c:2
PluginAdminLog m_AdminLog
const int MAX
Definition EnConvert.c:27
proto string ToString()
override bool IsFireplace()
override void OnDebugButtonPressServer(int button_index)
override void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Definition ItemBase.c:5295
float m_VarWetMin
Definition ItemBase.c:4668
bool IsServerCheck(bool allow_client)
Definition ItemBase.c:8274
void SetVariableMask(int variable)
Definition ItemBase.c:8068
bool IsOpen()
Definition ItemBase.c:8610
void SetResultOfSplit(bool value)
Definition ItemBase.c:6620
bool DamageItemInCargo(float damage)
Definition ItemBase.c:6056
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Definition ItemBase.c:6436
int m_VariablesMask
Definition ItemBase.c:4648
float m_VarWet
Definition ItemBase.c:4665
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Definition ItemBase.c:4729
ref TIntArray m_SingleUseActions
Definition ItemBase.c:4715
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:5187
ref array< ref OverheatingParticle > m_OverheatingParticles
Definition ItemBase.c:4741
protected bool CanHaveWetness()
Definition ItemBase.c:9143
float GetHeatIsolationInit()
Definition ItemBase.c:8176
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Definition ItemBase.c:6246
bool m_IsSoundSynchRemote
Definition ItemBase.c:4691
float m_OverheatingShots
Definition ItemBase.c:4736
bool IsFullQuantity()
Definition ItemBase.c:7972
ref array< int > m_CompatibleLocks
Definition ItemBase.c:4753
override void AddTemperature(float value)
Definition ItemBase.c:8146
override float GetTemperatureMax()
Definition ItemBase.c:8171
float GetSingleInventoryItemWeightEx()
Definition ItemBase.c:7978
void LoadParticleConfigOnOverheating(int id)
Definition ItemBase.c:5058
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Definition ItemBase.c:8263
ref TIntArray m_InteractActions
Definition ItemBase.c:4717
override void InsertAgent(int agent, float count=1)
Definition ItemBase.c:8477
float m_VarQuantity
Definition ItemBase.c:4651
float m_VarTemperature
Definition ItemBase.c:4660
protected EffectSound m_SoundPlace
Definition ItemBase.c:4758
override bool CanBeSplit()
Definition ItemBase.c:6092
bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Definition ItemBase.c:7422
override float GetWetMax()
Definition ItemBase.c:8238
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Definition ItemBase.c:4728
bool m_CanBeMovedOverride
Definition ItemBase.c:4694
float GetEnergy()
Definition ItemBase.c:8092
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition ItemBase.c:9058
bool IsLiquidContainer()
Definition ItemBase.c:5484
int m_ColorComponentR
Definition ItemBase.c:4706
int m_ShotsToStartOverheating
Definition ItemBase.c:4738
protected void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Definition ItemBase.c:8855
void WriteVarsToCTX(ParamsWriteContext ctx)
Definition ItemBase.c:7383
int m_Cleanness
Definition ItemBase.c:4671
float m_VarTemperatureInit
Definition ItemBase.c:4661
void ConvertEnergyToQuantity()
Definition ItemBase.c:8118
int m_ItemBehaviour
Definition ItemBase.c:4684
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Definition ItemBase.c:6610
float m_HeatIsolation
Definition ItemBase.c:4681
float m_VarWetInit
Definition ItemBase.c:4667
override void RemoveAgent(int agent_id)
Definition ItemBase.c:8458
bool m_CanPlayImpactSound
Definition ItemBase.c:4677
bool m_HasQuantityBar
Definition ItemBase.c:4700
override void RemoveAllAgents()
Definition ItemBase.c:8467
override float GetQuantity()
Definition ItemBase.c:7967
void SetQuantityMax()
Definition ItemBase.c:7871
override void OnWetChanged(float newVal, float oldVal)
Definition ItemBase.c:8253
bool HasQuantity()
Definition ItemBase.c:7955
bool m_ThrowItemOnDrop
Definition ItemBase.c:4692
override bool IsBeingPlaced()
Definition ItemBase.c:5540
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:5194
void SetCleanness(int value, bool allow_client=false)
Definition ItemBase.c:8300
void SaveVariables(ParamsWriteContext ctx)
Definition ItemBase.c:7536
override void SetTemperature(float value, bool allow_client=false)
Definition ItemBase.c:8130
int GetLiquidTypeInit()
Definition ItemBase.c:8378
int m_CleannessMin
Definition ItemBase.c:4673
override void SetTakeable(bool pState)
Definition ItemBase.c:8843
bool IsResultOfSplit()
Definition ItemBase.c:6615
protected bool m_HideSelectionsBySlot
Definition ItemBase.c:4744
float m_VarWetPrev
Definition ItemBase.c:4666
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:5181
ref TIntArray m_ContinuousActions
Definition ItemBase.c:4716
override float GetTemperature()
Definition ItemBase.c:8156
void UpdateAllOverheatingParticles()
Definition ItemBase.c:5222
int m_VarLiquidType
Definition ItemBase.c:4683
void SaveAgents(ParamsWriteContext ctx)
Definition ItemBase.c:8546
int m_QuickBarBonus
Definition ItemBase.c:4685
void SerializeNumericalVars(array< float > floats_out)
Definition ItemBase.c:7279
float GetOverheatingCoef()
Definition ItemBase.c:5214
int m_ImpactSoundSurfaceHash
Definition ItemBase.c:4679
override void SetWet(float value, bool allow_client=false)
Definition ItemBase.c:8204
int m_MaxOverheatingValue
Definition ItemBase.c:4739
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Definition ItemBase.c:4656
bool m_IsTakeable
Definition ItemBase.c:4690
static ref map< string, int > m_WeaponTypeToID
Definition ItemBase.c:4731
void KillAllOverheatingParticles()
Definition ItemBase.c:5250
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Definition ItemBase.c:4636
float m_OverheatingDecayInterval
Definition ItemBase.c:4740
bool LoadAgents(ParamsReadContext ctx, int version)
Definition ItemBase.c:8539
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Definition ItemBase.c:6282
bool can_this_be_combined
Definition ItemBase.c:4696
int m_Count
Definition ItemBase.c:4656
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...
Definition ItemBase.c:7884
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Definition ItemBase.c:6649
bool m_WantPlayImpactSound
Definition ItemBase.c:4676
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Definition ItemBase.c:4730
int m_ColorComponentG
Definition ItemBase.c:4707
float m_StoreLoadedQuantity
Definition ItemBase.c:4658
override float GetWetMin()
Definition ItemBase.c:8243
int m_ColorComponentA
Definition ItemBase.c:4709
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:5135
void SplitIntoStackMaxHands(PlayerBase player)
Definition ItemBase.c:6330
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Definition ItemBase.c:6630
bool LoadVariables(ParamsReadContext ctx, int version=-1)
Definition ItemBase.c:7559
int m_VarQuantityInit
Definition ItemBase.c:4653
protected EffectSound m_SoundDeploy
Definition ItemBase.c:4759
static bool HasDebugActionsMask(int mask)
Definition ItemBase.c:5370
protected string m_LockSoundSet
Definition ItemBase.c:4756
int GetLiquidType()
Definition ItemBase.c:8383
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Definition ItemBase.c:5304
ref Timer m_CheckOverheating
Definition ItemBase.c:4737
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Definition ItemBase.c:9031
bool m_IsDeploySound
Definition ItemBase.c:4689
void PerformDamageSystemReinit()
Definition ItemBase.c:9019
int m_CleannessInit
Definition ItemBase.c:4672
int m_VarQuantityMax
Definition ItemBase.c:4655
bool ContainsAgent(int agent_id)
Definition ItemBase.c:8445
override void AddWet(float value)
Definition ItemBase.c:8223
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Definition ItemBase.c:8953
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Definition ItemBase.c:6123
protected ref TStringArray m_HeadHidingSelections
Definition ItemBase.c:4743
int GetQuantityMin()
Definition ItemBase.c:7945
int m_CleannessMax
Definition ItemBase.c:4674
float m_VarStackMax
Definition ItemBase.c:4657
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Definition ItemBase.c:6424
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Definition ItemBase.c:9108
float GetItemModelLength()
Definition ItemBase.c:8291
void DeSerializeNumericalVars(array< float > floats)
Definition ItemBase.c:7319
bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition ItemBase.c:7805
override int GetTargetQuantityMax(int attSlotID=-1)
Definition ItemBase.c:7929
bool m_IsOverheatingEffectActive
Definition ItemBase.c:4735
bool DamageItemAttachments(float damage)
Definition ItemBase.c:6075
protected int m_LockType
Definition ItemBase.c:4754
static void AddDebugActionsMask(int mask)
Definition ItemBase.c:5380
int m_VarQuantityMin
Definition ItemBase.c:4654
override float GetWet()
Definition ItemBase.c:8233
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...
Definition ItemBase.c:7866
static int m_LastRegisteredWeaponID
Definition ItemBase.c:4732
float m_VarTemperatureMin
Definition ItemBase.c:4662
static void RemoveDebugActionsMask(int mask)
Definition ItemBase.c:5385
bool m_CanThisBeSplit
Definition ItemBase.c:4697
void SetLiquidType(int value, bool allow_client=false)
Definition ItemBase.c:8371
protected bool m_CanBeDigged
Definition ItemBase.c:4701
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Definition ItemBase.c:6625
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Definition ItemBase.c:6251
float m_ItemModelLength
Definition ItemBase.c:4682
bool m_IsHologram
Definition ItemBase.c:4687
bool IsVariableSet(int variable)
'true' if this variable has ever been changed from default
Definition ItemBase.c:8084
override float GetTemperatureMin()
Definition ItemBase.c:8166
bool m_ItemBeingDroppedPhys
Definition ItemBase.c:4693
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Definition ItemBase.c:4637
ItemBase Inventory_Base
Definition ItemBase.c:1
bool m_FixDamageSystemInit
Definition ItemBase.c:4695
float m_ImpactSpeed
Definition ItemBase.c:4678
bool m_IsStoreLoad
Definition ItemBase.c:4698
bool IsSoundSynchRemote()
Definition ItemBase.c:8890
void LoadParticleConfigOnFire(int id)
Definition ItemBase.c:4989
ItemBase m_LightSourceItem
Definition ItemBase.c:4713
float GetDryingIncrement(string pIncrementName)
Definition ItemBase.c:8186
void SplitItem(PlayerBase player)
Definition ItemBase.c:6388
float m_VarQuantityPrev
Definition ItemBase.c:4652
bool m_CanShowQuantity
Definition ItemBase.c:4699
private int m_AttachedAgents
Definition ItemBase.c:4721
int m_ColorComponentB
Definition ItemBase.c:4708
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition ItemBase.c:9083
protected bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Definition ItemBase.c:4704
protected EffectSound m_SoundDeployFinish
Definition ItemBase.c:4760
bool m_IsBeingPlaced
Definition ItemBase.c:4686
void ExplodeAmmo()
Definition ItemBase.c:5978
float m_VarWetMax
Definition ItemBase.c:4669
float m_VarTemperatureMax
Definition ItemBase.c:4663
bool IsOverheatingEffectActive()
Definition ItemBase.c:5152
bool m_IsPlaceSound
Definition ItemBase.c:4688
override int GetQuantityMax()
Definition ItemBase.c:7907
string Type
EffectSound m_LockingSound
PlayerBase GetPlayer()
@ LOWEST
string name
void PluginItemDiagnostic()
PluginBase GetPlugin(typename plugin_type)
EntityAI GetItem()
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
int particle_id
override void Explode(int damageType, string ammoType="")
protected bool m_Initialized
class JsonUndergroundAreaTriggerData GetPosition
void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native DayZPlayer GetPlayer()
proto native SoundOnVehicle CreateSoundOnObject(Object source, string sound_name, float distance, bool looped, bool create_local=false)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
AnalyticsManagerClient GetAnalyticsClient()
Definition Game.c:1412
proto native bool ConfigIsExisting(string path)
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native UIManager GetUIManager()
proto native int ConfigGetType(string path)
Returns type of config value.
static ref TFloatArray ARRAY_FLOAT
static ref Param1< float > PARAM1_FLOAT
static ref Param1< int > PARAM1_INT
represents base for cargo storage for entities
Definition Cargo.c:7
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Debug.c:14
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:138
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Definition Debug.c:235
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
HumanInventory GetHumanInventory()
inventory
Definition Man.c:46
override bool IsMan()
Definition Man.c:33
script counterpart to engine's class Inventory
Definition Inventory.c:77
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
const int c_InventoryReservationTimeoutShortMS
Definition Inventory.c:684
proto native CargoBase GetCargo()
cargo
proto native EntityAI GetEntityInHands()
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Definition ItemBase.c:673
float m_VarWetMin
Definition ItemBase.c:46
bool IsServerCheck(bool allow_client)
Definition ItemBase.c:3652
override bool IsHologram()
Definition ItemBase.c:934
void SetVariableMask(int variable)
Definition ItemBase.c:3446
void SetResultOfSplit(bool value)
Definition ItemBase.c:1998
void OnCombine(ItemBase other_item)
Definition ItemBase.c:2053
bool IsBloodContainer()
Definition ItemBase.c:867
override void EECargoIn(EntityAI item)
Definition ItemBase.c:989
bool DamageItemInCargo(float damage)
Definition ItemBase.c:1434
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Definition ItemBase.c:1814
int m_VariablesMask
Definition ItemBase.c:26
float m_VarWet
Definition ItemBase.c:43
void PlayDeploySound()
Definition ItemBase.c:4298
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Definition ItemBase.c:107
ref TIntArray m_SingleUseActions
Definition ItemBase.c:93
override void OnCreatePhysics()
Definition ItemBase.c:1147
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:565
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Definition ItemBase.c:1157
ScriptedLightBase GetLight()
ref array< ref OverheatingParticle > m_OverheatingParticles
Definition ItemBase.c:119
protected bool CanHaveTemperature()
Definition ItemBase.c:4527
protected bool CanHaveWetness()
Definition ItemBase.c:4521
bool CanMakeGardenplot()
Definition ItemBase.c:944
float GetHeatIsolationInit()
Definition ItemBase.c:3554
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Definition ItemBase.c:1624
bool IsNVG()
Definition ItemBase.c:872
bool IsOpen()
Definition ItemBase.c:3988
bool m_IsSoundSynchRemote
Definition ItemBase.c:69
float m_OverheatingShots
Definition ItemBase.c:114
bool IsFullQuantity()
Definition ItemBase.c:3350
override void AddTemperature(float value)
Definition ItemBase.c:3524
bool CanExplodeInFire()
Definition ItemBase.c:2379
override float GetTemperatureMax()
Definition ItemBase.c:3549
float GetSingleInventoryItemWeightEx()
Definition ItemBase.c:3356
void LoadParticleConfigOnOverheating(int id)
Definition ItemBase.c:436
void StopItemDynamicPhysics()
Definition ItemBase.c:4391
bool m_RecipesInitialized
Definition ItemBase.c:20
float GetDeployTime()
how long it takes to deploy this item in seconds
Definition ItemBase.c:4213
TInputActionMap m_InputActionMap
Definition ItemBase.c:16
override void OnCEUpdate()
Definition ItemBase.c:4533
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Definition ItemBase.c:2554
void SetActions()
Definition ItemBase.c:299
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Definition ItemBase.c:3641
bool IsCargoException4x3(EntityAI item)
Definition ItemBase.c:4565
ref TIntArray m_InteractActions
Definition ItemBase.c:95
override void InsertAgent(int agent, float count=1)
Definition ItemBase.c:3855
float m_VarQuantity
Definition ItemBase.c:29
void TransferVariablesFloat(array< float > float_vars)
Definition ItemBase.c:2606
float m_VarTemperature
Definition ItemBase.c:38
string GetLockSoundSet()
Definition ItemBase.c:3705
protected EffectSound m_SoundPlace
Definition ItemBase.c:136
override void EOnContact(IEntity other, Contact extra)
Definition ItemBase.c:1125
override bool CanBeSplit()
Definition ItemBase.c:1470
bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition ItemBase.c:2151
bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Definition ItemBase.c:2800
void OnSyncVariables(ParamsReadContext ctx)
Definition ItemBase.c:2630
void OnItemInHandsPlayerSwimStart(PlayerBase player)
override float GetWetMax()
Definition ItemBase.c:3616
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Definition ItemBase.c:797
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Definition ItemBase.c:106
bool m_CanBeMovedOverride
Definition ItemBase.c:72
float GetEnergy()
Definition ItemBase.c:3470
float GetDisinfectQuantity(int system=0, Param param1=null)
Definition ItemBase.c:662
override bool CanDisplayCargo()
Definition ItemBase.c:3993
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition ItemBase.c:4436
array< string > GetHeadHidingSelection()
Definition ItemBase.c:4379
void SoundSynchRemote()
Definition ItemBase.c:4261
override void OnStoreSave(ParamsWriteContext ctx)
Definition ItemBase.c:3079
bool CanBeCooked()
Definition ItemBase.c:2404
bool IsLiquidContainer()
Definition ItemBase.c:862
int m_ColorComponentR
Definition ItemBase.c:84
float GetBandagingEffectivity()
Definition ItemBase.c:4374
void GetColor(out int r, out int g, out int b, out int a)
gets item's color variable as components
Definition ItemBase.c:3722
bool IsDeployable()
Definition ItemBase.c:4207
protected void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Definition ItemBase.c:4233
override bool CanReceiveItemIntoCargo(EntityAI item)
Definition ItemBase.c:4031
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition ItemBase.c:4156
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition ItemBase.c:4096
bool IsLiquidPresent()
Definition ItemBase.c:856
void WriteVarsToCTX(ParamsWriteContext ctx)
Definition ItemBase.c:2761
int m_Cleanness
Definition ItemBase.c:49
override protected float GetWeightSpecialized(bool forceRecalc=false)
Definition ItemBase.c:3370
override string ChangeIntoOnAttach(string slot)
Definition ItemBase.c:1293
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Definition ItemBase.c:1733
void SoundSynchRemoteReset()
Definition ItemBase.c:4254
float m_VarTemperatureInit
Definition ItemBase.c:39
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:822
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Definition ItemBase.c:2422
void ConvertEnergyToQuantity()
Definition ItemBase.c:3496
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Definition ItemBase.c:1988
float m_HeatIsolation
Definition ItemBase.c:59
float m_VarWetInit
Definition ItemBase.c:45
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition ItemBase.c:4116
override void RemoveAgent(int agent_id)
Definition ItemBase.c:3836
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Definition ItemBase.c:1578
override void EEKilled(Object killer)
Definition ItemBase.c:1249
static void ToggleDebugActionsMask(int mask)
Definition ItemBase.c:768
void RefreshPhysics()
PluginAdminLog m_AdminLog
Definition ItemBase.c:125
void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
bool m_HasQuantityBar
Definition ItemBase.c:78
void OnActivatedByTripWire()
void AddAction(typename actionName)
Definition ItemBase.c:311
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Definition ItemBase.c:4598
override void RemoveAllAgents()
Definition ItemBase.c:3845
override float GetQuantity()
Definition ItemBase.c:3345
void SetQuantityMax()
Definition ItemBase.c:3249
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition ItemBase.c:1825
override void OnWetChanged(float newVal, float oldVal)
Definition ItemBase.c:3631
void OnEndPlacement()
Definition ItemBase.c:932
int GetItemSize()
Definition ItemBase.c:2429
bool HasQuantity()
Definition ItemBase.c:3333
override string GetAttachmentSoundType()
Definition ItemBase.c:4245
bool m_ThrowItemOnDrop
Definition ItemBase.c:70
override string ChangeIntoOnDetach()
Definition ItemBase.c:1317
string GetLoopDeploySoundset()
override void OnEnergyAdded()
Definition ItemBase.c:3488
override float GetWetInit()
Definition ItemBase.c:3626
void Open()
Implementations only.
override bool CanPutInCargo(EntityAI parent)
Definition ItemBase.c:4002
int NameToID(string name)
Definition ItemBase.c:2618
override bool IsBeingPlaced()
Definition ItemBase.c:918
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:572
void SetCleanness(int value, bool allow_client=false)
Definition ItemBase.c:3678
void SaveVariables(ParamsWriteContext ctx)
Definition ItemBase.c:2914
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Definition ItemBase.c:3972
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Definition ItemBase.c:3736
float GetInfectionChance(int system=0, Param param=null)
Infection chance while/after using this item, originally used for wound infection after bandaging,...
Definition ItemBase.c:656
override void SetTemperature(float value, bool allow_client=false)
Definition ItemBase.c:3508
bool IsFacingPlayer(PlayerBase player, string selection)
Definition ItemBase.c:903
int GetLiquidTypeInit()
Definition ItemBase.c:3756
int m_CleannessMin
Definition ItemBase.c:51
override void SetWetMax()
Definition ItemBase.c:3606
override void SetTakeable(bool pState)
Definition ItemBase.c:4221
bool CanBeDigged()
Definition ItemBase.c:939
protected bool CanProcessDecay()
Definition ItemBase.c:4514
void SetIsHologram(bool is_hologram)
Definition ItemBase.c:949
bool IsResultOfSplit()
Definition ItemBase.c:1993
protected bool m_HideSelectionsBySlot
Definition ItemBase.c:122
float m_VarWetPrev
Definition ItemBase.c:44
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Definition ItemBase.c:288
override void OnRightClick()
Definition ItemBase.c:1863
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:559
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition ItemBase.c:3809
ref TIntArray m_ContinuousActions
Definition ItemBase.c:94
override float GetTemperature()
Definition ItemBase.c:3534
void UpdateAllOverheatingParticles()
Definition ItemBase.c:600
bool AllowFoodConsumption()
Definition ItemBase.c:3692
int m_VarLiquidType
Definition ItemBase.c:61
bool IsExplosive()
Definition ItemBase.c:879
void SaveAgents(ParamsWriteContext ctx)
Definition ItemBase.c:3924
void InitItemVariables()
Definition ItemBase.c:192
void SerializeNumericalVars(array< float > floats_out)
Definition ItemBase.c:2657
protected void ProcessDecay(float delta, bool hasRootAsPlayer)
Definition ItemBase.c:4503
float GetOverheatingCoef()
Definition ItemBase.c:592
int m_ImpactSoundSurfaceHash
Definition ItemBase.c:57
float GetSoakingIncrement(string pIncrementName)
Definition ItemBase.c:3573
override void SetWet(float value, bool allow_client=false)
Definition ItemBase.c:3582
bool m_IsTakeable
Definition ItemBase.c:68
static ref map< string, int > m_WeaponTypeToID
Definition ItemBase.c:109
void KillAllOverheatingParticles()
Definition ItemBase.c:628
string GetPlaceSoundset()
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Definition ItemBase.c:3429
float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Definition ItemBase.c:3271
override bool IsOneHandedBehaviour()
Definition ItemBase.c:4187
bool IsCoverFaceForShave(string slot_name)
Definition ItemBase.c:4421
ItemBase GetLightSourceItem()
Definition ItemBase.c:4586
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Definition ItemBase.c:1599
bool IsLightSource()
Definition ItemBase.c:891
bool LoadAgents(ParamsReadContext ctx, int version)
Definition ItemBase.c:3917
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Definition ItemBase.c:1660
void PlayDetachSound(string slot_type)
Definition ItemBase.c:4367
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition ItemBase.c:497
override void EEDelete(EntityAI parent)
Definition ItemBase.c:1215
array< int > GetValidFinishers()
returns an array of possible finishers
Definition ItemBase.c:4592
int GetLockType()
Definition ItemBase.c:3700
override void SetQuantityToMinimum()
Definition ItemBase.c:3255
void RemoveItemVariable(int variable)
Removes variable from variable mask, making it appear as though the variable has never been changed f...
Definition ItemBase.c:3456
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:4278
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Definition ItemBase.c:578
override bool CanObstruct()
Definition ItemBase.c:913
int GetQuantityInit()
Definition ItemBase.c:3328
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...
Definition ItemBase.c:3262
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Definition ItemBase.c:2027
bool m_WantPlayImpactSound
Definition ItemBase.c:54
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Definition ItemBase.c:108
int m_ColorComponentG
Definition ItemBase.c:85
override void AfterStoreLoad()
Definition ItemBase.c:3107
override float GetWetMin()
Definition ItemBase.c:3621
override int GetQuickBarBonus()
Definition ItemBase.c:271
bool m_ActionsInitialize
Definition ItemBase.c:17
int m_ColorComponentA
Definition ItemBase.c:87
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition ItemBase.c:513
void SplitIntoStackMaxHands(PlayerBase player)
Definition ItemBase.c:1708
void SetIsDeploySound(bool is_deploy_sound)
Definition ItemBase.c:4288
override void OnWasDetached(EntityAI parent, int slot_id)
Definition ItemBase.c:1285
string IDToName(int id)
Definition ItemBase.c:2624
bool CanBeMovedOverride()
Definition ItemBase.c:2444
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Definition ItemBase.c:2008
protected ref EffectSound m_LockingSound
Definition ItemBase.c:133
override void EEOnAfterLoad()
Definition ItemBase.c:3123
bool LoadVariables(ParamsReadContext ctx, int version=-1)
Definition ItemBase.c:2937
int m_VarQuantityInit
Definition ItemBase.c:31
override bool IsIgnoredByConstruction()
Definition ItemBase.c:2391
protected EffectSound m_SoundDeploy
Definition ItemBase.c:137
bool HasFoodStage()
Definition ItemBase.c:2398
static bool HasDebugActionsMask(int mask)
Definition ItemBase.c:748
void DoAmmoExplosion()
Definition ItemBase.c:1369
void RemoveLightSourceItem()
Definition ItemBase.c:4581
int GetLiquidType()
Definition ItemBase.c:3761
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Definition ItemBase.c:682
ref Timer m_CheckOverheating
Definition ItemBase.c:115
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Definition ItemBase.c:4409
override float GetTemperatureInit()
Definition ItemBase.c:3539
string GetDeploySoundset()
bool CanDecay()
Definition ItemBase.c:4508
void ItemBase()
Definition ItemBase.c:141
void OnApply(PlayerBase player)
static int GetDebugActionsMask()
Definition ItemBase.c:743
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition ItemBase.c:1393
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Definition ItemBase.c:3409
void OnOverheatingDecay()
Definition ItemBase.c:535
bool m_IsDeploySound
Definition ItemBase.c:67
void PerformDamageSystemReinit()
Definition ItemBase.c:4397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition ItemBase.c:1001
void OnInventoryEnter(Man player)
Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter.
Definition ItemBase.c:3768
static void SetDebugActionsMask(int mask)
Definition ItemBase.c:753
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition ItemBase.c:2980
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition ItemBase.c:4136
void SetCEBasedQuantity()
Definition ItemBase.c:781
int m_CleannessInit
Definition ItemBase.c:50
int m_VarQuantityMax
Definition ItemBase.c:33
bool ContainsAgent(int agent_id)
Definition ItemBase.c:3823
void SetIsBeingPlaced(bool is_being_placed)
Definition ItemBase.c:923
override void RemoveAllAgentsExcept(int agents_to_keep_mask)
Definition ItemBase.c:3850
override void AddWet(float value)
Definition ItemBase.c:3601
override void OnMovedInsideCargo(EntityAI container)
Definition ItemBase.c:994
bool HidesSelectionBySlot()
Definition ItemBase.c:4384
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Definition ItemBase.c:4331
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Definition ItemBase.c:1501
void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Definition ItemBase.c:1478
float GetFilterDamageRatio()
Definition ItemBase.c:667
override bool CanPutAsAttachment(EntityAI parent)
Definition ItemBase.c:4016
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Definition ItemBase.c:810
protected ref TStringArray m_HeadHidingSelections
Definition ItemBase.c:121
WrittenNoteData GetWrittenNoteData()
Definition ItemBase.c:4389
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Definition ItemBase.c:1925
override bool IsTakeable()
Definition ItemBase.c:4227
int GetDamageSystemVersionChange()
Re-sets DamageSystem changes.
Definition ItemBase.c:705
override bool IsHeavyBehaviour()
Definition ItemBase.c:4177
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition ItemBase.c:4480
int GetQuantityMin()
Definition ItemBase.c:3323
override void OnWasAttached(EntityAI parent, int slot_id)
Definition ItemBase.c:1273
string GetExplosiveTriggerSlotName()
Definition ItemBase.c:884
void SplitIntoStackMaxHandsClient(PlayerBase player)
Definition ItemBase.c:1684
int m_CleannessMax
Definition ItemBase.c:52
float m_VarStackMax
Definition ItemBase.c:35
ref Timer m_PhysDropTimer
Definition ItemBase.c:128
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Definition ItemBase.c:1802
override void OnPlacementStarted(Man player)
Definition ItemBase.c:3802
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Definition ItemBase.c:4486
float GetItemModelLength()
Definition ItemBase.c:3669
void DeSerializeNumericalVars(array< float > floats)
Definition ItemBase.c:2697
void ~ItemBase()
Definition ItemBase.c:711
void PlayPlaceSound()
Definition ItemBase.c:4316
bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition ItemBase.c:3183
override int GetTargetQuantityMax(int attSlotID=-1)
Definition ItemBase.c:3307
override void OnVariablesSynchronized()
Definition ItemBase.c:3143
override bool KindOf(string tag)
Definition ItemBase.c:2534
void PlayDeployFinishSound()
Definition ItemBase.c:4307
bool IsDeploySound()
Definition ItemBase.c:4293
bool m_IsOverheatingEffectActive
Definition ItemBase.c:113
bool DamageItemAttachments(float damage)
Definition ItemBase.c:1453
bool IsPlaceSound()
Definition ItemBase.c:4283
bool CanBeCookedOnStick()
Definition ItemBase.c:2409
protected int m_LockType
Definition ItemBase.c:132
void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition ItemBase.c:2082
bool CanPlayDeployLoopSound()
Definition ItemBase.c:4325
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition ItemBase.c:1152
static void AddDebugActionsMask(int mask)
Definition ItemBase.c:758
int m_VarQuantityMin
Definition ItemBase.c:32
override float GetWet()
Definition ItemBase.c:3611
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...
Definition ItemBase.c:3244
void SetCanBeMovedOverride(bool setting)
Definition ItemBase.c:2451
float m_VarTemperatureMin
Definition ItemBase.c:40
static void RemoveDebugActionsMask(int mask)
Definition ItemBase.c:763
void SetLiquidType(int value, bool allow_client=false)
Definition ItemBase.c:3749
protected bool m_CanBeDigged
Definition ItemBase.c:79
override int GetAgents()
Definition ItemBase.c:3870
bool CanBeRepairedByCrafting()
Definition ItemBase.c:896
float GetOverheatingValue()
Definition ItemBase.c:492
void TransferAgents(int agents)
transfer agents from another item
Definition ItemBase.c:3864
bool CanEat()
Definition ItemBase.c:2385
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Definition ItemBase.c:2003
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Definition ItemBase.c:1629
bool CanRepair(ItemBase item_repair_kit)
Definition ItemBase.c:2415
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Definition ItemBase.c:2464
bool IsColorSet()
Definition ItemBase.c:3730
float m_ItemModelLength
Definition ItemBase.c:60
bool m_IsHologram
Definition ItemBase.c:65
static int m_DebugActionsMask
Definition ItemBase.c:19
bool IsVariableSet(int variable)
'true' if this variable has ever been changed from default
Definition ItemBase.c:3462
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition ItemBase.c:4040
array< float > GetVariablesFloat()
Definition ItemBase.c:2611
override float GetTemperatureMin()
Definition ItemBase.c:3544
bool m_ItemBeingDroppedPhys
Definition ItemBase.c:71
bool CanBeDisinfected()
Definition ItemBase.c:3136
void TransferModifiers(PlayerBase reciever)
float m_ImpactSpeed
Definition ItemBase.c:56
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Definition ItemBase.c:3933
void SetColor(int r, int g, int b, int a)
Definition ItemBase.c:3713
void RemoveAction(typename actionName)
Definition ItemBase.c:349
bool IsSoundSynchRemote()
Definition ItemBase.c:4268
void LoadParticleConfigOnFire(int id)
Definition ItemBase.c:367
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Definition ItemBase.c:2518
ItemBase m_LightSourceItem
Definition ItemBase.c:91
float GetDryingIncrement(string pIncrementName)
Definition ItemBase.c:3564
override void SetTemperatureMax()
Definition ItemBase.c:3529
void SplitItem(PlayerBase player)
Definition ItemBase.c:1766
float m_VarQuantityPrev
Definition ItemBase.c:30
float GetSingleInventoryItemWeight()
Definition ItemBase.c:3365
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Definition ItemBase.c:2482
bool m_CanShowQuantity
Definition ItemBase.c:77
private int m_AttachedAgents
Definition ItemBase.c:99
override EWetnessLevel GetWetLevel()
Definition ItemBase.c:3646
int m_ColorComponentB
Definition ItemBase.c:86
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition ItemBase.c:4461
protected bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Definition ItemBase.c:82
protected EffectSound m_SoundDeployFinish
Definition ItemBase.c:138
bool m_IsBeingPlaced
Definition ItemBase.c:64
string GetDeployFinishSoundset()
void OnInventoryExit(Man player)
Event called on item when it is removed from the player(Man) inventory, passes the old owner as a par...
Definition ItemBase.c:3781
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Definition ItemBase.c:1820
float GetHeatIsolation()
Definition ItemBase.c:3559
void ExplodeAmmo()
Definition ItemBase.c:1356
float m_VarWetMax
Definition ItemBase.c:47
bool IsPlayerInside(PlayerBase player, string selection)
Definition ItemBase.c:908
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition ItemBase.c:4076
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Definition ItemBase.c:4576
float m_VarTemperatureMax
Definition ItemBase.c:41
bool IsOverheatingEffectActive()
Definition ItemBase.c:530
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Definition ItemBase.c:2500
override bool IsItemBase()
Definition ItemBase.c:2528
bool m_IsPlaceSound
Definition ItemBase.c:66
void CopyScriptPropertiesFrom(EntityAI oldItem)
Definition ItemBase.c:4570
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Definition ItemBase.c:2061
override bool IsTwoHandedBehaviour()
Definition ItemBase.c:4197
bool PairWithDevice(notnull ItemBase otherDevice)
Definition ItemBase.c:4603
override int GetQuantityMax()
Definition ItemBase.c:3285
override void OnEnergyConsumed()
Definition ItemBase.c:3481
void InitializeActions()
Definition ItemBase.c:276
InventoryLocation.
proto native int GetType()
returns type of InventoryLocation
proto native bool IsValid()
verify current set inventory location
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
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 void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native EntityAI GetItem()
returns item of current inventory location
proto native void Reset()
proto native bool GetFlip()
returns flip status of cargo
proto native int GetSlot()
returns slot id if current type is Attachment
bool WriteToContext(ParamsWriteContext ctx)
provides access to slot configuration
static proto native bool IsSlotIdValid(int slotId)
verifies existence of the slot id
static proto native int GetStackMaxForSlotId(int slot_Id)
static proto native owned string GetSlotName(int id)
converts slot_id to string
override void OnDebugSpawn()
override bool CanDecay()
override string GetDeploySoundset()
Definition BarbedWire.c:437
override void OnInventoryExit(Man player)
Slot GetSlot()
Definition PlantBase.c:848
override void RefreshPhysics()
override bool CanExplodeInFire()
override bool IsPlayerInside(PlayerBase player, string selection)
override bool CanProcessDecay()
override int GetDamageSystemVersionChange()
override string GetPlaceSoundset()
override void OnCombine(ItemBase other_item)
override WrittenNoteData GetWrittenNoteData()
Definition Paper.c:30
override bool IsItemTent()
Definition TentBase.c:80
override void SetCEBasedQuantity()
Definition Battery9V.c:13
override bool CanPutAsAttachment(EntityAI parent)
Definition ItemBase.c:5
override void OnEndPlacement()
Definition KitBase.c:94
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Definition Rag.c:52
override bool IsClothing()
override string GetDeployFinishSoundset()
Definition KitBase.c:127
override void OnInventoryEnter(Man player)
Definition BarbedWire.c:246
override void ProcessDecay(float delta, bool hasRootAsPlayer)
override bool CanHaveTemperature()
override void InitItemVariables()
Definition Matchbox.c:3
override void SetActions()
static const int FLOAT
static bool IsActionLogEnable()
Definition Debug.c:590
Definition EnMath.c:7
void SetOverheatingLimitMax(float max)
void SetOverheatingLimitMin(float min)
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
void RegisterParticle(Particle p)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Legacy way of using particles in the game.
Definition Particle.c:7
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition Particle.c:266
The class that will be instanced (moddable)
Definition gameplay.c:378
void SetControlledDevice(EntityAI pDevice)
bool OnStoreLoad(ParamsReadContext ctx, int version)
Manager class for managing Effect (EffectParticle, EffectSound)
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
proto static native bool CanStoreInputUserData()
proto native void Send()
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
override void Stop()
proto native float GetDamage(string zoneName, string healthType)
const float DEFAULT_DEPLOY
UIScriptedMenu FindMenu(int id)
Returns menu with specific ID if it is open (see MenuID)
Definition UIManager.c:161
override void Refresh()
script counterpart to engine's class Weapon
void SetCalcDetails(string details)
Definition Debug.c:728
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
const float LOWEST
Definition EnConvert.c:100
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition gameplay.c:6
proto native CGame GetGame()
const int DEF_BIOLOGICAL
Definition constants.c:462
const int DEF_CHEMICAL
Definition constants.c:463
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto void Print(void var)
Prints content of variable to console/log.
const float WETNESS_RATE_WETTING_INSIDE
Definition constants.c:789
const float ITEM_TEMPERATURE_TO_EXPLODE_MIN
misc
Definition constants.c:847
const float TEMPERATURE_RATE_COOLING_INSIDE
Definition constants.c:794
const float WETNESS_RATE_WETTING_LIQUID
Definition constants.c:790
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< string > TStringArray
Definition EnScript.c:685
array< int > TIntArray
Definition EnScript.c:687
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:45
const int STATE_RUINED
Definition constants.c:742
const int VARIABLE_LIQUIDTYPE
Definition constants.c:568
const int VARIABLE_CLEANNESS
Definition constants.c:571
const int VARIABLE_COLOR
Definition constants.c:570
const int VARIABLE_TEMPERATURE
Definition constants.c:566
const int VARIABLE_QUANTITY
Definition constants.c:564
const int VARIABLE_WET
Definition constants.c:567
const float STATE_SOAKING_WET
Definition constants.c:767
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static proto float Round(float f)
Returns mathematical round of value.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:86
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Floor(float f)
Returns floor of value.
const int MENU_INVENTORY
Definition constants.c:158
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Definition constants.c:407
const int SAT_DEBUG_ACTION
Definition constants.c:408
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
proto native int GetColor()