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