DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл WeaponParticles.c

См. исходные тексты.

Структуры данных

class  WeaponParticlesBase
 
class  OverheatingParticle
 

Функции

class WeaponParticlesBase OnParticleCreated (ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
 
void WeaponParticlesBase (ItemBase muzzle_owner, string config_OnFire_entry)
 
void OnActivate (ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
 
void OnDeactivate (ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
 
void OnUpdate (ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
 
bool CheckBoltStateCondition (ItemBase weapon)
 
bool CheckHealthCondition (int health_label)
 
bool CheckOverheatingCondition (float overheating_coef)
 
bool CheckRainCondition (float rain_coef)
 
int CheckParticleOverride (string ammoType)
 
vector CheckOrientationOverride (vector local_pos, ItemBase muzzle_owner)
 

Переменные

bool m_IlluminateWorld
 
bool m_IgnoreIfSuppressed
 
bool m_OnlyIfBoltIsOpen
 
int m_MuzzleIndex
 
int m_OverrideParticle
 
int m_OnlyWithinHealthLabelMin
 
int m_OnlyWithinHealthLabelMax
 
float m_OnlyWithinOverheatLimitsMin
 
float m_OnlyWithinOverheatLimitsMax
 
float m_OnlyWithinRainLimitsMin
 
float m_OnlyWithinRainLimitsMax
 
string m_OverrideDirectionPoint
 
string m_OnlyIfBulletIs
 
string m_OnlyIfWeaponIs
 
string m_OverridePoint
 
vector m_OverrideDirectionVector
 
vector m_PositionOffset
 
string m_Name
 

Функции

◆ CheckBoltStateCondition()

bool CheckBoltStateCondition ( ItemBase weapon)

◆ CheckHealthCondition()

bool CheckHealthCondition ( int health_label)
629{
633 int m_MuzzleIndex;
642 string m_OnlyIfBulletIs;
643 string m_OnlyIfWeaponIs;
644 string m_OverridePoint;
647
648 string m_Name;
649
650 //======================================
651 // PRELOAD EVERYTHING
652 //======================================
653
655 {
657
658 // ignoreIfSuppressed
659 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
660
661 // onlyIfBoltIsOpen
662 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
663
664 // illuminateWorld
665 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
666
667 m_MuzzleIndex = -1;
668 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
669 {
670 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
671 }
672
673 // onlyIfWeaponIs
674 m_OnlyIfWeaponIs = "";
675 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
676
677 // onlyIfBulletIs
678 m_OnlyIfBulletIs = "";
679 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
680
681 // onlyWithinHealthLabel[]
683 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
684
685 if (health_limit.Count() == 2)
686 {
689 }
690 else
691 {
692 // Disable this filter
695 }
696
697 // onlyWithinOverheatLimits[]
699 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
700
701 if (overheat_limit.Count() == 2)
702 {
705 }
706 else
707 {
708 // Disable this filter
711 }
712
713 // onlyWithinRainLimits[]
715 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
716
717 if (rain_limit.Count() == 2)
718 {
721 }
722 else
723 {
724 // Disable this filter
727 }
728
729 // overridePoint
730 m_OverridePoint = "";
731 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
732
733 if (m_OverridePoint == "")
734 m_OverridePoint = "Usti hlavne"; // default memory point name
735
736 // overrideParticle
737 string particle_name = "";
738 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
739
740 if (particle_name != "")
741 {
743 }
744 else
745 {
747 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
749 }
750
751 // overrideDirectionPoint
753 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
754
755 if (m_OverrideDirectionPoint == "")
756 {
757 // overrideDirectionVector
758 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
759
760 if (test_ori != vector.Zero)
761 {
763 }
764 }
765
766 // positionOffset[]
768 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
769
770 if (v.Count() == 3)
771 {
772 float v1 = v.Get(0);
773 float v2 = v.Get(1);
774 float v3 = v.Get(2);
776 }
777 }
778
779
780
781 //======================================
782 // PLAY PARTICLES
783 //======================================
784 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
785 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
787 {
788 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
789 {
790 // Handle effect's parameters
791 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
792 {
793 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
794 {
795 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
796 {
797 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
798 {
799 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
800 {
801 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
802 {
803 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
804 {
805 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
806 {
807 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
808 {
809 // Get particle ID
811
813 {
814 // Get position of the particle
815 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
817
818 // Set orientation of the particle
820
821 // Create particle
822 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
824 }
825 else
826 {
827 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
828 }
829
830 // Create light
832 {
833 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
834 int randX = Math.RandomInt( 0,10 );
835 if ( randX > 8 )
836 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
837 else if ( randX > 4 )
839 else
840 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
841 }
842 }
843 }
844 }
845 }
846 }
847 }
848 }
849 }
850 }
851 }
852 }
853
855 {
856
857 }
858
860 {
861
862 }
863
865 {
866
867 }
868
869
870 //==============================================
871 // HANDLE CONFIG PARAMETERS
872 //==============================================
873
874
875 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
877 {
878 if ( m_OnlyIfBoltIsOpen )
879 {
881 WeaponStateBase current_state = wb.GetCurrentState();
882 return current_state.IsBoltOpen();
883 }
884
885 return true;
886 }
887
888 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
890 {
892 }
893
894 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
896 {
898 }
899
900 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
901 bool CheckRainCondition(float rain_coef)
902 {
904 }
905
906 // muzzleFlashParticle
908 {
909 int particle_id = -1;
910
911 string particle_file = "";
912 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
913 if (GetGame().ConfigGetText( cfg_path, particle_file))
915
916 // Config is accessed only once because the data is saved into a map for repeated access.
917
918 if ( particle_id > 0 || m_OverrideParticle == -1)
919 {
920 if (particle_file == "")
921 {
922 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
923 }
924 else
925 {
927
928 if (particle_id == 0)
929 {
930 string devStr;
931 #ifdef DEVELOPER
932 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
933 #endif
934 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
935 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
936 }
937 }
938 }
939 else
940 {
942 }
943
944 return particle_id;
945 }
946
947 // OverrideDirectionPoint & OverrideDirectionVector
949 {
950 vector particle_ori = "0 0 0";
951 if (m_OverrideDirectionPoint != "")
952 {
953 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
955 particle_ori = target_pos.VectorToAngles();
956 }
957 else
958 {
959 if (m_OverrideDirectionVector != Vector(0, 0, 0))
960 {
962 }
963
964 if (muzzle_owner.IsInherited(ItemSuppressor))
965 {
966 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
967 }
968 }
969
970 return particle_ori;
971 }
972}
973
974// FIRE particles
976
977// BULLET EJECT particles
979
980// OVERHEATING particles
982{
984 {
985 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
986 }
987
989 {
990 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
991 {
992 weapon.KillAllOverheatingParticles();
993 }
994 }
995
997 {
999 }
1000}
1001
1003{
1005 int m_ParticleID;
1009
1012
1014 {
1015 m_Particle = p;
1016 }
1017
1019 {
1020 return m_Particle;
1021 }
1022
1023 void SetOverheatingLimitMin(float min)
1024 {
1026 }
1027
1028 void SetOverheatingLimitMax(float max)
1029 {
1031 }
1032
1034 {
1035 return m_OverheatingLimitMin;
1036 }
1037
1039 {
1040 return m_OverheatingLimitMax;
1041 }
1042
1044 {
1046 m_Parent = parent;
1049 }
1050
1051 int GetParticleID()
1052 {
1053 return m_ParticleID;
1054 }
1055
1057 {
1058 return m_Parent;
1059 }
1060
1062 {
1063 return m_LocalPos;
1064 }
1065
1067 {
1068 return m_LocalOri;
1069 }
1070}
void OnDeactivate(PlayerBase player)
Definition HeavyMetal.c:211
void MuzzleFlashLight_1()
Definition MuzzleFlashLight.c:24
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition ParticleManager.c:84
int particle_id
Definition SmokeSimulation.c:28
void OnActivate()
Definition Trap_LandMine.c:67
void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition WeaponParticles.c:592
vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
Definition WeaponParticles.c:681
float m_OnlyWithinOverheatLimitsMin
Definition WeaponParticles.c:370
bool CheckHealthCondition(int health_label)
Definition WeaponParticles.c:622
bool m_IlluminateWorld
Definition WeaponParticles.c:363
void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
Definition WeaponParticles.c:387
vector m_OverrideDirectionVector
Definition WeaponParticles.c:378
string m_Name
Definition WeaponParticles.c:381
int m_OverrideParticle
Definition WeaponParticles.c:367
string m_OverrideDirectionPoint
Definition WeaponParticles.c:374
float m_OnlyWithinRainLimitsMax
Definition WeaponParticles.c:373
class WeaponParticlesBase OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
Definition WeaponParticles.c:362
bool m_OnlyIfBoltIsOpen
Definition WeaponParticles.c:365
bool CheckOverheatingCondition(float overheating_coef)
Definition WeaponParticles.c:628
vector m_PositionOffset
Definition WeaponParticles.c:379
string m_OnlyIfWeaponIs
Definition WeaponParticles.c:376
string m_OnlyIfBulletIs
Definition WeaponParticles.c:375
int m_MuzzleIndex
Definition WeaponParticles.c:366
float m_OnlyWithinRainLimitsMin
Definition WeaponParticles.c:372
bool m_IgnoreIfSuppressed
Definition WeaponParticles.c:364
string m_OverridePoint
Definition WeaponParticles.c:377
int m_OnlyWithinHealthLabelMin
Definition WeaponParticles.c:368
int CheckParticleOverride(string ammoType)
Definition WeaponParticles.c:640
bool CheckRainCondition(float rain_coef)
Definition WeaponParticles.c:634
bool CheckBoltStateCondition(ItemBase weapon)
Definition WeaponParticles.c:609
float m_OnlyWithinOverheatLimitsMax
Definition WeaponParticles.c:371
int m_OnlyWithinHealthLabelMax
Definition WeaponParticles.c:369
Definition InventoryItem.c:731
Definition Mosin_Compensator.c:2
Definition EnMath.c:7
Definition ObjectTyped.c:2
Definition WeaponParticles.c:382
void SetOverheatingLimitMax(float max)
Definition WeaponParticles.c:407
float GetOverheatingLimitMin()
Definition WeaponParticles.c:412
void SetOverheatingLimitMin(float min)
Definition WeaponParticles.c:402
float m_OverheatingLimitMax
Definition WeaponParticles.c:390
float GetOverheatingLimitMax()
Definition WeaponParticles.c:417
int m_ParticleID
Definition WeaponParticles.c:384
Particle GetParticle()
Definition WeaponParticles.c:397
Particle m_Particle
Definition WeaponParticles.c:383
Object GetParticleParent()
Definition WeaponParticles.c:435
vector GetParticleOri()
Definition WeaponParticles.c:445
Object m_Parent
Definition WeaponParticles.c:385
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Definition WeaponParticles.c:422
vector GetParticlePos()
Definition WeaponParticles.c:440
int GetParticleID()
Definition WeaponParticles.c:430
void RegisterParticle(Particle p)
Definition WeaponParticles.c:392
float m_OverheatingLimitMin
Definition WeaponParticles.c:389
vector m_LocalPos
Definition WeaponParticles.c:386
vector m_LocalOri
Definition WeaponParticles.c:387
Definition EntityAI.c:95
Legacy way of using particles in the game.
Definition Particle.c:7
Definition ParticleList.c:12
static bool IsValidId(int id)
Purely checks for an invalid number, does NOT mean it is actually registered.
Definition ParticleList.c:453
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
Definition ParticleList.c:483
Definition gameplay.c:1531
static bool m_GunParticlesState
Definition gameplay.c:1532
Definition PointLightBase.c:2
shorthand
Definition BoltActionRifle_Base.c:6
Definition WeaponParticles.c:8
represent weapon state base
Definition BulletHide.c:2
Definition EnConvert.c:106
static const vector Zero
Definition EnConvert.c:110
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Definition EnConvert.c:220
proto native CGame GetGame()
ErrorExSeverity
Definition 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()
Definition tools.c:349

◆ CheckOrientationOverride()

vector CheckOrientationOverride ( vector local_pos,
ItemBase muzzle_owner )
688{
692 int m_MuzzleIndex;
701 string m_OnlyIfBulletIs;
702 string m_OnlyIfWeaponIs;
703 string m_OverridePoint;
706
707 string m_Name;
708
709 //======================================
710 // PRELOAD EVERYTHING
711 //======================================
712
714 {
716
717 // ignoreIfSuppressed
718 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
719
720 // onlyIfBoltIsOpen
721 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
722
723 // illuminateWorld
724 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
725
726 m_MuzzleIndex = -1;
727 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
728 {
729 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
730 }
731
732 // onlyIfWeaponIs
733 m_OnlyIfWeaponIs = "";
734 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
735
736 // onlyIfBulletIs
737 m_OnlyIfBulletIs = "";
738 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
739
740 // onlyWithinHealthLabel[]
742 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
743
744 if (health_limit.Count() == 2)
745 {
748 }
749 else
750 {
751 // Disable this filter
754 }
755
756 // onlyWithinOverheatLimits[]
758 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
759
760 if (overheat_limit.Count() == 2)
761 {
764 }
765 else
766 {
767 // Disable this filter
770 }
771
772 // onlyWithinRainLimits[]
774 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
775
776 if (rain_limit.Count() == 2)
777 {
780 }
781 else
782 {
783 // Disable this filter
786 }
787
788 // overridePoint
789 m_OverridePoint = "";
790 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
791
792 if (m_OverridePoint == "")
793 m_OverridePoint = "Usti hlavne"; // default memory point name
794
795 // overrideParticle
796 string particle_name = "";
797 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
798
799 if (particle_name != "")
800 {
802 }
803 else
804 {
806 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
808 }
809
810 // overrideDirectionPoint
812 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
813
814 if (m_OverrideDirectionPoint == "")
815 {
816 // overrideDirectionVector
817 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
818
819 if (test_ori != vector.Zero)
820 {
822 }
823 }
824
825 // positionOffset[]
827 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
828
829 if (v.Count() == 3)
830 {
831 float v1 = v.Get(0);
832 float v2 = v.Get(1);
833 float v3 = v.Get(2);
835 }
836 }
837
838
839
840 //======================================
841 // PLAY PARTICLES
842 //======================================
843 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
844 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
846 {
847 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
848 {
849 // Handle effect's parameters
850 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
851 {
852 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
853 {
854 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
855 {
856 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
857 {
858 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
859 {
860 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
861 {
862 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
863 {
864 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
865 {
866 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
867 {
868 // Get particle ID
870
872 {
873 // Get position of the particle
874 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
876
877 // Set orientation of the particle
879
880 // Create particle
881 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
883 }
884 else
885 {
886 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
887 }
888
889 // Create light
891 {
892 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
893 int randX = Math.RandomInt( 0,10 );
894 if ( randX > 8 )
895 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
896 else if ( randX > 4 )
898 else
899 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
900 }
901 }
902 }
903 }
904 }
905 }
906 }
907 }
908 }
909 }
910 }
911 }
912
914 {
915
916 }
917
919 {
920
921 }
922
924 {
925
926 }
927
928
929 //==============================================
930 // HANDLE CONFIG PARAMETERS
931 //==============================================
932
933
934 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
936 {
937 if ( m_OnlyIfBoltIsOpen )
938 {
940 WeaponStateBase current_state = wb.GetCurrentState();
941 return current_state.IsBoltOpen();
942 }
943
944 return true;
945 }
946
947 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
949 {
951 }
952
953 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
955 {
957 }
958
959 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
960 bool CheckRainCondition(float rain_coef)
961 {
963 }
964
965 // muzzleFlashParticle
967 {
968 int particle_id = -1;
969
970 string particle_file = "";
971 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
972 if (GetGame().ConfigGetText( cfg_path, particle_file))
974
975 // Config is accessed only once because the data is saved into a map for repeated access.
976
977 if ( particle_id > 0 || m_OverrideParticle == -1)
978 {
979 if (particle_file == "")
980 {
981 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
982 }
983 else
984 {
986
987 if (particle_id == 0)
988 {
989 string devStr;
990 #ifdef DEVELOPER
991 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
992 #endif
993 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
994 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
995 }
996 }
997 }
998 else
999 {
1001 }
1002
1003 return particle_id;
1004 }
1005
1006 // OverrideDirectionPoint & OverrideDirectionVector
1008 {
1009 vector particle_ori = "0 0 0";
1010 if (m_OverrideDirectionPoint != "")
1011 {
1012 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
1014 particle_ori = target_pos.VectorToAngles();
1015 }
1016 else
1017 {
1018 if (m_OverrideDirectionVector != Vector(0, 0, 0))
1019 {
1021 }
1022
1023 if (muzzle_owner.IsInherited(ItemSuppressor))
1024 {
1025 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
1026 }
1027 }
1028
1029 return particle_ori;
1030 }
1031}
1032
1033// FIRE particles
1035
1036// BULLET EJECT particles
1038
1039// OVERHEATING particles
1041{
1043 {
1044 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
1045 }
1046
1048 {
1049 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
1050 {
1051 weapon.KillAllOverheatingParticles();
1052 }
1053 }
1054
1056 {
1058 }
1059}
1060
1062{
1064 int m_ParticleID;
1068
1071
1073 {
1074 m_Particle = p;
1075 }
1076
1078 {
1079 return m_Particle;
1080 }
1081
1082 void SetOverheatingLimitMin(float min)
1083 {
1085 }
1086
1087 void SetOverheatingLimitMax(float max)
1088 {
1090 }
1091
1093 {
1094 return m_OverheatingLimitMin;
1095 }
1096
1098 {
1099 return m_OverheatingLimitMax;
1100 }
1101
1103 {
1105 m_Parent = parent;
1108 }
1109
1110 int GetParticleID()
1111 {
1112 return m_ParticleID;
1113 }
1114
1116 {
1117 return m_Parent;
1118 }
1119
1121 {
1122 return m_LocalPos;
1123 }
1124
1126 {
1127 return m_LocalOri;
1128 }
1129}

◆ CheckOverheatingCondition()

bool CheckOverheatingCondition ( float overheating_coef)
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
661 {
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[]
689 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
690
691 if (health_limit.Count() == 2)
692 {
695 }
696 else
697 {
698 // Disable this filter
701 }
702
703 // onlyWithinOverheatLimits[]
705 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
706
707 if (overheat_limit.Count() == 2)
708 {
711 }
712 else
713 {
714 // Disable this filter
717 }
718
719 // onlyWithinRainLimits[]
721 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
722
723 if (rain_limit.Count() == 2)
724 {
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'",
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 {
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);
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.
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
817
819 {
820 // Get position of the particle
821 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
823
824 // Set orientation of the particle
826
827 // Create particle
828 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
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 )
845 else
846 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
847 }
848 }
849 }
850 }
851 }
852 }
853 }
854 }
855 }
856 }
857 }
858 }
859
861 {
862
863 }
864
866 {
867
868 }
869
871 {
872
873 }
874
875
876 //==============================================
877 // HANDLE CONFIG PARAMETERS
878 //==============================================
879
880
881 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
883 {
884 if ( m_OnlyIfBoltIsOpen )
885 {
887 WeaponStateBase current_state = wb.GetCurrentState();
888 return current_state.IsBoltOpen();
889 }
890
891 return true;
892 }
893
894 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
896 {
898 }
899
900 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
902 {
904 }
905
906 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
907 bool CheckRainCondition(float rain_coef)
908 {
910 }
911
912 // muzzleFlashParticle
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
955 {
956 vector particle_ori = "0 0 0";
957 if (m_OverrideDirectionPoint != "")
958 {
959 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
961 particle_ori = target_pos.VectorToAngles();
962 }
963 else
964 {
965 if (m_OverrideDirectionVector != Vector(0, 0, 0))
966 {
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
982
983// BULLET EJECT particles
985
986// OVERHEATING particles
988{
990 {
991 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
992 }
993
995 {
996 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
997 {
998 weapon.KillAllOverheatingParticles();
999 }
1000 }
1001
1003 {
1005 }
1006}
1007
1009{
1011 int m_ParticleID;
1015
1018
1020 {
1021 m_Particle = p;
1022 }
1023
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
1050 {
1052 m_Parent = parent;
1055 }
1056
1057 int GetParticleID()
1058 {
1059 return m_ParticleID;
1060 }
1061
1063 {
1064 return m_Parent;
1065 }
1066
1068 {
1069 return m_LocalPos;
1070 }
1071
1073 {
1074 return m_LocalOri;
1075 }
1076}

◆ CheckParticleOverride()

int CheckParticleOverride ( string ammoType)
647{
651 int m_MuzzleIndex;
660 string m_OnlyIfBulletIs;
661 string m_OnlyIfWeaponIs;
662 string m_OverridePoint;
665
666 string m_Name;
667
668 //======================================
669 // PRELOAD EVERYTHING
670 //======================================
671
673 {
675
676 // ignoreIfSuppressed
677 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
678
679 // onlyIfBoltIsOpen
680 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
681
682 // illuminateWorld
683 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
684
685 m_MuzzleIndex = -1;
686 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
687 {
688 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
689 }
690
691 // onlyIfWeaponIs
692 m_OnlyIfWeaponIs = "";
693 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
694
695 // onlyIfBulletIs
696 m_OnlyIfBulletIs = "";
697 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
698
699 // onlyWithinHealthLabel[]
701 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
702
703 if (health_limit.Count() == 2)
704 {
707 }
708 else
709 {
710 // Disable this filter
713 }
714
715 // onlyWithinOverheatLimits[]
717 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
718
719 if (overheat_limit.Count() == 2)
720 {
723 }
724 else
725 {
726 // Disable this filter
729 }
730
731 // onlyWithinRainLimits[]
733 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
734
735 if (rain_limit.Count() == 2)
736 {
739 }
740 else
741 {
742 // Disable this filter
745 }
746
747 // overridePoint
748 m_OverridePoint = "";
749 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
750
751 if (m_OverridePoint == "")
752 m_OverridePoint = "Usti hlavne"; // default memory point name
753
754 // overrideParticle
755 string particle_name = "";
756 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
757
758 if (particle_name != "")
759 {
761 }
762 else
763 {
765 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
767 }
768
769 // overrideDirectionPoint
771 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
772
773 if (m_OverrideDirectionPoint == "")
774 {
775 // overrideDirectionVector
776 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
777
778 if (test_ori != vector.Zero)
779 {
781 }
782 }
783
784 // positionOffset[]
786 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
787
788 if (v.Count() == 3)
789 {
790 float v1 = v.Get(0);
791 float v2 = v.Get(1);
792 float v3 = v.Get(2);
794 }
795 }
796
797
798
799 //======================================
800 // PLAY PARTICLES
801 //======================================
802 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
803 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
805 {
806 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
807 {
808 // Handle effect's parameters
809 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
810 {
811 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
812 {
813 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
814 {
815 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
816 {
817 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
818 {
819 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
820 {
821 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
822 {
823 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
824 {
825 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
826 {
827 // Get particle ID
829
831 {
832 // Get position of the particle
833 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
835
836 // Set orientation of the particle
838
839 // Create particle
840 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
842 }
843 else
844 {
845 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
846 }
847
848 // Create light
850 {
851 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
852 int randX = Math.RandomInt( 0,10 );
853 if ( randX > 8 )
854 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
855 else if ( randX > 4 )
857 else
858 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
859 }
860 }
861 }
862 }
863 }
864 }
865 }
866 }
867 }
868 }
869 }
870 }
871
873 {
874
875 }
876
878 {
879
880 }
881
883 {
884
885 }
886
887
888 //==============================================
889 // HANDLE CONFIG PARAMETERS
890 //==============================================
891
892
893 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
895 {
896 if ( m_OnlyIfBoltIsOpen )
897 {
899 WeaponStateBase current_state = wb.GetCurrentState();
900 return current_state.IsBoltOpen();
901 }
902
903 return true;
904 }
905
906 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
908 {
910 }
911
912 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
914 {
916 }
917
918 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
919 bool CheckRainCondition(float rain_coef)
920 {
922 }
923
924 // muzzleFlashParticle
926 {
927 int particle_id = -1;
928
929 string particle_file = "";
930 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
931 if (GetGame().ConfigGetText( cfg_path, particle_file))
933
934 // Config is accessed only once because the data is saved into a map for repeated access.
935
936 if ( particle_id > 0 || m_OverrideParticle == -1)
937 {
938 if (particle_file == "")
939 {
940 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
941 }
942 else
943 {
945
946 if (particle_id == 0)
947 {
948 string devStr;
949 #ifdef DEVELOPER
950 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
951 #endif
952 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
953 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
954 }
955 }
956 }
957 else
958 {
960 }
961
962 return particle_id;
963 }
964
965 // OverrideDirectionPoint & OverrideDirectionVector
967 {
968 vector particle_ori = "0 0 0";
969 if (m_OverrideDirectionPoint != "")
970 {
971 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
973 particle_ori = target_pos.VectorToAngles();
974 }
975 else
976 {
977 if (m_OverrideDirectionVector != Vector(0, 0, 0))
978 {
980 }
981
982 if (muzzle_owner.IsInherited(ItemSuppressor))
983 {
984 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
985 }
986 }
987
988 return particle_ori;
989 }
990}
991
992// FIRE particles
994
995// BULLET EJECT particles
997
998// OVERHEATING particles
1000{
1002 {
1003 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
1004 }
1005
1007 {
1008 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
1009 {
1010 weapon.KillAllOverheatingParticles();
1011 }
1012 }
1013
1015 {
1017 }
1018}
1019
1021{
1023 int m_ParticleID;
1027
1030
1032 {
1033 m_Particle = p;
1034 }
1035
1037 {
1038 return m_Particle;
1039 }
1040
1041 void SetOverheatingLimitMin(float min)
1042 {
1044 }
1045
1046 void SetOverheatingLimitMax(float max)
1047 {
1049 }
1050
1052 {
1053 return m_OverheatingLimitMin;
1054 }
1055
1057 {
1058 return m_OverheatingLimitMax;
1059 }
1060
1062 {
1064 m_Parent = parent;
1067 }
1068
1069 int GetParticleID()
1070 {
1071 return m_ParticleID;
1072 }
1073
1075 {
1076 return m_Parent;
1077 }
1078
1080 {
1081 return m_LocalPos;
1082 }
1083
1085 {
1086 return m_LocalOri;
1087 }
1088}

◆ CheckRainCondition()

bool CheckRainCondition ( float rain_coef)
641{
645 int m_MuzzleIndex;
654 string m_OnlyIfBulletIs;
655 string m_OnlyIfWeaponIs;
656 string m_OverridePoint;
659
660 string m_Name;
661
662 //======================================
663 // PRELOAD EVERYTHING
664 //======================================
665
667 {
669
670 // ignoreIfSuppressed
671 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
672
673 // onlyIfBoltIsOpen
674 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
675
676 // illuminateWorld
677 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
678
679 m_MuzzleIndex = -1;
680 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
681 {
682 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
683 }
684
685 // onlyIfWeaponIs
686 m_OnlyIfWeaponIs = "";
687 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
688
689 // onlyIfBulletIs
690 m_OnlyIfBulletIs = "";
691 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
692
693 // onlyWithinHealthLabel[]
695 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
696
697 if (health_limit.Count() == 2)
698 {
701 }
702 else
703 {
704 // Disable this filter
707 }
708
709 // onlyWithinOverheatLimits[]
711 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
712
713 if (overheat_limit.Count() == 2)
714 {
717 }
718 else
719 {
720 // Disable this filter
723 }
724
725 // onlyWithinRainLimits[]
727 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
728
729 if (rain_limit.Count() == 2)
730 {
733 }
734 else
735 {
736 // Disable this filter
739 }
740
741 // overridePoint
742 m_OverridePoint = "";
743 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
744
745 if (m_OverridePoint == "")
746 m_OverridePoint = "Usti hlavne"; // default memory point name
747
748 // overrideParticle
749 string particle_name = "";
750 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
751
752 if (particle_name != "")
753 {
755 }
756 else
757 {
759 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
761 }
762
763 // overrideDirectionPoint
765 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
766
767 if (m_OverrideDirectionPoint == "")
768 {
769 // overrideDirectionVector
770 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
771
772 if (test_ori != vector.Zero)
773 {
775 }
776 }
777
778 // positionOffset[]
780 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
781
782 if (v.Count() == 3)
783 {
784 float v1 = v.Get(0);
785 float v2 = v.Get(1);
786 float v3 = v.Get(2);
788 }
789 }
790
791
792
793 //======================================
794 // PLAY PARTICLES
795 //======================================
796 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
797 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
799 {
800 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
801 {
802 // Handle effect's parameters
803 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
804 {
805 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
806 {
807 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
808 {
809 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
810 {
811 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
812 {
813 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
814 {
815 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
816 {
817 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
818 {
819 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
820 {
821 // Get particle ID
823
825 {
826 // Get position of the particle
827 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
829
830 // Set orientation of the particle
832
833 // Create particle
834 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
836 }
837 else
838 {
839 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
840 }
841
842 // Create light
844 {
845 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
846 int randX = Math.RandomInt( 0,10 );
847 if ( randX > 8 )
848 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
849 else if ( randX > 4 )
851 else
852 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
853 }
854 }
855 }
856 }
857 }
858 }
859 }
860 }
861 }
862 }
863 }
864 }
865
867 {
868
869 }
870
872 {
873
874 }
875
877 {
878
879 }
880
881
882 //==============================================
883 // HANDLE CONFIG PARAMETERS
884 //==============================================
885
886
887 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
889 {
890 if ( m_OnlyIfBoltIsOpen )
891 {
893 WeaponStateBase current_state = wb.GetCurrentState();
894 return current_state.IsBoltOpen();
895 }
896
897 return true;
898 }
899
900 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
902 {
904 }
905
906 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
908 {
910 }
911
912 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
913 bool CheckRainCondition(float rain_coef)
914 {
916 }
917
918 // muzzleFlashParticle
920 {
921 int particle_id = -1;
922
923 string particle_file = "";
924 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
925 if (GetGame().ConfigGetText( cfg_path, particle_file))
927
928 // Config is accessed only once because the data is saved into a map for repeated access.
929
930 if ( particle_id > 0 || m_OverrideParticle == -1)
931 {
932 if (particle_file == "")
933 {
934 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
935 }
936 else
937 {
939
940 if (particle_id == 0)
941 {
942 string devStr;
943 #ifdef DEVELOPER
944 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
945 #endif
946 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
947 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
948 }
949 }
950 }
951 else
952 {
954 }
955
956 return particle_id;
957 }
958
959 // OverrideDirectionPoint & OverrideDirectionVector
961 {
962 vector particle_ori = "0 0 0";
963 if (m_OverrideDirectionPoint != "")
964 {
965 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
967 particle_ori = target_pos.VectorToAngles();
968 }
969 else
970 {
971 if (m_OverrideDirectionVector != Vector(0, 0, 0))
972 {
974 }
975
976 if (muzzle_owner.IsInherited(ItemSuppressor))
977 {
978 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
979 }
980 }
981
982 return particle_ori;
983 }
984}
985
986// FIRE particles
988
989// BULLET EJECT particles
991
992// OVERHEATING particles
994{
996 {
997 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
998 }
999
1001 {
1002 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
1003 {
1004 weapon.KillAllOverheatingParticles();
1005 }
1006 }
1007
1009 {
1011 }
1012}
1013
1015{
1017 int m_ParticleID;
1021
1024
1026 {
1027 m_Particle = p;
1028 }
1029
1031 {
1032 return m_Particle;
1033 }
1034
1035 void SetOverheatingLimitMin(float min)
1036 {
1038 }
1039
1040 void SetOverheatingLimitMax(float max)
1041 {
1043 }
1044
1046 {
1047 return m_OverheatingLimitMin;
1048 }
1049
1051 {
1052 return m_OverheatingLimitMax;
1053 }
1054
1056 {
1058 m_Parent = parent;
1061 }
1062
1063 int GetParticleID()
1064 {
1065 return m_ParticleID;
1066 }
1067
1069 {
1070 return m_Parent;
1071 }
1072
1074 {
1075 return m_LocalPos;
1076 }
1077
1079 {
1080 return m_LocalOri;
1081 }
1082}

◆ OnActivate()

void OnActivate ( ItemBase weapon,
int muzzle_index,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
526{
530 int m_MuzzleIndex;
539 string m_OnlyIfBulletIs;
540 string m_OnlyIfWeaponIs;
541 string m_OverridePoint;
544
545 string m_Name;
546
547 //======================================
548 // PRELOAD EVERYTHING
549 //======================================
550
552 {
554
555 // ignoreIfSuppressed
556 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
557
558 // onlyIfBoltIsOpen
559 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
560
561 // illuminateWorld
562 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
563
564 m_MuzzleIndex = -1;
565 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
566 {
567 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
568 }
569
570 // onlyIfWeaponIs
571 m_OnlyIfWeaponIs = "";
572 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
573
574 // onlyIfBulletIs
575 m_OnlyIfBulletIs = "";
576 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
577
578 // onlyWithinHealthLabel[]
580 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
581
582 if (health_limit.Count() == 2)
583 {
586 }
587 else
588 {
589 // Disable this filter
592 }
593
594 // onlyWithinOverheatLimits[]
596 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
597
598 if (overheat_limit.Count() == 2)
599 {
602 }
603 else
604 {
605 // Disable this filter
608 }
609
610 // onlyWithinRainLimits[]
612 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
613
614 if (rain_limit.Count() == 2)
615 {
618 }
619 else
620 {
621 // Disable this filter
624 }
625
626 // overridePoint
627 m_OverridePoint = "";
628 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
629
630 if (m_OverridePoint == "")
631 m_OverridePoint = "Usti hlavne"; // default memory point name
632
633 // overrideParticle
634 string particle_name = "";
635 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
636
637 if (particle_name != "")
638 {
640 }
641 else
642 {
644 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
646 }
647
648 // overrideDirectionPoint
650 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
651
652 if (m_OverrideDirectionPoint == "")
653 {
654 // overrideDirectionVector
655 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
656
657 if (test_ori != vector.Zero)
658 {
660 }
661 }
662
663 // positionOffset[]
665 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
666
667 if (v.Count() == 3)
668 {
669 float v1 = v.Get(0);
670 float v2 = v.Get(1);
671 float v3 = v.Get(2);
673 }
674 }
675
676
677
678 //======================================
679 // PLAY PARTICLES
680 //======================================
681 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
682 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
684 {
685 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
686 {
687 // Handle effect's parameters
688 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
689 {
690 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
691 {
692 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
693 {
694 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
695 {
696 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
697 {
698 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
699 {
700 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
701 {
702 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
703 {
704 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
705 {
706 // Get particle ID
708
710 {
711 // Get position of the particle
712 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
714
715 // Set orientation of the particle
717
718 // Create particle
719 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
721 }
722 else
723 {
724 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
725 }
726
727 // Create light
729 {
730 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
731 int randX = Math.RandomInt( 0,10 );
732 if ( randX > 8 )
733 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
734 else if ( randX > 4 )
736 else
737 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
738 }
739 }
740 }
741 }
742 }
743 }
744 }
745 }
746 }
747 }
748 }
749 }
750
752 {
753
754 }
755
757 {
758
759 }
760
762 {
763
764 }
765
766
767 //==============================================
768 // HANDLE CONFIG PARAMETERS
769 //==============================================
770
771
772 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
774 {
775 if ( m_OnlyIfBoltIsOpen )
776 {
778 WeaponStateBase current_state = wb.GetCurrentState();
779 return current_state.IsBoltOpen();
780 }
781
782 return true;
783 }
784
785 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
787 {
789 }
790
791 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
793 {
795 }
796
797 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
798 bool CheckRainCondition(float rain_coef)
799 {
801 }
802
803 // muzzleFlashParticle
805 {
806 int particle_id = -1;
807
808 string particle_file = "";
809 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
810 if (GetGame().ConfigGetText( cfg_path, particle_file))
812
813 // Config is accessed only once because the data is saved into a map for repeated access.
814
815 if ( particle_id > 0 || m_OverrideParticle == -1)
816 {
817 if (particle_file == "")
818 {
819 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
820 }
821 else
822 {
824
825 if (particle_id == 0)
826 {
827 string devStr;
828 #ifdef DEVELOPER
829 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
830 #endif
831 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
832 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
833 }
834 }
835 }
836 else
837 {
839 }
840
841 return particle_id;
842 }
843
844 // OverrideDirectionPoint & OverrideDirectionVector
846 {
847 vector particle_ori = "0 0 0";
848 if (m_OverrideDirectionPoint != "")
849 {
850 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
852 particle_ori = target_pos.VectorToAngles();
853 }
854 else
855 {
856 if (m_OverrideDirectionVector != Vector(0, 0, 0))
857 {
859 }
860
861 if (muzzle_owner.IsInherited(ItemSuppressor))
862 {
863 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
864 }
865 }
866
867 return particle_ori;
868 }
869}
870
871// FIRE particles
873
874// BULLET EJECT particles
876
877// OVERHEATING particles
879{
881 {
882 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
883 }
884
886 {
887 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
888 {
889 weapon.KillAllOverheatingParticles();
890 }
891 }
892
894 {
896 }
897}
898
900{
902 int m_ParticleID;
906
909
911 {
912 m_Particle = p;
913 }
914
916 {
917 return m_Particle;
918 }
919
920 void SetOverheatingLimitMin(float min)
921 {
923 }
924
925 void SetOverheatingLimitMax(float max)
926 {
928 }
929
931 {
933 }
934
936 {
938 }
939
941 {
943 m_Parent = parent;
946 }
947
948 int GetParticleID()
949 {
950 return m_ParticleID;
951 }
952
954 {
955 return m_Parent;
956 }
957
959 {
960 return m_LocalPos;
961 }
962
964 {
965 return m_LocalOri;
966 }
967}

◆ OnDeactivate()

override void OnDeactivate ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
599{
603 int m_MuzzleIndex;
612 string m_OnlyIfBulletIs;
613 string m_OnlyIfWeaponIs;
614 string m_OverridePoint;
617
618 string m_Name;
619
620 //======================================
621 // PRELOAD EVERYTHING
622 //======================================
623
625 {
627
628 // ignoreIfSuppressed
629 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
630
631 // onlyIfBoltIsOpen
632 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
633
634 // illuminateWorld
635 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
636
637 m_MuzzleIndex = -1;
638 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
639 {
640 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
641 }
642
643 // onlyIfWeaponIs
644 m_OnlyIfWeaponIs = "";
645 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
646
647 // onlyIfBulletIs
648 m_OnlyIfBulletIs = "";
649 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
650
651 // onlyWithinHealthLabel[]
653 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
654
655 if (health_limit.Count() == 2)
656 {
659 }
660 else
661 {
662 // Disable this filter
665 }
666
667 // onlyWithinOverheatLimits[]
669 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
670
671 if (overheat_limit.Count() == 2)
672 {
675 }
676 else
677 {
678 // Disable this filter
681 }
682
683 // onlyWithinRainLimits[]
685 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
686
687 if (rain_limit.Count() == 2)
688 {
691 }
692 else
693 {
694 // Disable this filter
697 }
698
699 // overridePoint
700 m_OverridePoint = "";
701 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
702
703 if (m_OverridePoint == "")
704 m_OverridePoint = "Usti hlavne"; // default memory point name
705
706 // overrideParticle
707 string particle_name = "";
708 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
709
710 if (particle_name != "")
711 {
713 }
714 else
715 {
717 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
719 }
720
721 // overrideDirectionPoint
723 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
724
725 if (m_OverrideDirectionPoint == "")
726 {
727 // overrideDirectionVector
728 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
729
730 if (test_ori != vector.Zero)
731 {
733 }
734 }
735
736 // positionOffset[]
738 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
739
740 if (v.Count() == 3)
741 {
742 float v1 = v.Get(0);
743 float v2 = v.Get(1);
744 float v3 = v.Get(2);
746 }
747 }
748
749
750
751 //======================================
752 // PLAY PARTICLES
753 //======================================
754 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
755 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
757 {
758 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
759 {
760 // Handle effect's parameters
761 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
762 {
763 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
764 {
765 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
766 {
767 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
768 {
769 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
770 {
771 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
772 {
773 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
774 {
775 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
776 {
777 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
778 {
779 // Get particle ID
781
783 {
784 // Get position of the particle
785 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
787
788 // Set orientation of the particle
790
791 // Create particle
792 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
794 }
795 else
796 {
797 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
798 }
799
800 // Create light
802 {
803 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
804 int randX = Math.RandomInt( 0,10 );
805 if ( randX > 8 )
806 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
807 else if ( randX > 4 )
809 else
810 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
811 }
812 }
813 }
814 }
815 }
816 }
817 }
818 }
819 }
820 }
821 }
822 }
823
825 {
826
827 }
828
830 {
831
832 }
833
835 {
836
837 }
838
839
840 //==============================================
841 // HANDLE CONFIG PARAMETERS
842 //==============================================
843
844
845 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
847 {
848 if ( m_OnlyIfBoltIsOpen )
849 {
851 WeaponStateBase current_state = wb.GetCurrentState();
852 return current_state.IsBoltOpen();
853 }
854
855 return true;
856 }
857
858 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
860 {
862 }
863
864 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
866 {
868 }
869
870 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
871 bool CheckRainCondition(float rain_coef)
872 {
874 }
875
876 // muzzleFlashParticle
878 {
879 int particle_id = -1;
880
881 string particle_file = "";
882 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
883 if (GetGame().ConfigGetText( cfg_path, particle_file))
885
886 // Config is accessed only once because the data is saved into a map for repeated access.
887
888 if ( particle_id > 0 || m_OverrideParticle == -1)
889 {
890 if (particle_file == "")
891 {
892 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
893 }
894 else
895 {
897
898 if (particle_id == 0)
899 {
900 string devStr;
901 #ifdef DEVELOPER
902 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
903 #endif
904 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
905 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
906 }
907 }
908 }
909 else
910 {
912 }
913
914 return particle_id;
915 }
916
917 // OverrideDirectionPoint & OverrideDirectionVector
919 {
920 vector particle_ori = "0 0 0";
921 if (m_OverrideDirectionPoint != "")
922 {
923 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
925 particle_ori = target_pos.VectorToAngles();
926 }
927 else
928 {
929 if (m_OverrideDirectionVector != Vector(0, 0, 0))
930 {
932 }
933
934 if (muzzle_owner.IsInherited(ItemSuppressor))
935 {
936 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
937 }
938 }
939
940 return particle_ori;
941 }
942}
943
944// FIRE particles
946
947// BULLET EJECT particles
949
950// OVERHEATING particles
952{
954 {
955 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
956 }
957
959 {
960 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
961 {
962 weapon.KillAllOverheatingParticles();
963 }
964 }
965
967 {
969 }
970}
971
973{
975 int m_ParticleID;
979
982
984 {
985 m_Particle = p;
986 }
987
989 {
990 return m_Particle;
991 }
992
993 void SetOverheatingLimitMin(float min)
994 {
996 }
997
998 void SetOverheatingLimitMax(float max)
999 {
1001 }
1002
1004 {
1005 return m_OverheatingLimitMin;
1006 }
1007
1009 {
1010 return m_OverheatingLimitMax;
1011 }
1012
1014 {
1016 m_Parent = parent;
1019 }
1020
1021 int GetParticleID()
1022 {
1023 return m_ParticleID;
1024 }
1025
1027 {
1028 return m_Parent;
1029 }
1030
1032 {
1033 return m_LocalPos;
1034 }
1035
1037 {
1038 return m_LocalOri;
1039 }
1040}

◆ OnParticleCreated()

void OnParticleCreated ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search,
Particle p )
363 {
364 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
365 }

◆ OnUpdate()

override void OnUpdate ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )
604{
608 int m_MuzzleIndex;
617 string m_OnlyIfBulletIs;
618 string m_OnlyIfWeaponIs;
619 string m_OverridePoint;
622
623 string m_Name;
624
625 //======================================
626 // PRELOAD EVERYTHING
627 //======================================
628
630 {
632
633 // ignoreIfSuppressed
634 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
635
636 // onlyIfBoltIsOpen
637 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
638
639 // illuminateWorld
640 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
641
642 m_MuzzleIndex = -1;
643 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
644 {
645 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
646 }
647
648 // onlyIfWeaponIs
649 m_OnlyIfWeaponIs = "";
650 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
651
652 // onlyIfBulletIs
653 m_OnlyIfBulletIs = "";
654 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
655
656 // onlyWithinHealthLabel[]
658 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
659
660 if (health_limit.Count() == 2)
661 {
664 }
665 else
666 {
667 // Disable this filter
670 }
671
672 // onlyWithinOverheatLimits[]
674 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
675
676 if (overheat_limit.Count() == 2)
677 {
680 }
681 else
682 {
683 // Disable this filter
686 }
687
688 // onlyWithinRainLimits[]
690 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
691
692 if (rain_limit.Count() == 2)
693 {
696 }
697 else
698 {
699 // Disable this filter
702 }
703
704 // overridePoint
705 m_OverridePoint = "";
706 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
707
708 if (m_OverridePoint == "")
709 m_OverridePoint = "Usti hlavne"; // default memory point name
710
711 // overrideParticle
712 string particle_name = "";
713 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
714
715 if (particle_name != "")
716 {
718 }
719 else
720 {
722 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
724 }
725
726 // overrideDirectionPoint
728 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
729
730 if (m_OverrideDirectionPoint == "")
731 {
732 // overrideDirectionVector
733 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
734
735 if (test_ori != vector.Zero)
736 {
738 }
739 }
740
741 // positionOffset[]
743 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
744
745 if (v.Count() == 3)
746 {
747 float v1 = v.Get(0);
748 float v2 = v.Get(1);
749 float v3 = v.Get(2);
751 }
752 }
753
754
755
756 //======================================
757 // PLAY PARTICLES
758 //======================================
759 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
760 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
762 {
763 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
764 {
765 // Handle effect's parameters
766 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
767 {
768 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
769 {
770 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
771 {
772 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
773 {
774 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
775 {
776 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
777 {
778 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
779 {
780 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
781 {
782 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
783 {
784 // Get particle ID
786
788 {
789 // Get position of the particle
790 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
792
793 // Set orientation of the particle
795
796 // Create particle
797 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
799 }
800 else
801 {
802 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
803 }
804
805 // Create light
807 {
808 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
809 int randX = Math.RandomInt( 0,10 );
810 if ( randX > 8 )
811 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
812 else if ( randX > 4 )
814 else
815 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
816 }
817 }
818 }
819 }
820 }
821 }
822 }
823 }
824 }
825 }
826 }
827 }
828
830 {
831
832 }
833
835 {
836
837 }
838
840 {
841
842 }
843
844
845 //==============================================
846 // HANDLE CONFIG PARAMETERS
847 //==============================================
848
849
850 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
852 {
853 if ( m_OnlyIfBoltIsOpen )
854 {
856 WeaponStateBase current_state = wb.GetCurrentState();
857 return current_state.IsBoltOpen();
858 }
859
860 return true;
861 }
862
863 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
865 {
867 }
868
869 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
871 {
873 }
874
875 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
876 bool CheckRainCondition(float rain_coef)
877 {
879 }
880
881 // muzzleFlashParticle
883 {
884 int particle_id = -1;
885
886 string particle_file = "";
887 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
888 if (GetGame().ConfigGetText( cfg_path, particle_file))
890
891 // Config is accessed only once because the data is saved into a map for repeated access.
892
893 if ( particle_id > 0 || m_OverrideParticle == -1)
894 {
895 if (particle_file == "")
896 {
897 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
898 }
899 else
900 {
902
903 if (particle_id == 0)
904 {
905 string devStr;
906 #ifdef DEVELOPER
907 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
908 #endif
909 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
910 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
911 }
912 }
913 }
914 else
915 {
917 }
918
919 return particle_id;
920 }
921
922 // OverrideDirectionPoint & OverrideDirectionVector
924 {
925 vector particle_ori = "0 0 0";
926 if (m_OverrideDirectionPoint != "")
927 {
928 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
930 particle_ori = target_pos.VectorToAngles();
931 }
932 else
933 {
934 if (m_OverrideDirectionVector != Vector(0, 0, 0))
935 {
937 }
938
939 if (muzzle_owner.IsInherited(ItemSuppressor))
940 {
941 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
942 }
943 }
944
945 return particle_ori;
946 }
947}
948
949// FIRE particles
951
952// BULLET EJECT particles
954
955// OVERHEATING particles
957{
959 {
960 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
961 }
962
964 {
965 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
966 {
967 weapon.KillAllOverheatingParticles();
968 }
969 }
970
972 {
974 }
975}
976
978{
980 int m_ParticleID;
984
987
989 {
990 m_Particle = p;
991 }
992
994 {
995 return m_Particle;
996 }
997
998 void SetOverheatingLimitMin(float min)
999 {
1001 }
1002
1003 void SetOverheatingLimitMax(float max)
1004 {
1006 }
1007
1009 {
1010 return m_OverheatingLimitMin;
1011 }
1012
1014 {
1015 return m_OverheatingLimitMax;
1016 }
1017
1019 {
1021 m_Parent = parent;
1024 }
1025
1026 int GetParticleID()
1027 {
1028 return m_ParticleID;
1029 }
1030
1032 {
1033 return m_Parent;
1034 }
1035
1037 {
1038 return m_LocalPos;
1039 }
1040
1042 {
1043 return m_LocalOri;
1044 }
1045}

◆ WeaponParticlesBase()

void WeaponParticlesBase ( ItemBase muzzle_owner,
string config_OnFire_entry )
393 {
394 m_Particle = p;
395 }
396
398 {
399 return m_Particle;
400 }
401
402 void SetOverheatingLimitMin(float min)
403 {
404 m_OverheatingLimitMin = min;
405 }
406
407 void SetOverheatingLimitMax(float max)
408 {
409 m_OverheatingLimitMax = max;
410 }
411
412 float GetOverheatingLimitMin()
413 {
414 return m_OverheatingLimitMin;
415 }
416
417 float GetOverheatingLimitMax()
418 {
419 return m_OverheatingLimitMax;
420 }
421
422 void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
423 {
424 m_ParticleID = particle_id;
425 m_Parent = parent;
428 }
429
430 int GetParticleID()
431 {
432 return m_ParticleID;
433 }
434
435 Object GetParticleParent()
436 {
437 return m_Parent;
438 }
439
440 vector GetParticlePos()
441 {
442 return m_LocalPos;
443 }
444
445 vector GetParticleOri()
446 {
447 return m_LocalOri;
448 }
449}
vector m_LocalPos
Cached local pos.
Definition Effect.c:60
vector m_LocalOri
Local orientation set by SetAttachedLocalOri, only used by EffectParticle.
Definition Effect.c:62
proto native ParticleSource GetParticle(int index)
Manually get the particle at index.
Widget m_Parent
Definition SizeToChild.c:92

Переменные

◆ m_IgnoreIfSuppressed

bool m_IgnoreIfSuppressed

◆ m_IlluminateWorld

bool m_IlluminateWorld

◆ m_MuzzleIndex

int m_MuzzleIndex

◆ m_Name

string m_Name

◆ m_OnlyIfBoltIsOpen

bool m_OnlyIfBoltIsOpen

◆ m_OnlyIfBulletIs

string m_OnlyIfBulletIs

◆ m_OnlyIfWeaponIs

string m_OnlyIfWeaponIs

◆ m_OnlyWithinHealthLabelMax

int m_OnlyWithinHealthLabelMax

◆ m_OnlyWithinHealthLabelMin

int m_OnlyWithinHealthLabelMin

◆ m_OnlyWithinOverheatLimitsMax

float m_OnlyWithinOverheatLimitsMax

◆ m_OnlyWithinOverheatLimitsMin

float m_OnlyWithinOverheatLimitsMin

◆ m_OnlyWithinRainLimitsMax

float m_OnlyWithinRainLimitsMax

◆ m_OnlyWithinRainLimitsMin

float m_OnlyWithinRainLimitsMin

◆ m_OverrideDirectionPoint

string m_OverrideDirectionPoint

◆ m_OverrideDirectionVector

vector m_OverrideDirectionVector

◆ m_OverrideParticle

int m_OverrideParticle

◆ m_OverridePoint

string m_OverridePoint

◆ m_PositionOffset

vector m_PositionOffset