DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
EntityAI.c
Go to the documentation of this file.
2{
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}
81
82class EntityAI extends Entity
83{
84 bool m_DeathSyncSent;
85 bool m_KilledByHeadshot;
86 bool m_PreparedToDelete = false;
87 bool m_RefresherViable = false;
88 bool m_WeightDirty = 1;
89 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
90 private ref set<int> m_AttachmentExclusionMaskGlobal; //additional mask values and simple item values. Independent of slot-specific behavior!
91 private ref set<int> m_AttachmentExclusionMaskChildren; //additional mask values and simple item values
92
93 ref DestructionEffectBase m_DestructionBehaviourObj;
94
95 ref KillerData m_KillerData;
96 private ref HiddenSelectionsData m_HiddenSelectionsData;
97
98 const int DEAD_REPLACE_DELAY = 2000;
99 const int DELETE_CHECK_DELAY = 100;
100
101 ref array<EntityAI> m_AttachmentsWithCargo;
102 ref array<EntityAI> m_AttachmentsWithAttachments;
103 ref InventoryLocation m_OldLocation;
104
105 protected ref DamageZoneMap m_DamageZoneMap;
106 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
107
108 float m_Weight;
109 float m_WeightEx;
110 float m_ConfigWeight = ConfigGetInt("weight");
111 protected bool m_CanDisplayWeight;
112 private float m_LastUpdatedTime;
113 protected float m_ElapsedSinceLastUpdate;
114
115 protected UTemperatureSource m_UniversalTemperatureSource;
116
117 bool m_PendingDelete = false;
118 bool m_Initialized = false;
119 bool m_TransportHitRegistered = false;
120 vector m_TransportHitVelocity;
121
122 //Called on item attached to this item (EntityAI item, string slot, EntityAI parent)
123 protected ref ScriptInvoker m_OnItemAttached;
124 //Called on item detached from this item (EntityAI item, string slot, EntityAI parent)
125 protected ref ScriptInvoker m_OnItemDetached;
126 //Called when an item is added to the cargo of this item (EntityAI item, EntityAI parent)
127 protected ref ScriptInvoker m_OnItemAddedIntoCargo;
128 //Called when an item is removed from the cargo of this item (EntityAI item, EntityAI parent)
129 protected ref ScriptInvoker m_OnItemRemovedFromCargo;
130 //Called when an item is moved around in the cargo of this item (EntityAI item, EntityAI parent)
131 protected ref ScriptInvoker m_OnItemMovedInCargo;
132 //Called when an item is flipped around in cargo (bool flip)
133 protected ref ScriptInvoker m_OnItemFlipped;
134 //Called when an items view index is changed
135 protected ref ScriptInvoker m_OnViewIndexChanged;
136 //Called when an location in this item is reserved (EntityAI item) - cargo
137 protected ref ScriptInvoker m_OnSetLock;
138 //Called when this item is unreserved (EntityAI item) - cargo
139 protected ref ScriptInvoker m_OnReleaseLock;
140 //Called when an location in this item is reserved (EntityAI item) - attachment
141 protected ref ScriptInvoker m_OnAttachmentSetLock;
142 //Called when this item is unreserved (EntityAI item) - attachment
143 protected ref ScriptInvoker m_OnAttachmentReleaseLock;
144
145 void EntityAI()
146 {
147 // Set up the Energy Manager
148 string type = GetType();
149 string param_access_energy_sys = "CfgVehicles " + type + " EnergyManager ";
150 bool is_electic_device = GetGame().ConfigIsExisting(param_access_energy_sys);
151
152 if (is_electic_device) // TO DO: Check if this instance is a hologram (advanced placement). If Yes, then do not create Energy Manager component.
153 {
154 CreateComponent(COMP_TYPE_ENERGY_MANAGER);
155 RegisterNetSyncVariableBool("m_EM.m_IsSwichedOn");
156 RegisterNetSyncVariableBool("m_EM.m_CanWork");
157 RegisterNetSyncVariableBool("m_EM.m_IsPlugged");
158 RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDLow");
159 RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDHigh");
160 RegisterNetSyncVariableFloat("m_EM.m_Energy");
161 }
162
163 // Item preview index
164 RegisterNetSyncVariableInt( "m_ViewIndex", 0, 99 );
165 // Refresher signalization
166 RegisterNetSyncVariableBool("m_RefresherViable");
167
168 m_AttachmentsWithCargo = new array<EntityAI>();
169 m_AttachmentsWithAttachments = new array<EntityAI>();
170 m_LastUpdatedTime = 0.0;
171 m_ElapsedSinceLastUpdate = 0.0;
172
173 m_CanDisplayWeight = ConfigGetBool("displayWeight");
174
175 InitDamageZoneMapping();
176 InitDamageZoneDisplayNameMapping();
177
178 m_HiddenSelectionsData = new HiddenSelectionsData( GetType() );
179
181 }
182
183 void ~EntityAI()
184 {
185
186 }
187
188 void DeferredInit()
189 {
190 m_Initialized = true;
191 }
192
193 bool IsInitialized()
194 {
195 return m_Initialized;
196 }
197
199 int GetHideIconMask()
200 {
201 return EInventoryIconVisibility.ALWAYS;
202 }
203
204 private ref ComponentsBank m_ComponentsBank;
205 ComponentEnergyManager m_EM; // This reference is necesarry due to synchronization, since it's impossible to synchronize values from a component :(
206
208 Component CreateComponent(int comp_type, string extended_class_name="")
209 {
210 return GetComponent(comp_type, extended_class_name);
211 }
212
214 Component GetComponent(int comp_type, string extended_class_name="")
215 {
216 if ( m_ComponentsBank == NULL )
217 m_ComponentsBank = new ComponentsBank(this);
218
219 return m_ComponentsBank.GetComponent(comp_type, extended_class_name);
220 }
221
223 bool DeleteComponent(int comp_type)
224 {
225 return m_ComponentsBank.DeleteComponent(comp_type);
226 }
227
228 string GetDestructionBehaviour()
229 {
230 return "";
231 }
232
233 bool IsDestructionBehaviour()
234 {
235 return false;
236 }
237
239 bool HasComponent(int comp_type)
240 {
241 if ( m_ComponentsBank )
242 return m_ComponentsBank.IsComponentAlreadyExist(comp_type);
243
244 return false;
245 }
246
248 void MaxLifetimeRefreshCalc()
249 {
250 if ( (!GetGame().IsMultiplayer() || GetGame().IsServer()) && GetEconomyProfile() )
251 {
252 float lifetime = GetEconomyProfile().GetLifetime();
253 int frequency = GetCEApi().GetCEGlobalInt("FlagRefreshFrequency");
254 if ( frequency <= 0 )
255 {
257 }
258
259 if ( frequency <= lifetime )
260 {
261 m_RefresherViable = true;
262 SetSynchDirty();
263 }
264 }
265 }
266
268 {
269 if (IsRuined())
270 {
271 return false;
272 }
273 return m_RefresherViable;
274 }
275
276 #ifdef DEVELOPER
277 override void SetDebugItem()
278 {
279 super.SetDebugItem();
280 _item = this;
281 }
282 #endif
283
284
286 void InitDamageZoneMapping()
287 {
288 m_DamageZoneMap = new DamageZoneMap;
289 DamageSystem.GetDamageZoneMap(this,m_DamageZoneMap);
290 }
291
293 void InitDamageZoneDisplayNameMapping()
294 {
295 string path_base;
296 string path;
297 string component_name;
298
299 if ( IsWeapon() )
300 {
301 path_base = CFG_WEAPONSPATH;
302 }
303 else if ( IsMagazine() )
304 {
305 path_base = CFG_MAGAZINESPATH;
306 }
307 else
308 {
309 path_base = CFG_VEHICLESPATH;
310 }
311
312 path_base = string.Format( "%1 %2 DamageSystem DamageZones", path_base, GetType() );
313
314 if ( !GetGame().ConfigIsExisting(path_base) )
315 {
316 component_name = GetDisplayName();
317 GetGame().FormatRawConfigStringKeys(component_name);
318 m_DamageDisplayNameMap.Insert( "".Hash(), component_name );
319 }
320 else
321 {
322 TStringArray zone_names = new TStringArray;
323 GetDamageZones( zone_names );
324
325 for ( int i = 0; i < zone_names.Count(); i++ )
326 {
327 path = string.Format( "%1 %2 displayName", path_base, zone_names[i] );
328
329 if (GetGame().ConfigIsExisting(path) && GetGame().ConfigGetTextRaw(path,component_name))
330 {
331 GetGame().FormatRawConfigStringKeys(component_name);
332 m_DamageDisplayNameMap.Insert( zone_names[i].Hash(), component_name );
333 }
334 }
335 }
336 }
337
338 DamageZoneMap GetEntityDamageZoneMap()
339 {
340 return m_DamageZoneMap;
341 }
342
343 map<int, string> GetEntityDamageDisplayNameMap()
344 {
345 return m_DamageDisplayNameMap;
346 }
347
349 bool CanDisplayWeight()
350 {
351 return m_CanDisplayWeight;
352 }
353
355 void Log(string msg, string fnc_name = "n/a")
356 {
357 Debug.Log(msg, "Object", "n/a", fnc_name, this.GetType());
358 }
359
361 void LogWarning(string msg, string fnc_name = "n/a")
362 {
363 Debug.LogWarning(msg, "Object", "n/a", fnc_name, this.GetType());
364 }
365
367 void LogError(string msg, string fnc_name = "n/a")
368 {
369 Debug.LogError(msg, "Object", "n/a", fnc_name, this.GetType());
370 }
371
373 bool IsSkinned()
374 {
375 return GetCompBS() && GetCompBS().IsSkinned();
376 }
377
378 void SetAsSkinned()
379 {
380 if (GetCompBS())
381 GetCompBS().SetAsSkinned();
382 }
383
384 bool CanBeSkinnedWith(EntityAI tool)
385 {
386 if ( !IsSkinned() && tool )
387 if ( !IsAlive() )
388 return true;
389 return false;
390 }
392
393 // ITEM TO ITEM FIRE DISTRIBUTION
396 {
397 return false;
398 }
399
401 bool CanBeIgnitedBy(EntityAI igniter = NULL)
402 {
403 return false;
404 }
405
407 bool CanIgniteItem(EntityAI ignite_target = NULL)
408 {
409 return false;
410 }
411
413 bool IsIgnited()
414 {
415 if (m_EM)
416 return m_EM.IsWorking();
417 return false;
418 }
419
420 // Change return value to true if last detached item cause disassemble of item - different handlig some inventory operations
422 {
423 return false;
424 }
425
426 bool IsBasebuildingKit()
427 {
428 return false;
429 }
430
432 bool PlacementCanBeRotated()
433 {
434 return true;
435 }
436
438 void OnIgnitedTarget( EntityAI target_item)
439 {
440
441 }
442
444 void OnIgnitedThis( EntityAI fire_source)
445 {
446
447 }
448
450 void OnIgnitedTargetFailed( EntityAI target_item)
451 {
452
453 }
454
456 void OnIgnitedThisFailed( EntityAI fire_source)
457 {
458
459 }
460
462 bool IsTargetIgnitionSuccessful(EntityAI item_target)
463 {
464 return true;
465 }
466
468 bool IsThisIgnitionSuccessful(EntityAI item_source = NULL)
469 {
470 return true;
471 }
472 // End of fire distribution ^
473
474 // ADVANCED PLACEMENT EVENTS
475 void OnPlacementStarted( Man player ) { }
476
477 void OnHologramBeingPlaced( Man player ) { }
478
479 // now includes information on final object position
480 void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" ) { }
481
482 void OnPlacementCancelled( Man player )
483 {
484 if (m_EM)
485 {
486 Man attached_to = Man.Cast( GetHierarchyParent() );
487 if (!attached_to || attached_to == player )// Check for exception with attaching a cable reel to an electric fence
488 {
489 //If cord length is 0, item powersource is most likely an attachment and should not be unplugged
490 //if (em.GetCordLength() <= 0)
491 if (m_EM.GetCordLength() <= 0)
492 {
493 //em.SwitchOff();
494 return;
495 }
496 //em.UnplugAllDevices();
497 //em.UnplugThis();
498 m_EM.UnplugAllDevices();
499 m_EM.UnplugThis();
500 }
501 }
502 }
503
504 bool CanBePlaced( Man player, vector position ) { return true; }
505
507 string CanBePlacedFailMessage( Man player, vector position )
508 {
509 return "";
510 }
511
514 {
515 return false;
516 }
517
519 float HeightCheckOverride()
520 {
521 return 0.0;
522 }
523
525 float HeightStartCheckOverride()
526 {
527 return 0.0;
528 }
529
531 bool IsEmpty()
532 {
533 return (!HasAnyCargo() && GetInventory().AttachmentCount() == 0);
534 }
535
536 bool CanBeSplit()
537 {
538 return false;
539 }
540
542 bool HasAnyCargo()
543 {
544 CargoBase cargo = GetInventory().GetCargo();
545
546 if(!cargo) return false;//this is not a cargo container
547
548 if( cargo.GetItemCount() > 0 )
549 {
550 return true;
551 }
552 else
553 {
554 return false;
555 }
556 }
557
558 array<EntityAI> GetAttachmentsWithCargo()
559 {
560 return m_AttachmentsWithCargo;
561 }
562
563 array<EntityAI> GetAttachmentsWithAttachments()
564 {
565 return m_AttachmentsWithAttachments;
566 }
567
568 int GetAgents() { return 0; }
569 void RemoveAgent(int agent_id);
570 void RemoveAllAgents();
571 void RemoveAllAgentsExcept(int agent_to_keep);
572 void InsertAgent(int agent, float count = 1);
573
574 override bool IsEntityAI() { return true; }
575
576 bool IsInventoryVisible()
577 {
578 return !( GetParent() || GetHierarchyParent() );
579 }
580
581 bool IsPlayer()
582 {
583 return false;
584 }
585
586 bool IsAnimal()
587 {
588 return false;
589 }
590
591 bool IsZombie()
592 {
593 return false;
594 }
595
596 bool IsZombieMilitary()
597 {
598 return false;
599 }
600
602 {
603 return IsDamageDestroyed();
604 }
605
606 bool CanBeTargetedByAI(EntityAI ai)
607 {
608 if (ai && ai.IsBeingBackstabbed())
609 {
610 return false;
611 }
612
613 if ( !dBodyIsActive( this ) && !IsMan() )
614 return false;
615 return !IsDamageDestroyed();
616 }
617
618 bool CanBeBackstabbed()
619 {
620 return false;
621 }
622
631 override void Delete()
632 {
633 m_PendingDelete = true;
634 super.Delete();
635 }
636
637 void DeleteOnClient()
638 {
639 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame().ObjectDeleteOnClient, this);
640 }
641
642 // delete synchronized between server and client
643 void DeleteSafe()
644 {
645 if (GetHierarchyRootPlayer() == null)
646 {
647 Delete();
648 }
649 else
650 {
651 if ( GetGame().IsServer() && GetGame().IsMultiplayer() )
652 GetHierarchyRootPlayer().JunctureDeleteItem( this );
653 else
654 GetHierarchyRootPlayer().AddItemToDelete( this );
655 }
656 }
657
658 //legacy, wrong name, use 'DeleteSafe()' instead
659 void DeleteSave()
660 {
661 DeleteSafe();
662 }
663
664 bool IsSetForDeletion()
665 {
666 return IsPreparedToDelete() || m_PendingDelete || ToDelete() || IsPendingDeletion();
667 }
668
669 void SetPrepareToDelete()
670 {
671 m_PreparedToDelete = true;
672 }
673
674 bool IsPreparedToDelete()
675 {
676 return m_PreparedToDelete;
677 }
678
679
680 void CheckForDestroy()
681 {
682 if ( IsPrepareToDelete() )
683 {
684 GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( TryDelete, DELETE_CHECK_DELAY, false);
685 }
686 }
687
688 bool IsPrepareToDelete()
689 {
690 return false;
691 }
692
693 bool TryDelete()
694 {
695 if ( !IsPrepareToDelete() )
696 return false;
697
698 if ( GetGame().HasInventoryJunctureItem(this) )
699 {
700 GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( TryDelete, DELETE_CHECK_DELAY, false);
701 return false;
702 }
703
704 OnBeforeTryDelete();
705 DeleteSafe();
706 return true;
707 }
708
709 void OnBeforeTryDelete() {}
710
712 proto native EntityAI GetHierarchyRoot();
713
715 proto native Man GetHierarchyRootPlayer();
716
718 proto native EntityAI GetHierarchyParent();
719
721 proto native CEItemProfile GetEconomyProfile();
722
723 // !returns the number of levels bellow the hierarchy root this entity is at
724 int GetHierarchyLevel(int lvl = 0)
725 {
726 if (!GetHierarchyParent())
727 return lvl;
728 else
729 {
730 return GetHierarchyParent().GetHierarchyLevel(lvl+1);
731 }
732 }
733
734 void OnInventoryInit()
735 {
736 InitAttachmentExclusionValues();
737 }
738
740 void EEInit()
741 {
742 if (GetInventory())
743 {
744 GetInventory().EEInit();
745 m_AttachmentsWithCargo.Clear();
746 m_AttachmentsWithAttachments.Clear();
747 for ( int i = 0; i < GetInventory().AttachmentCount(); i++ )
748 {
749 EntityAI attachment = GetInventory().GetAttachmentFromIndex( i );
750 if ( attachment )
751 {
752 if ( attachment.GetInventory().GetCargo() )
753 {
754 m_AttachmentsWithCargo.Insert( attachment );
755 }
756
757 if ( attachment.GetInventory().GetAttachmentSlotsCount() > 0 )
758 {
759 m_AttachmentsWithAttachments.Insert( attachment );
760 }
761 }
762 }
763 }
764
765 MaxLifetimeRefreshCalc();
766 }
767
769 void EEDelete(EntityAI parent)
770 {
771 m_PendingDelete = true;
772 GetInventory().EEDelete(parent);
773
774 if (m_EM)
775 m_EM.OnDeviceDestroyed();
776 }
777
778 override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
779 {
780 super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
781 #ifndef SERVER
782 g_Game.GetWorld().AddEnvShootingSource(pos, 1.0);
783 #endif
784 if (m_DestructionBehaviourObj && m_DestructionBehaviourObj.HasExplosionDamage())
785 {
786 m_DestructionBehaviourObj.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
787 }
788 }
789
790
791 void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner) { }
792
793 void OnItemAttachmentSlotChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc) {}
794
795 void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
796 {
797 EntityAI old_owner = oldLoc.GetParent();
798 EntityAI new_owner = newLoc.GetParent();
799 OnItemLocationChanged(old_owner, new_owner);
800
801 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT && newLoc.GetType() == InventoryLocationType.ATTACHMENT)
802 {
803 OnItemAttachmentSlotChanged(oldLoc,newLoc);
804 }
805
806 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT)
807 {
808 if (old_owner)
809 OnWasDetached(old_owner, oldLoc.GetSlot());
810 else
811 Error("EntityAI::EEItemLocationChanged - detached, but old_owner is null");
812 }
813
814 if (newLoc.GetType() == InventoryLocationType.ATTACHMENT)
815 {
816 if (new_owner)
817 OnWasAttached(newLoc.GetParent(), newLoc.GetSlot());
818 else
819 Error("EntityAI::EEItemLocationChanged - attached, but new_owner is null");
820 }
821 }
822
824 void EEParentedTo(EntityAI parent)
825 {
826 }
827
829 void EEParentedFrom(EntityAI parent)
830 {
831 }
832
833 void EEInventoryIn (Man newParentMan, EntityAI diz, EntityAI newParent)
834 {
835 }
836 void EEInventoryOut (Man oldParentMan, EntityAI diz, EntityAI newParent)
837 {
838 m_LastUpdatedTime = 0.0;
839
840 if (GetInventory() && newParent == null)
841 {
842 GetInventory().ResetFlipCargo();
843 }
844 }
845
846 void EEAmmoChanged()
847 {
848 SetWeightDirty();
849 }
850
851 void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
852 {
853 // Notify potential parent that this item was ruined
854 EntityAI parent = GetHierarchyParent();
855
856 if (newLevel == GameConstants.STATE_RUINED)
857 {
858 if (parent)
859 {
860 parent.OnAttachmentRuined(this);
861 }
862 if (!zone)
863 {
864 OnDamageDestroyed(oldLevel);
865 }
866 AttemptDestructionBehaviour(oldLevel,newLevel, zone);
867 }
868 }
869
871 void OnDamageDestroyed(int oldLevel);
872
873 void AttemptDestructionBehaviour(int oldLevel, int newLevel, string zone)
874 {
875 if (IsDestructionBehaviour() && GetDestructionBehaviour())
876 {
877 typename destType = GetDestructionBehaviour().ToType();
878
879 if (destType)
880 {
881 if (!m_DestructionBehaviourObj)
882 {
883 m_DestructionBehaviourObj = DestructionEffectBase.Cast(destType.Spawn());
884 }
885
886 if (m_DestructionBehaviourObj)
887 {
888 m_DestructionBehaviourObj.OnHealthLevelChanged(this, oldLevel, newLevel, zone);
889 }
890 }
891 else
892 {
893 ErrorEx("Incorrect destruction behaviour type, make sure the class returned in 'GetDestructionBehaviour()' is a valid type inheriting from 'DestructionEffectBase'");
894 }
895 }
896 }
897
898
899 void SetTakeable(bool pState);
900
902 void EEKilled(Object killer)
903 {
904 //analytics
905 GetGame().GetAnalyticsServer().OnEntityKilled( killer, this );
906
907 if( ReplaceOnDeath() )
908 GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeathUpdate, DEAD_REPLACE_DELAY, false);
909 }
910
911 bool ReplaceOnDeath()
912 {
913 return false;
914 }
915
916 string GetDeadItemName()
917 {
918 return "";
919 }
920
922 {
923 return false;
924 }
925
926 void DeathUpdate()
927 {
928 EntityAI dead_entity = EntityAI.Cast( GetGame().CreateObjectEx( GetDeadItemName(), GetPosition(), ECE_OBJECT_SWAP, RF_ORIGINAL ) );
929 dead_entity.SetOrientation(GetOrientation());
930 if ( KeepHealthOnReplace() )
931 dead_entity.SetHealth(GetHealth());
932 this.Delete();
933 }
934
936 void OnAttachmentRuined(EntityAI attachment)
937 {
938 // ...
939 }
940
941 void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
942 {
943 #ifdef DEVELOPER
944 //Print("EEHitBy: " + this + "; damageResult:"+ damageResult.GetDamage("","") +"; damageType: "+ damageType +"; source: "+ source +"; component: "+ component +"; dmgZone: "+ dmgZone +"; ammo: "+ ammo +"; modelPos: "+ modelPos);
945 #endif
946 }
947
948 // called only on the client who caused the hit
949 void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
950 {
951
952 }
953
954 // !Called on PARENT when a child is attached to it.
955 void EEItemAttached(EntityAI item, string slot_name)
956 {
957 int slotId = InventorySlots.GetSlotIdFromString(slot_name);
958 PropagateExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId),slotId); //Performed from parent to avoid event order issues on swap
959 SetWeightDirty();
960
961 if ( m_ComponentsBank != NULL )
962 {
963 for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
964 {
965 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
966 {
967 m_ComponentsBank.GetComponent(comp_key).Event_OnItemAttached(item, slot_name);
968 }
969 }
970 }
971
972 // Energy Manager
973 if ( m_EM && item.GetCompEM())
974 m_EM.OnAttachmentAdded(item);
975
976 if ( item.GetInventory().GetCargo() )
977 m_AttachmentsWithCargo.Insert( item );
978
979 if ( item.GetInventory().GetAttachmentSlotsCount() > 0 )
980 m_AttachmentsWithAttachments.Insert( item );
981
982 if ( m_OnItemAttached )
983 m_OnItemAttached.Invoke( item, slot_name, this );
984 }
985
986 void SwitchItemSelectionTexture(EntityAI item, string slot_name);
987 void SwitchItemSelectionTextureEx(EItemManipulationContext context, Param par = null);
988
989 // !Called on PARENT when a child is detached from it.
990 void EEItemDetached(EntityAI item, string slot_name)
991 {
992 int slotId = InventorySlots.GetSlotIdFromString(slot_name);
993 ClearExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId),slotId); //Performed from parent to avoid event order issues on swap
994 SetWeightDirty();
995
996 if ( m_ComponentsBank != NULL )
997 {
998 for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
999 {
1000 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
1001 {
1002 m_ComponentsBank.GetComponent(comp_key).Event_OnItemDetached(item, slot_name);
1003 }
1004 }
1005 }
1006
1007 // Energy Manager
1008 if (m_EM && item.GetCompEM())
1009 m_EM.OnAttachmentRemoved(item);
1010
1011 if ( m_AttachmentsWithCargo.Find( item ) > -1 )
1012 m_AttachmentsWithCargo.RemoveItem( item );
1013
1014 if ( m_AttachmentsWithAttachments.Find( item ) > -1 )
1015 m_AttachmentsWithAttachments.RemoveItem( item );
1016
1017
1018 if ( m_OnItemDetached )
1019 m_OnItemDetached.Invoke( item, slot_name, this );
1020 }
1021
1022 void EECargoIn(EntityAI item)
1023 {
1024 SetWeightDirty();
1025
1026 if( m_OnItemAddedIntoCargo )
1027 m_OnItemAddedIntoCargo.Invoke( item, this );
1028
1029 item.OnMovedInsideCargo(this);
1030 }
1031
1032 void EECargoOut(EntityAI item)
1033 {
1034 SetWeightDirty();
1035
1036 if( m_OnItemRemovedFromCargo )
1037 m_OnItemRemovedFromCargo.Invoke( item, this );
1038
1039 item.OnRemovedFromCargo(this);
1040 }
1041
1042 void EECargoMove(EntityAI item)
1043 {
1044 if( m_OnItemMovedInCargo )
1045 m_OnItemMovedInCargo.Invoke( item, this );
1046 item.OnMovedWithinCargo(this);
1047 }
1048
1049 ScriptInvoker GetOnItemAttached()
1050 {
1051 if( !m_OnItemAttached )
1052 m_OnItemAttached = new ScriptInvoker;
1053 return m_OnItemAttached;
1054 }
1055
1056 ScriptInvoker GetOnItemDetached()
1057 {
1058 if( !m_OnItemDetached )
1059 m_OnItemDetached = new ScriptInvoker;
1060 return m_OnItemDetached;
1061 }
1062
1063 ScriptInvoker GetOnItemAddedIntoCargo()
1064 {
1065 if( !m_OnItemAddedIntoCargo )
1066 m_OnItemAddedIntoCargo = new ScriptInvoker;
1067 return m_OnItemAddedIntoCargo;
1068 }
1069
1070 ScriptInvoker GetOnItemRemovedFromCargo()
1071 {
1072 if( !m_OnItemRemovedFromCargo )
1073 m_OnItemRemovedFromCargo = new ScriptInvoker;
1074 return m_OnItemRemovedFromCargo;
1075 }
1076
1077 ScriptInvoker GetOnItemMovedInCargo()
1078 {
1079 if( !m_OnItemMovedInCargo )
1080 m_OnItemMovedInCargo = new ScriptInvoker;
1081 return m_OnItemMovedInCargo;
1082 }
1083
1084 ScriptInvoker GetOnItemFlipped()
1085 {
1086 if( !m_OnItemFlipped )
1087 m_OnItemFlipped = new ScriptInvoker;
1088 return m_OnItemFlipped;
1089 }
1090
1091 ScriptInvoker GetOnViewIndexChanged()
1092 {
1093 if( !m_OnViewIndexChanged )
1094 m_OnViewIndexChanged = new ScriptInvoker;
1095 return m_OnViewIndexChanged;
1096 }
1097
1098 ScriptInvoker GetOnSetLock()
1099 {
1100 if( !m_OnSetLock )
1101 m_OnSetLock = new ScriptInvoker;
1102 return m_OnSetLock;
1103 }
1104
1105 ScriptInvoker GetOnReleaseLock()
1106 {
1107 if( !m_OnReleaseLock )
1108 m_OnReleaseLock = new ScriptInvoker;
1109 return m_OnReleaseLock;
1110 }
1111
1112 ScriptInvoker GetOnAttachmentSetLock()
1113 {
1114 if( !m_OnAttachmentSetLock )
1115 m_OnAttachmentSetLock = new ScriptInvoker;
1116 return m_OnAttachmentSetLock;
1117 }
1118
1119 ScriptInvoker GetOnAttachmentReleaseLock()
1120 {
1121 if( !m_OnAttachmentReleaseLock )
1122 m_OnAttachmentReleaseLock = new ScriptInvoker;
1123 return m_OnAttachmentReleaseLock;
1124 }
1125
1126
1128 void OnMovedInsideCargo(EntityAI container)
1129 {
1130 if (m_EM)
1131 m_EM.HandleMoveInsideCargo(container);
1132 }
1133
1135 void OnRemovedFromCargo(EntityAI container)
1136 {
1137
1138 }
1139
1141 void OnMovedWithinCargo(EntityAI container)
1142 {
1143
1144 }
1145
1147 void EEOnAfterLoad()
1148 {
1149 // ENERGY MANAGER
1150 // Restore connections between devices which were connected before server restart
1151 if ( m_EM && m_EM.GetRestorePlugState() )
1152 {
1153 int b1 = m_EM.GetEnergySourceStorageIDb1();
1154 int b2 = m_EM.GetEnergySourceStorageIDb2();
1155 int b3 = m_EM.GetEnergySourceStorageIDb3();
1156 int b4 = m_EM.GetEnergySourceStorageIDb4();
1157
1158 // get pointer to EntityAI based on this ID
1159 EntityAI potential_energy_source = GetGame().GetEntityByPersitentID(b1, b2, b3, b4); // This function is available only in this event!
1160
1161 // IMPORTANT!
1162 // 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)
1163 // 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.
1164 // Therefore their plug state is being restored withing the EEItemAttached() event while being excluded by the following 'if' conditions...
1165
1166 bool is_attachment = false;
1167
1168 if (potential_energy_source)
1169 is_attachment = GetInventory().HasAttachment(potential_energy_source);
1170
1171 if ( !is_attachment && potential_energy_source )
1172 is_attachment = potential_energy_source.GetInventory().HasAttachment(this);
1173
1174 if ( potential_energy_source && potential_energy_source.GetCompEM() /*&& potential_energy_source.HasEnergyManager()*/ && !is_attachment )
1175 m_EM.PlugThisInto(potential_energy_source); // restore connection
1176 }
1177 }
1178
1180 void EEOnCECreate()
1181 {
1182 }
1183
1185 void AfterStoreLoad()
1186 {
1187 }
1188
1190 void OnBinLoadItemsDropped()
1191 {
1192 if ( GetHierarchyRootPlayer() )
1193 {
1194 //GetGame().RPCSingleParam(GetHierarchyRootPlayer(), ERPCs.RPC_WARNING_ITEMDROP, null, true, GetHierarchyRootPlayer().GetIdentity());
1195 GetHierarchyRootPlayer().SetProcessUIWarning(true);
1196 }
1197 }
1198
1200 void HideAllSelections()
1201 {
1202 string cfg_path = "cfgVehicles " + GetType() + " AnimationSources";
1203
1204 if ( GetGame().ConfigIsExisting(cfg_path) )
1205 {
1206 int selections = GetGame().ConfigGetChildrenCount(cfg_path);
1207
1208 for (int i = 0; i < selections; i++)
1209 {
1210 string selection_name;
1211 GetGame().ConfigGetChildName(cfg_path, i, selection_name);
1212 HideSelection(selection_name);
1213 }
1214 }
1215 }
1216
1218 void ShowAllSelections()
1219 {
1220 string cfg_path = "cfgVehicles " + GetType() + " AnimationSources";
1221
1222 if ( GetGame().ConfigIsExisting(cfg_path) )
1223 {
1224 int selections = GetGame().ConfigGetChildrenCount(cfg_path);
1225
1226 for (int i = 0; i < selections; i++)
1227 {
1228 string selection_name;
1229 GetGame().ConfigGetChildName(cfg_path, i, selection_name);
1230 ShowSelection(selection_name);
1231 }
1232 }
1233 }
1234
1241 bool CanReceiveAttachment (EntityAI attachment, int slotId)
1242 {
1243 //generic occupancy check
1244 EntityAI currentAtt = GetInventory().FindAttachment(slotId);
1245 bool hasInternalConflict = attachment.HasInternalExclusionConflicts(slotId);
1246 if (currentAtt) //probably a swap or same-type swap
1247 {
1248 set<int> diff = attachment.GetAttachmentExclusionMaskAll(slotId);
1249 diff.RemoveItems(currentAtt.GetAttachmentExclusionMaskAll(slotId));
1250 if (diff.Count() == 0)
1251 {
1252 return !hasInternalConflict;
1253 }
1254 else
1255 {
1256 return !hasInternalConflict && !IsExclusionFlagPresentRecursive(diff,slotId);
1257 }
1258 }
1259 return !hasInternalConflict && !IsExclusionFlagPresentRecursive(attachment.GetAttachmentExclusionMaskAll(slotId),slotId);
1260 }
1261
1268 bool CanLoadAttachment(EntityAI attachment)
1269 {
1270 return true;
1271 }
1272
1280 bool CanPutAsAttachment (EntityAI parent)
1281 {
1282 return !IsHologram();
1283 }
1284
1285 //If return true, item can be attached even from parent to this. Item will be switched during proccess. (only hands)
1286 bool CanSwitchDuringAttach(EntityAI parent)
1287 {
1288 return false;
1289 }
1296 bool CanReleaseAttachment (EntityAI attachment)
1297 {
1298 if( attachment && attachment.GetInventory() && GetInventory() )
1299 {
1301 attachment.GetInventory().GetCurrentInventoryLocation( il );
1302 if( il.IsValid() )
1303 {
1304 int slot = il.GetSlot();
1305 return !GetInventory().GetSlotLock( slot );
1306 }
1307 }
1308 return true;
1309 }
1316 bool CanDetachAttachment (EntityAI parent)
1317 {
1318 return true;
1319 }
1320
1321 bool CanCombineAttachment(notnull EntityAI e, int slot, bool stack_max_limit = false)
1322 {
1323 EntityAI att = GetInventory().FindAttachment(slot);
1324 if(att)
1325 return att.CanBeCombined(e, true, stack_max_limit);
1326 return false;
1327 }
1328
1329 bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false )
1330 {
1331 return false;
1332 }
1333
1334 void CombineItemsClient(EntityAI entity2, bool use_stack_max = false )
1335 {}
1336
1344 {
1345 if (GetInventory() && GetInventory().GetCargo())
1346 return GetInventory().GetCargo().CanReceiveItemIntoCargo(item));
1347
1348 return true;
1349 }
1350
1358 {
1359 return true;
1360 }
1361
1368 bool CanPutInCargo (EntityAI parent)
1369 {
1370 return !IsHologram();
1371 }
1372
1379 bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
1380 {
1381 if (GetInventory() && GetInventory().GetCargo())
1382 return GetInventory().GetCargo().CanSwapItemInCargo(child_entity, new_entity));
1383
1384 return true;
1385 }
1386
1393 bool CanReleaseCargo (EntityAI cargo)
1394 {
1395 return true;
1396 }
1397
1404 bool CanRemoveFromCargo (EntityAI parent)
1405 {
1406 return true;
1407 }
1408
1415 /*bool CanReceiveItemIntoInventory (EntityAI entity_ai)
1416 {
1417 return true;
1418 }*/
1419
1426 /*bool CanPutInInventory (EntityAI parent)
1427 {
1428 return true;
1429 }*/
1430
1437 bool CanReceiveItemIntoHands (EntityAI item_to_hands)
1438 {
1439 return true;
1440 }
1441
1442 bool IsBeingPlaced()
1443 {
1444 return false;
1445 }
1446
1447 override bool IsHologram()
1448 {
1449 return false;
1450 }
1451
1452 bool CanSaveItemInHands (EntityAI item_in_hands)
1453 {
1454 return true;
1455 }
1456
1463 bool CanPutIntoHands (EntityAI parent)
1464 {
1465 return !IsHologram();
1466 }
1467
1474 bool CanReleaseFromHands (EntityAI handheld)
1475 {
1476 return true;
1477 }
1478
1485 bool CanRemoveFromHands (EntityAI parent)
1486 {
1487 return true;
1488 }
1489
1494 bool CanDisplayAttachmentSlot( string slot_name )
1495 {
1496 Debug.LogWarning("Obsolete function - use CanDisplayAttachmentSlot with slot id parameter");
1498 }
1499
1504 bool CanDisplayAttachmentSlot( int slot_id )
1505 {
1506 return InventorySlots.GetShowForSlotId(slot_id);
1507 }
1508
1512 bool CanDisplayAnyAttachmentSlot()
1513 {
1514 int count = GetInventory().GetAttachmentSlotsCount();
1515 int slotID;
1516 for (int i = 0; i < count; i++)
1517 {
1518 slotID = GetInventory().GetAttachmentSlotId(i);
1519 if (CanDisplayAttachmentSlot(slotID))
1520 {
1521 return true;
1522 }
1523 }
1524
1525 return false;
1526 }
1527
1532 bool CanDisplayAttachmentCategory( string category_name )
1533 {
1534 return true;
1535 }
1536
1540 bool CanDisplayCargo()
1541 {
1542 return true;
1543 }
1544
1548 bool CanAssignToQuickbar()
1549 {
1550 return true;
1551 }
1552
1556 bool CanAssignAttachmentsToQuickbar()
1557 {
1558 return true;
1559 }
1560
1565 {
1566 return GetHierarchyRootPlayer() == GetGame().GetPlayer();
1567 }
1568
1569 // !Called on CHILD when it's attached to parent.
1570 void OnWasAttached( EntityAI parent, int slot_id );
1571
1572 // !Called on CHILD when it's detached from parent.
1573 void OnWasDetached( EntityAI parent, int slot_id );
1574
1575 void OnCargoChanged() { }
1576
1577 bool IsTakeable()
1578 {
1579 return false;
1580 }
1581
1582 proto native GameInventory GetInventory ();
1583 proto native void CreateAndInitInventory ();
1584 proto native void DestroyInventory ();
1585
1586 int GetSlotsCountCorrect()
1587 {
1588 if( GetInventory() )
1589 return GetInventory().GetAttachmentSlotsCount();
1590 else
1591 return -1;
1592 }
1593
1594 EntityAI FindAttachmentBySlotName(string slot_name)
1595 {
1596 if ( GetGame() )
1597 {
1598 int slot_id = InventorySlots.GetSlotIdFromString(slot_name);
1599 if (slot_id != InventorySlots.INVALID)
1600 return GetInventory().FindAttachment(slot_id);
1601 }
1602 return null;
1603 }
1604
1608 bool IsLockedInSlot()
1609 {
1610 EntityAI parent = GetHierarchyParent();
1611 if ( parent )
1612 {
1613 InventoryLocation inventory_location = new InventoryLocation();
1614 GetInventory().GetCurrentInventoryLocation( inventory_location );
1615
1616 return parent.GetInventory().GetSlotLock( inventory_location.GetSlot() );
1617 }
1618
1619 return false;
1620 }
1621
1626 {
1627 if ( GetGame().IsMultiplayer() )
1628 return GetInventory().TakeEntityToInventory(InventoryMode.JUNCTURE, flags, item);
1629 else
1630 return GetInventory().TakeEntityToInventory(InventoryMode.PREDICTIVE, flags, item);
1631 }
1633 {
1634 return GetInventory().TakeEntityToInventory(InventoryMode.LOCAL, flags, item);
1635 }
1637 {
1638 return GetInventory().TakeEntityToInventory(InventoryMode.SERVER, flags, item);
1639 }
1640 bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1641 {
1642 if ( GetGame().IsMultiplayer() )
1643 return GetInventory().TakeEntityToTargetInventory(InventoryMode.JUNCTURE, target, flags, item);
1644 else
1645 return GetInventory().TakeEntityToTargetInventory(InventoryMode.PREDICTIVE, target, flags, item);
1646 }
1647 bool LocalTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1648 {
1649 return GetInventory().TakeEntityToTargetInventory(InventoryMode.LOCAL, target, flags, item);
1650 }
1651 bool ServerTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1652 {
1653 return GetInventory().TakeEntityToTargetInventory(InventoryMode.SERVER, target, flags, item);
1654 }
1658 bool PredictiveTakeEntityToCargo (notnull EntityAI item)
1659 {
1660 if ( GetGame().IsMultiplayer() )
1661 return GetInventory().TakeEntityToCargo(InventoryMode.JUNCTURE, item);
1662 else
1663 return GetInventory().TakeEntityToCargo(InventoryMode.PREDICTIVE, item);
1664 }
1665 bool LocalTakeEntityToCargo (notnull EntityAI item)
1666 {
1667 return GetInventory().TakeEntityToCargo(InventoryMode.LOCAL, item);
1668 }
1669 bool ServerTakeEntityToCargo (notnull EntityAI item)
1670 {
1671 return GetInventory().TakeEntityToCargo(InventoryMode.SERVER, item);
1672 }
1673
1674 bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1675 {
1676 if ( GetGame().IsMultiplayer() )
1677 return GetInventory().TakeEntityToTargetCargo(InventoryMode.JUNCTURE, target, item);
1678 else
1679 return GetInventory().TakeEntityToTargetCargo(InventoryMode.PREDICTIVE, target, item);
1680 }
1681 bool LocalTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1682 {
1683 return GetInventory().TakeEntityToTargetCargo(InventoryMode.LOCAL, target, item);
1684 }
1685 bool ServerTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1686 {
1687 return GetInventory().TakeEntityToTargetCargo(InventoryMode.SERVER, target, item);
1688 }
1692 bool PredictiveTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col)
1693 {
1694 if ( GetGame().IsMultiplayer() )
1695 return GetInventory().TakeEntityToCargoEx(InventoryMode.JUNCTURE, item, idx, row, col);
1696 else
1697 return GetInventory().TakeEntityToCargoEx(InventoryMode.PREDICTIVE, item, idx, row, col);
1698 }
1699 bool LocalTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col)
1700 {
1701 return GetInventory().TakeEntityToCargoEx(InventoryMode.LOCAL, item, idx, row, col);
1702 }
1703
1704 bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1705 {
1706 if ( GetGame().IsMultiplayer() )
1707 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.JUNCTURE, cargo, item, row, col);
1708 else
1709 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.PREDICTIVE, cargo, item, row, col);
1710 }
1711 bool LocalTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1712 {
1713 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.LOCAL, cargo, item, row, col);
1714 }
1715 bool ServerTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1716 {
1717 return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.SERVER, cargo, item, row, col);
1718 }
1722 bool PredictiveTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
1723 {
1724 if ( GetGame().IsMultiplayer() )
1725 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.JUNCTURE, item, slot);
1726 else
1727 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.PREDICTIVE, item, slot);
1728 }
1729 bool LocalTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
1730 {
1731 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.LOCAL, item, slot);
1732 }
1733 bool ServerTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
1734 {
1735 return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.SERVER, item, slot);
1736 }
1737
1738 bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
1739 {
1740 if ( GetGame().IsMultiplayer() )
1741 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.JUNCTURE, target, item, slot);
1742 else
1743 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.PREDICTIVE, target, item, slot);
1744 }
1745 bool LocalTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
1746 {
1747 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.LOCAL, target, item, slot);
1748 }
1749 bool ServerTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
1750 {
1751 return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.SERVER, target, item, slot);
1752 }
1753
1754 bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
1755 {
1756 if ( GetGame().IsMultiplayer() )
1757 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.JUNCTURE, target, item);
1758 else
1759 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.PREDICTIVE, target, item);
1760 }
1761 bool LocalTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
1762 {
1763 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.LOCAL, target, item);
1764 }
1765 bool ServerTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
1766 {
1767 return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.SERVER, target, item);
1768 }
1769
1770 bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
1771 {
1772 if ( GetGame().IsMultiplayer() )
1773 return GetInventory().TakeToDst(InventoryMode.JUNCTURE, src, dst);
1774 else
1775 return GetInventory().TakeToDst(InventoryMode.PREDICTIVE, src, dst);
1776 }
1777 bool LocalTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
1778 {
1779 return GetInventory().TakeToDst(InventoryMode.LOCAL, src, dst);
1780 }
1781 bool ServerTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
1782 {
1783 return GetInventory().TakeToDst(InventoryMode.SERVER, src, dst);
1784 }
1785
1790 {
1791 if ( GetGame().IsMultiplayer() )
1792 return GetInventory().TakeEntityAsAttachment(InventoryMode.JUNCTURE, item);
1793 else
1794 return GetInventory().TakeEntityAsAttachment(InventoryMode.PREDICTIVE, item);
1795 }
1796 bool LocalTakeEntityAsAttachment (notnull EntityAI item)
1797 {
1798 return GetInventory().TakeEntityAsAttachment(InventoryMode.LOCAL, item);
1799 }
1800 bool ServerTakeEntityAsAttachment (notnull EntityAI item)
1801 {
1802 return GetInventory().TakeEntityAsAttachment(InventoryMode.SERVER, item);
1803 }
1804
1805 bool PredictiveDropEntity (notnull EntityAI item) { return false; }
1806 bool LocalDropEntity (notnull EntityAI item) { return false; }
1807 bool ServerDropEntity (notnull EntityAI item) { return false; }
1808
1812 EntityAI GetAttachmentByType(typename type)
1813 {
1814 for ( int i = 0; i < GetInventory().AttachmentCount(); i++ )
1815 {
1816 EntityAI attachment = GetInventory().GetAttachmentFromIndex( i );
1817 if ( attachment && attachment.IsInherited( type ) )
1818 return attachment;
1819 }
1820 return NULL;
1821 }
1822
1826 EntityAI GetAttachmentByConfigTypeName(string type)
1827 {
1828 for ( int i = 0; i < GetInventory().AttachmentCount(); i++ )
1829 {
1830 EntityAI attachment = GetInventory().GetAttachmentFromIndex ( i );
1831 if ( attachment.IsKindOf ( type ) )
1832 return attachment;
1833 }
1834 return NULL;
1835 }
1839 bool CanDropEntity(notnull EntityAI item) { return true; }
1840
1843 EntityAI SpawnEntityOnGroundPos(string object_name, vector pos)
1844 {
1846 vector mat[4];
1848 mat[3] = pos;
1849 il.SetGround(NULL, mat);
1850 return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT);
1851 }
1854 EntityAI SpawnEntityOnGround(string object_name, vector mat[4])
1855 {
1857 il.SetGround(NULL, mat);
1858 return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT);
1859 }
1860
1861 //----------------------------------------------------------------
1862
1863 bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
1864 {
1865 return true;
1866 }
1867
1868 // Forward declarations to allow lower modules to access properties that are modified from higher modules
1869 // These are mainly used within the ItemBase
1870 void SetWet(float value, bool allow_client = false) {};
1871 void AddWet(float value) {};
1872 void SetWetMax() {};
1873
1874 float GetWet()
1875 {
1876 return 0;
1877 }
1878
1879 float GetWetMax()
1880 {
1881 return 0;
1882 }
1883
1884 float GetWetMin()
1885 {
1886 return 0;
1887 }
1888
1889 float GetWetInit()
1890 {
1891 return 0;
1892 }
1893
1894 bool HasWetness()
1895 {
1896 return GetWetMax() - GetWetMin() != 0;
1897 }
1898
1899 void OnWetChanged(float newVal, float oldVal);
1900
1901 void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel);
1902 // ! Returns current wet level of the entity
1904
1905 // ! Calculates wet level from a given wetness, to get level of an entity, use 'GetWetLevel()' instead
1906 static EWetnessLevel GetWetLevelInternal(float wetness)
1907 {
1908 if (wetness < GameConstants.STATE_DAMP)
1909 {
1910 return EWetnessLevel.DRY;
1911 }
1912 else if (wetness < GameConstants.STATE_WET)
1913 {
1914 return EWetnessLevel.DAMP;
1915 }
1916 else if (wetness < GameConstants.STATE_SOAKING_WET)
1917 {
1918 return EWetnessLevel.WET;
1919 }
1920 else if (wetness < GameConstants.STATE_DRENCHED)
1921 {
1922 return EWetnessLevel.SOAKING;
1923 }
1924 return EWetnessLevel.DRENCHED;
1925 }
1926 //----------------------------------------------------------------
1927
1928 float GetQuantity()
1929 {
1930 return 0;
1931 }
1932
1933 int GetQuantityMax()
1934 {
1935 return 0;
1936 }
1937
1938 void SetQuantityToMinimum();
1939
1940 int GetTargetQuantityMax(int attSlotID = -1)
1941 {
1942 return 0;
1943 }
1944
1945 int GetQuickBarBonus()
1946 {
1947 return 0;
1948 }
1949
1950 //----------------------------------------------------------------
1951
1952 void SetTemperature(float value, bool allow_client = false) {};
1953 void AddTemperature(float value) {};
1954 void SetTemperatureMax() {};
1955
1956 float GetTemperature()
1957 {
1958 return 0;
1959 }
1960
1961 float GetTemperatureInit()
1962 {
1963 return 0;
1964 }
1965
1966 float GetTemperatureMin()
1967 {
1968 return 0;
1969 }
1970
1971 float GetTemperatureMax()
1972 {
1973 return 0;
1974 }
1975
1976 //----------------------------------------------------------------
1977
1978 HiddenSelectionsData GetHiddenSelectionsData()
1979 {
1980 return m_HiddenSelectionsData;
1981 }
1982
1984 int GetHiddenSelectionIndex( string selection )
1985 {
1986 if (m_HiddenSelectionsData)
1987 return m_HiddenSelectionsData.GetHiddenSelectionIndex( selection );
1988
1989 return -1;
1990 }
1991
1993 override TStringArray GetHiddenSelections()
1994 {
1995 if (m_HiddenSelectionsData)
1996 return m_HiddenSelectionsData.m_HiddenSelections;
1997 else
1998 return super.GetHiddenSelections();
1999 }
2000
2002 override TStringArray GetHiddenSelectionsTextures()
2003 {
2004 if (m_HiddenSelectionsData)
2005 return m_HiddenSelectionsData.m_HiddenSelectionsTextures;
2006 else
2007 return super.GetHiddenSelectionsTextures();
2008 }
2009
2011 override TStringArray GetHiddenSelectionsMaterials()
2012 {
2013 if (m_HiddenSelectionsData)
2014 return m_HiddenSelectionsData.m_HiddenSelectionsMaterials;
2015 else
2016 return super.GetHiddenSelectionsMaterials();
2017 }
2018
2030 proto native void PlaceOnSurfaceRotated(out vector trans[4], vector pos, float dx = 0, float dz = 0, float fAngle = 0, bool align = false);
2031
2038 proto native void RegisterNetSyncVariableBool(string variableName);
2039
2046 proto native void RegisterNetSyncVariableBoolSignal(string variableName);
2047
2056 proto native void RegisterNetSyncVariableInt(string variableName, int minValue = 0, int maxValue = 0);
2057
2067 proto native void RegisterNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1);
2068
2069 proto native void UpdateNetSyncVariableInt(string variableName, float minValue = 0, float maxValue = 0);
2070 proto native void UpdateNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1);
2071
2072 proto native void SwitchLight(bool isOn);
2073
2075 proto native void SetSimpleHiddenSelectionState(int index, bool state);
2076 proto native bool IsSimpleHiddenSelectionVisible(int index);
2077
2079 proto native void SetObjectTexture(int index, string texture_name);
2081 proto native void SetObjectMaterial(int index, string mat_name);
2082
2083 proto native bool IsPilotLight();
2084 proto native void SetPilotLight(bool isOn);
2085
2104 {
2105 // Saving of energy related states
2106 if ( m_EM )
2107 {
2108 // Save energy amount
2109 ctx.Write( m_EM.GetEnergy() );
2110
2111 // Save passive/active state
2112 ctx.Write( m_EM.IsPassive() );
2113
2114 // Save ON/OFF state
2115 ctx.Write( m_EM.IsSwitchedOn() );
2116
2117 // Save plugged/unplugged state
2118 ctx.Write( m_EM.IsPlugged() );
2119
2120 // ENERGY SOURCE
2121 // Save energy source IDs
2122 EntityAI energy_source = m_EM.GetEnergySource();
2123 int b1 = 0;
2124 int b2 = 0;
2125 int b3 = 0;
2126 int b4 = 0;
2127
2128 if (energy_source)
2129 {
2130 energy_source.GetPersistentID(b1, b2, b3, b4);
2131 }
2132
2133 ctx.Write( b1 ); // Save energy source block 1
2134 ctx.Write( b2 ); // Save energy source block 2
2135 ctx.Write( b3 ); // Save energy source block 3
2136 ctx.Write( b4 ); // Save energy source block 4
2137 }
2138 }
2139
2164 bool OnStoreLoad (ParamsReadContext ctx, int version)
2165 {
2166 // Restoring of energy related states
2167
2168 if ( m_EM )
2169 {
2170 // Load energy amount
2171 float f_energy = 0;
2172 if ( !ctx.Read( f_energy ) )
2173 f_energy = 0;
2174 m_EM.SetEnergy(f_energy);
2175
2176 // Load passive/active state
2177 bool b_is_passive = false;
2178 if ( !ctx.Read( b_is_passive ) )
2179 return false;
2180 m_EM.SetPassiveState(b_is_passive);
2181
2182 // Load ON/OFF state
2183 bool b_is_on = false;
2184 if ( !ctx.Read( b_is_on ) )
2185 {
2186 m_EM.SwitchOn();
2187 return false;
2188 }
2189
2190 // Load plugged/unplugged state
2191 bool b_is_plugged = false;
2192 if ( !ctx.Read( b_is_plugged ) )
2193 return false;
2194
2195 // ENERGY SOURCE
2196 if ( version <= 103 )
2197 {
2198 // Load energy source ID low
2199 int i_energy_source_ID_low = 0; // Even 0 can be valid ID!
2200 if ( !ctx.Read( i_energy_source_ID_low ) )
2201 return false;
2202
2203 // Load energy source ID high
2204 int i_energy_source_ID_high = 0; // Even 0 can be valid ID!
2205 if ( !ctx.Read( i_energy_source_ID_high ) )
2206 return false;
2207 }
2208 else
2209 {
2210 int b1 = 0;
2211 int b2 = 0;
2212 int b3 = 0;
2213 int b4 = 0;
2214
2215 if ( !ctx.Read(b1) ) return false;
2216 if ( !ctx.Read(b2) ) return false;
2217 if ( !ctx.Read(b3) ) return false;
2218 if ( !ctx.Read(b4) ) return false;
2219
2220 if ( b_is_plugged )
2221 {
2222 // Because function GetEntityByPersitentID() cannot be called here, ID values must be stored and used later.
2223 m_EM.StoreEnergySourceIDs( b1, b2, b3, b4 );
2224 m_EM.RestorePlugState(true);
2225 }
2226 }
2227
2228 if (b_is_on)
2229 {
2230 m_EM.SwitchOn();
2231 }
2232 }
2233 return true;
2234 }
2235
2237 proto native void SetSynchDirty();
2238
2243 {
2244 if ( m_EM )
2245 {
2246 if ( GetGame().IsMultiplayer() )
2247 {
2248 bool is_on = m_EM.IsSwitchedOn();
2249
2250 if (is_on != m_EM.GetPreviousSwitchState())
2251 {
2252 if (is_on)
2253 m_EM.SwitchOn();
2254 else
2255 m_EM.SwitchOff();
2256 }
2257
2258 int id_low = m_EM.GetEnergySourceNetworkIDLow();
2259 int id_High = m_EM.GetEnergySourceNetworkIDHigh();
2260
2261 EntityAI energy_source = EntityAI.Cast( GetGame().GetObjectByNetworkId(id_low, id_High) );
2262
2263 if (energy_source)
2264 {
2265 ComponentEnergyManager esem = energy_source.GetCompEM();
2266
2267 if ( !esem )
2268 {
2269 string object = energy_source.GetType();
2270 Error("Synchronization error! Object " + object + " has no instance of the Energy Manager component!");
2271 }
2272
2273 m_EM.PlugThisInto(energy_source);
2274
2275 }
2276 else
2277 {
2278 m_EM.UnplugThis();
2279 }
2280
2281 m_EM.DeviceUpdate();
2282 m_EM.StartUpdates();
2283 }
2284 }
2285 }
2286
2287 proto native void SetAITargetCallbacks(AbstractAITargetCallbacks callbacks);
2288
2289 override void EOnFrame(IEntity other, float timeSlice)
2290 {
2291 if ( m_ComponentsBank != NULL )
2292 {
2293 for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
2294 {
2295 if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
2296 {
2297 m_ComponentsBank.GetComponent(comp_key).Event_OnFrame(other, timeSlice);
2298 }
2299 }
2300 }
2301 }
2302
2303 string GetDebugText()
2304 {
2305 string text = string.Empty;
2306
2307 text += "Weight: " + GetWeightEx() + "\n";
2308 text += "Disabled: " + GetIsSimulationDisabled() + "\n";
2309 #ifdef SERVER
2310 text += "CE Lifetime default: " + (int)GetEconomyProfile().GetLifetime() + "\n";
2311 text += "CE Lifetime remaining: " + (int)GetLifetime() + "\n";
2312 #endif
2313
2314 ComponentEnergyManager compEM = GetCompEM();
2315 if (compEM)
2316 {
2317 text += "Energy Source: " + Object.GetDebugName(compEM.GetEnergySource()) + "\n";
2318 text += "Switched On: " + compEM.IsSwitchedOn() + "\n";
2319 text += "Is Working: " + compEM.IsWorking() + "\n";
2320 }
2321
2322 return text;
2323 }
2324
2325
2326 void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
2327 {/*
2328 button1 = "DebugButton1";
2329 button2 = "DebugButton2";
2330 button3 = "DebugButton3";
2331 button4 = "DebugButton4";
2332 */
2333 }
2334
2335 void OnDebugButtonPressClient(int button_index)
2336 {
2337 // you can react here to debug button press, buttons are indexed starting at 1 and up
2338 }
2339
2340 void OnDebugButtonPressServer(int button_index)
2341 {
2342 // you can react here to debug button press, buttons are indexed starting at 1 and up
2343 }
2344
2345 Shape DebugBBoxDraw()
2346 {
2347 return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDraw();
2348 }
2349
2350 void DebugBBoxSetColor(int color)
2351 {
2352 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxSetColor(color);
2353 }
2354
2355 void DebugBBoxDelete()
2356 {
2357 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDelete();
2358 }
2359
2360 Shape DebugDirectionDraw(float distance = 1)
2361 {
2362 return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDraw(distance);
2363 }
2364
2365 void DebugDirectionSetColor(int color)
2366 {
2367 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionSetColor(color);
2368 }
2369
2370 void DebugDirectionDelete()
2371 {
2372 GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDelete();
2373 }
2374
2376 void HideSelection( string selection_name )
2377 {
2378 if ( !ToDelete() )
2379 {
2380 SetAnimationPhase ( selection_name, 1 ); // 1 = hide, 0 = unhide!
2381 }
2382 }
2383
2385 void ShowSelection( string selection_name )
2386 {
2387 if ( !ToDelete() )
2388 {
2389 SetAnimationPhase ( selection_name, 0 ); // 1 = hide, 0 = unhide!
2390 }
2391 }
2392
2395 proto void GetPersistentID( out int b1, out int b2, out int b3, out int b4 );
2396
2398 proto native void SetLifetime( float fLifeTime );
2400 proto native float GetLifetime();
2402 proto native void IncreaseLifetime();
2403
2405 proto native void SetLifetimeMax( float fLifeTime );
2407 proto native float GetLifetimeMax();
2408
2410 void IncreaseLifetimeUp()
2411 {
2412 IncreaseLifetime();
2413 if (GetHierarchyParent())
2414 GetHierarchyParent().IncreaseLifetimeUp();
2415 }
2416
2417
2418 // BODY STAGING
2420 ComponentBodyStaging GetCompBS()
2421 {
2422 if ( HasComponent(COMP_TYPE_BODY_STAGING) )
2423 return ComponentBodyStaging.Cast( GetComponent(COMP_TYPE_BODY_STAGING) );
2424 return NULL;
2425 }
2426
2430 ComponentEnergyManager GetCompEM()
2431 {
2432 if (m_EM)
2433 return m_EM;
2434
2435 if ( HasComponent(COMP_TYPE_ENERGY_MANAGER) )
2436 return ComponentEnergyManager.Cast( GetComponent(COMP_TYPE_ENERGY_MANAGER) );
2437 return NULL;
2438 }
2439
2441 bool HasEnergyManager()
2442 {
2443 return HasComponent(COMP_TYPE_ENERGY_MANAGER);
2444 }
2445
2446 // ------ Public Events for Energy manager component. Overwrite these and put your own functionality into them. ------
2447
2449 void OnWorkStart() {}
2450
2452 void OnWork( float consumed_energy ) {}
2453
2455 void OnWorkStop() {}
2456
2458 void OnSwitchOn() {}
2459
2461 void OnSwitchOff() {}
2462
2464 void OnIsPlugged(EntityAI source_device) {}
2465
2467 void OnIsUnplugged( EntityAI last_energy_source ) {}
2468
2470 void OnOwnSocketTaken( EntityAI device ) {}
2471
2473 void OnOwnSocketReleased( EntityAI device ) {}
2474
2476 void OnInitEnergy() {}
2477
2479 void OnEnergyConsumed() {}
2480
2482 void OnEnergyAdded() {}
2484
2485 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
2486 {
2487 super.OnRPC(sender, rpc_type, ctx);
2488
2489 if ( GetGame().IsClient() )
2490 {
2491 switch (rpc_type)
2492 {
2493 // BODY STAGING - server => client synchronization of skinned state.
2494 case ERPCs.RPC_BS_SKINNED_STATE:
2495 {
2496 Param1<bool> p_skinned_state= new Param1<bool>(false);
2497 if (ctx.Read(p_skinned_state))
2498 {
2499 float state = p_skinned_state.param1;
2500 if (state && GetCompBS())
2501 GetCompBS().SetAsSkinnedClient();
2502 }
2503 break;
2504 }
2505
2506 case ERPCs.RPC_EXPLODE_EVENT:
2507 {
2508 OnExplodeClient();
2509 break;
2510 }
2511 }
2512 }
2513 }
2514
2515 #ifdef DIAG_DEVELOPER
2516 void FixEntity()
2517 {
2518 SetFullHealth();
2519
2520 if (GetInventory())
2521 {
2522 int i = 0;
2523 int AttachmentsCount = GetInventory().AttachmentCount();
2524 if (AttachmentsCount > 0)
2525 {
2526 for (i = 0; i < AttachmentsCount; i++)
2527 {
2528 GetInventory().GetAttachmentFromIndex(i).FixEntity();
2529 }
2530 }
2531
2532 CargoBase cargo = GetInventory().GetCargo();
2533 if (cargo)
2534 {
2535 int cargoCount = cargo.GetItemCount();
2536 for (i = 0; i < cargoCount; i++)
2537 {
2538 cargo.GetItem(i).FixEntity();
2539 }
2540 }
2541 }
2542 }
2543 #endif
2544
2545 float GetWetWeightModifier()
2546 {
2548 }
2549
2550 float GetConfigWeightModified()
2551 {
2552 return m_ConfigWeight * GetWetWeightModifier();
2553 }
2554
2555 #ifdef DEVELOPER
2556 string GetConfigWeightModifiedDebugText()
2557 {
2558 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
2559 {
2560 return "(" + m_ConfigWeight + "(config weight) * " + GetWetWeightModifier() + "(Wetness Modifier))";
2561 }
2562 return string.Empty;
2563 }
2564 #endif
2565
2566
2567 //Obsolete, use GetWeightEx()
2568 int GetWeight()
2569 {
2570 return GetWeightEx();
2571 }
2572
2573 void ClearWeightDirty()
2574 {
2575 //Print("ent:" + this + " - ClearWeightDirty");
2576 m_WeightDirty = 0;
2577 }
2578
2579 void SetWeightDirty()
2580 {
2581 #ifdef DEVELOPER
2582 if (WeightDebug.m_VerbosityFlags & WeightDebugType.SET_DIRTY_FLAG)
2583 {
2584 Print("---------------------------------------");
2585 Print("ent:" + this + " - SetWeightDirty");
2586 if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK)
2587 {
2588 DumpStack();
2589 }
2590 Print("---------------------------------------");
2591 }
2592 #endif
2593 m_WeightDirty = 1;
2594 if (GetHierarchyParent())
2595 {
2596 GetHierarchyParent().SetWeightDirty();
2597 }
2598 }
2599 // returns weight of all cargo and attachments
2600 float GetInventoryAndCargoWeight(bool forceRecalc = false)
2601 {
2602 float totalWeight;
2603 if (GetInventory())
2604 {
2605 int i = 0;
2606 int AttachmentsCount = GetInventory().AttachmentCount();
2607 if (AttachmentsCount > 0)
2608 {
2609 for (i = 0; i < AttachmentsCount; i++)
2610 {
2611 totalWeight += GetInventory().GetAttachmentFromIndex(i).GetWeightEx(forceRecalc);
2612 }
2613 }
2614
2615 CargoBase cargo = GetInventory().GetCargo();
2616 if (cargo)
2617 {
2618 int cargoCount = cargo.GetItemCount();
2619 for (i = 0; i < cargoCount; i++)
2620 {
2621 totalWeight += cargo.GetItem(i).GetWeightEx(forceRecalc);
2622 }
2623 }
2624 }
2625 return totalWeight;
2626 }
2628 protected float GetWeightSpecialized(bool forceRecalc = false)
2629 {
2630 return GetInventoryAndCargoWeight(forceRecalc);
2631 }
2632
2634 //this method is not meant to be overriden, to adjust weight calculation for specific item type, override 'GetWeightSpecialized(bool forceRecalc = false)' instead
2635 float GetWeightEx(bool forceRecalc = false)
2636 {
2637 if (m_WeightDirty || forceRecalc)//recalculate
2638 {
2639 m_WeightEx = GetWeightSpecialized(forceRecalc);
2640 ClearWeightDirty();
2641
2642 #ifdef DEVELOPER
2643 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
2644 {
2645 WeightDebug.GetWeightDebug(this).SetWeight(m_WeightEx);
2646 }
2647 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_DIRTY)
2648 {
2649 Print("ent:" + this + " - Dirty Recalc");
2650 if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK)
2651 {
2652 DumpStack();
2653 }
2654 }
2655 #endif
2656 }
2657
2658 return m_WeightEx;
2659 }
2660
2661 void UpdateWeight(WeightUpdateType updateType = WeightUpdateType.FULL, float weightAdjustment = 0);
2662
2666 int m_ViewIndex = 0;
2667
2669 void SetViewIndex( int index )
2670 {
2671 m_ViewIndex = index;
2672
2673 if( GetGame().IsServer() )
2674 {
2675 SetSynchDirty();
2676 }
2677 }
2678
2680 int GetViewIndex()
2681 {
2682 if ( MemoryPointExists( "invView2" ) )
2683 {
2684 #ifdef PLATFORM_WINDOWS
2686 GetInventory().GetCurrentInventoryLocation( il );
2687 InventoryLocationType type = il.GetType();
2688 switch ( type )
2689 {
2690 case InventoryLocationType.CARGO:
2691 {
2692 return 0;
2693 }
2694 case InventoryLocationType.ATTACHMENT:
2695 {
2696 return 1;
2697 }
2698 case InventoryLocationType.HANDS:
2699 {
2700 return 0;
2701 }
2702 case InventoryLocationType.GROUND:
2703 {
2704 return 1;
2705 }
2706 case InventoryLocationType.PROXYCARGO:
2707 {
2708 return 0;
2709 }
2710 default:
2711 {
2712 return 0;
2713 }
2714 }
2715 #endif
2716
2717 #ifdef PLATFORM_CONSOLE
2718 return 1;
2719 #endif
2720 }
2721 return 0;
2722 }
2724
2726 string GetHitComponentForAI()
2727 {
2728 Debug.LogError("EntityAI: HitComponentForAI not set properly for that entity (" + GetType() + ")");
2730 return "";
2731 }
2732
2734 string GetDefaultHitComponent()
2735 {
2736 Debug.LogError("EntityAI: DefaultHitComponent not set properly for that entity (" + GetType() + ")");
2738 return "";
2739 }
2740
2743 {
2744 Debug.LogError("EntityAI: DefaultHitPositionComponent not set for that entity (" + GetType() + ")");
2745 return "";
2746 }
2747
2749 {
2750 Debug.LogError("EntityAI: SuitableFinisherHitComponents not set for that entity (" + GetType() + ")");
2751 return null;
2752 }
2753
2755 {
2756 Debug.LogError("EntityAI: DefaultHitPosition not set for that entity (" + GetType() + ")");
2757 return vector.Zero;
2758 }
2759
2761 int GetMeleeTargetType()
2762 {
2763 return EMeleeTargetType.ALIGNABLE;
2764 }
2765
2767 string GetAttachmentSoundType()
2768 {
2769 return "None";
2770 }
2771
2773 bool IsHeavyBehaviour()
2774 {
2775 return false;
2776 }
2777
2780 {
2781 return false;
2782 }
2783
2786 {
2787 return false;
2788 }
2789
2790 string ChangeIntoOnAttach(string slot) {}
2791 string ChangeIntoOnDetach() {}
2792
2805 void OnCEUpdate()
2806 {
2807 float currentTime = GetGame().GetTickTime();
2808 if (m_LastUpdatedTime == 0)
2809 m_LastUpdatedTime = currentTime;
2810
2811 m_ElapsedSinceLastUpdate = currentTime - m_LastUpdatedTime;
2812 m_LastUpdatedTime = currentTime;
2813 }
2814
2815 void OnDebugSpawn()
2816 {
2817 array<string> slots = new array<string>;
2818 ConfigGetTextArray("Attachments", slots);
2819
2820 array<string> mags = new array<string>;
2821 ConfigGetTextArray("magazines", mags);
2822
2823 //-------
2824
2825 TStringArray all_paths = new TStringArray;
2826
2827 all_paths.Insert(CFG_VEHICLESPATH);
2828 all_paths.Insert(CFG_MAGAZINESPATH);
2829 all_paths.Insert(CFG_WEAPONSPATH);
2830
2831 string config_path;
2832 string child_name;
2833 int scope;
2834 string path;
2835 int consumable_count;
2836
2837 for (int i = 0; i < all_paths.Count(); i++)
2838 {
2839 config_path = all_paths.Get(i);
2840 int children_count = GetGame().ConfigGetChildrenCount(config_path);
2841
2842 for (int x = 0; x < children_count; x++)
2843 {
2844 GetGame().ConfigGetChildName(config_path, x, child_name);
2845 path = config_path + " " + child_name;
2846 scope = GetGame().ConfigGetInt( config_path + " " + child_name + " scope" );
2847 bool should_check = 1;
2848 if ( config_path == "CfgVehicles" && scope == 0)
2849 {
2850 should_check = 0;
2851 }
2852
2853 if ( should_check )
2854 {
2855 string inv_slot;
2856 GetGame().ConfigGetText( config_path + " " + child_name + " inventorySlot",inv_slot );
2857 for (int z = 0; z < slots.Count(); z++)
2858 {
2859 if (slots.Get(z) == inv_slot)
2860 {
2861 this.GetInventory().CreateInInventory( child_name );
2862 continue;
2863 //Print("matching attachment: " + child_name + " for inv. slot name:" +inv_slot);
2864 }
2865 }
2866 }
2867 }
2868 }
2869 };
2870
2871 override EntityAI ProcessMeleeItemDamage(int mode = 0)
2872 {
2873 if (GetGame().IsServer())
2874 AddHealth("","Health",-MELEE_ITEM_DAMAGE);
2875 return this;
2876 }
2877
2880 {
2882 }
2883
2885 {
2886 return "";
2887 }
2888
2889 void ProcessInvulnerabilityCheck(string servercfg_param)
2890 {
2891 if ( GetGame() && GetGame().IsMultiplayer() && GetGame().IsServer() )
2892 {
2893 int invulnerability;
2894 switch (servercfg_param)
2895 {
2896 case "disableContainerDamage":
2898 break;
2899
2900 case "disableBaseDamage":
2901 invulnerability = CfgGameplayHandler.GetDisableBaseDamage();
2902 break;
2903 }
2904
2905 if (invulnerability > 0)
2906 {
2907 SetAllowDamage(false);
2908 }
2909 }
2910 }
2911
2912 void SetBayonetAttached(bool pState, int slot_idx = -1) {};
2913 bool HasBayonetAttached() {};
2914 int GetBayonetAttachmentIdx() {};
2915
2916 void SetButtstockAttached(bool pState, int slot_idx = -1) {};
2917 bool HasButtstockAttached() {};
2918 int GetButtstockAttachmentIdx() {};
2919
2920 void SetInvisibleRecursive(bool invisible, EntityAI parent = null, array<int> attachments = null)
2921 {
2922 array<int> childrenAtt = new array<int>;
2923 array<int> attachmentsArray = new array<int>;
2924 if (attachments)
2925 attachmentsArray.Copy(attachments);
2926 else
2927 {
2928 for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); i++)
2929 {
2930 attachmentsArray.Insert(GetInventory().GetAttachmentSlotId(i));
2931 }
2932 }
2933
2934 EntityAI item;
2935
2936 foreach( int slot : attachmentsArray )
2937 {
2938 if( parent )
2939 item = parent.GetInventory().FindAttachment(slot);
2940 else
2941 item = this;//GetInventory().FindAttachment(slot);
2942
2943 if( item )
2944 {
2945 if( item.GetInventory().AttachmentCount() > 0 )
2946 {
2947 for(i = 0; i < item.GetInventory().GetAttachmentSlotsCount(); i++)
2948 {
2949 childrenAtt.Insert(item.GetInventory().GetAttachmentSlotId(i));
2950 }
2951
2952 SetInvisibleRecursive(invisible,item,childrenAtt);
2953 }
2954
2955 item.SetInvisible(invisible);
2956 }
2957 }
2958 }
2959
2960 void SoundHardTreeFallingPlay()
2961 {
2962 EffectSound sound = SEffectManager.PlaySound( "hardTreeFall_SoundSet", GetPosition() );
2963 sound.SetAutodestroy( true );
2964 }
2965
2966 void SoundSoftTreeFallingPlay()
2967 {
2968 EffectSound sound = SEffectManager.PlaySound( "softTreeFall_SoundSet", GetPosition() );
2969 sound.SetAutodestroy( true );
2970 }
2971
2972 void SoundHardBushFallingPlay()
2973 {
2974 EffectSound sound = SEffectManager.PlaySound( "hardBushFall_SoundSet", GetPosition() );
2975 sound.SetAutodestroy( true );
2976 }
2977
2978 void SoundSoftBushFallingPlay()
2979 {
2980 EffectSound sound = SEffectManager.PlaySound( "softBushFall_SoundSet", GetPosition() );
2981 sound.SetAutodestroy( true );
2982 }
2983
2984 void RegisterTransportHit(Transport transport)
2985 {
2986 if (!m_TransportHitRegistered)
2987 {
2988 m_TransportHitRegistered = true;
2989 m_TransportHitVelocity = GetVelocity(transport);
2990 Car car;
2991 float damage;
2992 vector impulse;
2993
2994 // a different attempt to solve hits from "standing" car to the players
2995 if (Car.CastTo(car, transport))
2996 {
2997 if (car.GetSpeedometerAbsolute() > 2 )
2998 {
2999 damage = m_TransportHitVelocity.Length();
3000 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
3001 }
3002 else
3003 {
3004 m_TransportHitRegistered = false;
3005 }
3006
3007 // compute impulse and apply only if the body dies
3008 if (IsDamageDestroyed() && car.GetSpeedometerAbsolute() > 3)
3009 {
3010 impulse = 40 * m_TransportHitVelocity;
3011 impulse[1] = 40 * 1.5;
3012 dBodyApplyImpulse(this, impulse);
3013 }
3014 }
3015 else //old solution just in case if somebody use it
3016 {
3017 // avoid damage because of small movements
3018 if (m_TransportHitVelocity.Length() > 0.1)
3019 {
3020 damage = m_TransportHitVelocity.Length();
3021 ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
3022 }
3023 else
3024 {
3025 m_TransportHitRegistered = false;
3026 }
3027
3028 // compute impulse and apply only if the body dies
3029 if (IsDamageDestroyed() && m_TransportHitVelocity.Length() > 0.3)
3030 {
3031 impulse = 40 * m_TransportHitVelocity;
3032 impulse[1] = 40 * 1.5;
3033 dBodyApplyImpulse(this, impulse);
3034 }
3035 }
3036 }
3037 }
3038
3039 bool GetInventoryHandAnimation(notnull InventoryLocation loc, out int value)
3040 {
3041 value = -1;
3042 return false;
3043 }
3044
3045 bool TranslateSlotFromSelection(string selection_name, out int slot_id)
3046 {
3047 return false;
3048 }
3049
3051 bool IsUniversalTemperatureSource()
3052 {
3053 return GetUniversalTemperatureSource() != null && GetUniversalTemperatureSource().IsActive();
3054 }
3055
3056 UTemperatureSource GetUniversalTemperatureSource()
3057 {
3058 return m_UniversalTemperatureSource;
3059 }
3060
3061 void SetUniversalTemperatureSource(UTemperatureSource uts)
3062 {
3063 m_UniversalTemperatureSource = uts;
3064 }
3065
3066 vector GetUniversalTemperatureSourcePosition()
3067 {
3068 return GetPosition();
3069 }
3070
3073
3074 void PairRemote(notnull EntityAI trigger);
3075
3076 void UnpairRemote();
3077
3078 EntityAI GetPairDevice();
3079
3080 void SetPersistentPairID(int id)
3081 {
3083 if (raib)
3084 {
3085 raib.SetPersistentPairID(id);
3086 }
3087 }
3088
3091 bool IsValveTurnable(int pValveIndex);
3092 int GetTurnableValveIndex(int pComponentIndex);
3093 void ExecuteActionsConnectedToValve(int pValveIndex);
3094
3096// attachment exclusion section //
3098 private void InitAttachmentExclusionValues()
3099 {
3100 m_AttachmentExclusionSlotMap = new map<int,ref set<int>>();
3101 m_AttachmentExclusionMaskGlobal = new set<int>;
3102 m_AttachmentExclusionMaskChildren = new set<int>();
3103
3104 int count = GetInventory().GetSlotIdCount();
3105 //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)
3106 if (count == 0)
3107 return;
3108
3109 InitInherentSlotExclusionMap();
3110 InitGlobalExclusionValues();
3111 InitLegacyConfigExclusionValues();
3112 }
3113
3115 private void InitInherentSlotExclusionMap()
3116 {
3117 int count = GetInventory().GetSlotIdCount();
3118 //starting with the INVALID slot, so it is always in the map of attachable items
3119 SetAttachmentExclusionMaskSlot(InventorySlots.INVALID,GetAttachmentExclusionInitSlotValue(InventorySlots.INVALID));
3120
3121 int slotId;
3122 for (int i = 0; i < count; i++)
3123 {
3124 slotId = GetInventory().GetSlotId(i);
3125 SetAttachmentExclusionMaskSlot(slotId,GetAttachmentExclusionInitSlotValue(slotId));
3126 }
3127 }
3128
3130 protected set<int> GetAttachmentExclusionInitSlotValue(int slotId)
3131 {
3132 set<int> dflt = new set<int>;
3133 return dflt;
3134 }
3135
3136 //Initiated last, and only for items that do not have others defined already
3137 protected void InitLegacyConfigExclusionValues()
3138 {
3139 bool performLegacyInit = InitLegacyExclusionCheck();
3140
3141 //adding implicit slot info AFTER the check is performed
3142 InitLegacySlotExclusionValuesImplicit();
3143
3144 if (performLegacyInit)
3145 InitLegacySlotExclusionValuesDerived();
3146 }
3147
3148 //returns 'false' if the script initialization
3149 protected bool InitLegacyExclusionCheck()
3150 {
3151 //first check the globals
3152 if (m_AttachmentExclusionMaskGlobal.Count() > 0)
3153 return false;
3154
3155 //now the map
3156 int count = m_AttachmentExclusionSlotMap.Count();
3157 if (count > 1) //more than InventorySlots.INVALID
3158 {
3159 for (int i = 0; i < count; i++)
3160 {
3161 int countSet = m_AttachmentExclusionSlotMap.GetElement(i).Count();
3162 if (countSet > 0) //SOMETHING is defined
3163 {
3164 return false;
3165 }
3166 }
3167 }
3168
3169 return true;
3170 }
3171
3177 protected void InitLegacySlotExclusionValuesImplicit()
3178 {
3179 int slotId;
3180 int slotCount = GetInventory().GetSlotIdCount();
3181 for (int i = 0; i < slotCount; i++)
3182 {
3183 slotId = GetInventory().GetSlotId(i);
3184 set<int> tmp;
3185 switch (slotId)
3186 {
3187 case InventorySlots.HEADGEAR:
3188 {
3189 tmp = new set<int>;
3190 tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
3191 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK);
3192 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP);
3193 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR);
3194 SetAttachmentExclusionMaskSlot(slotId,tmp);
3195 break;
3196 }
3197
3198 case InventorySlots.MASK:
3199 {
3200 tmp = new set<int>;
3201 tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
3202 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR);
3203 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP);
3204 tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR);
3205 SetAttachmentExclusionMaskSlot(slotId,tmp);
3206 break;
3207 }
3208
3209 case InventorySlots.EYEWEAR:
3210 {
3211 tmp = new set<int>;
3212 tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
3213 if (ConfigGetBool("isStrap"))
3214 {
3215 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR);
3216 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK);
3217 }
3218 else
3219 {
3220 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR);
3221 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK);
3222 }
3223 SetAttachmentExclusionMaskSlot(slotId,tmp);
3224 break;
3225 }
3226 }
3227 }
3228 }
3229
3230 protected void InitLegacySlotExclusionValuesDerived()
3231 {
3232 int slotId;
3233 int slotCount = GetInventory().GetSlotIdCount();
3234 for (int i = 0; i < slotCount; i++)
3235 {
3236 slotId = GetInventory().GetSlotId(i);
3237 set<int> tmp;
3238 switch (slotId)
3239 {
3240 case InventorySlots.HEADGEAR:
3241 {
3242 tmp = new set<int>;
3243 tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
3244 if (ConfigGetBool("noNVStrap"))
3245 {
3246 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR);
3247 }
3248 if (ConfigGetBool("noMask"))
3249 {
3250 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR);
3251 }
3252 if (ConfigGetBool("noEyewear"))
3253 {
3254 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR);
3255 }
3256 SetAttachmentExclusionMaskSlot(slotId,tmp);
3257 break;
3258 }
3259
3260 case InventorySlots.MASK:
3261 {
3262 tmp = new set<int>;
3263 tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
3264 if (ConfigGetBool("noNVStrap"))
3265 {
3266 tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK);
3267 }
3268 if (ConfigGetBool("noHelmet"))
3269 {
3270 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK);
3271 }
3272 if (ConfigGetBool("noEyewear"))
3273 {
3274 tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK);
3275 }
3276 SetAttachmentExclusionMaskSlot(slotId,tmp);
3277 break;
3278 }
3279
3280 case InventorySlots.EYEWEAR:
3281 {
3282 tmp = new set<int>;
3283 tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
3284 if (ConfigGetBool("isStrap"))
3285 {
3286 if (ConfigGetBool("noHelmet"))
3287 {
3288 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP);
3289 }
3290 if (ConfigGetBool("noMask"))
3291 {
3292 tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP);
3293 }
3294 }
3295 else
3296 {
3297 if (ConfigGetBool("noHelmet"))
3298 {
3299 tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR);
3300 }
3301 if (ConfigGetBool("noMask"))
3302 {
3303 tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR);
3304 }
3305 }
3306 SetAttachmentExclusionMaskSlot(slotId,tmp);
3307 break;
3308 }
3309 }
3310 }
3311 }
3312
3314 protected void InitGlobalExclusionValues();
3315
3317 protected void AddSingleExclusionValueGlobal(EAttExclusions value)
3318 {
3319 if (m_AttachmentExclusionMaskGlobal.Find(value) == -1)
3320 m_AttachmentExclusionMaskGlobal.Insert(value);
3321 }
3322
3324 protected void ClearSingleExclusionValueGlobal(EAttExclusions value)
3325 {
3326 int idx = m_AttachmentExclusionMaskGlobal.Find(value);
3327 if (idx != -1)
3328 m_AttachmentExclusionMaskGlobal.Remove(idx);
3329 }
3330
3331 protected void SetAttachmentExclusionMaskGlobal(set<int> values)
3332 {
3333 m_AttachmentExclusionMaskGlobal.Clear();
3334 m_AttachmentExclusionMaskGlobal.Copy(values);
3335 }
3336
3338 protected void SetAttachmentExclusionMaskSlot(int slotId, set<int> values)
3339 {
3340 if (m_AttachmentExclusionSlotMap)
3341 {
3342 m_AttachmentExclusionSlotMap.Set(slotId,values);
3343 }
3344 else
3345 ErrorEx("m_AttachmentExclusionSlotMap not available! Fill the 'inventorySlot[]' in the " + this + " config file.");
3346 }
3347
3348 private void PropagateExclusionValueRecursive(set<int> values, int slotId)
3349 {
3350 if (values && values.Count() != 0)
3351 {
3352 set<int> passThis;
3354 GetInventory().GetCurrentInventoryLocation(lcn);
3355 if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis))
3356 {
3357 m_AttachmentExclusionMaskChildren.InsertSet(passThis);
3358 EntityAI parent = GetHierarchyParent();
3359 if (parent)
3360 parent.PropagateExclusionValueRecursive(passThis,lcn.GetSlot());
3361 }
3362 }
3363 }
3364
3365 private void ClearExclusionValueRecursive(set<int> values, int slotId)
3366 {
3367 if (values && values.Count() != 0)
3368 {
3369 set<int> passThis;
3371 GetInventory().GetCurrentInventoryLocation(lcn);
3372 if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis))
3373 {
3374 int count = passThis.Count();
3375 for (int i = 0; i < count; i++)
3376 {
3377 m_AttachmentExclusionMaskChildren.RemoveItem(passThis[i]);
3378 }
3379 EntityAI parent = GetHierarchyParent();
3380 if (parent)
3381 parent.ClearExclusionValueRecursive(passThis,lcn.GetSlot());
3382 }
3383 }
3384 }
3385
3387 set<int> GetAttachmentExclusionMaskAll(int slotId)
3388 {
3389 set<int> values = new set<int>();
3390 set<int> slotValues = GetAttachmentExclusionMaskSlot(slotId);
3391 if (slotValues)
3392 values.InsertSet(slotValues);
3393 values.InsertSet(m_AttachmentExclusionMaskGlobal);
3394 values.InsertSet(m_AttachmentExclusionMaskChildren);
3395
3396 return values;
3397 }
3398
3400 set<int> GetAttachmentExclusionMaskSlot(int slotId)
3401 {
3402 return m_AttachmentExclusionSlotMap.Get(slotId);
3403 }
3404
3406 set<int> GetAttachmentExclusionMaskGlobal()
3407 {
3408 return m_AttachmentExclusionMaskGlobal;
3409 }
3410
3412 set<int> GetAttachmentExclusionMaskChildren()
3413 {
3414 return m_AttachmentExclusionMaskChildren;
3415 }
3416
3418 private bool HasInternalExclusionConflicts(int targetSlot)
3419 {
3420 set<int> targetSlotValues = GetAttachmentExclusionMaskSlot(targetSlot);
3421 if (targetSlotValues) //can be null, if so, no conflict
3422 {
3423 set<int> additionalValues = new set<int>(); //NOT slot values
3424 additionalValues.InsertSet(GetAttachmentExclusionMaskGlobal());
3425 additionalValues.InsertSet(GetAttachmentExclusionMaskChildren());
3426
3427 int countTarget = targetSlotValues.Count();
3428 for (int i = 0; i < countTarget; i++)
3429 {
3430 if (additionalValues.Find(targetSlotValues[i]) != -1)
3431 {
3432 return true;
3433 }
3434 }
3435 }
3436 return false;
3437 }
3438
3440 protected bool IsExclusionFlagPresent(set<int> values)
3441 {
3442 int slotId;
3443 string slotName;
3444 GetInventory().GetCurrentAttachmentSlotInfo(slotId,slotName); //if currently attached, treat it accordingly
3445
3446 set<int> currentSlotValuesAll = GetAttachmentExclusionMaskAll(slotId);
3447 int count = values.Count();
3448 for (int i = 0; i < count; i++)
3449 {
3450 if (currentSlotValuesAll.Find(values[i]) != -1)
3451 return true;
3452 }
3453 return false;
3454 }
3455
3457 protected bool IsExclusionFlagPresentRecursive(set<int> values, int targetSlot)
3458 {
3459 if (values && values.Count() != 0)
3460 {
3462 GetInventory().GetCurrentInventoryLocation(lcn);
3463 EntityAI parent = GetHierarchyParent();
3464 set<int> passThis;
3465 if (CheckExclusionAccessCondition(lcn.GetSlot(),targetSlot, values, passThis))
3466 {
3467 if (parent && parent != this) //we reached root if false
3468 {
3469 return parent.IsExclusionFlagPresentRecursive(passThis,lcn.GetSlot());
3470 }
3471 }
3472 return IsExclusionFlagPresent(passThis);
3473 }
3474
3475 return false;
3476 }
3477
3479 protected bool CheckExclusionAccessCondition(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue)
3480 {
3481 bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND;
3482 bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND;
3483
3484 if (occupiedException)
3485 {
3486 adjustedValue = value;
3487 return false;
3488 }
3489
3490 if (targetException)
3491 {
3492 adjustedValue = null;
3493 return false;
3494 }
3495
3496 AdjustExclusionAccessCondition(occupiedSlot,targetSlot,value,adjustedValue);
3497 return adjustedValue.Count() != 0;
3498 }
3499
3501 protected void AdjustExclusionAccessCondition(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue)
3502 {
3503 adjustedValue = value;
3504 }
3505
3507 protected bool CheckExclusionAccessPropagation(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue)
3508 {
3509 bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND;
3510 bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND;
3511
3512 if (targetException)
3513 {
3514 adjustedValue = null;
3515 return false;
3516 }
3517
3518 AdjustExclusionAccessPropagation(occupiedSlot,targetSlot,value,adjustedValue);
3519 return adjustedValue.Count() != 0;
3520 }
3521
3523 protected void AdjustExclusionAccessPropagation(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue)
3524 {
3525 AdjustExclusionAccessCondition(occupiedSlot,testedSlot,value,adjustedValue);
3526 }
3527
3528 bool IsManagingArrows()
3529 {
3530 return false;
3531 }
3532
3534 {
3535 return null;
3536 }
3537
3538 void SetFromProjectile(ProjectileStoppedInfo info)
3539 {
3540 }
3542
3543#ifdef DEVELOPER
3544void 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
3545{
3546 if (entity)
3547 entity.SetDebugItem();
3548
3549}
3550Object _item;//watched item goes here(LCTRL+RMB->Watch)
3551#endif
enum EWetnessLevel BUSH_SOFT
enum EWetnessLevel FULL
enum EWetnessLevel HIDE_HANDS_SLOT
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
enum EWetnessLevel TREE_SOFT
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
InventoryMode
Definition Inventory.c:20
eBleedingSourceType GetType()
protected bool IsDamageDestroyed(ActionTarget target)
Definition ActionBase.c:912
override bool ReplaceOnDeath()
Definition AnimalBase.c:177
override ArrowManagerBase GetArrowManager()
Definition AnimalBase.c:31
override string GetDeadItemName()
Definition AnimalBase.c:187
override bool IsRefresherSignalingViable()
Definition AnimalBase.c:36
override bool KeepHealthOnReplace()
Definition AnimalBase.c:192
vector GetOrientation()
override bool IgnoreOutOfReachCondition()
override void EEInit()
override void EEItemDetached(EntityAI item, string slot_name)
override bool CanPutIntoHands(EntityAI parent)
override int GetHideIconMask()
override bool CanRemoveFromCargo(EntityAI parent)
override void EEItemAttached(EntityAI item, string slot_name)
override string GetInvulnerabilityTypeString()
class RecipeCacheData int
override vector GetDefaultHitPosition()
Definition CarScript.c:2445
override float GetLiquidThroughputCoef()
Definition CarScript.c:477
proto native CEApi GetCEApi()
Get the CE API.
const int ECE_OBJECT_SWAP
const int RF_ORIGINAL
const int ECE_PLACE_ON_SURFACE
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int RF_DEFAULT
override bool CanDisplayAttachmentCategory(string category_name)
override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
Definition ClockBase.c:128
override void OnDamageDestroyed(int oldLevel)
Definition ClockBase.c:134
override bool IsInitialized()
override bool CanLoadItemIntoCargo(EntityAI item)
override bool CanLoadAttachment(EntityAI attachment)
map< string, ref array< string > > DamageZoneMap
override bool IsManagingArrows()
Definition DayZAnimal.c:70
DayZGame g_Game
Definition DayZGame.c:3654
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
EMeleeTargetType
ERPCs
Definition ERPCs.c:2
void AfterStoreLoad()
override void OnCEUpdate()
override void EEKilled(Object killer)
override void EEDelete(EntityAI parent)
override void UnpairRemote()
override bool IsTakeable()
override void OnDebugButtonPressServer(int button_index)
override void OnAttachmentRuined(EntityAI attachment)
override bool CanReleaseAttachment(EntityAI attachment)
override bool DisassembleOnLastDetach()
override bool IsPrepareToDelete()
override void EECargoOut(EntityAI item)
override void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4)
override bool IsEmpty()
override bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
override bool HasFlammableMaterial()
override protected bool CanBeIgnitedBy(EntityAI igniter=NULL)
override protected void OnIgnitedThis(EntityAI fire_source)
Executed on Server when some item ignited this one.
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 bool IsHologram()
Definition ItemBase.c:5556
override void EECargoIn(EntityAI item)
Definition ItemBase.c:5611
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Definition ItemBase.c:5779
override void AddTemperature(float value)
Definition ItemBase.c:8146
override float GetTemperatureMax()
Definition ItemBase.c:8171
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Definition ItemBase.c:8263
override void InsertAgent(int agent, float count=1)
Definition ItemBase.c:8477
override bool CanBeSplit()
Definition ItemBase.c:6092
override float GetWetMax()
Definition ItemBase.c:8238
override bool CanDisplayCargo()
Definition ItemBase.c:8615
override bool CanReceiveItemIntoCargo(EntityAI item)
Definition ItemBase.c:8653
override protected float GetWeightSpecialized(bool forceRecalc=false)
Definition ItemBase.c:7992
override string ChangeIntoOnAttach(string slot)
Definition ItemBase.c:5915
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:5444
override void RemoveAgent(int agent_id)
Definition ItemBase.c:8458
override void RemoveAllAgents()
Definition ItemBase.c:8467
override float GetQuantity()
Definition ItemBase.c:7967
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition ItemBase.c:6447
override void OnWetChanged(float newVal, float oldVal)
Definition ItemBase.c:8253
override string GetAttachmentSoundType()
Definition ItemBase.c:8867
override string ChangeIntoOnDetach()
Definition ItemBase.c:5939
override void OnEnergyAdded()
Definition ItemBase.c:8110
override float GetWetInit()
Definition ItemBase.c:8248
override bool IsBeingPlaced()
Definition ItemBase.c:5540
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Definition ItemBase.c:8594
override void SetTemperature(float value, bool allow_client=false)
Definition ItemBase.c:8130
override void SetWetMax()
Definition ItemBase.c:8228
override void SetTakeable(bool pState)
Definition ItemBase.c:8843
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition ItemBase.c:8431
override float GetTemperature()
Definition ItemBase.c:8156
override void SetWet(float value, bool allow_client=false)
Definition ItemBase.c:8204
override bool IsOneHandedBehaviour()
Definition ItemBase.c:8809
override void SetQuantityToMinimum()
Definition ItemBase.c:7877
override float GetWetMin()
Definition ItemBase.c:8243
override int GetQuickBarBonus()
Definition ItemBase.c:4893
override void EEOnAfterLoad()
Definition ItemBase.c:7745
override float GetTemperatureInit()
Definition ItemBase.c:8161
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition ItemBase.c:6015
override void RemoveAllAgentsExcept(int agents_to_keep_mask)
Definition ItemBase.c:8472
override void AddWet(float value)
Definition ItemBase.c:8223
override void OnMovedInsideCargo(EntityAI container)
Definition ItemBase.c:5616
override bool CanPutAsAttachment(EntityAI parent)
Definition ItemBase.c:8638
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Definition ItemBase.c:6547
override bool IsHeavyBehaviour()
Definition ItemBase.c:8799
override void OnWasAttached(EntityAI parent, int slot_id)
Definition ItemBase.c:5895
override void OnPlacementStarted(Man player)
Definition ItemBase.c:8424
override int GetTargetQuantityMax(int attSlotID=-1)
Definition ItemBase.c:7929
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition ItemBase.c:5774
override float GetWet()
Definition ItemBase.c:8233
override int GetAgents()
Definition ItemBase.c:8492
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition ItemBase.c:8662
override float GetTemperatureMin()
Definition ItemBase.c:8166
override void SetTemperatureMax()
Definition ItemBase.c:8151
override EWetnessLevel GetWetLevel()
Definition ItemBase.c:8268
override bool IsTwoHandedBehaviour()
Definition ItemBase.c:8819
override int GetQuantityMax()
Definition ItemBase.c:7907
override void OnEnergyConsumed()
Definition ItemBase.c:8103
override void OnVariablesSynchronized()
override bool HasTurnableValveBehavior()
override bool IsValveTurnable(int pValveIndex)
override int GetTurnableValveIndex(int pComponentIndex)
void LogWarning(string message, LogTemplateID template_id=0)
Creates warning log (optional) from LogTemplate which are registred.
class LogTemplates Log(string message, LogTemplateID template_id=0)
Creates debug log (optional) from LogTemplate which are registred.
void LogError(string message, LogTemplateID template_id=0)
Creates error log (optional) from LogTemplate which are registred.
override void OnWorkStop()
void OnStoreSave(ParamsWriteContext ctx)
string GetDebugText()
bool OnStoreLoad(ParamsReadContext ctx, int version)
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
override void PairRemote(notnull EntityAI trigger)
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
override bool CanPutInCargo(EntityAI parent)
override void OnWork(float consumed_energy)
override void OnWorkStart()
void OnRPC(float stamina, float stamina_cap, bool cooldown)
deprecated use, StaminaHandler uses SyncJunctures now
protected override void EOnFrame(IEntity other, float timeSlice)
override bool DoPlacingHeightCheck()
override bool CanDisplayAttachmentSlot(int slot_id)
override void OnPlacementCancelled(Man player)
override bool CanBePlaced(Man player, vector position)
Definition TrapBase.c:618
override bool CanRemoveFromHands(EntityAI parent)
Definition TrapBase.c:613
protected bool m_Initialized
class JsonUndergroundAreaTriggerData GetPosition
void OnEntityKilled(Object killer, EntityAI target)
AnalyticsManagerServer GetAnalyticsServer()
Definition Game.c:1407
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native DayZPlayer GetPlayer()
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto native bool ConfigIsExisting(string path)
bool FormatRawConfigStringKeys(inout string value)
Changes localization key format to script-friendly format.
Definition Game.c:452
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native EntityAI GetEntityByPersitentID(int b1, int b2, int b3, int b4)
proto native float GetTickTime()
Returns current time from start of the game.
represents base for cargo storage for entities
Definition Cargo.c:7
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
static bool GetDisableBaseDamage()
static array< float > GetWetnessWeightModifiers()
static bool GetDisableContainerDamage()
void StoreEnergySourceIDs(int b1, int b2, int b3, int b4)
void SwitchOff()
Energy manager: Switches OFF the device.
bool IsPlugged()
Energy manager: Returns true if this device is plugged into some other device (even if they are OFF o...
float GetEnergy()
Energy manager: Returns the amount of stored energy this device has.
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
void OnAttachmentAdded(EntityAI elec_device)
void UnplugThis()
Energy manager: Unplugs this device from its power source.
void SwitchOn()
Energy manager: Switches ON the device so it starts doing its work if it has enough energy.
void SetEnergy(float new_energy)
Energy manager: Sets stored energy for this device. It ignores the min/max limit!
void HandleMoveInsideCargo(EntityAI container)
bool IsWorking()
Energy manager: Returns true if this device is working right now.
void UnplugAllDevices()
Energy manager: Unplugs everything directly connected to this device.
void OnAttachmentRemoved(EntityAI elec_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...
float GetCordLength()
Energy manager: Returns the length of the virtual power cord.
void SetPassiveState(bool state=true)
Energy manager: Changes the status of this device. When it's passive (true), the main timer and OnWor...
bool IsPassive()
Energy manager: Returns true if this device is set to be passive. False if otherwise.
bool IsSwitchedOn()
Energy manager: Returns state of the switch. Whenever the device is working or not does not matter....
Definition Debug.c:14
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Definition Debug.c:235
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
static void LogWarning(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as warning message.
Definition Debug.c:220
void OnHealthLevelChanged(notnull EntityAI entity, int oldLevel, int newLevel, string zone)
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 bool LocalTakeEntityToCargo(notnull EntityAI item)
Definition Man.c:374
override bool PredictiveTakeEntityAsAttachmentEx(notnull EntityAI item, int slot)
Definition Man.c:438
override bool IsInventoryVisible()
Definition Building.c:41
override bool LocalTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Man.c:801
override bool ServerTakeEntityAsAttachment(notnull EntityAI item)
Definition Man.c:418
override bool PredictiveTakeEntityToCargo(notnull EntityAI item)
Definition Man.c:360
override bool ServerTakeEntityToTargetCargoEx(notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Definition Man.c:644
override bool CanDropEntity(notnull EntityAI item)
Definition Man.c:127
override bool ServerTakeEntityToInventory(FindInventoryLocationType flags, notnull EntityAI item)
Definition Man.c:340
override bool LocalTakeEntityToInventory(FindInventoryLocationType flags, notnull EntityAI item)
Definition Man.c:335
override bool PredictiveDropEntity(notnull EntityAI item)
Definition Man.c:94
override bool LocalTakeEntityToTargetAttachmentEx(notnull EntityAI target, notnull EntityAI item, int slot)
Definition Man.c:721
override bool PredictiveTakeEntityToTargetAttachmentEx(notnull EntityAI target, notnull EntityAI item, int slot)
Definition Man.c:707
override bool PredictiveTakeEntityToTargetAttachment(notnull EntityAI target, notnull EntityAI item)
Definition Man.c:746
override bool ServerTakeEntityAsAttachmentEx(notnull EntityAI item, int slot)
Definition Man.c:457
override bool PredictiveTakeEntityToTargetCargoEx(notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Definition Man.c:625
override bool PredictiveTakeEntityToInventory(FindInventoryLocationType flags, notnull EntityAI item)
Definition Man.c:321
override bool LocalTakeEntityToTargetInventory(notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
Definition Man.c:605
override int GetMeleeTargetType()
Definition Building.c:46
override bool PredictiveTakeEntityAsAttachment(notnull EntityAI item)
Definition Man.c:399
override bool ServerTakeEntityToTargetCargo(notnull EntityAI target, notnull EntityAI item)
Definition Man.c:683
override bool LocalDropEntity(notnull EntityAI item)
Definition Man.c:108
override bool PredictiveTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Man.c:787
override bool ServerTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Man.c:806
override bool IsIgnoredByConstruction()
Definition Transport.c:66
override bool LocalTakeEntityAsAttachmentEx(notnull EntityAI item, int slot)
Definition Man.c:452
void Man()
Definition Man.c:28
override bool ServerTakeEntityToTargetAttachmentEx(notnull EntityAI target, notnull EntityAI item, int slot)
Definition Man.c:726
override bool ServerTakeEntityToCargo(notnull EntityAI item)
Definition Man.c:379
override bool ServerTakeEntityToTargetAttachment(notnull EntityAI target, notnull EntityAI item)
Definition Man.c:765
override bool IsMan()
Definition Man.c:33
override bool LocalTakeEntityToTargetCargoEx(notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Definition Man.c:639
override bool PredictiveTakeEntityToTargetInventory(notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
Definition Man.c:570
override bool PredictiveTakeEntityToTargetCargo(notnull EntityAI target, notnull EntityAI item)
Definition Man.c:664
override bool LocalTakeEntityToTargetCargo(notnull EntityAI target, notnull EntityAI item)
Definition Man.c:678
override bool LocalTakeEntityAsAttachment(notnull EntityAI item)
Definition Man.c:413
override bool LocalTakeEntityToTargetAttachment(notnull EntityAI target, notnull EntityAI item)
Definition Man.c:760
override bool ServerDropEntity(notnull EntityAI item)
Definition Man.c:113
Definition Camera.c:2
script counterpart to engine's class Inventory
Definition Inventory.c:77
int GetHiddenSelectionIndex(string selection)
InventoryLocation.
proto native int GetType()
returns type of InventoryLocation
proto native bool IsValid()
verify current set inventory location
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native int GetSlot()
returns slot id if current type is Attachment
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native bool GetShowForSlotId(int slot_Id)
const int INVALID
Invalid slot (-1)
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:378
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.
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto void Call(func fn, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
Base native class for all motorized wheeled vehicles.
Definition Car.c:80
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Definition EnConvert.c:110
proto native float Length()
Returns length of vector (magnitude)
override bool CanAssignToQuickbar()
Definition crafting.c:79
string GetDefaultHitComponent()
Definition dayzplayer.c:497
string GetDefaultHitPositionComponent()
Definition dayzplayer.c:502
string GetHitComponentForAI()
Definition dayzplayer.c:485
array< string > GetSuitableFinisherHitComponents()
Definition dayzplayer.c:507
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:256
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
const int REFRESHER_FREQUENCY_DEFAULT
Definition constants.c:857
const float MELEE_ITEM_DAMAGE
Definition constants.c:584
array< string > TStringArray
Definition EnScript.c:685
const int STATE_RUINED
Definition constants.c:742
const float STATE_SOAKING_WET
Definition constants.c:767
const float STATE_WET
Definition constants.c:768
const float STATE_DRENCHED
Definition constants.c:766
const float STATE_DAMP
Definition constants.c:769
const float LIQUID_THROUGHPUT_DEFAULT
Definition constants.c:509
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:233
const string CFG_VEHICLESPATH
Definition constants.c:195
const string CFG_WEAPONSPATH
Definition constants.c:196
const string CFG_MAGAZINESPATH
Definition constants.c:197
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)
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
static const string Empty
Definition EnString.c:7
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:396