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