Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
entityai.c
Go to the documentation of this file.
9
10enum SurfaceAnimationBone
11{
15 RightBackLimb
16}
17
18enum PlantType
19{
20 TREE_HARD = 1000,
21 TREE_SOFT = 1001,
22 BUSH_HARD = 1002,
23 BUSH_SOFT = 1003,
24}
25
26enum WeightUpdateType
27{
28 FULL = 0,
32 RECURSIVE_REMOVE
33}
34
35enum EItemManipulationContext
36{
37 UPDATE, //generic operation
40}
41
43enum EInventoryIconVisibility
44{
45 ALWAYS = 0,
47 //further values yet unused, but nice to have anyway
50}
51
53enum EAttExclusions
54{
55 OCCUPANCY_INVALID = -1,
56 //Legacy relations
57 LEGACY_EYEWEAR_HEADGEAR,
58 LEGACY_EYEWEAR_MASK,
59 LEGACY_HEADSTRAP_HEADGEAR,
60 LEGACY_HEADSTRAP_MASK,
61 LEGACY_HEADGEAR_MASK,
62 LEGACY_HEADGEAR_EYEWEWEAR,
63 LEGACY_HEADGEAR_HEADSTRAP,
64 LEGACY_MASK_HEADGEAR,
65 LEGACY_MASK_EYEWEWEAR,
66 LEGACY_MASK_HEADSTRAP,
67 //
68 EXCLUSION_HEADGEAR_HELMET_0, //full helmet
69 //EXCLUSION_HEADGEAR_HELMET_0_A, //example of another 'vector' of potential conflict, like between helmet and eyewear..otherwise the other non-helmet entities would collide through the 'EXCLUSION_HEADSTRAP_0' value.
70 EXCLUSION_HEADSTRAP_0,
71 EXCLUSION_MASK_0,
72 EXCLUSION_MASK_1,
73 EXCLUSION_MASK_2, //Mostly Gasmasks
74 EXCLUSION_MASK_3, //bandana mask special behavior
75 EXCLUSION_GLASSES_REGULAR_0,
76 EXCLUSION_GLASSES_TIGHT_0,
77 //values to solve the edge-cases with shaving action
78 SHAVING_MASK_ATT_0,
79 SHAVING_HEADGEAR_ATT_0,
80 SHAVING_EYEWEAR_ATT_0,
81}
82
83class DebugSpawnParams
84{
85 Man m_Player;
86
87 static DebugSpawnParams None()
88 {
89 DebugSpawnParams params = new DebugSpawnParams();
90 params.m_Player = null;
91 return params;
92 }
93
94 static DebugSpawnParams WithPlayer(Man player)
95 {
96 DebugSpawnParams params = new DebugSpawnParams();
97 params.m_Player = player;
98 return params;
99 }
101
102class TSelectableActionInfoArrayEx extends array<ref Param> {}
104typedef Param4<int, int, string, int> TSelectableActionInfoWithColor;
105
106class EntityAI extends Entity
107{
108 bool m_DeathSyncSent;
109 bool m_KilledByHeadshot;
110 bool m_PreparedToDelete = false;
111 bool m_RefresherViable = false;
112 bool m_WeightDirty = 1;
113 protected bool m_RoofAbove = false;
114 private ref map<int,ref set<int>> m_AttachmentExclusionSlotMap; //own masks for different slots <slot,mask>. Kept on instance to better respond to various state changes
115 private ref set<int> m_AttachmentExclusionMaskGlobal; //additional mask values and simple item values. Independent of slot-specific behavior!
116 private ref set<int> m_AttachmentExclusionMaskChildren; //additional mask values and simple item values
117
118 ref DestructionEffectBase m_DestructionBehaviourObj;
119
120 ref KillerData m_KillerData;
121 private ref HiddenSelectionsData m_HiddenSelectionsData;
122
123 const int DEAD_REPLACE_DELAY = 250;
124 const int DELETE_CHECK_DELAY = 100;
125
126 ref array<EntityAI> m_AttachmentsWithCargo;
127 ref array<EntityAI> m_AttachmentsWithAttachments;
128 ref InventoryLocation m_OldLocation;
129
131 private ref map<int, string> m_DamageDisplayNameMap = new map<int, string>; //values are localization keys as strings, use 'Widget.TranslateString' method to get the localized one
132
133 float m_Weight;
134 float m_WeightEx;
135 float m_ConfigWeight = ConfigGetInt("weight");
136 protected bool m_CanDisplayWeight;
137 private float m_LastUpdatedTime; //CE update time
138 protected float m_ElapsedSinceLastUpdate; //CE update time
139 protected float m_PreviousRoofTestTime = 0;
140
141 protected UTemperatureSource m_UniversalTemperatureSource;
142
143 bool m_PendingDelete = false;
144 bool m_Initialized = false;
147
148 // ============================================
149 // Variable Manipulation System
150 // ============================================
151 int m_VariablesMask;//this holds information about which vars have been changed from their default values
152
153 // Temperature
164
166
167 protected bool m_IsFrozen;
168 protected bool m_IsFrozenLocal;
169 protected float m_FreezeThawProgress;
170
171 protected float m_OverheatProgress;
172
173 //---------------------------------------------
174
175 //Called on item attached to this item (EntityAI item, string slot, EntityAI parent)
177 //Called on item detached from this item (EntityAI item, string slot, EntityAI parent)
179 //Called when an item is added to the cargo of this item (EntityAI item, EntityAI parent)
181 //Called when an item is removed from the cargo of this item (EntityAI item, EntityAI parent)
183 //Called when an item is moved around in the cargo of this item (EntityAI item, EntityAI parent)
185 //Called when an item is flipped around in cargo (bool flip)
187 //Called when an items view index is changed
189 //Called when an location in this item is reserved (EntityAI item) - cargo
191 //Called when this item is unreserved (EntityAI item) - cargo
193 //Called when an location in this item is reserved (EntityAI item) - attachment
195 //Called when this item is unreserved (EntityAI item) - attachment
197 //Called when this entity is hit
199 //Called when this entity is killed
201
202 private ref map<eAgents, float> m_BloodInfectionChanceCached;
203
204 #ifdef DEVELOPER
205 float m_LastFTChangeTime;;
206 float m_PresumedTimeRemaining;
207 #endif
208
209 void EntityAI()
210 {
211 // Set up the Energy Manager
212 string type = GetType();
213 string param_access_energy_sys = "CfgVehicles " + type + " EnergyManager ";
214 bool is_electic_device = g_Game.ConfigIsExisting(param_access_energy_sys);
215
216 if (is_electic_device) // TO DO: Check if this instance is a hologram (advanced placement). If Yes, then do not create Energy Manager component.
217 {
218 CreateComponent(COMP_TYPE_ENERGY_MANAGER);
219 RegisterNetSyncVariableBool("m_EM.m_IsSwichedOn");
220 RegisterNetSyncVariableBool("m_EM.m_CanWork");
221 RegisterNetSyncVariableBool("m_EM.m_IsPlugged");
222 RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDLow");
223 RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDHigh");
224 RegisterNetSyncVariableFloat("m_EM.m_Energy");
225 }
226
227 // Item preview index
228 RegisterNetSyncVariableInt( "m_ViewIndex", 0, 99 );
229 // Refresher signalization
230 RegisterNetSyncVariableBool("m_RefresherViable");
231
232 m_AttachmentsWithCargo = new array<EntityAI>();
233 m_AttachmentsWithAttachments = new array<EntityAI>();
234 m_LastUpdatedTime = 0.0;
236
237 m_CanDisplayWeight = ConfigGetBool("displayWeight");
238
239 InitDamageZoneMapping();
240 InitDamageZoneDisplayNameMapping();
241 InitItemVariables();
242
243 m_HiddenSelectionsData = new HiddenSelectionsData( GetType() );
244
245 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeferredInit,34);
246
247 m_BloodInfectionChanceCached = new map<eAgents, float>();
248 }
249
250 void ~EntityAI()
251 {
252
253 }
254
255 void InitItemVariables()
256 {
257 m_VarTemperatureInit = ConfigGetFloat("varTemperatureInit");
258 m_VarTemperatureMin = ConfigGetFloat("varTemperatureMin");
259 m_VarTemperatureMax = ConfigGetFloat("varTemperatureMax");
260
261 if (ConfigIsExisting("varTemperatureFreezePoint"))
262 m_VarTemperatureFreezeThreshold = ConfigGetFloat("varTemperatureFreezePoint");
263 else
264 m_VarTemperatureFreezeThreshold = float.LOWEST;
265
266 if (ConfigIsExisting("varTemperatureThawPoint"))
267 m_VarTemperatureThawThreshold = ConfigGetFloat("varTemperatureThawPoint");
268 else
269 m_VarTemperatureThawThreshold = float.LOWEST;
270
271 m_VarTemperatureFreezeTime = Math.Clamp(ConfigGetFloat("varTemperatureFreezeTime"),1,float.MAX);
272 m_VarTemperatureThawTime = Math.Clamp(ConfigGetFloat("varTemperatureThawTime"),1,float.MAX);
273 if (ConfigIsExisting("varTemperatureOverheatTime"))
274 m_VarTemperatureOverheatTime = ConfigGetFloat("varTemperatureOverheatTime");
275 else
276 m_VarTemperatureOverheatTime = -1;
277
278 if (ConfigIsExisting("varHeatPermeabilityCoef"))
279 m_VarHeatPermeabilityCoef = ConfigGetFloat("varHeatPermeabilityCoef");
280 else
281 m_VarHeatPermeabilityCoef = 1;
282
283 if (CanHaveTemperature())
284 {
285 RegisterNetSyncVariableFloat("m_VarTemperature", GetTemperatureMin(),GetTemperatureMax());
286 RegisterNetSyncVariableBool("m_IsFrozen");
287
288 if (g_Game.IsServer())
289 m_TAC = new TemperatureAccessComponent(this);
290
291 if (!g_Game.IsMultiplayer() || g_Game.IsClient())
292 m_FreezeThawProgress = -1;
293 }
294 }
295
296 void DeferredInit()
297 {
298 m_Initialized = true;
299 }
300
301 bool IsInitialized()
302 {
303 return m_Initialized;
304 }
305
307 int GetHideIconMask()
308 {
309 return EInventoryIconVisibility.ALWAYS;
310 }
311
312 private ref ComponentsBank m_ComponentsBank;
313 ComponentEnergyManager m_EM; // This reference is necesarry due to synchronization, since it's impossible to synchronize values from a component :(
314
316 Component CreateComponent(int comp_type, string extended_class_name="")
317 {
318 return GetComponent(comp_type, extended_class_name);
319 }
320
322 Component GetComponent(int comp_type, string extended_class_name="")
323 {
324 if ( m_ComponentsBank == NULL )
325 m_ComponentsBank = new ComponentsBank(this);
326
327 return m_ComponentsBank.GetComponent(comp_type, extended_class_name);
328 }
329
331 bool DeleteComponent(int comp_type)
332 {
333 return m_ComponentsBank.DeleteComponent(comp_type);
334 }
335
336 ECachedEquipmentItemCategory GetCachedEquipmentCategory()
337 {
339 }
340
342 {
343 return "";
344 }
345
347 {
348 return false;
349 }
350
352 bool HasComponent(int comp_type)
353 {
354 if ( m_ComponentsBank )
355 return m_ComponentsBank.IsComponentAlreadyExist(comp_type);
356
357 return false;
358 }
359
361 void MaxLifetimeRefreshCalc()
362 {
363 if ( (!g_Game.IsMultiplayer() || g_Game.IsServer()) && GetEconomyProfile() )
364 {
365 float lifetime = GetEconomyProfile().GetLifetime();
366 int frequency = GetCEApi().GetCEGlobalInt("FlagRefreshFrequency");
367 if ( frequency <= 0 )
368 {
369 frequency = GameConstants.REFRESHER_FREQUENCY_DEFAULT;
370 }
371
372 if ( frequency <= lifetime )
373 {
374 m_RefresherViable = true;
375 SetSynchDirty();
376 }
377 }
378 }
379
381 {
382 if (IsRuined())
383 {
384 return false;
385 }
386 return m_RefresherViable;
387 }
388
389 #ifdef DEVELOPER
390 override void SetDebugItem()
391 {
392 super.SetDebugItem();
393 _item = this;
394 }
395 #endif
396
397
399 void InitDamageZoneMapping()
400 {
401 m_DamageZoneMap = new DamageZoneMap;
402 DamageSystem.GetDamageZoneMap(this,m_DamageZoneMap);
403 }
404
406 void InitDamageZoneDisplayNameMapping()
407 {
408 string path_base;
409 string path;
410 string component_name;
411
412 if ( IsWeapon() )
413 {
414 path_base = CFG_WEAPONSPATH;
415 }
416 else if ( IsMagazine() )
417 {
418 path_base = CFG_MAGAZINESPATH;
419 }
420 else
421 {
422 path_base = CFG_VEHICLESPATH;
423 }
424
425 path_base = string.Format( "%1 %2 DamageSystem DamageZones", path_base, GetType() );
426
427 if ( !g_Game.ConfigIsExisting(path_base) )
428 {
429 component_name = GetDisplayName();
430 g_Game.FormatRawConfigStringKeys(component_name);
431 m_DamageDisplayNameMap.Insert( "".Hash(), component_name );
432 }
433 else
434 {
435 TStringArray zone_names = new TStringArray;
436 GetDamageZones( zone_names );
437
438 for ( int i = 0; i < zone_names.Count(); i++ )
439 {
440 path = string.Format( "%1 %2 displayName", path_base, zone_names[i] );
441
442 if (g_Game.ConfigIsExisting(path) && g_Game.ConfigGetTextRaw(path,component_name))
443 {
444 g_Game.FormatRawConfigStringKeys(component_name);
445 m_DamageDisplayNameMap.Insert( zone_names[i].Hash(), component_name );
446 }
447 }
448 }
449 }
450
451 protected float ConvertNonlethalDamage(float damage, DamageType damageType)
452 {
453 return 0.0;
454 }
455
457 float ConvertNonlethalDamage(float damage)
458 {
459 return 0.0;
460 }
461
466
468 {
469 return m_DamageDisplayNameMap;
470 }
471
474 {
475 return m_CanDisplayWeight;
476 }
477
479 void Log(string msg, string fnc_name = "n/a")
480 {
481 Debug.Log(msg, "Object", "n/a", fnc_name, this.GetType());
482 }
483
485 void LogWarning(string msg, string fnc_name = "n/a")
486 {
487 Debug.LogWarning(msg, "Object", "n/a", fnc_name, this.GetType());
488 }
489
491 void LogError(string msg, string fnc_name = "n/a")
492 {
493 Debug.LogError(msg, "Object", "n/a", fnc_name, this.GetType());
494 }
495
498 {
499 return GetCompBS() && GetCompBS().IsSkinned();
500 }
501
503 {
504 if (GetCompBS())
505 GetCompBS().SetAsSkinned();
506 }
507
508 bool CanBeSkinnedWith(EntityAI tool)
509 {
510 if ( !IsSkinned() && tool )
511 if ( !IsAlive() )
512 return true;
513 return false;
514 }
515
517 {
518 float value = 0.0;
519 if (m_BloodInfectionChanceCached.Find(type, value))
520 return value;
521
522 return value;
523 }
524
526 {
527 string basePath = string.Format("cfgVehicles %1 Skinning BloodInfectionSettings", GetType());
528 if (g_Game.ConfigIsExisting(basePath))
529 {
530 string agentName = EnumTools.EnumToString(eAgents, type);
531 agentName.ToLower();
532 float value = g_Game.ConfigGetFloat(string.Format("%1 %2 chance", basePath, agentName));
533 m_BloodInfectionChanceCached.Set(type, value);
534 }
535 }
536
537
538 // ITEM TO ITEM FIRE DISTRIBUTION
541 {
542 return false;
543 }
544
546 bool CanBeIgnitedBy(EntityAI igniter = NULL)
547 {
548 return false;
549 }
550
552 bool CanIgniteItem(EntityAI ignite_target = NULL)
553 {
554 return false;
555 }
556
559 {
560 if (m_EM)
561 return m_EM.IsWorking();
562 return false;
563 }
564
565 // Change return value to true if last detached item cause disassemble of item - different handlig some inventory operations
567 {
568 return false;
569 }
570
572 {
573 return false;
574 }
575
577 {
578 return false;
579 }
580
583 {
584 return true;
585 }
586
588 void OnIgnitedTarget( EntityAI target_item)
589 {
590
591 }
592
594 void OnIgnitedThis( EntityAI fire_source)
595 {
596
597 }
598
600 void OnIgnitedTargetFailed( EntityAI target_item)
601 {
602
603 }
604
606 void OnIgnitedThisFailed( EntityAI fire_source)
607 {
608
609 }
610
612 bool IsTargetIgnitionSuccessful(EntityAI item_target)
613 {
614 return true;
615 }
616
618 bool IsThisIgnitionSuccessful(EntityAI item_source = NULL)
619 {
620 return true;
621 }
622 // End of fire distribution ^
623
624 // ADVANCED PLACEMENT EVENTS
625 void OnPlacementStarted(Man player);
626 void OnHologramBeingPlaced(Man player);
627 void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0");
628 void OnPlacementCancelled(Man player);
629
630 bool CanBePlaced(Man player, vector position)
631 {
632 return true;
633 }
634
636 string CanBePlacedFailMessage( Man player, vector position )
637 {
638 return "";
639 }
640
643 {
644 return false;
645 }
646
649 {
650 return 0.0;
651 }
652
655 {
656 return 0.0;
657 }
658
660 bool IsEmpty()
661 {
662 return (!HasAnyCargo() && GetInventory().AttachmentCount() == 0);
663 }
664
667 {
668 return false;
669 }
670
673 {
674 return false;
675 }
676
679 {
680 CargoBase cargo = GetInventory().GetCargo();
681
682 if(!cargo) return false;//this is not a cargo container
683
684 return cargo.GetItemCount() > 0;
685 }
686
688 {
689 return m_AttachmentsWithCargo;
690 }
691
693 {
694 return m_AttachmentsWithAttachments;
695 }
696
697 //is there any roof above
699 {
700 return m_RoofAbove;
701 }
702
703 void SetRoofAbove(bool state)
704 {
705 m_RoofAbove = state;
706 }
707
709 void CheckForRoofLimited(float timeTresholdMS = 3000);
710
711 int GetAgents() { return 0; }
712 void RemoveAgent(int agent_id);
714 void RemoveAllAgentsExcept(int agent_to_keep);
715 void InsertAgent(int agent, float count = 1);
716
717 override bool IsEntityAI() { return true; }
718
720 {
721 return !( GetParent() || GetHierarchyParent() );
722 }
723
724 bool IsPlayer()
725 {
726 return false;
727 }
728
729 bool IsAnimal()
730 {
731 return false;
732 }
733
734 bool IsZombie()
735 {
736 return false;
737 }
738
740 {
741 return false;
742 }
743
745 {
746 return IsDamageDestroyed();
747 }
748
749 bool CanBeTargetedByAI(EntityAI ai)
750 {
751 if (ai && ai.IsBeingBackstabbed())
752 {
753 return false;
754 }
755
756 if ( !dBodyIsActive( this ) && !IsMan() )
757 return false;
758 return !IsDamageDestroyed();
759 }
760
762 {
763 return false;
764 }
765
774 override void Delete()
775 {
776 m_PendingDelete = true;
777 super.Delete();
778 }
779
781 {
782 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Call(g_Game.ObjectDeleteOnClient, this);
783 }
784
785 // delete synchronized between server and client
787 {
788 if (GetHierarchyRootPlayer() == null || (GetHierarchyRootPlayer() && !GetHierarchyRootPlayer().IsAlive()))
789 {
790 Delete();
791 }
792 else
793 {
794 if (g_Game.IsServer() && g_Game.IsMultiplayer())
795 GetHierarchyRootPlayer().JunctureDeleteItem(this);
796 else
797 GetHierarchyRootPlayer().AddItemToDelete(this);
798 }
799 }
800
801 //legacy, wrong name, use 'DeleteSafe()' instead
803 {
804 DeleteSafe();
805 }
806
808 {
809 return IsPreparedToDelete() || m_PendingDelete || ToDelete() || IsPendingDeletion();
810 }
811
812 override bool CanBeActionTarget()
813 {
814 if (super.CanBeActionTarget())
815 {
816 return !IsSetForDeletion();
817 }
818 else
819 {
820 return false;
821 }
822 }
823
825 {
826 m_PreparedToDelete = true;
827 }
828
830 {
831 return m_PreparedToDelete;
832 }
833
834
836 {
837 if (IsPrepareToDelete())
838 {
839 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(TryDelete, DELETE_CHECK_DELAY, false);
840 }
841 }
842
844 {
845 return false;
846 }
847
849 {
850 if (!IsPrepareToDelete())
851 {
852 Debug.Log("TryDelete - not ready for deletion");
853 return false;
854 }
855
856 if (g_Game.HasInventoryJunctureItem(this))
857 {
858 Debug.Log("TryDelete - deferred call");
859 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(TryDelete, DELETE_CHECK_DELAY, false);
860 return false;
861 }
862
864 Debug.Log("TryDelete - OnBeforeTryDelete end");
865 DeleteSafe();
866 Debug.Log("TryDelete - DeleteSafe end");
867
868 return true;
869 }
870
872
874 proto native EntityAI GetHierarchyRoot();
875
877 proto native Man GetHierarchyRootPlayer();
878
880 proto native EntityAI GetHierarchyParent();
881
883 proto native CEItemProfile GetEconomyProfile();
884
885 // !returns the number of levels bellow the hierarchy root this entity is at
886 int GetHierarchyLevel(int lvl = 0)
887 {
888 if (!GetHierarchyParent())
889 return lvl;
890
891 return GetHierarchyParent().GetHierarchyLevel(lvl+1);
892 }
893
895 {
896 InitAttachmentExclusionValues();
897 }
898
900 void EEInit()
901 {
902 GameInventory inventory = GetInventory();
903 if (inventory)
904 {
905 inventory.EEInit();
906 m_AttachmentsWithCargo.Clear();
907 m_AttachmentsWithAttachments.Clear();
908 for ( int i = 0; i < inventory.AttachmentCount(); ++i )
909 {
910 EntityAI attachment = inventory.GetAttachmentFromIndex( i );
911 if ( attachment )
912 {
913 GameInventory attachmentInventory = attachment.GetInventory();
914 if ( attachmentInventory.GetCargo() )
915 {
916 m_AttachmentsWithCargo.Insert( attachment );
917 }
918
919 if ( attachmentInventory.GetAttachmentSlotsCount() > 0 )
920 {
921 m_AttachmentsWithAttachments.Insert( attachment );
922 }
923 }
924 }
925 }
926
927 MaxLifetimeRefreshCalc();
928
929 if (CanHaveTemperature() && g_Game.IsServer())
931 }
932
934 void EEDelete(EntityAI parent)
935 {
936 m_PendingDelete = true;
937 GetInventory().EEDelete(parent);
938
939 if (m_EM)
940 m_EM.OnDeviceDestroyed();
941 }
942
943 override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
944 {
945 super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
946 #ifndef SERVER
947 g_Game.GetWorld().AddEnvShootingSource(pos, 1.0);
948 #endif
949 if (m_DestructionBehaviourObj && m_DestructionBehaviourObj.HasExplosionDamage())
950 {
951 m_DestructionBehaviourObj.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
952 }
953 }
954
955
956 void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner);
959
961
962 void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
963 {
964 EntityAI oldOwner = oldLoc.GetParent();
965 EntityAI newOwner = newLoc.GetParent();
966 OnItemLocationChanged(oldOwner, newOwner);
967
968 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT && newLoc.GetType() == InventoryLocationType.ATTACHMENT)
969 OnItemAttachmentSlotChanged(oldLoc, newLoc);
970
971 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT)
972 {
973 if (oldOwner)
974 OnWasDetached(oldOwner, oldLoc.GetSlot());
975 else
976 Error("EntityAI::EEItemLocationChanged - detached, but oldOwner is null");
977 }
978
979 if (newLoc.GetType() == InventoryLocationType.ATTACHMENT)
980 {
981 if (newOwner)
982 OnWasAttached(newOwner, newLoc.GetSlot());
983 else
984 Error("EntityAI::EEItemLocationChanged - attached, but newOwner is null");
985 }
986
987 Man player;
988 if (oldLoc.GetType() == InventoryLocationType.HANDS)
989 {
990 player = Man.Cast(oldOwner);
991 player.OnItemInHandsChanged();
992 player.GetCachedEquipment().OnItemCargoOut(this);
993 }
994
995 if (newLoc.GetType() == InventoryLocationType.HANDS)
996 {
997 player = Man.Cast(newOwner);
998 player.OnItemInHandsChanged();
999 player.GetCachedEquipment().OnItemCargoIn(this);
1000 }
1001 }
1002
1004 void EEParentedTo(EntityAI parent);
1005
1007 void EEParentedFrom(EntityAI parent);
1008
1009 void EEInventoryIn(Man newParentMan, EntityAI diz, EntityAI newParent);
1010 void EEInventoryOut(Man oldParentMan, EntityAI diz, EntityAI newParent)
1011 {
1012 m_LastUpdatedTime = g_Game.GetTickTime();
1013
1014 if (newParent == null)
1015 {
1016 GameInventory inventory = GetInventory();
1017 if (inventory)
1018 inventory.ResetFlipCargo();
1019 }
1020 }
1021
1023 {
1025 }
1026
1027 void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
1028 {
1029 // Notify potential parent that this item was ruined
1030 EntityAI parent = GetHierarchyParent();
1031
1032 if (newLevel == GameConstants.STATE_RUINED)
1033 {
1034 if (parent)
1035 {
1036 parent.OnAttachmentRuined(this);
1037 }
1038 if (!zone)
1039 {
1040 OnDamageDestroyed(oldLevel);
1041 }
1042 AttemptDestructionBehaviour(oldLevel,newLevel, zone);
1043 }
1044 }
1045
1047 void OnDamageDestroyed(int oldLevel);
1048
1049 void AttemptDestructionBehaviour(int oldLevel, int newLevel, string zone)
1050 {
1052 {
1053 typename destType = GetDestructionBehaviour().ToType();
1054
1055 if (destType)
1056 {
1057 if (!m_DestructionBehaviourObj)
1058 {
1059 m_DestructionBehaviourObj = DestructionEffectBase.Cast(destType.Spawn());
1060 }
1061
1062 if (m_DestructionBehaviourObj)
1063 {
1064 m_DestructionBehaviourObj.OnHealthLevelChanged(this, oldLevel, newLevel, zone);
1065 }
1066 }
1067 else
1068 {
1069 ErrorEx("Incorrect destruction behaviour type, make sure the class returned in 'GetDestructionBehaviour()' is a valid type inheriting from 'DestructionEffectBase'");
1070 }
1071 }
1072 }
1073
1074
1075 void SetTakeable(bool pState);
1076
1078 void EEKilled(Object killer)
1079 {
1081 m_OnKilledInvoker.Invoke(this, killer);
1082
1083 g_Game.GetAnalyticsServer().OnEntityKilled(killer, this);
1084
1085 if (ReplaceOnDeath())
1086 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeathUpdate, DEAD_REPLACE_DELAY, false);
1087 }
1088
1090 {
1091 return false;
1092 }
1093
1095 {
1096 return "";
1097 }
1098
1100 {
1101 return false;
1102 }
1103
1105 {
1106 EntityAI dead_entity = EntityAI.Cast( g_Game.CreateObjectEx( GetDeadItemName(), GetPosition(), ECE_OBJECT_SWAP, RF_ORIGINAL ) );
1107 dead_entity.SetOrientation(GetOrientation());
1108 if (KeepHealthOnReplace())
1109 dead_entity.SetHealth(GetHealth());
1110
1111 DeleteSafe();
1112 }
1113
1115 void OnAttachmentRuined(EntityAI attachment);
1116
1117 void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
1118 {
1119 if (m_OnHitByInvoker)
1120 m_OnHitByInvoker.Invoke(this, damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
1121 #ifdef DEVELOPER
1122 //Print("EEHitBy: " + this + "; damageResult:"+ damageResult.GetDamage("","") +"; damageType: "+ damageType +"; source: "+ source +"; component: "+ component +"; dmgZone: "+ dmgZone +"; ammo: "+ ammo +"; modelPos: "+ modelPos);
1123 #endif
1124 }
1125
1126 // called only on the client who caused the hit
1127 void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
1128 {
1129
1130 }
1131
1132 // !Called on PARENT when a child is attached to it.
1133 void EEItemAttached(EntityAI item, string slot_name)
1134 {
1135 int slotId = InventorySlots.GetSlotIdFromString(slot_name);
1136 PropagateExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId), slotId); //Performed from parent to avoid event order issues on swap
1138
1139 Man player = GetHierarchyRootPlayer();
1140 if (player)
1141 player.GetCachedEquipment().OnItemAttached(item, slotId, this);
1142
1143 if ( m_ComponentsBank != NULL )
1144 {
1145 for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
1146 {
1147 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
1148 {
1149 m_ComponentsBank.GetComponent(comp_key).Event_OnItemAttached(item, slot_name);
1150 }
1151 }
1152 }
1153
1154 // Energy Manager
1155 if ( m_EM && item.GetCompEM())
1156 m_EM.OnAttachmentAdded(item);
1157
1158 GameInventory itemInventory = item.GetInventory();
1159 if ( itemInventory.GetCargo() )
1160 m_AttachmentsWithCargo.Insert( item );
1161
1162 if ( itemInventory.GetAttachmentSlotsCount() > 0 )
1163 m_AttachmentsWithAttachments.Insert( item );
1164
1165 if ( m_OnItemAttached )
1166 m_OnItemAttached.Invoke( item, slot_name, this );
1167 }
1168
1169 void SwitchItemSelectionTexture(EntityAI item, string slot_name);
1170 void SwitchItemSelectionTextureEx(EItemManipulationContext context, Param par = null);
1171
1172 // !Called on PARENT when a child is detached from it.
1173 void EEItemDetached(EntityAI item, string slot_name)
1174 {
1175 int slotId = InventorySlots.GetSlotIdFromString(slot_name);
1176 ClearExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId), slotId); //Performed from parent to avoid event order issues on swap
1178
1179 Man player = GetHierarchyRootPlayer();
1180 if (player)
1181 player.GetCachedEquipment().OnItemDetached(item, slotId, this);
1182
1183 if ( m_ComponentsBank != NULL )
1184 {
1185 for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
1186 {
1187 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
1188 {
1189 m_ComponentsBank.GetComponent(comp_key).Event_OnItemDetached(item, slot_name);
1190 }
1191 }
1192 }
1193
1194 // Energy Manager
1195 if (m_EM && item.GetCompEM())
1196 m_EM.OnAttachmentRemoved(item);
1197
1198 if ( m_AttachmentsWithCargo.Find( item ) > -1 )
1199 m_AttachmentsWithCargo.RemoveItem( item );
1200
1201 if ( m_AttachmentsWithAttachments.Find( item ) > -1 )
1202 m_AttachmentsWithAttachments.RemoveItem( item );
1203
1204 if ( m_OnItemDetached )
1205 m_OnItemDetached.Invoke( item, slot_name, this );
1206 }
1207
1208 void EECargoIn(EntityAI item)
1209 {
1211
1213 m_OnItemAddedIntoCargo.Invoke( item, this );
1214
1215 Man player = item.GetHierarchyRootPlayer();
1216 if (player)
1217 player.GetCachedEquipment().OnItemCargoIn(item);
1218 item.OnMovedInsideCargo(this);
1219 }
1220
1221 void EECargoOut(EntityAI item)
1222 {
1224
1226 m_OnItemRemovedFromCargo.Invoke( item, this );
1227
1228 Man player = item.GetHierarchyRootPlayer();
1229 if (player)
1230 player.GetCachedEquipment().OnItemCargoOut(item);
1231 item.OnRemovedFromCargo(this);
1232 }
1233
1234 void EECargoMove(EntityAI item)
1235 {
1237 m_OnItemMovedInCargo.Invoke( item, this );
1238 item.OnMovedWithinCargo(this);
1239 }
1240
1247
1254
1261
1268
1275
1282
1289
1291 {
1292 if( !m_OnSetLock )
1294 return m_OnSetLock;
1295 }
1296
1303
1310
1317
1324
1331
1332
1334 void OnMovedInsideCargo(EntityAI container)
1335 {
1336 if (m_EM)
1337 m_EM.HandleMoveInsideCargo(container);
1338 }
1339
1341 void OnRemovedFromCargo(EntityAI container)
1342 {
1343
1344 }
1345
1347 void OnMovedWithinCargo(EntityAI container)
1348 {
1349
1350 }
1351
1354 {
1355 // ENERGY MANAGER
1356 // Restore connections between devices which were connected before server restart
1357 if ( m_EM && m_EM.GetRestorePlugState() )
1358 {
1359 int b1 = m_EM.GetEnergySourceStorageIDb1();
1360 int b2 = m_EM.GetEnergySourceStorageIDb2();
1361 int b3 = m_EM.GetEnergySourceStorageIDb3();
1362 int b4 = m_EM.GetEnergySourceStorageIDb4();
1363
1364 // get pointer to EntityAI based on this ID
1365 EntityAI potential_energy_source = g_Game.GetEntityByPersitentID(b1, b2, b3, b4); // This function is available only in this event!
1366
1367 // IMPORTANT!
1368 // Object IDs acquired here become INVALID when electric devices are transfered to another server while in plugged state (like Flashlight plugged into its attachment 9V battery)
1369 // To avoid issues, these items must be excluded from this system of restoring plug state so they don't unintentionally plug to incorrect devices through these invalid IDs.
1370 // Therefore their plug state is being restored withing the EEItemAttached() event while being excluded by the following 'if' conditions...
1371
1372 bool is_attachment = false;
1373
1374 if (potential_energy_source)
1375 is_attachment = GetInventory().HasAttachment(potential_energy_source);
1376
1377 if ( !is_attachment && potential_energy_source )
1378 is_attachment = potential_energy_source.GetInventory().HasAttachment(this);
1379
1380 if ( potential_energy_source && potential_energy_source.GetCompEM() /*&& potential_energy_source.HasEnergyManager()*/ && !is_attachment )
1381 m_EM.PlugThisInto(potential_energy_source); // restore connection
1382 }
1383 }
1384
1387 {
1388 }
1389
1392 {
1393 }
1394
1397 {
1399 GetHierarchyRootPlayer().SetProcessUIWarning(true);
1400 }
1401
1404 {
1405 string cfg_path = "cfgVehicles " + GetType() + " AnimationSources";
1406
1407 if ( g_Game.ConfigIsExisting(cfg_path) )
1408 {
1409 int selections = g_Game.ConfigGetChildrenCount(cfg_path);
1410
1411 for (int i = 0; i < selections; i++)
1412 {
1413 string selection_name;
1414 g_Game.ConfigGetChildName(cfg_path, i, selection_name);
1415 HideSelection(selection_name);
1416 }
1417 }
1418 }
1419
1422 {
1423 string cfg_path = "cfgVehicles " + GetType() + " AnimationSources";
1424
1425 if ( g_Game.ConfigIsExisting(cfg_path) )
1426 {
1427 int selections = g_Game.ConfigGetChildrenCount(cfg_path);
1428
1429 for (int i = 0; i < selections; i++)
1430 {
1431 string selection_name;
1432 g_Game.ConfigGetChildName(cfg_path, i, selection_name);
1433 ShowSelection(selection_name);
1434 }
1435 }
1436 }
1437
1444 bool CanReceiveAttachment (EntityAI attachment, int slotId)
1445 {
1446 //generic occupancy check
1447 return CheckAttachmentReceiveExclusion(attachment,slotId);
1448 }
1449
1456 bool CanLoadAttachment(EntityAI attachment)
1457 {
1458 return true;
1459 }
1460
1468 bool CanPutAsAttachment (EntityAI parent)
1469 {
1470 return !IsHologram();
1471 }
1472
1473 //If return true, item can be attached even from parent to this. Item will be switched during proccess. (only hands)
1474 bool CanSwitchDuringAttach(EntityAI parent)
1475 {
1476 return false;
1477 }
1478
1484 bool CanReleaseAttachment (EntityAI attachment)
1485 {
1486 if (attachment)
1487 {
1488 GameInventory attachmentInventory = attachment.GetInventory();
1489 if (attachmentInventory)
1490 {
1491 GameInventory inventory = GetInventory();
1492 if (inventory)
1493 {
1495 attachmentInventory.GetCurrentInventoryLocation( il );
1496 if( il.IsValid() )
1497 {
1498 int slot = il.GetSlot();
1499 return !inventory.GetSlotLock( slot );
1500 }
1501 }
1502 }
1503 }
1504 return true;
1505 }
1506
1512 bool CanDetachAttachment (EntityAI parent)
1513 {
1514 return true;
1515 }
1516
1518 {
1519 return true;
1520 }
1521
1522 bool CanCombineAttachment(notnull EntityAI e, int slot, bool stack_max_limit = false)
1523 {
1524 EntityAI att = GetInventory().FindAttachment(slot);
1525 if(att)
1526 return att.CanBeCombined(e, true, stack_max_limit);
1527 return false;
1528 }
1529
1530 bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false )
1531 {
1532 return false;
1533 }
1534
1535 void CombineItemsEx(EntityAI entity2, bool use_stack_max = false );
1536
1537 void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id);
1538
1539 void CombineItemsClient(EntityAI entity2, bool use_stack_max = false )
1540 {}
1541
1542 void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id);
1543
1550 bool CanReceiveItemIntoCargo(EntityAI item)
1551 {
1552 GameInventory inventory = GetInventory();
1553 if (inventory)
1554 {
1555 CargoBase cargo = inventory.GetCargo();
1556 if (cargo)
1557 return cargo.CanReceiveItemIntoCargo(item);
1558 }
1559 return true;
1560 }
1561
1568 bool CanLoadItemIntoCargo(EntityAI item)
1569 {
1570 return true;
1571 }
1572
1579 bool CanPutInCargo (EntityAI parent)
1580 {
1581 return !IsHologram();
1582 }
1583
1590 bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
1591 {
1592 GameInventory inventory = GetInventory();
1593 if (inventory)
1594 {
1595 CargoBase cargo = inventory.GetCargo();
1596 if (cargo)
1597 return cargo.CanSwapItemInCargo(child_entity, new_entity);
1598 }
1599 return true;
1600 }
1601
1608 bool CanReleaseCargo (EntityAI cargo)
1609 {
1610 return true;
1611 }
1612
1619 bool CanRemoveFromCargo (EntityAI parent)
1620 {
1621 return true;
1622 }
1623
1630 /*bool CanReceiveItemIntoInventory (EntityAI entity_ai)
1631 {
1632 return true;
1633 }*/
1634
1641 /*bool CanPutInInventory (EntityAI parent)
1642 {
1643 return true;
1644 }*/
1645
1652 bool CanReceiveItemIntoHands (EntityAI item_to_hands)
1653 {
1654 return true;
1655 }
1656
1658 {
1660 EntityAI ent = this;
1661 int attachmentDepth = 0;
1662 while (ent)
1663 {
1664 if (ent.GetInventory().GetCurrentInventoryLocation(lcn) && lcn.IsValid())
1665 {
1666 int lcnType = lcn.GetType();
1667 if (lcnType == InventoryLocationType.CARGO || lcnType == InventoryLocationType.PROXYCARGO)
1668 {
1669 return false;
1670 }
1671
1672 //hands treated as regular attachment here
1673 if (lcnType == InventoryLocationType.ATTACHMENT || lcnType == InventoryLocationType.HANDS)
1674 {
1675 attachmentDepth++;
1676 }
1677 }
1678
1679 ent = ent.GetHierarchyParent();
1680 }
1681
1682 return attachmentDepth <= GameConstants.INVENTORY_MAX_REACHABLE_DEPTH_ATT;
1683 }
1684
1686 {
1687 return false;
1688 }
1689
1690 override bool IsHologram()
1691 {
1692 return false;
1693 }
1694
1695 bool CanSaveItemInHands (EntityAI item_in_hands)
1696 {
1697 return true;
1698 }
1699
1706 bool CanPutIntoHands (EntityAI parent)
1707 {
1708 return !IsHologram();
1709 }
1710
1717 bool CanReleaseFromHands (EntityAI handheld)
1718 {
1719 return true;
1720 }
1721
1728 bool CanRemoveFromHands (EntityAI parent)
1729 {
1730 return true;
1731 }
1732
1737 bool CanDisplayAttachmentSlot( string slot_name )
1738 {
1739 Debug.LogWarning("Obsolete function - use CanDisplayAttachmentSlot with slot id parameter");
1740 return InventorySlots.GetShowForSlotId(InventorySlots.GetSlotIdFromString(slot_name));
1741 }
1742
1747 bool CanDisplayAttachmentSlot( int slot_id )
1748 {
1749 return InventorySlots.GetShowForSlotId(slot_id);
1750 }
1751
1756 {
1757 GameInventory inventory = GetInventory();
1758 int count = inventory.GetAttachmentSlotsCount();
1759 int slotID;
1760 for (int i = 0; i < count; ++i)
1761 {
1762 slotID = inventory.GetAttachmentSlotId(i);
1763 if (CanDisplayAttachmentSlot(slotID))
1764 {
1765 return true;
1766 }
1767 }
1768
1769 return false;
1770 }
1771
1776 bool CanDisplayAttachmentCategory( string category_name )
1777 {
1778 return true;
1779 }
1780
1785 {
1786 return GetInventory().GetCargo() != null;
1787 }
1788
1793 {
1794 return true;
1795 }
1796
1801 {
1802 return true;
1803 }
1804
1809 {
1810 return GetHierarchyRootPlayer() == g_Game.GetPlayer();
1811 }
1812
1813 // !Called on CHILD when it's attached to parent.
1814 void OnWasAttached(EntityAI parent, int slot_id);
1815
1816 // !Called on CHILD when it's detached from parent.
1817 void OnWasDetached( EntityAI parent, int slot_id )
1818 {
1819 if (!IsFlagSet(EntityFlags.VISIBLE))
1820 {
1821 SetInvisible(false);
1822 OnInvisibleSet(false);
1823 SetInvisibleRecursive(false,parent);
1824 }
1825 }
1826
1828
1830 {
1831 return false;
1832 }
1833
1835 proto native void CreateAndInitInventory();
1836 proto native void DestroyInventory();
1837
1839 {
1840 GameInventory inventory = GetInventory();
1841 if (inventory)
1842 return inventory.GetAttachmentSlotsCount();
1843 else
1844 return -1;
1845 }
1846
1847 EntityAI FindAttachmentBySlotName(string slot_name)
1848 {
1849 GameInventory inventory = GetInventory();
1850 if (g_Game && inventory)
1851 {
1852 int slot_id = InventorySlots.GetSlotIdFromString(slot_name);
1853 if (slot_id != InventorySlots.INVALID)
1854 return inventory.FindAttachment(slot_id);
1855 }
1856 return null;
1857 }
1858
1859 // Check whether attachmnent slot is reserved
1860 bool IsSlotReserved(int slotID)
1861 {
1862 Man player = GetHierarchyRootPlayer();
1863 if (!player)
1864 return false;
1865
1866 HumanInventory inv = player.GetHumanInventory();
1867 if (!inv || inv.GetUserReservedLocationCount() == 0)
1868 return false;
1869
1870 int id = inv.FindFirstUserReservedLocationIndexForContainer(this);
1872 if (id == -1)
1873 return false;
1874
1875 inv.GetUserReservedLocation(id, loc);
1876
1877 if (loc.GetSlot() != slotID)
1878 return false;
1879
1880 return true;
1881 }
1882
1887 {
1888 EntityAI parent = GetHierarchyParent();
1889 if ( parent )
1890 {
1891 InventoryLocation inventory_location = new InventoryLocation();
1892 GetInventory().GetCurrentInventoryLocation( inventory_location );
1893
1894 return parent.GetInventory().GetSlotLock( inventory_location.GetSlot() );
1895 }
1896
1897 return false;
1898 }
1899
1904 {
1905 if ( g_Game.IsMultiplayer() )
1906 return GetInventory().TakeEntityToInventory(InventoryMode.JUNCTURE, flags, item);
1907 else
1908 return GetInventory().TakeEntityToInventory(InventoryMode.PREDICTIVE, flags, item);
1909 }
1910 bool LocalTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
1911 {
1912 return GetInventory().TakeEntityToInventory(InventoryMode.LOCAL, flags, item);
1913 }
1914 bool ServerTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
1915 {
1916 return GetInventory().TakeEntityToInventory(InventoryMode.SERVER, flags, item);
1917 }
1918 bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1919 {
1920 if ( g_Game.IsMultiplayer() )
1921 return GetInventory().TakeEntityToTargetInventory(InventoryMode.JUNCTURE, target, flags, item);
1922 else
1923 return GetInventory().TakeEntityToTargetInventory(InventoryMode.PREDICTIVE, target, flags, item);
1924 }
1925 bool LocalTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1926 {
1927 return GetInventory().TakeEntityToTargetInventory(InventoryMode.LOCAL, target, flags, item);
1928 }
1929 bool ServerTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1930 {
1931 return GetInventory().TakeEntityToTargetInventory(InventoryMode.SERVER, target, flags, item);
1932 }
1933
1936 bool PredictiveTakeEntityToCargo (notnull EntityAI item)
1937 {
1938 if ( g_Game.IsMultiplayer() )
1939 return GetInventory().TakeEntityToCargo(InventoryMode.JUNCTURE, item);
1940 else
1941 return GetInventory().TakeEntityToCargo(InventoryMode.PREDICTIVE, item);
1942 }
1943 bool LocalTakeEntityToCargo (notnull EntityAI item)
1944 {
1945 return GetInventory().TakeEntityToCargo(InventoryMode.LOCAL, item);
1946 }
1947 bool ServerTakeEntityToCargo (notnull EntityAI item)
1948 {
1949 return GetInventory().TakeEntityToCargo(InventoryMode.SERVER, item);
1950 }
1951
1952 bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1953 {
1954 if ( g_Game.IsMultiplayer() )
1955 return GetInventory().TakeEntityToTargetCargo(InventoryMode.JUNCTURE, target, item);
1956 else
1957 return GetInventory().TakeEntityToTargetCargo(InventoryMode.PREDICTIVE, target, item);
1958 }
1959 bool LocalTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1960 {
1961 return GetInventory().TakeEntityToTargetCargo(InventoryMode.LOCAL, target, item);
1962 }
1963 bool ServerTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1964 {
1965 return GetInventory().TakeEntityToTargetCargo(InventoryMode.SERVER, target, item);
1966 }
1967
1970 bool PredictiveTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col)
1971 {
1972 if ( g_Game.IsMultiplayer() )
1973 return GetInventory().TakeEntityToCargoEx(InventoryMode.JUNCTURE, item, idx, row, col);
1974 else
1975 return GetInventory().TakeEntityToCargoEx(InventoryMode.PREDICTIVE, item, idx, row, col);
1976 }
1977 bool LocalTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col)
1978 {
1979 return GetInventory().TakeEntityToCargoEx(InventoryMode.LOCAL, item, idx, row, col);
1980 }
1981
1982 bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1983 {
1984 if ( g_Game.IsMultiplayer() )
1985 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.JUNCTURE, cargo, item, row, col);
1986 else
1987 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.PREDICTIVE, cargo, item, row, col);
1988 }
1989 bool LocalTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1990 {
1991 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.LOCAL, cargo, item, row, col);
1992 }
1993 bool ServerTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1994 {
1995 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.SERVER, cargo, item, row, col);
1996 }
1997
2000 bool PredictiveTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
2001 {
2002 if ( g_Game.IsMultiplayer() )
2003 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.JUNCTURE, item, slot);
2004 else
2005 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.PREDICTIVE, item, slot);
2006 }
2007 bool LocalTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
2008 {
2009 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.LOCAL, item, slot);
2010 }
2011 bool ServerTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
2012 {
2013 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.SERVER, item, slot);
2014 }
2015
2016 bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
2017 {
2018 if ( g_Game.IsMultiplayer() )
2019 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.JUNCTURE, target, item, slot);
2020 else
2021 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.PREDICTIVE, target, item, slot);
2022 }
2023 bool LocalTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
2024 {
2025 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.LOCAL, target, item, slot);
2026 }
2027 bool ServerTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
2028 {
2029 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.SERVER, target, item, slot);
2030 }
2031
2032 bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
2033 {
2034 if ( g_Game.IsMultiplayer() )
2035 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.JUNCTURE, target, item);
2036 else
2037 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.PREDICTIVE, target, item);
2038 }
2039 bool LocalTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
2040 {
2041 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.LOCAL, target, item);
2042 }
2043 bool ServerTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
2044 {
2045 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.SERVER, target, item);
2046 }
2047
2049 {
2050 if ( g_Game.IsMultiplayer() )
2051 return GetInventory().TakeToDst(InventoryMode.JUNCTURE, src, dst);
2052 else
2053 return GetInventory().TakeToDst(InventoryMode.PREDICTIVE, src, dst);
2054 }
2056 {
2057 return GetInventory().TakeToDst(InventoryMode.LOCAL, src, dst);
2058 }
2060 {
2061 return GetInventory().TakeToDst(InventoryMode.SERVER, src, dst);
2062 }
2063
2067 bool PredictiveTakeEntityAsAttachment(notnull EntityAI item)
2068 {
2069 if (g_Game.IsMultiplayer())
2070 return GetInventory().TakeEntityAsAttachment(InventoryMode.JUNCTURE, item);
2071 else
2072 return GetInventory().TakeEntityAsAttachment(InventoryMode.PREDICTIVE, item);
2073 }
2074 bool LocalTakeEntityAsAttachment (notnull EntityAI item)
2075 {
2076 return GetInventory().TakeEntityAsAttachment(InventoryMode.LOCAL, item);
2077 }
2078 bool ServerTakeEntityAsAttachment (notnull EntityAI item)
2079 {
2080 return GetInventory().TakeEntityAsAttachment(InventoryMode.SERVER, item);
2081 }
2082
2083 bool PredictiveDropEntity(notnull EntityAI item)
2084 {
2085 return false;
2086 }
2087
2088 bool LocalDropEntity(notnull EntityAI item)
2089 {
2090 return false;
2091 }
2092
2093 bool ServerDropEntity(notnull EntityAI item)
2094 {
2095 return false;
2096 }
2097
2101 EntityAI GetAttachmentByType(typename type)
2102 {
2103 GameInventory inventory = GetInventory();
2104 int nAttachment = inventory.AttachmentCount();
2105 for ( int i = 0; i < nAttachment; ++i )
2106 {
2107 EntityAI attachment = inventory.GetAttachmentFromIndex( i );
2108 if ( attachment && attachment.IsInherited( type ) )
2109 return attachment;
2110 }
2111 return NULL;
2112 }
2113
2117 EntityAI GetAttachmentByConfigTypeName(string type)
2118 {
2119 GameInventory inventory = GetInventory();
2120 int nAttachment = inventory.AttachmentCount();
2121 for ( int i = 0; i < nAttachment; ++i )
2122 {
2123 EntityAI attachment = inventory.GetAttachmentFromIndex ( i );
2124 if ( attachment.IsKindOf ( type ) )
2125 return attachment;
2126 }
2127 return NULL;
2128 }
2129
2132 bool CanDropEntity(notnull EntityAI item)
2133 {
2134 return true;
2135 }
2136
2137 EntityAI SpawnInInventoryOrGroundPos(string object_name, GameInventory inv, vector pos)
2138 {
2139 if (inv)
2140 {
2141 EntityAI res = inv.CreateInInventory(object_name);
2142 if (res)
2143 {
2144 return res;
2145 }
2146 }
2147
2148 return SpawnEntityOnGroundPos(object_name, pos);
2149 }
2150
2153 EntityAI SpawnEntityOnGroundPos(string object_name, vector pos)
2154 {
2156 vector mat[4];
2157 Math3D.MatrixIdentity4(mat);
2158 mat[3] = pos;
2159 il.SetGround(NULL, mat);
2160 return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT);
2161 }
2162
2164 EntityAI SpawnEntityOnGround(string object_name, vector mat[4])
2165 {
2167 il.SetGround(NULL, mat);
2168 return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT);
2169 }
2170
2171 //----------------------------------------------------------------
2172
2173 bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
2174 {
2175 return true;
2176 }
2177
2178 // Forward declarations to allow lower modules to access properties that are modified from higher modules
2179 // These are mainly used within the ItemBase
2180 void SetWet(float value, bool allow_client = false);
2181 void AddWet(float value);
2183
2184 float GetWet()
2185 {
2186 return 0;
2187 }
2188
2190 {
2191 return 0;
2192 }
2193
2195 {
2196 return 0;
2197 }
2198
2200 {
2201 return 0;
2202 }
2203
2205 {
2206 return GetWetMax() - GetWetMin() != 0;
2207 }
2208
2209 void OnWetChanged(float newVal, float oldVal);
2210
2212 // ! Returns current wet level of the entity
2214
2215 // ! Calculates wet level from a given wetness, to get level of an entity, use 'GetWetLevel()' instead
2217 {
2218 if (wetness < GameConstants.STATE_DAMP)
2219 {
2220 return EWetnessLevel.DRY;
2221 }
2222 else if (wetness < GameConstants.STATE_WET)
2223 {
2224 return EWetnessLevel.DAMP;
2225 }
2226 else if (wetness < GameConstants.STATE_SOAKING_WET)
2227 {
2228 return EWetnessLevel.WET;
2229 }
2230 else if (wetness < GameConstants.STATE_DRENCHED)
2231 {
2232 return EWetnessLevel.SOAKING;
2233 }
2234 return EWetnessLevel.DRENCHED;
2235 }
2236 //----------------------------------------------------------------
2238 {
2239 return false;
2240 }
2241
2242 bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true);
2243
2245 {
2246 return 0;
2247 }
2248
2249 void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false);
2250
2252 {
2253 return 0;
2254 }
2255
2257 {
2258 return 0;
2259 }
2260
2262 {
2263 return 0;
2264 }
2265
2267
2268 int GetTargetQuantityMax(int attSlotID = -1)
2269 {
2270 return 0;
2271 }
2272
2274 {
2275 return 0;
2276 }
2277
2278 //----------------------------------------------------------------
2279
2281 {
2282 return (IsMan() || IsAnimal() || IsZombie()) && IsAlive() || IsCorpse();
2283 }
2284
2285 protected void InitTemperature()
2286 {
2287 EntityAI rootParent = GetHierarchyRoot();
2288 bool isParentAliveOrganism = false;
2289 if (rootParent && rootParent != this)
2290 isParentAliveOrganism = (rootParent.IsMan() || rootParent.IsAnimal() || rootParent.IsZombie()) && rootParent.IsAlive();
2291
2293 {
2295 }
2296 else if (isParentAliveOrganism) //living player's inventory etc.
2297 {
2298 SetTemperatureDirect(rootParent.GetTemperature());
2299 }
2300 else
2301 {
2302 SetTemperatureDirect(g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this));
2303 }
2304
2306 }
2307
2308 void SetTemperatureDirect(float value, bool allow_client = false)
2309 {
2310 if (!IsServerCheck(allow_client))
2311 return;
2312
2313 float min = GetTemperatureMin();
2314 float max = GetTemperatureMax();
2315 float previousValue = m_VarTemperature;
2316 m_VarTemperature = Math.Clamp(value, min, max);
2317
2318 if (previousValue != m_VarTemperature)
2320 }
2321
2323 void SetTemperature(float value, bool allow_client = false)
2324 {
2325 /*#ifdef DEVELOPER
2326 ErrorEx("Obsolete 'SetTemperature' called! Metadata will be extrapolated from base values.");
2327 #endif*/
2328
2329 if (!IsServerCheck(allow_client))
2330 return;
2331
2333 }
2334
2335 void AddTemperature(float value)
2336 {
2337 SetTemperature(value + GetTemperature());
2338 }
2339
2343 {
2344 #ifdef DEVELOPER
2345 m_LastFTChangeTime = -1;
2346 m_PresumedTimeRemaining = -1;
2347 #endif
2348
2349 if (!CanHaveTemperature())
2350 {
2351 Debug.Log("SetTemperatureEx | entity " + this + " does not have temperature range defined!");
2352 return;
2353 }
2354
2355 if (!m_TAC.TryAccessSource(data))
2356 return;
2357
2358 if (!IsServerCheck(false))
2359 return;
2360
2361 InterpolateTempData(TemperatureDataInterpolated.Cast(data));
2362 float target = Math.Clamp(data.m_AdjustedTarget, GetTemperatureMin(), GetTemperatureMax());
2363 float delta;
2364 //overheating
2365 if (CanItemOverheat())
2366 {
2368 delta = data.m_AdjustedTarget - GetTemperature();
2369 else
2370 delta = data.m_AdjustedTarget - GetItemOverheatThreshold();
2371
2372 HandleItemOverheating(delta,data);
2373 }
2374
2375 //freezing, can obstruct temperature change
2376 if (CanFreeze())
2377 {
2378 if (!m_IsFrozen)
2379 {
2380 delta = target - GetTemperatureFreezeThreshold();
2381 if (target < GetTemperatureFreezeThreshold())
2382 {
2383 //first crossing the threshold
2384 if (m_VarTemperature >= GetTemperatureFreezeThreshold()) //going DOWN or STAYING AT THRESHOLD, FREEZING;
2385 {
2387 }
2388 else //going UP, still FREEZING
2389 {
2390 SetTemperatureDirect(target);
2391 }
2392 HandleFreezingProgression(delta,data);
2393 }
2394 else
2395 {
2396 SetTemperatureDirect(target);
2397 if (target > GetTemperatureFreezeThreshold())
2398 HandleFreezingProgression(delta,data);
2399 }
2400 }
2401 else
2402 {
2403 delta = target - GetTemperatureThawThreshold();
2404 if (target > GetTemperatureThawThreshold())
2405 {
2406 //first crossing the threshold
2407 if (m_VarTemperature <= GetTemperatureThawThreshold()) //going UP, THAWING
2408 {
2410 }
2411 else //going DOWN, still THAWING
2412 {
2413 SetTemperatureDirect(target);
2414 }
2415 HandleFreezingProgression(delta,data);
2416 }
2417 else
2418 {
2419 SetTemperatureDirect(target);
2420 if (target < GetTemperatureThawThreshold())
2421 HandleFreezingProgression(delta,data);
2422 }
2423 }
2424 }
2425 else
2426 {
2427 SetTemperatureDirect(target);
2428 }
2429 }
2430
2433 {
2434 if (!CanHaveTemperature())
2435 {
2436 Debug.Log("RefreshTemperatureAccess | entity " + this + " does not have temperature range defined!");
2437 return;
2438 }
2439
2440 m_TAC.TryAccessSource(data);
2441 }
2442
2443 void InterpolateTempData(TemperatureDataInterpolated data)
2444 {
2445 if (data)
2446 data.InterpolateTemperatureDelta(GetTemperature());
2447 }
2448
2449
2456
2458 {
2459 return m_VarTemperature;
2460 }
2461
2463 {
2464 return m_VarTemperatureInit;
2465 }
2466
2468 {
2469 return m_VarTemperatureMin;
2470 }
2471
2473 {
2474 return m_VarTemperatureMax;
2475 }
2476
2478 bool GetCookingTargetTemperature(out float temperature)
2479 {
2480 return false;
2481 }
2482
2488 {
2490 }
2491
2496
2501
2503 {
2505 }
2506
2508 {
2510 }
2511
2514 {
2515 return m_FreezeThawProgress;
2516 }
2517
2520 {
2521 return m_FreezeThawProgress <= 0.0 || m_FreezeThawProgress >= 1.0;
2522 }
2523
2525 protected void SetFreezeThawProgress(float val)
2526 {
2528 }
2529
2534
2536 {
2537 return m_IsFrozen;
2538 }
2539
2540 void SetFrozen(bool frozen)
2541 {
2542 if (!CanFreeze() && frozen)
2543 return;
2544
2545 bool previous = m_IsFrozen;
2546 m_IsFrozen = frozen;
2547 SetFreezeThawProgress(frozen);
2548
2549 if (previous != frozen)
2550 {
2551 SetSynchDirty();
2553 }
2554 }
2555
2556 protected void HandleFreezingProgression(float deltaHeat, TemperatureData data)
2557 {
2558 float progressVal = m_FreezeThawProgress;
2559 float progressDelta = 1;
2560
2561 if (deltaHeat > 0)
2562 progressDelta = -1;
2563
2564 if (data.m_UpdateTimeInfo == -1)
2565 progressDelta = (-deltaHeat / GameConstants.TEMPERATURE_RATE_AVERAGE_ABS) * GameConstants.TEMPERATURE_FREEZETHAW_LEGACY_COEF; //reverse-calculate the progress if actual time is not available
2566 else
2567 progressDelta *= data.m_UpdateTimeInfo;
2568
2569 if (progressDelta == 0)
2570 return;
2571
2572 float changeTimeDefault;
2573 float changeTimeMin;
2574 float changeTime;
2575
2576 if (!m_IsFrozen)
2577 {
2578 changeTimeDefault = GetTemperatureFreezeTime();
2579 changeTimeMin = GameConstants.TEMPERATURE_TIME_FREEZE_MIN;
2580 }
2581 else
2582 {
2583 changeTimeDefault = GetTemperatureThawTime();
2584 changeTimeMin = GameConstants.TEMPERATURE_TIME_THAW_MIN;
2585 }
2586
2587 float coef = data.m_UpdateTimeCoef;
2588 if (deltaHeat < 0) //use cooling coef when freezing (mostly just to make sure)
2589 coef = GameConstants.TEMP_COEF_COOLING_GLOBAL;
2590
2591 if (coef != 0)
2592 changeTimeDefault *= 1/coef;
2593
2594 changeTime = Math.Lerp(Math.Max(changeTimeDefault,changeTimeMin),changeTimeMin,data.m_InterpolatedFraction);
2595 progressVal = progressVal + progressDelta / changeTime;
2596
2597 float remnantTemp = 0;
2598 if (!m_IsFrozen && progressVal >= 1)
2599 {
2600 SetFrozen(true);
2601 if (progressVal > 1.0)
2602 {
2603 if (data.m_UpdateTimeInfo == -1)
2604 remnantTemp = (progressVal - 1) * changeTime * GameConstants.TEMPERATURE_RATE_AVERAGE_ABS * -1;
2605 else
2606 remnantTemp = (((progressVal - 1) * changeTime) / progressDelta) * deltaHeat;
2607 }
2608 }
2609 else if (m_IsFrozen && progressVal <= 0)
2610 {
2611 SetFrozen(false);
2612 if (progressVal < 0.0)
2613 {
2614 if (data.m_UpdateTimeInfo == -1)
2615 remnantTemp = -progressVal * changeTime * GameConstants.TEMPERATURE_RATE_AVERAGE_ABS;
2616 else
2617 remnantTemp = ((-progressVal * changeTime) / progressDelta) * deltaHeat;
2618 }
2619 }
2620 else
2621 {
2622 if ((progressDelta < 0 && !m_IsFrozen) || (progressDelta > 0 && m_IsFrozen))
2623 progressVal = (progressDelta * GameConstants.TEMPERATURE_FREEZETHAW_ACCELERATION_COEF) / changeTime + m_FreezeThawProgress;
2624
2625 SetFreezeThawProgress(Math.Clamp(progressVal,0,1));
2626 }
2627
2628 if (remnantTemp >= GameConstants.TEMPERATURE_SENSITIVITY_THRESHOLD)//discards tiny values
2629 SetTemperatureDirect(GetTemperature() + remnantTemp);
2630
2631 #ifdef DEVELOPER
2632 if (progressVal > 0 && progressVal < 1)
2633 {
2634 m_LastFTChangeTime = changeTime;
2635 if (!m_IsFrozen)
2636 m_PresumedTimeRemaining = (1 - progressVal) * changeTime;
2637 else
2638 m_PresumedTimeRemaining = progressVal * changeTime;
2639 }
2640 #endif
2641 }
2642
2645
2646 //----------------------------------------------------------------
2649 {
2650 return GetItemOverheatTime() >= 0;
2651 }
2652
2655 {
2656 return GetTemperatureMax();
2657 }
2658
2661 {
2663 }
2664
2666 {
2667 return m_OverheatProgress >= 1;
2668 }
2669
2671 {
2672 return m_OverheatProgress;
2673 }
2674
2675 void SetItemOverheatProgress(float val, float deltaTime = 0)
2676 {
2677 float previous = m_OverheatProgress;
2678 m_OverheatProgress = Math.Clamp(val,0,1);
2679
2680 if (m_OverheatProgress >= 1)
2681 {
2682 if (previous < 1)
2684
2685 OnItemOverheat(deltaTime);
2686 }
2687 else if (previous >= 1)
2688 {
2690 }
2691 }
2692
2694 protected void OnItemOverheatStart();
2695 protected void OnItemOverheat(float deltaTime);
2696 protected void OnItemOverheatEnd();
2697
2698 protected void HandleItemOverheating(float deltaHeat, TemperatureData data)
2699 {
2700 float deltaTime = 1;
2701 float progressVal = m_OverheatProgress;
2702
2703 if (deltaHeat < 0)
2704 deltaTime = -1;
2705
2706 if (data.m_UpdateTimeInfo == -1)
2707 deltaTime = deltaHeat / GameConstants.TEMPERATURE_RATE_AVERAGE_ABS; //reverse-calculate the progress if actual time is not available
2708 else
2709 deltaTime *= data.m_UpdateTimeInfo;
2710
2711 if (GetItemOverheatTime() > 0)
2712 {
2713 float changeTime = Math.Lerp(Math.Max(GameConstants.TEMPERATURE_TIME_OVERHEAT_MIN,GetItemOverheatTime()),GameConstants.TEMPERATURE_TIME_OVERHEAT_MIN,Math.Clamp(data.m_InterpolatedFraction,0,1));
2714 progressVal += deltaTime / changeTime;
2715 }
2716 else
2717 {
2718 if (deltaHeat < 0)
2719 progressVal = 0;
2720 else if (deltaHeat > 0)
2721 progressVal = 1;
2722 }
2723
2724 SetItemOverheatProgress(Math.Clamp(progressVal,0,1),deltaTime);
2725 }
2726 //----------------------------------------------------------------
2727
2728 void SetLiquidType(int value, bool allow_client = false);
2730 {
2731 return 0;
2732 }
2733
2734 //----------------------------------------------------------------
2735 void SetColor(int r, int g, int b, int a);
2736 void GetColor(out int r,out int g,out int b,out int a)
2737 {
2738 r = -1;
2739 g = -1;
2740 b = -1;
2741 a = -1;
2742 }
2743
2744 //----------------------------------------------------------------
2745
2746 void SetStoreLoad(bool value);
2748 {
2749 return false;
2750 }
2751
2752 void SetStoreLoadedQuantity(float value);
2754 {
2755 return 0.0;
2756 }
2757
2758 //----------------------------------------------------------------
2759
2760 void SetCleanness(int value, bool allow_client = false);
2762 {
2763 return 0;
2764 }
2765
2766 //----------------------------------------------------------------
2767
2768 bool IsServerCheck(bool allow_client)
2769 {
2770 if (g_Game.IsServer())
2771 return true;
2772
2773 if (allow_client)
2774 return true;
2775
2776 if (g_Game.IsClient() && g_Game.IsMultiplayer())
2777 {
2778 Error("Attempting to change variable client side, variables are supposed to be changed on server only !!");
2779 return false;
2780 }
2781
2782 return true;
2783 }
2784
2785 //----------------------------------------------------------------
2786
2788 {
2789 return m_HiddenSelectionsData;
2790 }
2791
2793 int GetHiddenSelectionIndex( string selection )
2794 {
2795 if (m_HiddenSelectionsData)
2796 return m_HiddenSelectionsData.GetHiddenSelectionIndex( selection );
2797
2798 return -1;
2799 }
2800
2803 {
2804 if (m_HiddenSelectionsData)
2805 return m_HiddenSelectionsData.m_HiddenSelections;
2806 else
2807 return super.GetHiddenSelections();
2808 }
2809
2812 {
2813 if (m_HiddenSelectionsData)
2814 return m_HiddenSelectionsData.m_HiddenSelectionsTextures;
2815 else
2816 return super.GetHiddenSelectionsTextures();
2817 }
2818
2821 {
2822 if (m_HiddenSelectionsData)
2823 return m_HiddenSelectionsData.m_HiddenSelectionsMaterials;
2824 else
2825 return super.GetHiddenSelectionsMaterials();
2826 }
2827
2839 proto native void PlaceOnSurfaceRotated(out vector trans[4], vector pos, float dx = 0, float dz = 0, float fAngle = 0, bool align = false);
2840
2847 proto native void RegisterNetSyncVariableBool(string variableName);
2848
2855 proto native void RegisterNetSyncVariableBoolSignal(string variableName);
2856
2865 proto native void RegisterNetSyncVariableInt(string variableName, int minValue = 0, int maxValue = 0);
2866
2876 proto native void RegisterNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1);
2877
2884 proto native void RegisterNetSyncVariableObject(string variableName);
2885
2886 proto native void UpdateNetSyncVariableInt(string variableName, float minValue = 0, float maxValue = 0);
2887 proto native void UpdateNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1);
2888
2889 proto native void SwitchLight(bool isOn);
2890
2892 proto native void SetSimpleHiddenSelectionState(int index, bool state);
2893 proto native bool IsSimpleHiddenSelectionVisible(int index);
2894
2896 proto native void SetObjectTexture(int index, string texture_name);
2897 proto native owned string GetObjectTexture(int index);
2899 proto native void SetObjectMaterial(int index, string mat_name);
2900 proto native owned string GetObjectMaterial(int index);
2901
2902 proto native void SetRequiredSimulation(bool req);
2903 proto native bool IsRequiredSimulation();
2904
2905 proto native bool IsPilotLight();
2906 proto native void SetPilotLight(bool isOn);
2907
2926 {
2927 // Saving of energy related states
2928 if ( m_EM )
2929 {
2930 // Save energy amount
2931 ctx.Write( m_EM.GetEnergy() );
2932
2933 // Save passive/active state
2934 ctx.Write( m_EM.IsPassive() );
2935
2936 // Save ON/OFF state
2937 ctx.Write( m_EM.IsSwitchedOn() );
2938
2939 // Save plugged/unplugged state
2940 ctx.Write( m_EM.IsPlugged() );
2941
2942 // ENERGY SOURCE
2943 // Save energy source IDs
2944 EntityAI energy_source = m_EM.GetEnergySource();
2945 int b1 = 0;
2946 int b2 = 0;
2947 int b3 = 0;
2948 int b4 = 0;
2949
2950 if (energy_source)
2951 {
2952 energy_source.GetPersistentID(b1, b2, b3, b4);
2953 }
2954
2955 ctx.Write( b1 ); // Save energy source block 1
2956 ctx.Write( b2 ); // Save energy source block 2
2957 ctx.Write( b3 ); // Save energy source block 3
2958 ctx.Write( b4 ); // Save energy source block 4
2959 }
2960
2961 // variable management system
2962 SaveVariables(ctx);
2963 }
2964
2988
2989 bool OnStoreLoad (ParamsReadContext ctx, int version)
2990 {
2991 // Restoring of energy related states
2992 if ( m_EM )
2993 {
2994 // Load energy amount
2995 float f_energy = 0;
2996 if ( !ctx.Read( f_energy ) )
2997 f_energy = 0;
2998 m_EM.SetEnergy(f_energy);
2999
3000 // Load passive/active state
3001 bool b_is_passive = false;
3002 if ( !ctx.Read( b_is_passive ) )
3003 return false;
3004 m_EM.SetPassiveState(b_is_passive);
3005
3006 // Load ON/OFF state
3007 bool b_is_on = false;
3008 if ( !ctx.Read( b_is_on ) )
3009 {
3010 m_EM.SwitchOn();
3011 return false;
3012 }
3013
3014 // Load plugged/unplugged state
3015 bool b_is_plugged = false;
3016 if ( !ctx.Read( b_is_plugged ) )
3017 return false;
3018
3019 // ENERGY SOURCE
3020 if ( version <= 103 )
3021 {
3022 // Load energy source ID low
3023 int i_energy_source_ID_low = 0; // Even 0 can be valid ID!
3024 if ( !ctx.Read( i_energy_source_ID_low ) )
3025 return false;
3026
3027 // Load energy source ID high
3028 int i_energy_source_ID_high = 0; // Even 0 can be valid ID!
3029 if ( !ctx.Read( i_energy_source_ID_high ) )
3030 return false;
3031 }
3032 else
3033 {
3034 int b1 = 0;
3035 int b2 = 0;
3036 int b3 = 0;
3037 int b4 = 0;
3038
3039 if ( !ctx.Read(b1) ) return false;
3040 if ( !ctx.Read(b2) ) return false;
3041 if ( !ctx.Read(b3) ) return false;
3042 if ( !ctx.Read(b4) ) return false;
3043
3044 if ( b_is_plugged )
3045 {
3046 // Because function GetEntityByPersitentID() cannot be called here, ID values must be stored and used later.
3047 m_EM.StoreEnergySourceIDs( b1, b2, b3, b4 );
3048 m_EM.RestorePlugState(true);
3049 }
3050 }
3051
3052 if (b_is_on)
3053 {
3054 m_EM.SwitchOn();
3055 }
3056 }
3057
3058 if (version >= 140)
3059 {
3060 // variable management system
3061 if (!LoadVariables(ctx, version))
3062 return false;
3063 }
3064
3065 return true;
3066 }
3067
3069 proto native void SetSynchDirty();
3070
3075 {
3076 if ( m_EM )
3077 {
3078 if ( g_Game.IsMultiplayer() )
3079 {
3080 bool is_on = m_EM.IsSwitchedOn();
3081
3082 if (is_on != m_EM.GetPreviousSwitchState())
3083 {
3084 if (is_on)
3085 m_EM.SwitchOn();
3086 else
3087 m_EM.SwitchOff();
3088 }
3089
3090 int id_low = m_EM.GetEnergySourceNetworkIDLow();
3091 int id_High = m_EM.GetEnergySourceNetworkIDHigh();
3092
3093 EntityAI energy_source = EntityAI.Cast( g_Game.GetObjectByNetworkId(id_low, id_High) );
3094
3095 if (energy_source)
3096 {
3097 ComponentEnergyManager esem = energy_source.GetCompEM();
3098
3099 if ( !esem )
3100 {
3101 string object = energy_source.GetType();
3102 Error("Synchronization error! Object " + object + " has no instance of the Energy Manager component!");
3103 }
3104
3105 m_EM.PlugThisInto(energy_source);
3106
3107 }
3108 else
3109 {
3110 m_EM.UnplugThis();
3111 }
3112
3113 m_EM.DeviceUpdate();
3114 m_EM.StartUpdates();
3115 }
3116 }
3117
3118 if (m_IsFrozen != m_IsFrozenLocal && !g_Game.IsDedicatedServer())
3119 {
3122 }
3123 }
3124
3125 //-----------------------------
3126 // VARIABLE MANIPULATION SYSTEM
3127 //-----------------------------
3129 bool IsVariableSet(int variable)
3130 {
3131 return (variable & m_VariablesMask);
3132 }
3133
3134 void SetVariableMask(int variable)
3135 {
3136 m_VariablesMask = variable | m_VariablesMask;
3137 if (g_Game.IsServer())
3138 {
3139 SetSynchDirty();
3140 }
3141 }
3142
3144 void RemoveItemVariable(int variable)
3145 {
3146 m_VariablesMask = ~variable & m_VariablesMask;
3147 }
3148
3150 {
3151 DeSerializeNumericalVars(float_vars);
3152 }
3153
3155 {
3156 CachedObjectsArrays.ARRAY_FLOAT.Clear();
3158 return CachedObjectsArrays.ARRAY_FLOAT;
3159 }
3160
3162 {
3163 //first set the flags
3164 int varFlags = 0;
3165
3166 if (m_VariablesMask)
3167 varFlags = ItemVariableFlags.FLOAT;
3168
3169 ctx.Write(varFlags);
3170 //-------------------
3171 //now serialize the variables
3172
3173 //floats
3174 if (m_VariablesMask)
3175 WriteVarsToCTX(ctx);
3176 }
3177
3178 //----------------------------------------------------------------
3179 bool LoadVariables(ParamsReadContext ctx, int version = -1)
3180 {
3181 int varFlags;
3182
3183 //read the flags
3184 if (!ctx.Read(varFlags))
3185 {
3186 return false;
3187 }
3188
3189 //--------------
3190 if (varFlags & ItemVariableFlags.FLOAT)
3191 {
3192 if (!ReadVarsFromCTX(ctx, version))
3193 return false;
3194 }
3195 return true;
3196 }
3197
3200 {
3201 ctx.Write(m_VariablesMask);
3202
3203 //--------------------------------------------
3205 {
3206 ctx.Write(GetTemperature());
3207 ctx.Write((int)GetIsFrozen());
3208 }
3209 }
3210
3212 bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
3213 {
3214 if (version < 140)
3215 return true;
3216
3217 int intValue;
3218 float value;
3219
3220 if (!ctx.Read(intValue))
3221 return false;
3222
3223 m_VariablesMask = intValue; //necessary for higher implement overrides. Hope it does not bork some init somewhere.
3224
3225 //--------------------------------------------
3227 {
3228 if (!ctx.Read(value))
3229 return false;
3230 SetTemperatureDirect(value);
3231
3232 if (!ctx.Read(intValue))
3233 return false;
3234 SetFrozen(intValue);
3235 }
3236
3237 return true;
3238 }
3239
3241 {
3242 // the order of serialization must be the same as the order of de-serialization
3243 floats_out.Insert(m_VariablesMask);
3244
3245 //--------------------------------------------
3247 {
3248 floats_out.Insert(m_VarTemperature);
3249 floats_out.Insert((float)GetIsFrozen());
3250 floats_out.Insert((float)GetFreezeThawProgress());
3251 }
3252 }
3253
3255 {
3256 // the order of serialization must be the same as the order of de-serialization
3257 int index = 0;
3258 int mask = Math.Round(floats.Get(index));
3259
3260 index++;
3261 //--------------------------------------------
3262 if (mask & VARIABLE_TEMPERATURE)
3263 {
3264 float temperature = floats.Get(index);
3265 SetTemperatureDirect(temperature);
3266 floats.RemoveOrdered(index);
3267
3268 bool frozen = Math.Round(floats.Get(index));
3269 SetFrozen(frozen);
3270 floats.RemoveOrdered(index);
3271
3272 float FTProgress = floats.Get(index);
3273 SetFreezeThawProgress(FTProgress);
3274 floats.RemoveOrdered(index);
3275 }
3276 }
3277
3278 //----------------------------------------------------------------
3279
3281
3282 override void EOnFrame(IEntity other, float timeSlice)
3283 {
3284 if ( m_ComponentsBank != NULL )
3285 {
3286 for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
3287 {
3288 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
3289 {
3290 m_ComponentsBank.GetComponent(comp_key).Event_OnFrame(other, timeSlice);
3291 }
3292 }
3293 }
3294 }
3295
3297 {
3298 string text = string.Empty;
3299
3300 text += "Weight: " + GetWeightEx() + "\n";
3301 text += "Disabled: " + GetIsSimulationDisabled() + "\n";
3302 #ifdef SERVER
3303 if (GetEconomyProfile())
3304 text += "CE Lifetime default: " + (int)GetEconomyProfile().GetLifetime() + "\n";
3305 text += "CE Lifetime remaining: " + (int)GetLifetime() + "\n";
3306 #endif
3307
3309 if (compEM)
3310 {
3311 text += "Energy Source: " + Object.GetDebugName(compEM.GetEnergySource()) + "\n";
3312 text += "Switched On: " + compEM.IsSwitchedOn() + "\n";
3313 text += "Is Working: " + compEM.IsWorking() + "\n";
3314 }
3315
3316 return text;
3317 }
3318
3319
3320 void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4){}//DEPRICATED, USE GetDebugActions / OnAction
3321 void OnDebugButtonPressClient(int button_index){}//DEPRICATED, USE GetDebugActions / OnAction
3322 void OnDebugButtonPressServer(int button_index){}//DEPRICATED, USE GetDebugActions / OnAction
3323
3324
3326 {
3327 return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDraw();
3328 }
3329
3330 void DebugBBoxSetColor(int color)
3331 {
3332 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxSetColor(color);
3333 }
3334
3336 {
3337 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDelete();
3338 }
3339
3340 Shape DebugDirectionDraw(float distance = 1)
3341 {
3342 return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDraw(distance);
3343 }
3344
3346 {
3347 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionSetColor(color);
3348 }
3349
3351 {
3352 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDelete();
3353 }
3354
3356 void HideSelection( string selection_name )
3357 {
3358 if ( !ToDelete() )
3359 {
3360 SetAnimationPhase ( selection_name, 1 ); // 1 = hide, 0 = unhide!
3361 }
3362 }
3363
3365 void ShowSelection( string selection_name )
3366 {
3367 if ( !ToDelete() )
3368 {
3369 SetAnimationPhase ( selection_name, 0 ); // 1 = hide, 0 = unhide!
3370 }
3371 }
3372
3375 proto void GetPersistentID( out int b1, out int b2, out int b3, out int b4 );
3376
3378 proto native void SetLifetime( float fLifeTime );
3380 proto native float GetLifetime();
3382 proto native void IncreaseLifetime();
3383
3385 proto native void SetLifetimeMax( float fLifeTime );
3387 proto native float GetLifetimeMax();
3388
3391 {
3393 if (GetHierarchyParent())
3394 GetHierarchyParent().IncreaseLifetimeUp();
3395 }
3396
3397
3398 // BODY STAGING
3401 {
3402 if ( HasComponent(COMP_TYPE_BODY_STAGING) )
3403 return ComponentBodyStaging.Cast( GetComponent(COMP_TYPE_BODY_STAGING) );
3404 return NULL;
3405 }
3406
3411 {
3412 if (m_EM)
3413 return m_EM;
3414
3415 if ( HasComponent(COMP_TYPE_ENERGY_MANAGER) )
3416 return ComponentEnergyManager.Cast( GetComponent(COMP_TYPE_ENERGY_MANAGER) );
3417 return NULL;
3418 }
3419
3422 {
3423 return HasComponent(COMP_TYPE_ENERGY_MANAGER);
3424 }
3425
3426 // ------ Public Events for Energy manager component. Overwrite these and put your own functionality into them. ------
3427
3429 void OnWorkStart() {}
3430
3432 void OnWork( float consumed_energy ) {}
3433
3435 void OnWorkStop() {}
3436
3438 void OnSwitchOn() {}
3439
3441 void OnSwitchOff() {}
3442
3444 void OnIsPlugged(EntityAI source_device) {}
3445
3447 void OnIsUnplugged( EntityAI last_energy_source ) {}
3448
3450 void OnOwnSocketTaken( EntityAI device ) {}
3451
3453 void OnOwnSocketReleased( EntityAI device ) {}
3454
3457
3460
3464
3465 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
3466 {
3467 super.OnRPC(sender, rpc_type, ctx);
3468
3469 if ( g_Game.IsClient() )
3470 {
3471 switch (rpc_type)
3472 {
3473 // BODY STAGING - server => client synchronization of skinned state.
3474 case ERPCs.RPC_BS_SKINNED_STATE:
3475 {
3476 Param1<bool> p_skinned_state= new Param1<bool>(false);
3477 if (ctx.Read(p_skinned_state))
3478 {
3479 float state = p_skinned_state.param1;
3480 if (state && GetCompBS())
3481 GetCompBS().SetAsSkinnedClient();
3482 }
3483 break;
3484 }
3485
3486 case ERPCs.RPC_EXPLODE_EVENT:
3487 {
3488 OnExplodeClient();
3489 break;
3490 }
3491 }
3492 }
3493 }
3494
3495 #ifdef DIAG_DEVELOPER
3496 void FixEntity()
3497 {
3498 if (!(g_Game.IsServer()))
3499 return;
3500 SetFullHealth();
3501
3502 GameInventory inventory = GetInventory();
3503 if (inventory)
3504 {
3505 int i = 0;
3506 int AttachmentsCount = inventory.AttachmentCount();
3507 for (i = 0; i < AttachmentsCount; ++i)
3508 {
3509 inventory.GetAttachmentFromIndex(i).FixEntity();
3510 }
3511
3512 CargoBase cargo = inventory.GetCargo();
3513 if (cargo)
3514 {
3515 int cargoCount = cargo.GetItemCount();
3516 for (i = 0; i < cargoCount; ++i)
3517 {
3518 cargo.GetItem(i).FixEntity();
3519 }
3520 }
3521 }
3522 }
3523 #endif
3524
3526 {
3527 return CfgGameplayHandler.GetWetnessWeightModifiers()[GetWetLevel()];
3528 }
3529
3531 {
3532 return m_ConfigWeight * GetWetWeightModifier();
3533 }
3534
3535 #ifdef DEVELOPER
3536 string GetConfigWeightModifiedDebugText()
3537 {
3538 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3539 {
3540 return "(" + m_ConfigWeight + "(config weight) * " + GetWetWeightModifier() + "(Wetness Modifier))";
3541 }
3542 return string.Empty;
3543 }
3544 #endif
3545
3546
3547 //Obsolete, use GetWeightEx()
3549 {
3550 return GetWeightEx();
3551 }
3552
3554 {
3555 //Print("ent:" + this + " - ClearWeightDirty");
3556 m_WeightDirty = 0;
3557 }
3558
3560 {
3561 #ifdef DEVELOPER
3562 if (WeightDebug.m_VerbosityFlags & WeightDebugType.SET_DIRTY_FLAG)
3563 {
3564 Print("---------------------------------------");
3565 Print("ent:" + this + " - SetWeightDirty");
3566 if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK)
3567 {
3568 DumpStack();
3569 }
3570 Print("---------------------------------------");
3571 }
3572 #endif
3573 m_WeightDirty = 1;
3574 if (GetHierarchyParent())
3575 {
3576 GetHierarchyParent().SetWeightDirty();
3577 }
3578 }
3579 // returns weight of all cargo and attachments
3580 float GetInventoryAndCargoWeight(bool forceRecalc = false)
3581 {
3582 GameInventory inventory = GetInventory();
3583 float totalWeight;
3584 if (inventory)
3585 {
3586 int i = 0;
3587 int AttachmentsCount = inventory.AttachmentCount();
3588 for (i = 0; i < AttachmentsCount; ++i)
3589 {
3590 totalWeight += inventory.GetAttachmentFromIndex(i).GetWeightEx(forceRecalc);
3591 }
3592
3593 CargoBase cargo = inventory.GetCargo();
3594 if (cargo)
3595 {
3596 int cargoCount = cargo.GetItemCount();
3597 for (i = 0; i < cargoCount; ++i)
3598 {
3599 totalWeight += cargo.GetItem(i).GetWeightEx(forceRecalc);
3600 }
3601 }
3602 }
3603 return totalWeight;
3604 }
3605
3606 protected float GetWeightSpecialized(bool forceRecalc = false)
3607 {
3608 return GetInventoryAndCargoWeight(forceRecalc);
3609 }
3610
3612 //this method is not meant to be overriden, to adjust weight calculation for specific item type, override 'GetWeightSpecialized(bool forceRecalc = false)' instead
3613 float GetWeightEx(bool forceRecalc = false)
3614 {
3615 if (m_WeightDirty || forceRecalc)//recalculate
3616 {
3617 m_WeightEx = GetWeightSpecialized(forceRecalc);
3619
3620 #ifdef DEVELOPER
3621 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3622 {
3623 WeightDebug.GetWeightDebug(this).SetWeight(m_WeightEx);
3624 }
3625 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_DIRTY)
3626 {
3627 Print("ent:" + this + " - Dirty Recalc");
3628 if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK)
3629 {
3630 DumpStack();
3631 }
3632 }
3633 #endif
3634 }
3635
3636 return m_WeightEx;
3637 }
3638
3639 void UpdateWeight(WeightUpdateType updateType = WeightUpdateType.FULL, float weightAdjustment = 0);
3640
3642
3643 void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
3644 {
3645 //fix entity
3646 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FIX_ENTITY, "Fix Entity", FadeColors.LIGHT_GREY));
3647 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
3648
3649 //weight
3650 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT, "Print Weight", FadeColors.LIGHT_GREY));
3651 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT_RECALC, "Print Weight Verbose", FadeColors.LIGHT_GREY));
3652 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT, "Print Player Weight", FadeColors.LIGHT_GREY));
3653 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT_RECALC, "Print Player Weight Verbose", FadeColors.LIGHT_GREY));
3654 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
3655 }
3656
3657 bool OnAction(int action_id, Man player, ParamsReadContext ctx)
3658 {
3659 if (action_id == EActions.FIX_ENTITY)
3660 {
3661 #ifdef DIAG_DEVELOPER
3662 FixEntity();
3663 #endif
3664 }
3665 else if (action_id == EActions.GET_TOTAL_WEIGHT) //Prints total weight of item + its contents
3666 {
3667 WeightDebug.ClearWeightDebug();
3668 #ifndef SERVER
3669 Debug.Log("======================== "+ GetType() +" =================================");
3670 #endif
3671 Debug.Log("Weight:" + GetWeightEx().ToString());
3672 Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx());
3673 Debug.Log("----------------------------------------------------------------------------------------------");
3674 }
3675 else if (action_id == EActions.GET_TOTAL_WEIGHT_RECALC) //Prints total weight of item + its contents
3676 {
3677 WeightDebug.ClearWeightDebug();
3678 WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED);
3679 #ifndef SERVER
3680 Debug.Log("======================== "+ GetType() +" RECALC ===========================");
3681 #endif
3682 Debug.Log("Weight:" + GetWeightEx(true).ToString());
3683 Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx());
3684 WeightDebug.PrintAll(this);
3685 Debug.Log("----------------------------------------------------------------------------------------------");
3686 WeightDebug.SetVerbosityFlags(0);
3687 }
3688 else if (action_id == EActions.GET_PLAYER_WEIGHT) //Prints total weight of item + its contents
3689 {
3690 WeightDebug.ClearWeightDebug();
3691 #ifndef SERVER
3692 Debug.Log("======================== PLAYER: "+player+" ===========================");
3693 #endif
3694 Debug.Log("New overall weight Player:"+player.GetWeightEx().ToString());
3695
3696 Debug.Log("----------------------------------------------------------------------------------------------");
3697 }
3698 else if (action_id == EActions.GET_PLAYER_WEIGHT_RECALC) //Prints total weight of item + its contents
3699 {
3700 WeightDebug.ClearWeightDebug();
3701 WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED);
3702 #ifndef SERVER
3703 Debug.Log("======================== PLAYER RECALC: "+player+" ===========================");
3704 #endif
3705 Debug.Log("New overall weight Player:"+player.GetWeightEx(true).ToString());
3706 WeightDebug.PrintAll(player);
3707 Debug.Log("----------------------------------------------------------------------------------------------");
3708 WeightDebug.SetVerbosityFlags(0);
3709 }
3710 return false;
3711 }
3712
3717
3719 void SetViewIndex( int index )
3720 {
3721 m_ViewIndex = index;
3722
3723 if( g_Game.IsServer() )
3724 {
3725 SetSynchDirty();
3726 }
3727 }
3728
3731 {
3732 if ( MemoryPointExists( "invView2" ) )
3733 {
3734 #ifdef PLATFORM_WINDOWS
3736 GetInventory().GetCurrentInventoryLocation( il );
3737 InventoryLocationType type = il.GetType();
3738 switch ( type )
3739 {
3740 case InventoryLocationType.CARGO:
3741 {
3742 return 0;
3743 }
3744 case InventoryLocationType.ATTACHMENT:
3745 {
3746 return 1;
3747 }
3748 case InventoryLocationType.HANDS:
3749 {
3750 return 0;
3751 }
3752 case InventoryLocationType.GROUND:
3753 {
3754 return 1;
3755 }
3756 case InventoryLocationType.PROXYCARGO:
3757 {
3758 return 0;
3759 }
3760 default:
3761 {
3762 return 0;
3763 }
3764 }
3765 #endif
3766
3767 #ifdef PLATFORM_CONSOLE
3768 return 1;
3769 #endif
3770 }
3771 return 0;
3772 }
3773
3774
3777 {
3778 Debug.LogError("EntityAI: HitComponentForAI not set properly for that entity (" + GetType() + ")");
3780 return "";
3781 }
3782
3785 {
3786 Debug.LogError("EntityAI: DefaultHitComponent not set properly for that entity (" + GetType() + ")");
3788 return "";
3789 }
3790
3793 {
3794 Debug.LogError("EntityAI: DefaultHitPositionComponent not set for that entity (" + GetType() + ")");
3795 return "";
3796 }
3797
3799 {
3800 Debug.LogError("EntityAI: SuitableFinisherHitComponents not set for that entity (" + GetType() + ")");
3801 return null;
3802 }
3803
3805 {
3806 Debug.LogError("EntityAI: DefaultHitPosition not set for that entity (" + GetType() + ")");
3807 return vector.Zero;
3808 }
3809
3812 {
3813 return EMeleeTargetType.ALIGNABLE;
3814 }
3815
3818 {
3819 return "None";
3820 }
3821
3824 {
3825 return false;
3826 }
3827
3830 {
3831 return false;
3832 }
3833
3836 {
3837 return false;
3838 }
3839
3840 string ChangeIntoOnAttach(string slot) {}
3842
3845 {
3847 }
3848
3850 {
3851 return false;
3852 }
3853
3867 {
3868 float currentTime = g_Game.GetTickTime();
3869 if (m_LastUpdatedTime == 0)
3870 m_LastUpdatedTime = currentTime;
3871
3872 m_ElapsedSinceLastUpdate = currentTime - m_LastUpdatedTime;
3873 m_LastUpdatedTime = currentTime;
3874
3876 }
3877
3879 {
3880 //currently only temperature on EntityAI
3881 if (g_Game.IsWorldWetTempUpdateEnabled())
3882 {
3884 {
3885 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
3886 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
3887 {
3888 float heatPermCoef = 1.0;
3889 EntityAI ent = this;
3890 while (ent)
3891 {
3892 heatPermCoef *= ent.GetHeatPermeabilityCoef();
3893 ent = ent.GetHierarchyParent();
3894 }
3895
3896 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,m_ElapsedSinceLastUpdate,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
3897 }
3898 }
3899 }
3900 }
3901
3902 void OnDebugSpawnEx(DebugSpawnParams params)
3903 {
3904 OnDebugSpawn();
3905 }
3906
3908 {
3909 array<string> slots = new array<string>;
3910 ConfigGetTextArray("Attachments", slots);
3911
3912 array<string> mags = new array<string>;
3913 ConfigGetTextArray("magazines", mags);
3914
3915 //-------
3916
3917 TStringArray all_paths = new TStringArray;
3918
3919 all_paths.Insert(CFG_VEHICLESPATH);
3920 all_paths.Insert(CFG_MAGAZINESPATH);
3921 all_paths.Insert(CFG_WEAPONSPATH);
3922
3923 string config_path;
3924 string child_name;
3925 int scope;
3926 string path;
3927 int consumable_count;
3928
3929 for (int i = 0; i < all_paths.Count(); i++)
3930 {
3931 config_path = all_paths.Get(i);
3932 int children_count = g_Game.ConfigGetChildrenCount(config_path);
3933
3934 for (int x = 0; x < children_count; x++)
3935 {
3936 g_Game.ConfigGetChildName(config_path, x, child_name);
3937 path = config_path + " " + child_name;
3938 scope = g_Game.ConfigGetInt( config_path + " " + child_name + " scope" );
3939 bool should_check = true;
3940 if ( config_path == "CfgVehicles" && scope == 0)
3941 {
3942 should_check = false;
3943 }
3944
3945 if ( should_check )
3946 {
3947 string inv_slot;
3948 g_Game.ConfigGetText( config_path + " " + child_name + " inventorySlot",inv_slot );
3949 for (int z = 0; z < slots.Count(); z++)
3950 {
3951 if (slots.Get(z) == inv_slot)
3952 {
3953 this.GetInventory().CreateInInventory( child_name );
3954 continue;
3955 //Print("matching attachment: " + child_name + " for inv. slot name:" +inv_slot);
3956 }
3957 }
3958 }
3959 }
3960 }
3961 };
3962
3963 override EntityAI ProcessMeleeItemDamage(int mode = 0)
3964 {
3965 if (g_Game.IsServer())
3966 AddHealth("","Health",-MELEE_ITEM_DAMAGE);
3967 return this;
3968 }
3969
3972 {
3974 }
3975
3977 {
3978 return "";
3979 }
3980
3981 void ProcessInvulnerabilityCheck(string servercfg_param)
3982 {
3983 if ( g_Game && g_Game.IsMultiplayer() && g_Game.IsServer() )
3984 {
3985 int invulnerability;
3986 switch (servercfg_param)
3987 {
3988 case "disableContainerDamage":
3989 invulnerability = CfgGameplayHandler.GetDisableContainerDamage();
3990 break;
3991
3992 case "disableBaseDamage":
3993 invulnerability = CfgGameplayHandler.GetDisableBaseDamage();
3994 break;
3995 }
3996
3997 if (invulnerability > 0)
3998 {
3999 SetAllowDamage(false);
4000 }
4001 }
4002 }
4003
4004 void SetBayonetAttached(bool pState, int slot_idx = -1) {};
4007
4008 void SetButtstockAttached(bool pState, int slot_idx = -1) {};
4011
4012 void SetInvisibleRecursive(bool invisible, EntityAI parent = null, array<int> attachments = null)
4013 {
4014 array<int> childrenAtt = new array<int>;
4015 array<int> attachmentsArray = new array<int>;
4016 if (attachments)
4017 attachmentsArray.Copy(attachments);
4018 else
4019 {
4020 GameInventory inventory = GetInventory();
4021 int nAttachmentSlots = inventory.GetAttachmentSlotsCount();
4022 for (int i = 0; i < nAttachmentSlots; ++i)
4023 {
4024 attachmentsArray.Insert(inventory.GetAttachmentSlotId(i));
4025 }
4026 }
4027
4028 EntityAI item;
4029
4030 GameInventory parentInventory;
4031 if (parent)
4032 parentInventory = parent.GetInventory();
4033
4034 foreach( int slot : attachmentsArray )
4035 {
4036 if( parentInventory )
4037 item = parentInventory.FindAttachment(slot);
4038 else
4039 item = this;//GetInventory().FindAttachment(slot);
4040
4041 if( item )
4042 {
4043 GameInventory itemInventory = item.GetInventory();
4044 int nAttachment = itemInventory.AttachmentCount();
4045 if( nAttachment > 0 )
4046 {
4047 int nAttachmentSlots2 = itemInventory.GetAttachmentSlotsCount();
4048 for(i = 0; i < nAttachmentSlots2; ++i)
4049 {
4050 childrenAtt.Insert(itemInventory.GetAttachmentSlotId(i));
4051 }
4052
4053 SetInvisibleRecursive(invisible,item,childrenAtt);
4054 }
4055
4056 item.SetInvisible(invisible);
4057 item.OnInvisibleSet(invisible);
4058 }
4059 }
4060 }
4061
4063 {
4064 EffectSound sound = SEffectManager.PlaySound( "hardTreeFall_SoundSet", GetPosition() );
4065 sound.SetAutodestroy( true );
4066 }
4067
4069 {
4070 EffectSound sound = SEffectManager.PlaySound( "softTreeFall_SoundSet", GetPosition() );
4071 sound.SetAutodestroy( true );
4072 }
4073
4075 {
4076 EffectSound sound = SEffectManager.PlaySound( "hardBushFall_SoundSet", GetPosition() );
4077 sound.SetAutodestroy( true );
4078 }
4079
4081 {
4082 EffectSound sound = SEffectManager.PlaySound( "softBushFall_SoundSet", GetPosition() );
4083 sound.SetAutodestroy( true );
4084 }
4085
4087 {
4089 {
4092 Car car;
4093 Boat boat;
4094 float damage;
4095 vector impulse;
4096
4097 // a different attempt to solve hits from "standing" car to the players
4098 if (Car.CastTo(car, transport))
4099 {
4100 if (car.GetSpeedometerAbsolute() > 2 )
4101 {
4102 damage = m_TransportHitVelocity.Length();
4103 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
4104 }
4105 else
4106 {
4108 }
4109
4110 // compute impulse and apply only if the body dies
4111 if (IsDamageDestroyed() && car.GetSpeedometerAbsolute() > 3)
4112 {
4113 impulse = 40 * m_TransportHitVelocity;
4114 impulse[1] = 40 * 1.5;
4115 dBodyApplyImpulse(this, impulse);
4116 }
4117 }
4118 else if (Boat.CastTo(boat, transport))
4119 {
4120 Human player = Human.Cast(this);
4121 if (player && player.PhysicsGetLinkedEntity() == boat) // standing on boat
4122 {
4124 return;
4125 }
4126
4127 if (m_TransportHitVelocity.Normalize() > 5) // 5 m/s
4128 {
4129 damage = m_TransportHitVelocity.Length() * 0.5;
4130 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
4131 }
4132 else
4134 }
4135 else //old solution just in case if somebody use it
4136 {
4137 // avoid damage because of small movements
4138 if (m_TransportHitVelocity.Length() > 0.1)
4139 {
4140 damage = m_TransportHitVelocity.Length();
4141 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
4142 }
4143 else
4144 {
4146 }
4147
4148 // compute impulse and apply only if the body dies
4149 if (IsDamageDestroyed() && m_TransportHitVelocity.Length() > 0.3)
4150 {
4151 impulse = 40 * m_TransportHitVelocity;
4152 impulse[1] = 40 * 1.5;
4153 dBodyApplyImpulse(this, impulse);
4154 }
4155 }
4156 }
4157 }
4158
4159 bool GetInventoryHandAnimation(notnull InventoryLocation loc, out int value)
4160 {
4161 value = -1;
4162 return false;
4163 }
4164
4165 bool TranslateSlotFromSelection(string selection_name, out int slot_id)
4166 {
4167 return false;
4168 }
4169
4172 {
4173 return GetUniversalTemperatureSource() != null && GetUniversalTemperatureSource().IsActive();
4174 }
4175
4177 {
4179 }
4180
4181 void SetUniversalTemperatureSource(UTemperatureSource uts)
4182 {
4184 }
4185
4190
4193
4194 void PairRemote(notnull EntityAI trigger);
4195
4197
4198 EntityAI GetPairDevice();
4199
4201 {
4203 if (raib)
4204 {
4205 raib.SetPersistentPairID(id);
4206 }
4207 }
4208
4211 bool IsValveTurnable(int pValveIndex);
4212 int GetTurnableValveIndex(int pComponentIndex);
4213 void ExecuteActionsConnectedToValve(int pValveIndex);
4214
4216// attachment exclusion section //
4218 private void InitAttachmentExclusionValues()
4219 {
4220 m_AttachmentExclusionSlotMap = new map<int,ref set<int>>();
4221 m_AttachmentExclusionMaskGlobal = new set<int>;
4222 m_AttachmentExclusionMaskChildren = new set<int>();
4223
4224 int count = GetInventory().GetSlotIdCount();
4225 //no sense in performing inits for something that cannot be attached anywhere (hand/lefthand and some other 'special' slots are the reason for creating 'new' sets above)
4226 if (count == 0)
4227 return;
4228
4229 InitInherentSlotExclusionMap();
4232 }
4233
4235 private void InitInherentSlotExclusionMap()
4236 {
4237 GameInventory inventory = GetInventory();
4238 int count = inventory.GetSlotIdCount();
4239 //starting with the INVALID slot, so it is always in the map of attachable items
4240 SetAttachmentExclusionMaskSlot(InventorySlots.INVALID,GetAttachmentExclusionInitSlotValue(InventorySlots.INVALID));
4241
4242 int slotId;
4243 for (int i = 0; i < count; ++i)
4244 {
4245 slotId = inventory.GetSlotId(i);
4246 SetAttachmentExclusionMaskSlot(slotId,GetAttachmentExclusionInitSlotValue(slotId));
4247 }
4248 }
4249
4251 protected set<int> GetAttachmentExclusionInitSlotValue(int slotId)
4252 {
4253 set<int> dflt = new set<int>;
4254 return dflt;
4255 }
4256
4257 //Initiated last, and only for items that do not have others defined already
4259 {
4260 bool performLegacyInit = InitLegacyExclusionCheck();
4261
4262 //adding implicit slot info AFTER the check is performed
4264
4265 if (performLegacyInit)
4267 }
4268
4269 //returns 'false' if the script initialization
4271 {
4272 //first check the globals
4273 if (m_AttachmentExclusionMaskGlobal.Count() > 0)
4274 return false;
4275
4276 //now the map
4277 int count = m_AttachmentExclusionSlotMap.Count();
4278 if (count > 1) //more than InventorySlots.INVALID
4279 {
4280 for (int i = 0; i < count; i++)
4281 {
4282 int countSet = m_AttachmentExclusionSlotMap.GetElement(i).Count();
4283 if (countSet > 0) //SOMETHING is defined
4284 {
4285 return false;
4286 }
4287 }
4288 }
4289
4290 return true;
4291 }
4292
4299 {
4300 int slotId;
4301 GameInventory gameInventory = GetInventory();
4302 int slotCount = gameInventory.GetSlotIdCount();
4303 for (int i = 0; i < slotCount; i++)
4304 {
4305 slotId = gameInventory.GetSlotId(i);
4306 set<int> tmp;
4307 switch (slotId)
4308 {
4309 case InventorySlots.HEADGEAR:
4310 {
4311 tmp = new set<int>;
4312 tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
4313 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK);
4314 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP);
4315 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR);
4317 break;
4318 }
4319
4320 case InventorySlots.MASK:
4321 {
4322 tmp = new set<int>;
4323 tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
4324 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR);
4325 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP);
4326 tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR);
4328 break;
4329 }
4330
4331 case InventorySlots.EYEWEAR:
4332 {
4333 tmp = new set<int>;
4334 tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
4335 if (ConfigGetBool("isStrap"))
4336 {
4337 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR);
4338 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK);
4339 }
4340 else
4341 {
4342 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR);
4343 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK);
4344 }
4346 break;
4347 }
4348 }
4349 }
4350 }
4351
4353 {
4354 int slotId;
4355 GameInventory gameInventory = GetInventory();
4356 int slotCount = gameInventory.GetSlotIdCount();
4357 for (int i = 0; i < slotCount; i++)
4358 {
4359 slotId = gameInventory.GetSlotId(i);
4360 set<int> tmp;
4361 switch (slotId)
4362 {
4363 case InventorySlots.HEADGEAR:
4364 {
4365 tmp = new set<int>;
4366 tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
4367 if (ConfigGetBool("noNVStrap"))
4368 {
4369 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR);
4370 }
4371 if (ConfigGetBool("noMask"))
4372 {
4373 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR);
4374 }
4375 if (ConfigGetBool("noEyewear"))
4376 {
4377 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR);
4378 }
4380 break;
4381 }
4382
4383 case InventorySlots.MASK:
4384 {
4385 tmp = new set<int>;
4386 tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
4387 if (ConfigGetBool("noNVStrap"))
4388 {
4389 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK);
4390 }
4391 if (ConfigGetBool("noHelmet"))
4392 {
4393 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK);
4394 }
4395 if (ConfigGetBool("noEyewear"))
4396 {
4397 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK);
4398 }
4400 break;
4401 }
4402
4403 case InventorySlots.EYEWEAR:
4404 {
4405 tmp = new set<int>;
4406 tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
4407 if (ConfigGetBool("isStrap"))
4408 {
4409 if (ConfigGetBool("noHelmet"))
4410 {
4411 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP);
4412 }
4413 if (ConfigGetBool("noMask"))
4414 {
4415 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP);
4416 }
4417 }
4418 else
4419 {
4420 if (ConfigGetBool("noHelmet"))
4421 {
4422 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR);
4423 }
4424 if (ConfigGetBool("noMask"))
4425 {
4426 tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR);
4427 }
4428 }
4430 break;
4431 }
4432 }
4433 }
4434 }
4435
4438
4440 protected void AddSingleExclusionValueGlobal(EAttExclusions value)
4441 {
4442 if (m_AttachmentExclusionMaskGlobal.Find(value) == -1)
4443 m_AttachmentExclusionMaskGlobal.Insert(value);
4444 }
4445
4447 protected void ClearSingleExclusionValueGlobal(EAttExclusions value)
4448 {
4449 int idx = m_AttachmentExclusionMaskGlobal.Find(value);
4450 if (idx != -1)
4451 m_AttachmentExclusionMaskGlobal.Remove(idx);
4452 }
4453
4454 protected void SetAttachmentExclusionMaskGlobal(set<int> values)
4455 {
4456 m_AttachmentExclusionMaskGlobal.Clear();
4457 m_AttachmentExclusionMaskGlobal.Copy(values);
4458 }
4459
4461 protected void SetAttachmentExclusionMaskSlot(int slotId, set<int> values)
4462 {
4463 if (m_AttachmentExclusionSlotMap)
4464 {
4465 m_AttachmentExclusionSlotMap.Set(slotId,values);
4466 }
4467 else
4468 ErrorEx("m_AttachmentExclusionSlotMap not available! Fill the 'inventorySlot[]' in the " + this + " config file.");
4469 }
4470
4471 private void PropagateExclusionValueRecursive(set<int> values, int slotId)
4472 {
4473 if (values && values.Count() != 0)
4474 {
4475 set<int> passThis;
4477 GetInventory().GetCurrentInventoryLocation(lcn);
4478 if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis))
4479 {
4480 m_AttachmentExclusionMaskChildren.InsertSet(passThis);
4481 EntityAI parent = GetHierarchyParent();
4482 if (parent)
4483 parent.PropagateExclusionValueRecursive(passThis,lcn.GetSlot());
4484 }
4485 }
4486 }
4487
4488 private void ClearExclusionValueRecursive(set<int> values, int slotId)
4489 {
4490 if (values && values.Count() != 0)
4491 {
4492 set<int> passThis;
4493 InventoryLocation lcn = new InventoryLocation();
4494 GetInventory().GetCurrentInventoryLocation(lcn);
4495 if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis))
4496 {
4497 int count = passThis.Count();
4498 for (int i = 0; i < count; ++i)
4499 {
4500 m_AttachmentExclusionMaskChildren.RemoveItem(passThis[i]);
4501 }
4502 EntityAI parent = GetHierarchyParent();
4503 if (parent)
4504 parent.ClearExclusionValueRecursive(passThis,lcn.GetSlot());
4505 }
4506 }
4507 }
4508
4510 set<int> GetAttachmentExclusionMaskAll(int slotId)
4511 {
4512 set<int> values = new set<int>();
4513 set<int> slotValues = GetAttachmentExclusionMaskSlot(slotId);
4514 if (slotValues)
4515 values.InsertSet(slotValues);
4516 values.InsertSet(m_AttachmentExclusionMaskGlobal);
4517 values.InsertSet(m_AttachmentExclusionMaskChildren);
4518
4519 return values;
4520 }
4521
4523 set<int> GetAttachmentExclusionMaskSlot(int slotId)
4524 {
4525 return m_AttachmentExclusionSlotMap.Get(slotId);
4526 }
4527
4529 set<int> GetAttachmentExclusionMaskGlobal()
4530 {
4531 return m_AttachmentExclusionMaskGlobal;
4532 }
4533
4535 set<int> GetAttachmentExclusionMaskChildren()
4536 {
4537 return m_AttachmentExclusionMaskChildren;
4538 }
4539
4541 private bool HasInternalExclusionConflicts(int targetSlot)
4542 {
4543 set<int> targetSlotValues = GetAttachmentExclusionMaskSlot(targetSlot);
4544 if (targetSlotValues) //can be null, if so, no conflict
4545 {
4546 set<int> additionalValues = new set<int>(); //NOT slot values
4547 additionalValues.InsertSet(GetAttachmentExclusionMaskGlobal());
4548 additionalValues.InsertSet(GetAttachmentExclusionMaskChildren());
4549
4550 if (additionalValues.Count() > 0)
4551 {
4552 int countTarget = targetSlotValues.Count();
4553 for (int i = 0; i < countTarget; i++)
4554 {
4555 if (additionalValues.Find(targetSlotValues[i]) != -1)
4556 {
4557 return true;
4558 }
4559 }
4560 }
4561 }
4562 return false;
4563 }
4564
4566 protected bool IsExclusionFlagPresent(set<int> values)
4567 {
4568 int slotId;
4569 string slotName;
4570 GetInventory().GetCurrentAttachmentSlotInfo(slotId,slotName); //if currently attached, treat it accordingly
4571
4572 set<int> currentSlotValuesAll = GetAttachmentExclusionMaskAll(slotId);
4573 int count = values.Count();
4574 for (int i = 0; i < count; ++i)
4575 {
4576 if (currentSlotValuesAll.Find(values[i]) != -1)
4577 return true;
4578 }
4579 return false;
4580 }
4581
4583 protected bool IsExclusionFlagPresentRecursive(set<int> values, int targetSlot)
4584 {
4585 if (values && values.Count() != 0)
4586 {
4588 GetInventory().GetCurrentInventoryLocation(lcn);
4589 EntityAI parent = GetHierarchyParent();
4590 set<int> passThis;
4591 if (CheckExclusionAccessCondition(lcn.GetSlot(),targetSlot, values, passThis))
4592 {
4593 if (parent && parent != this) //we reached root if false
4594 {
4595 return parent.IsExclusionFlagPresentRecursive(passThis,lcn.GetSlot());
4596 }
4597 }
4598 return IsExclusionFlagPresent(passThis);
4599 }
4600
4601 return false;
4602 }
4603
4605 protected bool CheckExclusionAccessCondition(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue)
4606 {
4607 bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND;
4608 bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND;
4609
4610 if (occupiedException)
4611 {
4612 adjustedValue = value;
4613 return false;
4614 }
4615
4616 if (targetException)
4617 {
4618 adjustedValue = null;
4619 return false;
4620 }
4621
4622 AdjustExclusionAccessCondition(occupiedSlot,targetSlot,value,adjustedValue);
4623 return adjustedValue.Count() != 0;
4624 }
4625
4627 protected void AdjustExclusionAccessCondition(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue)
4628 {
4629 adjustedValue = value;
4630 }
4631
4633 protected bool CheckExclusionAccessPropagation(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue)
4634 {
4635 bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND;
4636 bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND || targetSlot == InventorySlots.INVALID;
4637
4638 if (targetException)
4639 {
4640 adjustedValue = null;
4641 return false;
4642 }
4643
4644 AdjustExclusionAccessPropagation(occupiedSlot,targetSlot,value,adjustedValue);
4645 return adjustedValue.Count() != 0;
4646 }
4647
4649 protected void AdjustExclusionAccessPropagation(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue)
4650 {
4651 AdjustExclusionAccessCondition(occupiedSlot,testedSlot,value,adjustedValue);
4652 }
4653
4655 bool CheckAttachmentReceiveExclusion(EntityAI attachment, int slotId)
4656 {
4657 EntityAI currentAtt = GetInventory().FindAttachment(slotId);
4658 bool hasInternalConflict = attachment.HasInternalExclusionConflicts(slotId);
4659 set<int> diff;
4660 InventoryLocation curLoc = new InventoryLocation();
4661 if (currentAtt) //probably a swap or same-type swap
4662 {
4663 diff = attachment.GetAttachmentExclusionMaskAll(slotId);
4664 diff.RemoveItems(currentAtt.GetAttachmentExclusionMaskAll(slotId));
4665 if (diff.Count() == 0)
4666 {
4667 return !hasInternalConflict;
4668 }
4669 else
4670 {
4671 return !hasInternalConflict && !IsExclusionFlagPresentRecursive(diff,slotId);
4672 }
4673 }
4674 else if (attachment.GetInventory().GetCurrentInventoryLocation(curLoc) && curLoc.GetType() == InventoryLocationType.ATTACHMENT)
4675 {
4676 EntityAI rootOwner = attachment.GetHierarchyRoot();
4677 if (rootOwner && rootOwner == this.GetHierarchyRoot()) //attachment within the same exclusion hierarchy context
4678 {
4679 diff = attachment.GetAttachmentExclusionMaskAll(slotId);
4680 diff.RemoveItems(attachment.GetAttachmentExclusionMaskAll(curLoc.GetSlot()));
4681 if (diff.Count() == 0)
4682 {
4683 return !hasInternalConflict;
4684 }
4685 else
4686 {
4687 return !hasInternalConflict && !IsExclusionFlagPresentRecursive(diff,slotId);
4688 }
4689 }
4690 }
4691 return !hasInternalConflict && !IsExclusionFlagPresentRecursive(attachment.GetAttachmentExclusionMaskAll(slotId),slotId);
4692 }
4693
4695 {
4696 return false;
4697 }
4698
4700 {
4701 return null;
4702 }
4703
4707
4709};
4710
4711#ifdef DEVELOPER
4712void SetDebugDeveloper_item(Object entity)//without a setter,the place where the setting happens is near impossible to find as way too many hits for "_item" exist
4713{
4714 if (entity)
4715 entity.SetDebugItem();
4716
4717}
4718Object _item;//watched item goes here(LCTRL+RMB->Watch)
4719#endif
enum EWetnessLevel BUSH_SOFT
enum EWetnessLevel FULL
enum EWetnessLevel HIDE_HANDS_SLOT
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition entityai.c:104
enum EWetnessLevel UPDATE
enum EWetnessLevel HIDE_VICINITY
enum EWetnessLevel DETACHING
enum EWetnessLevel BUSH_HARD
enum EWetnessLevel LeftFrontLimb
enum EWetnessLevel REMOVE
enum EWetnessLevel RECURSIVE_ADD
enum EWetnessLevel TREE_HARD
Param3 int
enum EWetnessLevel TREE_SOFT
Param3 TSelectableActionInfo
enum EWetnessLevel HIDE_PLAYER_CONTAINER
enum EWetnessLevel RightFrontLimb
enum EWetnessLevel LeftBackLimb
EWetnessLevel
Definition entityai.c:2
@ DAMP
Definition entityai.c:4
@ DRENCHED
Definition entityai.c:7
@ WET
Definition entityai.c:5
@ DRY
Definition entityai.c:3
@ SOAKING
Definition entityai.c:6
enum EWetnessLevel ADD
enum EWetnessLevel ATTACHING
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
class LogManager EntityAI
eBleedingSourceType GetType()
override bool IsDestructionBehaviour()
Definition animalbase.c:126
override bool IsSelfAdjustingTemperature()
Definition animalbase.c:59
override bool ReplaceOnDeath()
Definition animalbase.c:260
class Animal_CapraHircus extends AnimalBase GetDestructionBehaviour()
Definition animalbase.c:121
override bool IsRefresherSignalingViable()
Definition animalbase.c:54
override void OnDamageDestroyed(int oldLevel)
Definition animalbase.c:145
override bool KeepHealthOnReplace()
Definition animalbase.c:275
vector GetOrientation()
map m_Player
const int ECE_OBJECT_SWAP
const int RF_ORIGINAL
const int ECE_PLACE_ON_SURFACE
const int RF_DEFAULT
PlayerSpawnPreset slotName
represents base for cargo storage for entities
Definition cargo.c:7
bool IsWorking()
Energy manager: Returns true if this device is working right now.
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
bool IsSwitchedOn()
Energy manager: Returns state of the switch. Whenever the device is working or not does not matter....
Definition debug.c:2
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.
override int GetHideIconMask()
Definition transport.c:293
Definition camera.c:2
bool PredictiveDropEntity(notnull EntityAI item)
Definition entityai.c:2083
bool CanLoadAttachment(EntityAI attachment)
Definition entityai.c:1456
void LogError(string msg, string fnc_name="n/a")
LogError.
Definition entityai.c:491
void OnSwitchOff()
Energy manager event: Called when the device is switched OFF.
Definition entityai.c:3441
void InitLegacySlotExclusionValuesImplicit()
adding base one-directional relations between headgear, masks, eyewear, and headstraps (exception)
Definition entityai.c:4298
bool PredictiveTakeEntityToTargetAttachment(notnull EntityAI target, notnull EntityAI item)
Definition entityai.c:2032
float GetWetWeightModifier()
Definition entityai.c:3525
void SetStoreLoadedQuantity(float value)
void OnEnergyConsumed()
Energy manager event: Called when energy was consumed on this device. ALWAYS CALL super....
Definition entityai.c:3459
proto native EntityAI GetHierarchyParent()
Returns direct parent of current entity.
bool IsZombie()
Definition entityai.c:734
void TransferVariablesFloat(array< float > float_vars)
Definition entityai.c:3149
proto native Man GetHierarchyRootPlayer()
Returns root of current hierarchy cast to Man.
EntityAI GetAttachmentByType(typename type)
Get attached entity by type.
Definition entityai.c:2101
bool m_RoofAbove
Definition entityai.c:113
bool IsEmpty()
is this container empty or not, checks both cargo and attachments
Definition entityai.c:660
vector GetUniversalTemperatureSourcePosition()
Definition entityai.c:4186
void InterpolateTempData(TemperatureDataInterpolated data)
Definition entityai.c:2443
float GetQuantity()
Definition entityai.c:2244
void SoundSoftBushFallingPlay()
Definition entityai.c:4080
bool ServerTakeEntityToTargetAttachment(notnull EntityAI target, notnull EntityAI item)
Definition entityai.c:2043
bool CanCombineAttachment(notnull EntityAI e, int slot, bool stack_max_limit=false)
Definition entityai.c:1522
void HideSelection(string selection_name)
Hides selection of the given name. Must be configed in config.cpp and models.cfg.
Definition entityai.c:3356
bool CanDetachAttachment(EntityAI parent)
calls this->CanDetachAttachment(parent)
Definition entityai.c:1512
void ClearWeightDirty()
Definition entityai.c:3553
bool CanAssignToQuickbar()
Definition entityai.c:1792
bool CanReceiveAttachment(EntityAI attachment, int slotId)
calls this->CanReceiveAttachment(attachment)
Definition entityai.c:1444
float GetTemperatureFreezeTime()
Definition entityai.c:2502
bool CanBeTargetedByAI(EntityAI ai)
Definition entityai.c:749
int GetTurnableValveIndex(int pComponentIndex)
bool UseConfigInitTemperature()
Definition entityai.c:2280
bool CanBePlaced(Man player, vector position)
Definition entityai.c:630
void EEDelete(EntityAI parent)
Called right before object deleting.
Definition entityai.c:934
proto native float GetLifetimeMax()
Get max economy lifetime per instance - default is from DB (seconds).
int GetQuantityMax()
Definition entityai.c:2256
bool PredictiveTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition entityai.c:2048
ArrowManagerBase GetArrowManager()
Definition entityai.c:4699
float GetTemperatureInit()
Definition entityai.c:2462
void GetColor(out int r, out int g, out int b, out int a)
Definition entityai.c:2736
float m_VarTemperatureFreezeTime
Definition entityai.c:160
void ProcessInvulnerabilityCheck(string servercfg_param)
Definition entityai.c:3981
bool CanDisplayAttachmentSlot(string slot_name)
Definition entityai.c:1737
void DeleteOnClient()
Definition entityai.c:780
void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
void OnOwnSocketReleased(EntityAI device)
Energy manager event: When something is UNPLUGGED from this device.
Definition entityai.c:3453
void SetColor(int r, int g, int b, int a)
bool LocalTakeEntityToTargetCargoEx(notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Definition entityai.c:1989
ref TemperatureAccessComponent m_TAC
Definition entityai.c:165
float GetItemOverheatProgress()
Definition entityai.c:2670
float GetWeightSpecialized(bool forceRecalc=false)
returns weight of the entity in a way that's specific to the entity type and is internal to the weigh...
Definition entityai.c:3606
void SoundHardBushFallingPlay()
Definition entityai.c:4074
bool ServerTakeEntityToTargetAttachmentEx(notnull EntityAI target, notnull EntityAI item, int slot)
Definition entityai.c:2027
float ConvertNonlethalDamage(float damage)
DEPRECATED - for legacy purposes.
Definition entityai.c:457
void DeathUpdate()
Definition entityai.c:1104
void EEInventoryIn(Man newParentMan, EntityAI diz, EntityAI newParent)
string GetAttachmentSoundType()
returns sound type of attachment (used for clothing and weapons on DayZPlayerImplement,...
Definition entityai.c:3817
float GetWetMin()
Definition entityai.c:2194
float GetTemperatureFreezeThreshold()
Definition entityai.c:2492
bool PredictiveTakeEntityToTargetCargo(notnull EntityAI target, notnull EntityAI item)
Definition entityai.c:1952
proto native bool IsPilotLight()
void OnChildItemRemoved(InventoryItem item)
bool IsSetForDeletion()
Definition entityai.c:807
EntityAI SpawnEntityOnGround(string object_name, vector mat[4])
Definition entityai.c:2164
void CacheSkinningBloodInfectionChance(eAgents type)
Definition entityai.c:525
void SwitchItemSelectionTexture(EntityAI item, string slot_name)
void EEParentedFrom(EntityAI parent)
Called from 'IEntity.RemoveChild' or 'IEntity.AddChild' when hierarchy changes.
bool GetInventoryHandAnimation(notnull InventoryLocation loc, out int value)
Definition entityai.c:4159
ScriptInvoker GetOnItemRemovedFromCargo()
Definition entityai.c:1262
void AfterStoreLoad()
Called when entity is being loaded from DB or Storage (after all children loaded).
Definition entityai.c:1391
void SetFrozen(bool frozen)
Definition entityai.c:2540
bool CanBeBackstabbed()
Definition entityai.c:761
void RegisterTransportHit(Transport transport)
Definition entityai.c:4086
bool OnStoreLoad(ParamsReadContext ctx, int version)
Called when data is loaded from persistence (on server side).
Definition entityai.c:2989
float GetItemOverheatThreshold()
if undefined, max temperature used as default
Definition entityai.c:2654
EntityAI GetPairDevice()
void SetPersistentPairID(int id)
Definition entityai.c:4200
void OnIsUnplugged(EntityAI last_energy_source)
Energy manager event: Called when this device is UNPLUGGED from the energy source.
Definition entityai.c:3447
array< EntityAI > GetAttachmentsWithAttachments()
Definition entityai.c:692
bool HasAnyCargo()
is this container empty or not, checks only cargo
Definition entityai.c:678
ScriptInvoker GetOnSetLock()
Definition entityai.c:1290
void SetFreezeThawProgress(float val)
0->1 when freezing, 1->0 when thawing
Definition entityai.c:2525
bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
Definition entityai.c:2173
void OnBinLoadItemsDropped()
Called when an item fails to get loaded into the inventory of an entity and gets dropped.
Definition entityai.c:1396
int GetWeight()
Definition entityai.c:3548
void OnDebugSpawnEx(DebugSpawnParams params)
Definition entityai.c:3902
bool CanLoadItemIntoCargo(EntityAI item)
calls this->CanLoadItemIntoCargo(item), is called on server start when loading in the storage
Definition entityai.c:1568
proto native void SetRequiredSimulation(bool req)
bool m_CanDisplayWeight
Definition entityai.c:136
ref ScriptInvoker m_OnAttachmentSetLock
Definition entityai.c:194
EntityAI SpawnEntityOnGroundPos(string object_name, vector pos)
Definition entityai.c:2153
override TStringArray GetHiddenSelectionsMaterials()
Returns the hiddenSelectionsMaterials array from the object's config.
Definition entityai.c:2820
override TStringArray GetHiddenSelections()
Returns the hiddenSelectionsTextures array from the object's config.
Definition entityai.c:2802
float GetHeatPermeabilityCoef()
Returns temperature change speed multiplier for this item and all its children (multiplicative intera...
Definition entityai.c:2487
bool IsIgnoredByConstruction()
Definition entityai.c:744
float m_VarTemperatureThawThreshold
Definition entityai.c:159
void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition entityai.c:1117
float HeightCheckOverride()
used as script-side override of distance for specific height checks
Definition entityai.c:648
Shape DebugBBoxDraw()
Definition entityai.c:3325
proto native void PlaceOnSurfaceRotated(out vector trans[4], vector pos, float dx=0, float dz=0, float fAngle=0, bool align=false)
void SerializeNumericalVars(array< float > floats_out)
Definition entityai.c:3240
int GetCleanness()
Definition entityai.c:2761
void SetAttachmentExclusionMaskSlot(int slotId, set< int > values)
sets values for specific slot
Definition entityai.c:4461
float m_PreviousRoofTestTime
Definition entityai.c:139
void InitTemperature()
Definition entityai.c:2285
ScriptInvoker GetOnKilledInvoker()
Definition entityai.c:1325
EntityAI SpawnInInventoryOrGroundPos(string object_name, GameInventory inv, vector pos)
Definition entityai.c:2137
void SetStoreLoad(bool value)
ScriptInvoker GetOnAttachmentReleaseLock()
Definition entityai.c:1311
void SetBayonetAttached(bool pState, int slot_idx=-1)
Definition entityai.c:4004
bool CanReleaseFromHands(EntityAI handheld)
calls this->CanReleaseFromHands(handheld)
Definition entityai.c:1717
bool TranslateSlotFromSelection(string selection_name, out int slot_id)
Definition entityai.c:4165
override TStringArray GetHiddenSelectionsTextures()
Returns the hiddenSelectionsTextures array from the object's config.
Definition entityai.c:2811
bool IsPrepareToDelete()
Definition entityai.c:843
bool m_Initialized
Definition entityai.c:144
bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition entityai.c:3657
float GetInventoryAndCargoWeight(bool forceRecalc=false)
Definition entityai.c:3580
proto native void RegisterNetSyncVariableFloat(string variableName, float minValue=0, float maxValue=0, int precision=1)
registers float variable synchronized over network
bool CanSwapItemInCargo(EntityAI child_entity, EntityAI new_entity)
calls this->CanSwapItemInCargo(child_entity, new_entity)
Definition entityai.c:1590
override EntityAI ProcessMeleeItemDamage(int mode=0)
Definition entityai.c:3963
void RemoveItemVariable(int variable)
Removes variable from variable mask, making it appear as though the variable has never been changed f...
Definition entityai.c:3144
void IncreaseLifetimeUp()
Reset economy lifetime to default across entity hierarchy all the way to the topmost entity.
Definition entityai.c:3390
void EEAmmoChanged()
Definition entityai.c:1022
void OnIgnitedThisFailed(EntityAI fire_source)
Executed on Server when some item failed to ignite this one.
Definition entityai.c:606
float GetWeightEx(bool forceRecalc=false)
returns overall weight of the entity, 'forceRecalc = true' is meant to be used only when debugging,...
Definition entityai.c:3613
void EEItemDetached(EntityAI item, string slot_name)
Definition entityai.c:1173
bool IsValveTurnable(int pValveIndex)
void OnDebugButtonPressServer(int button_index)
Definition entityai.c:3322
bool GetIsFrozen()
Definition entityai.c:2535
proto native GameInventory GetInventory()
bool GetCookingTargetTemperature(out float temperature)
specifically for cooking system, to get heat source target temperatures
Definition entityai.c:2478
float m_VarHeatPermeabilityCoef
Definition entityai.c:163
void SetTemperatureMax()
presumably for debug purposes?
Definition entityai.c:2451
ref ScriptInvoker m_OnKilledInvoker
Definition entityai.c:200
void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
bool LocalTakeEntityToTargetCargo(notnull EntityAI target, notnull EntityAI item)
Definition entityai.c:1959
bool LocalTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition entityai.c:2055
void OnInitEnergy()
Energy manager event: Object's initialization. Energy Manager is fully initialized by this point.
Definition entityai.c:3456
bool IsTwoHandedBehaviour()
returns item behaviour of item (more in ItemBase)
Definition entityai.c:3835
void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution).
bool LocalTakeEntityToCargo(notnull EntityAI item)
Definition entityai.c:1943
string ChangeIntoOnAttach(string slot)
Definition entityai.c:3840
bool CanReleaseCargo(EntityAI cargo)
calls this->CanReleaseCargo(cargo)
Definition entityai.c:1608
void OnStoreSave(ParamsWriteContext ctx)
Engine calls this function to collect data from entity to store for persistence (on server side).
Definition entityai.c:2925
float GetStoreLoadedQuantity()
Definition entityai.c:2753
ref ScriptInvoker m_OnSetLock
Definition entityai.c:190
void UnpairRemote()
bool IsPlayer()
Definition entityai.c:724
ref ScriptInvoker m_OnItemDetached
Definition entityai.c:178
void OnPlacementCancelled(Man player)
void RemoveAllAgents()
bool DoPlacingHeightCheck()
Do the roof check when placing this?
Definition entityai.c:642
proto native void CreateAndInitInventory()
void OnDebugSpawn()
Definition entityai.c:3907
void OnWorkStart()
Energy manager event: Called only once when this device starts doing its work.
Definition entityai.c:3429
bool HasTurnableValveBehavior()
Turnable Valve behaviour.
bool PredictiveTakeEntityToCargoEx(notnull EntityAI item, int idx, int row, int col)
Put item into into cargo on specific cargo location.
Definition entityai.c:1970
bool PredictiveTakeEntityToCargo(notnull EntityAI item)
Put item into into cargo.
Definition entityai.c:1936
ScriptInvoker GetOnItemMovedInCargo()
Definition entityai.c:1269
void EECargoMove(EntityAI item)
Definition entityai.c:1234
bool IsUniversalTemperatureSource()
Universal Temperature Sources Helpers.
Definition entityai.c:4171
void SetTemperatureEx(TemperatureData data)
sets temperature, handles base overheating and freezing state progression logics
Definition entityai.c:2342
bool PredictiveTakeEntityToTargetAttachmentEx(notnull EntityAI target, notnull EntityAI item, int slot)
Definition entityai.c:2016
bool LocalTakeEntityToTargetInventory(notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
Definition entityai.c:1925
void SetFromProjectile(ProjectileStoppedInfo info)
Definition entityai.c:4704
proto native void RegisterNetSyncVariableBoolSignal(string variableName)
when bool variable is true, it's sent to clients and become false again
proto native owned string GetObjectMaterial(int index)
void SetWetMax()
bool m_IsFrozen
Definition entityai.c:167
bool IsManagingArrows()
Definition entityai.c:4694
set< int > GetAttachmentExclusionInitSlotValue(int slotId)
override this to modify slot behavior for specific items, or just set 'm_AttachmentExclusionMaskGloba...
Definition entityai.c:4251
void OnWork(float consumed_energy)
Energy manager event: Called every device update if its supposed to do some work. The update can be e...
Definition entityai.c:3432
void CombineItemsClient(EntityAI entity2, bool use_stack_max=false)
Definition entityai.c:1539
void DebugDirectionDelete()
Definition entityai.c:3350
bool IsSkinned()
Skinning.
Definition entityai.c:497
static EWetnessLevel GetWetLevelInternal(float wetness)
Definition entityai.c:2216
void OnIsPlugged(EntityAI source_device)
Energy manager event: Called when this device is plugged into some energy source.
Definition entityai.c:3444
proto native void RegisterNetSyncVariableBool(string variableName)
registers bool variable synchronized over network
ref ScriptInvoker m_OnViewIndexChanged
Definition entityai.c:188
proto native void SetObjectMaterial(int index, string mat_name)
Change material in hiddenSelections.
Shape DebugDirectionDraw(float distance=1)
Definition entityai.c:3340
UTemperatureSource GetUniversalTemperatureSource()
Definition entityai.c:4176
int GetAgents()
Definition entityai.c:711
int GetQuantityMin()
Definition entityai.c:2261
bool CanBeFSwaped()
Definition entityai.c:1517
void DeleteSafe()
Definition entityai.c:786
void RefreshTemperatureAccess(TemperatureData data)
refreshes access without setting temperature, keeps the source locked in
Definition entityai.c:2432
bool HasWetness()
Definition entityai.c:2204
bool DisassembleOnLastDetach()
Definition entityai.c:566
float m_VarTemperatureInit
Definition entityai.c:155
void OnItemOverheatStart()
override to implement desired overheat behavior on entity
bool ServerTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition entityai.c:2059
void EEItemAttached(EntityAI item, string slot_name)
Definition entityai.c:1133
void EEOnAfterLoad()
Called when entity is part of "connected system" and being restored after load.
Definition entityai.c:1353
int GetButtstockAttachmentIdx()
Definition entityai.c:4010
bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Definition entityai.c:1530
proto native void UpdateNetSyncVariableFloat(string variableName, float minValue=0, float maxValue=0, int precision=1)
void OnWasDetached(EntityAI parent, int slot_id)
Definition entityai.c:1817
proto native void SetSimpleHiddenSelectionState(int index, bool state)
Simple hidden selection state; 0 == hidden.
void ExecuteActionsConnectedToValve(int pValveIndex)
bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
void DeleteSave()
Definition entityai.c:802
string CanBePlacedFailMessage(Man player, vector position)
Method which returns message why object can't be placed at given position.
Definition entityai.c:636
void OnIgnitedTarget(EntityAI target_item)
Executed on Server when this item ignites some target item.
Definition entityai.c:588
bool CanBeSkinnedWith(EntityAI tool)
Definition entityai.c:508
bool CanReceiveItemIntoHands(EntityAI item_to_hands)
calls this->CanReceiveItemIntoHands(item_to_hands)
Definition entityai.c:1652
void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Definition entityai.c:1386
bool CanDisplayAttachmentSlot(int slot_id)
Definition entityai.c:1747
bool IgnoreOutOfReachCondition()
Definition entityai.c:1808
int m_ViewIndex
Definition entityai.c:3716
bool LocalTakeEntityAsAttachment(notnull EntityAI item)
Definition entityai.c:2074
bool IsOneHandedBehaviour()
returns item behaviour of item (more in ItemBase)
Definition entityai.c:3829
ref ScriptInvoker m_OnItemMovedInCargo
Definition entityai.c:184
void OnBeforeTryDelete()
void EECargoIn(EntityAI item)
Definition entityai.c:1208
void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
int GetMeleeTargetType()
value is related to EMeleeTargetType
Definition entityai.c:3811
array< float > GetVariablesFloat()
Definition entityai.c:3154
void OnIgnitedTargetFailed(EntityAI target_item)
Executed on Server when this item failed to ignite target item.
Definition entityai.c:600
bool IsSplitable()
returns just the configured 'canBeSplit' bool
Definition entityai.c:666
bool HasButtstockAttached()
Definition entityai.c:4009
proto native void UpdateNetSyncVariableInt(string variableName, float minValue=0, float maxValue=0)
array< EntityAI > GetAttachmentsWithCargo()
Definition entityai.c:687
void DeSerializeNumericalVars(array< float > floats)
Definition entityai.c:3254
int GetViewIndex()
Returns item preview index !!!! IF OVERRIDING with more dynamic events call GetOnViewIndexChanged() i...
Definition entityai.c:3730
void OnOwnSocketTaken(EntityAI device)
Energy manager event: When something is plugged into this device.
Definition entityai.c:3450
bool IsPreparedToDelete()
Definition entityai.c:829
bool ServerTakeEntityToTargetCargo(notnull EntityAI target, notnull EntityAI item)
Definition entityai.c:1963
string GetDefaultHitPositionComponent()
returns default hit position component name for the Entity (overriden by type if needed - used mainly...
Definition entityai.c:3792
bool CanReleaseAttachment(EntityAI attachment)
calls this->CanReleaseAttachment(attachment)
Definition entityai.c:1484
bool LocalTakeEntityToInventory(FindInventoryLocationType flags, notnull EntityAI item)
Definition entityai.c:1910
proto native bool IsRequiredSimulation()
override bool IsHologram()
Definition entityai.c:1690
void AdjustExclusionAccessPropagation(int occupiedSlot, int testedSlot, set< int > value, inout set< int > adjustedValue)
if we want to filter propagation specifically; DO NOT override unless you know what you are doing.
Definition entityai.c:4649
void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
Definition entityai.c:3320
void EEKilled(Object killer)
called on server when the entity is killed
Definition entityai.c:1078
EntityAI GetAttachmentByConfigTypeName(string type)
Get attached entity by config type name.
Definition entityai.c:2117
float GetTemperatureThawTime()
Definition entityai.c:2507
void ClearInventory()
bool IsTargetIgnitionSuccessful(EntityAI item_target)
Final evaluation just before the target item is actually ignited. Evaluated on Server.
Definition entityai.c:612
proto native void IncreaseLifetime()
Reset economy lifetime to default (seconds).
bool KeepHealthOnReplace()
Definition entityai.c:1099
bool TryDelete()
Definition entityai.c:848
bool CanAssignAttachmentsToQuickbar()
Definition entityai.c:1800
void AddWet(float value)
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
Definition entityai.c:943
void InsertAgent(int agent, float count=1)
ref ScriptInvoker m_OnItemAddedIntoCargo
Definition entityai.c:180
void AddTemperature(float value)
Definition entityai.c:2335
void OnRemovedFromCargo(EntityAI container)
Called when this item exits cargo of some container.
Definition entityai.c:1341
void OnFreezeStateChangeServer()
proto native float GetLifetime()
Get remaining economy lifetime (seconds).
int m_VariablesMask
Definition entityai.c:151
proto native owned string GetObjectTexture(int index)
bool IsHeavyBehaviour()
returns item behaviour of item (more in ItemBase)
Definition entityai.c:3823
bool IsZombieMilitary()
Definition entityai.c:739
float GetSkinningBloodInfectionChance(eAgents type)
Definition entityai.c:516
void OnIgnitedThis(EntityAI fire_source)
Executed on Server when some item ignited this one.
Definition entityai.c:594
bool IsCookware()
Definition entityai.c:576
float m_VarTemperatureMax
Definition entityai.c:157
void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition entityai.c:1027
void SetVariableMask(int variable)
Definition entityai.c:3134
void OnSwitchOn()
Energy manager event: Called when the device is switched on.
Definition entityai.c:3438
bool IsAnimal()
Definition entityai.c:729
bool CanDropEntity(notnull EntityAI item)
Returns if item can be dropped out from this entity.
Definition entityai.c:2132
bool IsTakeable()
Definition entityai.c:1829
float GetTemperatureMin()
Definition entityai.c:2467
void SetItemOverheatProgress(float val, float deltaTime=0)
Definition entityai.c:2675
bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Reads from storage CTX.
Definition entityai.c:3212
bool PredictiveTakeEntityToTargetInventory(notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
Definition entityai.c:1918
ScriptInvoker GetOnItemAttached()
Definition entityai.c:1241
void OnDamageDestroyed(int oldLevel)
Called when the health gets to the min value, 'oldLevel' is previous health level,...
float m_ElapsedSinceLastUpdate
Definition entityai.c:138
void OnWorkStop()
Energy manager event: Called when the device stops working (was switched OFF or ran out of energy).
Definition entityai.c:3435
bool CanIgniteItem(EntityAI ignite_target=NULL)
Override this method and check if the given item can be ignited right now by this one....
Definition entityai.c:552
ScriptInvoker GetOnItemAddedIntoCargo()
Definition entityai.c:1255
bool HasQuantity()
Definition entityai.c:2237
ref ScriptInvoker m_OnItemAttached
Definition entityai.c:176
RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Remotely controlled devices helpers.
float m_VarTemperature
Definition entityai.c:154
float GetWetInit()
Definition entityai.c:2199
bool ServerTakeEntityToCargo(notnull EntityAI item)
Definition entityai.c:1947
ref ScriptInvoker m_OnItemFlipped
Definition entityai.c:186
bool CanSaveItemInHands(EntityAI item_in_hands)
Definition entityai.c:1695
UTemperatureSource m_UniversalTemperatureSource
Definition entityai.c:141
bool CanBeIgnitedBy(EntityAI igniter=NULL)
Override this method so it checks whenever this item can be ignited right now or not....
Definition entityai.c:546
override void EOnFrame(IEntity other, float timeSlice)
Definition entityai.c:3282
ScriptInvoker GetOnHitByInvoker()
Definition entityai.c:1318
bool ServerDropEntity(notnull EntityAI item)
Definition entityai.c:2093
proto native void DestroyInventory()
bool LocalTakeEntityToTargetAttachmentEx(notnull EntityAI target, notnull EntityAI item, int slot)
Definition entityai.c:2023
void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition entityai.c:962
void SetViewIndex(int index)
Sets item preview index.
Definition entityai.c:3719
void ShowSelection(string selection_name)
Shows selection of the given name. Must be configed in config.hpp and models.cfg.
Definition entityai.c:3365
string GetDebugText()
Definition entityai.c:3296
void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
array< string > GetSuitableFinisherHitComponents()
Definition entityai.c:3798
void OnCEUpdate()
Central economy calls this function whenever going over all the entities.
Definition entityai.c:3866
bool IsBeingPlaced()
Definition entityai.c:1685
void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
bool ReplaceOnDeath()
Definition entityai.c:1089
void SetAsSkinned()
Definition entityai.c:502
float GetWet()
Definition entityai.c:2184
void HandleFreezingProgression(float deltaHeat, TemperatureData data)
Definition entityai.c:2556
proto native void SetLifetimeMax(float fLifeTime)
Set (override) max economy lifetime per entity instance (seconds).
void OnHologramBeingPlaced(Man player)
DamageZoneMap GetEntityDamageZoneMap()
Definition entityai.c:462
void CheckForDestroy()
Definition entityai.c:835
bool ServerTakeEntityToTargetCargoEx(notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Definition entityai.c:1993
void SetTemperature(float value, bool allow_client=false)
not really deprecated, but missing context info from TemperatureData. Default values used instead.
Definition entityai.c:2323
void OnEnergyAdded()
Energy manager event: Called when energy was added on this device. ALWAYS CALL super....
Definition entityai.c:3462
bool IsItemOverheated()
Definition entityai.c:2665
ref ScriptInvoker m_OnHitByInvoker
Definition entityai.c:198
void OnItemOverheat(float deltaTime)
string GetInvulnerabilityTypeString()
Definition entityai.c:3976
bool PredictiveTakeEntityToTargetCargoEx(notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Definition entityai.c:1982
bool CheckAttachmentReceiveExclusion(EntityAI attachment, int slotId)
checks specifically for att. exclusion conflicts before att. receive
Definition entityai.c:4655
proto native CEItemProfile GetEconomyProfile()
Get economy item profile (if assigned, otherwise null).
bool CheckExclusionAccessCondition(int occupiedSlot, int targetSlot, set< int > value, inout set< int > adjustedValue)
Definition entityai.c:4605
void DebugDirectionSetColor(int color)
Definition entityai.c:3345
bool LocalTakeEntityToTargetAttachment(notnull EntityAI target, notnull EntityAI item)
Definition entityai.c:2039
proto native bool IsSimpleHiddenSelectionVisible(int index)
float GetTemperature()
Definition entityai.c:2457
void SaveVariables(ParamsWriteContext ctx)
Definition entityai.c:3161
void SetCleanness(int value, bool allow_client=false)
bool LocalTakeEntityToCargoEx(notnull EntityAI item, int idx, int row, int col)
Definition entityai.c:1977
bool CanHaveTemperature()
returns true used on selected items that have a temperature effect and can processes temperature chan...
Definition entityai.c:3844
bool ServerTakeEntityAsAttachmentEx(notnull EntityAI item, int slot)
Definition entityai.c:2011
void UpdateWeight(WeightUpdateType updateType=WeightUpdateType.FULL, float weightAdjustment=0)
float m_VarTemperatureThawTime
Definition entityai.c:161
float ConvertNonlethalDamage(float damage, DamageType damageType)
Definition entityai.c:451
proto native EntityAI GetHierarchyRoot()
Returns root of current hierarchy (for example: if this entity is in Backpack on gnd,...
void SwitchItemSelectionTextureEx(EItemManipulationContext context, Param par=null)
float HeightStartCheckOverride()
used as script-side override of start pos for specific height checks
Definition entityai.c:654
bool HasFlammableMaterial()
Override this method to return TRUE when this item has or can provide fire. Evaluated on server and c...
Definition entityai.c:540
bool IsExclusionFlagPresentRecursive(set< int > values, int targetSlot)
Gets flag from what is effectively an owner.
Definition entityai.c:4583
ComponentBodyStaging GetCompBS()
Use this to access Body Staging component on dead character. Returns NULL if the given object lacks s...
Definition entityai.c:3400
HiddenSelectionsData GetHiddenSelectionsData()
Definition entityai.c:2787
void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
void DebugBBoxSetColor(int color)
Definition entityai.c:3330
void AdjustExclusionAccessCondition(int occupiedSlot, int testedSlot, set< int > value, inout set< int > adjustedValue)
if we want to filter
Definition entityai.c:4627
string GetHitComponentForAI()
Returns hit component for the Entity (overriden for each Type - PlayerBase, DayZInfected,...
Definition entityai.c:3776
void LogWarning(string msg, string fnc_name="n/a")
LogWarning.
Definition entityai.c:485
string GetDeadItemName()
Definition entityai.c:1094
void SetWeightDirty()
Definition entityai.c:3559
ScriptInvoker GetOnViewIndexChanged()
Definition entityai.c:1283
void SoundHardTreeFallingPlay()
Definition entityai.c:4062
void AttemptDestructionBehaviour(int oldLevel, int newLevel, string zone)
Definition entityai.c:1049
void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
bool m_IsFrozenLocal
Definition entityai.c:168
proto native void RegisterNetSyncVariableInt(string variableName, int minValue=0, int maxValue=0)
registers int variable synchronized over network
void SetUniversalTemperatureSource(UTemperatureSource uts)
Definition entityai.c:4181
float GetConfigWeightModified()
Definition entityai.c:3530
bool CanItemOverheat()
Overheat time CAN be 0, GameConstants.TEMPERATURE_TIME_OVERHEAT_MIN is ignored if so.
Definition entityai.c:2648
void OnCargoChanged()
int GetBayonetAttachmentIdx()
Definition entityai.c:4006
ComponentEnergyManager GetCompEM()
Definition entityai.c:3410
void RemoveAllAgentsExcept(int agent_to_keep)
void SetTakeable(bool pState)
bool PredictiveTakeEntityToInventory(FindInventoryLocationType flags, notnull EntityAI item)
Put item anywhere into this entity (as attachment or into cargo, recursively).
Definition entityai.c:1903
proto native void SetObjectTexture(int index, string texture_name)
Change texture in hiddenSelections.
bool ServerTakeEntityToInventory(FindInventoryLocationType flags, notnull EntityAI item)
Definition entityai.c:1914
bool CanDisplayAnyAttachmentSlot()
Definition entityai.c:1755
float m_OverheatProgress
Definition entityai.c:171
void SetButtstockAttached(bool pState, int slot_idx=-1)
Definition entityai.c:4008
int GetTargetQuantityMax(int attSlotID=-1)
Definition entityai.c:2268
bool CanPutIntoHands(EntityAI parent)
calls this->CanPutIntoHands(parent)
Definition entityai.c:1706
bool IsSlotReserved(int slotID)
Definition entityai.c:1860
float m_VarTemperatureOverheatTime
Definition entityai.c:162
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Definition entityai.c:3465
int GetQuickBarBonus()
Definition entityai.c:2273
bool IsSelfAdjustingTemperature()
Definition entityai.c:3849
override void Delete()
Delete this object in next frame.
Definition entityai.c:774
bool CanDisplayWeight()
'displayWeight' in item config
Definition entityai.c:473
proto void GetPersistentID(out int b1, out int b2, out int b3, out int b4)
void SoundSoftTreeFallingPlay()
Definition entityai.c:4068
bool InitLegacyExclusionCheck()
Definition entityai.c:4270
bool IsVariableSet(int variable)
'true' if this variable has ever been changed from default
Definition entityai.c:3129
float GetSingleInventoryItemWeightEx()
Definition entityai.c:3641
bool CanReceiveItemIntoCargo(EntityAI item)
calls this->CanReceiveItemIntoCargo(item)
Definition entityai.c:1550
void ProcessVariables()
Definition entityai.c:3878
proto native void SwitchLight(bool isOn)
bool CanFreeze()
Definition entityai.c:2530
bool LoadVariables(ParamsReadContext ctx, int version=-1)
Definition entityai.c:3179
float GetWetMax()
Definition entityai.c:2189
EWetnessLevel GetWetLevel()
bool HasEnergyManager()
If this item has class EnergyManager in its config then it returns true. Otherwise returns false.
Definition entityai.c:3421
void ShowAllSelections()
Sets all animation values to 0, making them VISIBLE if they are configured in models....
Definition entityai.c:1421
bool CanSwitchDuringAttach(EntityAI parent)
Definition entityai.c:1474
bool CanBeSplit()
returns current splitability
Definition entityai.c:672
ScriptInvoker GetOnItemFlipped()
Definition entityai.c:1276
void HideAllSelections()
Sets all animation values to 1, making them INVISIBLE if they are configured in models....
Definition entityai.c:1403
void OnItemOverheatEnd()
note, that the deltaTime could be reverse-calculated and not totally accurate
void InitGlobalExclusionValues()
override to init part of the mask, independent of slot-specific behavior
bool IsBasebuildingKit()
Definition entityai.c:571
float GetFreezeThawProgress()
on server only
Definition entityai.c:2513
void SetPrepareToDelete()
Definition entityai.c:824
override bool IsEntityAI()
Definition entityai.c:717
void SetWet(float value, bool allow_client=false)
bool AreChildrenAccessible()
Definition entityai.c:1657
bool LocalDropEntity(notnull EntityAI item)
Definition entityai.c:2088
void OnInventoryInit()
Definition entityai.c:894
float GetQuantityNormalized()
Definition entityai.c:2251
void SetLiquidType(int value, bool allow_client=false)
bool CanRemoveFromHands(EntityAI parent)
calls this->CanRemoveFromHands(parent)
Definition entityai.c:1728
void OnChildItemReceived(InventoryItem item)
bool IsInventoryVisible()
Definition entityai.c:719
void OnPlacementStarted(Man player)
bool PlacementCanBeRotated()
Should return false if you want to disable hologram rotation.
Definition entityai.c:582
float GetItemOverheatTime()
any configured value >= 0 will simulate overheating
Definition entityai.c:2660
ScriptInvoker GetOnAttachmentSetLock()
Definition entityai.c:1304
bool CanDisplayAttachmentCategory(string category_name)
Definition entityai.c:1776
void EEInventoryOut(Man oldParentMan, EntityAI diz, EntityAI newParent)
Definition entityai.c:1010
proto native void SetAITargetCallbacks(AbstractAITargetCallbacks callbacks)
void OnFreezeStateChangeClient()
void OnWasAttached(EntityAI parent, int slot_id)
ref ScriptInvoker m_OnItemRemovedFromCargo
Definition entityai.c:182
void SetRoofAbove(bool state)
Definition entityai.c:703
float m_VarTemperatureMin
Definition entityai.c:156
void EECargoOut(EntityAI item)
Definition entityai.c:1221
void InitLegacySlotExclusionValuesDerived()
Definition entityai.c:4352
void InitLegacyConfigExclusionValues()
Definition entityai.c:4258
proto native void SetLifetime(float fLifeTime)
Set (override) remaining economy lifetime (seconds).
int GetHierarchyLevel(int lvl=0)
Definition entityai.c:886
EntityAI FindAttachmentBySlotName(string slot_name)
Definition entityai.c:1847
bool CanPutInCargo(EntityAI parent)
calls this->CanPutInCargo(parent)
Definition entityai.c:1579
bool IsFreezeThawProgressFinished()
on server only
Definition entityai.c:2519
void SetQuantityToMinimum()
bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
Final evaluation just before this item is actually ignited from fire source. Evaluated on Server.
Definition entityai.c:618
bool PredictiveTakeEntityAsAttachmentEx(notnull EntityAI item, int slot)
Returns if item can be added as attachment on specific slot. Note that slot index IS NOT slot ID!...
Definition entityai.c:2000
void RemoveAgent(int agent_id)
bool IsRoofAbove()
Definition entityai.c:698
bool IsExclusionFlagPresent(set< int > values)
checks 'this' if the incoming flag is present for the current state (slot behavior and others)
Definition entityai.c:4566
void SetAttachmentExclusionMaskGlobal(set< int > values)
Definition entityai.c:4454
void SetInvisibleRecursive(bool invisible, EntityAI parent=null, array< int > attachments=null)
Definition entityai.c:4012
bool LocalTakeEntityAsAttachmentEx(notnull EntityAI item, int slot)
Definition entityai.c:2007
void Log(string msg, string fnc_name="n/a")
Log.
Definition entityai.c:479
proto native void SetSynchDirty()
Sets object synchronization dirty flag, which signalize that object wants to be synchronized (take ef...
bool m_TransportHitRegistered
Definition entityai.c:145
void EEInit()
Called upon object creation.
Definition entityai.c:900
float m_VarTemperatureFreezeThreshold
Definition entityai.c:158
vector GetDefaultHitPosition()
Definition entityai.c:3804
bool m_PendingDelete
Definition entityai.c:143
bool PredictiveTakeEntityAsAttachment(notnull EntityAI item)
Put item into as attachment.
Definition entityai.c:2067
int GetHiddenSelectionIndex(string selection)
Returns index of the string found in cfg array 'hiddenSelections'. If it's not found then it returns ...
Definition entityai.c:2793
float m_FreezeThawProgress
Definition entityai.c:169
bool HasBayonetAttached()
Definition entityai.c:4005
bool IsLockedInSlot()
Definition entityai.c:1886
int GetLiquidType()
Definition entityai.c:2729
void DebugBBoxDelete()
Definition entityai.c:3335
void SetTemperatureDirect(float value, bool allow_client=false)
Definition entityai.c:2308
float GetLiquidThroughputCoef()
Returns liquid throughput coeficient.
Definition entityai.c:3971
void WriteVarsToCTX(ParamsWriteContext ctx)
Writes to storage CTX.
Definition entityai.c:3199
ref ScriptInvoker m_OnAttachmentReleaseLock
Definition entityai.c:196
float GetTemperatureThawThreshold()
Definition entityai.c:2497
void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition entityai.c:3643
ref ScriptInvoker m_OnReleaseLock
Definition entityai.c:192
void EEParentedTo(EntityAI parent)
Called from 'IEntity.AddChild'.
map< int, string > GetEntityDamageDisplayNameMap()
Definition entityai.c:467
void OnMovedInsideCargo(EntityAI container)
Called when this item enters cargo of some container.
Definition entityai.c:1334
void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
Definition entityai.c:1127
bool CanDisplayCargo()
Definition entityai.c:1784
void ClearSingleExclusionValueGlobal(EAttExclusions value)
to help with item staging exclusions
Definition entityai.c:4447
void OnVariablesSynchronized()
Called on clients after receiving synchronization data from server.
Definition entityai.c:3074
void OnAttachmentRuined(EntityAI attachment)
Called when some attachment of this parent is ruined. Called on server and client side.
void OnDebugButtonPressClient(int button_index)
Definition entityai.c:3321
proto native void SetPilotLight(bool isOn)
void AddSingleExclusionValueGlobal(EAttExclusions value)
to help with item staging exclusions
Definition entityai.c:4440
bool CanRemoveFromCargo(EntityAI parent)
calls this->CanRemoveFromCargo(parent)
Definition entityai.c:1619
void CombineItemsEx(EntityAI entity2, bool use_stack_max=false)
proto native void RegisterNetSyncVariableObject(string variableName)
registers object variable synchronized over network, only synchronizes if network id is assigned....
void OnMovedWithinCargo(EntityAI container)
Called when this item moves within cargo of some container.
Definition entityai.c:1347
override bool CanBeActionTarget()
Definition entityai.c:812
bool ServerTakeEntityToTargetInventory(notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
Definition entityai.c:1929
vector m_TransportHitVelocity
Definition entityai.c:146
void PairRemote(notnull EntityAI trigger)
void OnWetChanged(float newVal, float oldVal)
bool IsStoreLoad()
Definition entityai.c:2747
string GetDefaultHitComponent()
returns default hit component for the Entity (overriden for each Type - PlayerBase,...
Definition entityai.c:3784
ref DamageZoneMap m_DamageZoneMap
Definition entityai.c:130
bool IsIgnited()
Override this method and make it so it returns whenever this item is on fire right now or not....
Definition entityai.c:558
bool IsServerCheck(bool allow_client)
Definition entityai.c:2768
bool CheckExclusionAccessPropagation(int occupiedSlot, int targetSlot, set< int > value, inout set< int > adjustedValue)
special propagation contition
Definition entityai.c:4633
ScriptInvoker GetOnReleaseLock()
Definition entityai.c:1297
void HandleItemOverheating(float deltaHeat, TemperatureData data)
Definition entityai.c:2698
float GetTemperatureMax()
Definition entityai.c:2472
bool ServerTakeEntityAsAttachment(notnull EntityAI item)
Definition entityai.c:2078
bool CanPutAsAttachment(EntityAI parent)
calls this->CanPutAsAttachment(parent)
Definition entityai.c:1468
string ChangeIntoOnDetach()
Definition entityai.c:3841
ScriptInvoker GetOnItemDetached()
Definition entityai.c:1248
int GetSlotsCountCorrect()
Definition entityai.c:1838
script counterpart to engine's class Inventory
Definition inventory.c:81
proto native int GetAttachmentSlotsCount()
EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
Definition inventory.c:876
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native CargoBase GetCargo()
cargo
proto native bool GetSlotLock(int slot)
proto native int GetSlotId(int index)
attachments
void EEInit()
Definition inventory.c:845
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native int GetSlotIdCount()
proto native int GetAttachmentSlotId(int index)
proto native void ResetFlipCargo()
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)...
inventory for plain man/human
InventoryLocation.
provides access to slot configuration
Definition enmath.c:7
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
The class that will be instanced (moddable).
Definition gameplay.c:389
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.
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
Native class for boats - handles physics simulation.
Definition boat.c:32
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override bool IsInitialized()
override void DeferredInit()
map< string, ref array< string > > DamageZoneMap
DamageType
exposed from C++ (do not change)
DayZGame g_Game
Definition dayzgame.c:3942
EActions
Definition eactions.c:2
eAgents
Definition eagents.c:3
override bool IsCorpse()
EMeleeTargetType
const int MAX
Definition enconvert.c:27
proto string ToString()
float GetTemperature()
ERPCs
Definition erpcs.c:2
override bool IsPrepareToDelete()
override bool CanHaveTemperature()
Serializer ParamsReadContext
Definition gameplay.c:15
class LOD Object
EntityAI SpawnEntity(string object_name, notnull InventoryLocation inv_loc, int iSetupFlags, int iRotation)
Definition gameplay.c:1526
Serializer ParamsWriteContext
Definition gameplay.c:16
@ None
Definition enworld.c:73
const int COMP_TYPE_BODY_STAGING
Definition component.c:10
const int COMP_TYPE_COUNT
Definition component.c:12
const int COMP_TYPE_ENERGY_MANAGER
Definition component.c:9
const int COMP_TYPE_ETITY_DEBUG
Definition component.c:8
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
proto void DumpStack()
Prints current call stack (stack trace).
proto void Print(void var)
Prints content of variable to console/log.
enum ShapeType ErrorEx
bool IsPendingDeletion()
Get whether the Effect is queued up for being cleaned up.
Definition effect.c:260
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
const float MELEE_ITEM_DAMAGE
Definition constants.c:651
array< string > TStringArray
Definition enscript.c:712
EntityFlags
Entity flags.
Definition enentity.c:115
const int VARIABLE_TEMPERATURE
Definition constants.c:633
const float LIQUID_THROUGHPUT_DEFAULT
Definition constants.c:573
const string CFG_VEHICLESPATH
Definition constants.c:220
const string CFG_WEAPONSPATH
Definition constants.c:221
const string CFG_MAGAZINESPATH
Definition constants.c:222
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native bool dBodyIsActive(notnull IEntity ent)
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin).
const int SAT_DEBUG_ACTION
Definition constants.c:457
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
Object GetParent()
Get parent of the Effect.
Definition effect.c:422
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Icon x
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override void ProcessVariables()
Definition itembase.c:9548
float GetWeightSpecialized(bool forceRecalc=false)
Definition itembase.c:8423
override float GetTemperatureFreezeThreshold()
Definition itembase.c:9584
override float GetTemperatureFreezeTime()
Definition itembase.c:9608
override float GetTemperatureThawThreshold()
Definition itembase.c:9592
override EWetnessLevel GetWetLevel()
Definition itembase.c:8656
override float GetWetMax()
Definition itembase.c:8626
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Definition itembase.c:7919
override void WriteVarsToCTX(ParamsWriteContext ctx)
Definition itembase.c:7883
override float GetTemperatureThawTime()
Definition itembase.c:9616
override float GetSingleInventoryItemWeightEx()
Definition itembase.c:8409
override void DeSerializeNumericalVars(array< float > floats)
Definition itembase.c:7824
override float GetItemOverheatThreshold()
Definition itembase.c:9600
override void SerializeNumericalVars(array< float > floats_out)
Definition itembase.c:7788
override float GetWetMin()
Definition itembase.c:8631
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
override void OnWasDetached(EntityAI parent, int slot_id)
void TemperatureData(float val, ETemperatureAccessTypes accessType=ETemperatureAccessTypes.ACCESS_UNKNOWN, float time=-1, float timeCoef=1, float heatPermCoef=1)
override bool CanDisplayAttachmentSlot(int slot_id)
bool m_Initialized