DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ CheckOverheatingCondition()

bool OnParticleCreated::CheckOverheatingCondition ( float overheating_coef)

См. определение в файле WeaponParticles.c строка 628

635{
639 int m_MuzzleIndex;
648 string m_OnlyIfBulletIs;
649 string m_OnlyIfWeaponIs;
650 string m_OverridePoint;
653
654 string m_Name;
655
656 //======================================
657 // PRELOAD EVERYTHING
658 //======================================
659
660 void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
661 {
662 m_Name = config_OnFire_entry;
663
664 // ignoreIfSuppressed
665 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
666
667 // onlyIfBoltIsOpen
668 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
669
670 // illuminateWorld
671 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
672
673 m_MuzzleIndex = -1;
674 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
675 {
676 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
677 }
678
679 // onlyIfWeaponIs
680 m_OnlyIfWeaponIs = "";
681 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
682
683 // onlyIfBulletIs
684 m_OnlyIfBulletIs = "";
685 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
686
687 // onlyWithinHealthLabel[]
688 array<float> health_limit = new array<float>;
689 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
690
691 if (health_limit.Count() == 2)
692 {
693 m_OnlyWithinHealthLabelMin = health_limit.Get(0);
694 m_OnlyWithinHealthLabelMax = health_limit.Get(1);
695 }
696 else
697 {
698 // Disable this filter
701 }
702
703 // onlyWithinOverheatLimits[]
704 array<float> overheat_limit = new array<float>;
705 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
706
707 if (overheat_limit.Count() == 2)
708 {
709 m_OnlyWithinOverheatLimitsMin = overheat_limit.Get(0);
710 m_OnlyWithinOverheatLimitsMax = overheat_limit.Get(1);
711 }
712 else
713 {
714 // Disable this filter
717 }
718
719 // onlyWithinRainLimits[]
720 array<float> rain_limit = new array<float>;
721 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
722
723 if (rain_limit.Count() == 2)
724 {
725 m_OnlyWithinRainLimitsMin = rain_limit.Get(0);
726 m_OnlyWithinRainLimitsMax = rain_limit.Get(1);
727 }
728 else
729 {
730 // Disable this filter
733 }
734
735 // overridePoint
736 m_OverridePoint = "";
737 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
738
739 if (m_OverridePoint == "")
740 m_OverridePoint = "Usti hlavne"; // default memory point name
741
742 // overrideParticle
743 string particle_name = "";
744 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
745
746 if (particle_name != "")
747 {
749 }
750 else
751 {
753 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
754 config_OnFire_entry), ErrorExSeverity.INFO);
755 }
756
757 // overrideDirectionPoint
759 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
760
761 if (m_OverrideDirectionPoint == "")
762 {
763 // overrideDirectionVector
764 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
765
766 if (test_ori != vector.Zero)
767 {
768 m_OverrideDirectionVector = test_ori;
769 }
770 }
771
772 // positionOffset[]
774 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
775
776 if (v.Count() == 3)
777 {
778 float v1 = v.Get(0);
779 float v2 = v.Get(1);
780 float v3 = v.Get(2);
781 m_PositionOffset = Vector(v1, v2, v3);
782 }
783 }
784
785
786
787 //======================================
788 // PLAY PARTICLES
789 //======================================
790 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
791 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
792 void OnActivate(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
793 {
794 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
795 {
796 // Handle effect's parameters
797 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
798 {
799 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
800 {
801 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
802 {
803 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
804 {
805 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
806 {
807 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
808 {
809 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
810 {
811 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
812 {
813 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
814 {
815 // Get particle ID
816 int particle_id = CheckParticleOverride(ammoType);
817
819 {
820 // Get position of the particle
821 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
822 local_pos += m_PositionOffset;
823
824 // Set orientation of the particle
825 vector particle_ori = CheckOrientationOverride(local_pos, muzzle_owner);
826
827 // Create particle
828 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
829 OnParticleCreated(weapon, ammoType, muzzle_owner, suppressor, config_to_search, p);
830 }
831 else
832 {
833 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
834 }
835
836 // Create light
838 {
839 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
840 int randX = Math.RandomInt( 0,10 );
841 if ( randX > 8 )
842 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
843 else if ( randX > 4 )
844 ScriptedLightBase.CreateLight( MuzzleFlashLight_1, global_pos );
845 else
846 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
847 }
848 }
849 }
850 }
851 }
852 }
853 }
854 }
855 }
856 }
857 }
858 }
859
860 void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
861 {
862
863 }
864
865 void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
866 {
867
868 }
869
870 void OnUpdate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
871 {
872
873 }
874
875
876 //==============================================
877 // HANDLE CONFIG PARAMETERS
878 //==============================================
879
880
881 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
883 {
884 if ( m_OnlyIfBoltIsOpen )
885 {
886 Weapon_Base wb = Weapon_Base.Cast( weapon );
887 WeaponStateBase current_state = wb.GetCurrentState();
888 return current_state.IsBoltOpen();
889 }
890
891 return true;
892 }
893
894 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
895 bool CheckHealthCondition(int health_label)
896 {
897 return ( (health_label >= m_OnlyWithinHealthLabelMin) && (health_label <= m_OnlyWithinHealthLabelMax) );
898 }
899
900 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
901 bool CheckOverheatingCondition(float overheating_coef)
902 {
903 return ( (overheating_coef >= m_OnlyWithinOverheatLimitsMin) && (overheating_coef <= m_OnlyWithinOverheatLimitsMax) );
904 }
905
906 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
907 bool CheckRainCondition(float rain_coef)
908 {
909 return ( (rain_coef >= m_OnlyWithinRainLimitsMin) && (rain_coef <= m_OnlyWithinRainLimitsMax) );
910 }
911
912 // muzzleFlashParticle
913 int CheckParticleOverride(string ammoType)
914 {
915 int particle_id = -1;
916
917 string particle_file = "";
918 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
919 if (GetGame().ConfigGetText( cfg_path, particle_file))
921
922 // Config is accessed only once because the data is saved into a map for repeated access.
923
924 if ( particle_id > 0 || m_OverrideParticle == -1)
925 {
926 if (particle_file == "")
927 {
928 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
929 }
930 else
931 {
933
934 if (particle_id == 0)
935 {
936 string devStr;
937 #ifdef DEVELOPER
938 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
939 #endif
940 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
941 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
942 }
943 }
944 }
945 else
946 {
948 }
949
950 return particle_id;
951 }
952
953 // OverrideDirectionPoint & OverrideDirectionVector
954 vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
955 {
956 vector particle_ori = "0 0 0";
957 if (m_OverrideDirectionPoint != "")
958 {
959 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
960 target_pos = vector.Direction(local_pos, target_pos);
961 particle_ori = target_pos.VectorToAngles();
962 }
963 else
964 {
965 if (m_OverrideDirectionVector != Vector(0, 0, 0))
966 {
967 particle_ori = m_OverrideDirectionVector;
968 }
969
970 if (muzzle_owner.IsInherited(ItemSuppressor))
971 {
972 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
973 }
974 }
975
976 return particle_ori;
977 }
978}
979
980// FIRE particles
981class WeaponParticlesOnFire : WeaponParticlesBase {}
982
983// BULLET EJECT particles
984class WeaponParticlesOnBulletCasingEject : WeaponParticlesBase {}
985
986// OVERHEATING particles
987class WeaponParticlesOnOverheating: WeaponParticlesBase
988{
989 override void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
990 {
991 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
992 }
993
994 override void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
995 {
996 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
997 {
998 weapon.KillAllOverheatingParticles();
999 }
1000 }
1001
1002 override void OnUpdate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
1003 {
1004 OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
1005 }
1006}
1007
1009{
1010 Particle m_Particle;
1011 int m_ParticleID;
1013 vector m_LocalPos;
1014 vector m_LocalOri;
1015
1018
1019 void RegisterParticle( Particle p)
1020 {
1021 m_Particle = p;
1022 }
1023
1024 Particle GetParticle()
1025 {
1026 return m_Particle;
1027 }
1028
1029 void SetOverheatingLimitMin(float min)
1030 {
1032 }
1033
1034 void SetOverheatingLimitMax(float max)
1035 {
1037 }
1038
1040 {
1041 return m_OverheatingLimitMin;
1042 }
1043
1045 {
1046 return m_OverheatingLimitMax;
1047 }
1048
1049 void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
1050 {
1052 m_Parent = parent;
1053 m_LocalPos = local_pos;
1054 m_LocalOri = local_ori;
1055 }
1056
1057 int GetParticleID()
1058 {
1059 return m_ParticleID;
1060 }
1061
1063 {
1064 return m_Parent;
1065 }
1066
1067 vector GetParticlePos()
1068 {
1069 return m_LocalPos;
1070 }
1071
1072 vector GetParticleOri()
1073 {
1074 return m_LocalOri;
1075 }
1076}
class GP5GasMask extends MaskBase ItemBase
void MuzzleFlashLight_1()
Определения MuzzleFlashLight.c:24
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
int particle_id
Определения SmokeSimulation.c:28
class SyncedValue m_Name
void OnActivate()
Определения Trap_LandMine.c:67
bool CheckRainCondition(float rain_coef)
Определения WeaponParticles.c:634
void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения WeaponParticles.c:592
float m_OnlyWithinOverheatLimitsMin
Определения WeaponParticles.c:370
bool m_IlluminateWorld
Определения WeaponParticles.c:363
vector m_OverrideDirectionVector
Определения WeaponParticles.c:378
int m_OverrideParticle
Определения WeaponParticles.c:367
string m_OverrideDirectionPoint
Определения WeaponParticles.c:374
float m_OnlyWithinRainLimitsMax
Определения WeaponParticles.c:373
class WeaponParticlesBase OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
Определения WeaponParticles.c:362
bool m_OnlyIfBoltIsOpen
Определения WeaponParticles.c:365
vector m_PositionOffset
Определения WeaponParticles.c:379
string m_OnlyIfWeaponIs
Определения WeaponParticles.c:376
void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
Определения WeaponParticles.c:387
string m_OnlyIfBulletIs
Определения WeaponParticles.c:375
int CheckParticleOverride(string ammoType)
Определения WeaponParticles.c:640
int m_MuzzleIndex
Определения WeaponParticles.c:366
float m_OnlyWithinRainLimitsMin
Определения WeaponParticles.c:372
vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
Определения WeaponParticles.c:681
bool CheckHealthCondition(int health_label)
Определения WeaponParticles.c:622
bool m_IgnoreIfSuppressed
Определения WeaponParticles.c:364
string m_OverridePoint
Определения WeaponParticles.c:377
int m_OnlyWithinHealthLabelMin
Определения WeaponParticles.c:368
bool CheckBoltStateCondition(ItemBase weapon)
Определения WeaponParticles.c:609
float m_OnlyWithinOverheatLimitsMax
Определения WeaponParticles.c:371
int m_OnlyWithinHealthLabelMax
Определения WeaponParticles.c:369
bool CheckOverheatingCondition(float overheating_coef)
Определения WeaponParticles.c:628
proto native vector ConfigGetVector(string path)
Get vector value from config on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
Определения InventoryItem.c:731
Определения EnMath.c:7
vector m_LocalPos
Определения WeaponParticles.c:386
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
float m_OverheatingLimitMax
Определения WeaponParticles.c:390
vector GetParticleOri()
Определения WeaponParticles.c:445
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
Object GetParticleParent()
Определения WeaponParticles.c:435
int m_ParticleID
Определения WeaponParticles.c:384
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Object m_Parent
Определения WeaponParticles.c:385
Particle m_Particle
Определения WeaponParticles.c:383
float m_OverheatingLimitMin
Определения WeaponParticles.c:389
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
int GetParticleID()
Определения WeaponParticles.c:430
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
vector GetParticlePos()
Определения WeaponParticles.c:440
vector m_LocalOri
Определения WeaponParticles.c:387
vector m_DefaultPos
Used for Wiggle API, to restore after unparenting.
Определения Particle.c:33
vector m_DefaultOri
Used for Wiggle API, to restore after unparenting.
Определения Particle.c:31
int GetParticleID()
Gets particle id.
Определения Particle.c:297
Legacy way of using particles in the game.
Определения Particle.c:7
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
Определения ParticleList.c:500
static bool IsValidId(int id)
Purely checks for an invalid number, does NOT mean it is actually registered.
Определения ParticleList.c:470
Определения ParticleList.c:12
static bool m_GunParticlesState
Определения gameplay.c:1538
Определения gameplay.c:1537
shorthand
Определения BoltActionRifle_Base.c:6
void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения WeaponParticles.c:238
void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
Определения WeaponParticles.c:233
bool IsBoltOpen()
Определения WeaponStateBase.c:163
represent weapon state base
Определения BulletHide.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:110
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Определения EnConvert.c:220
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
Определения EnConvert.c:106
class LOD Object
proto native CGame GetGame()
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
proto native void OnUpdate()
Определения tools.c:349