DayZ 1.24
Loading...
Searching...
No Matches
WeaponParticles.c File Reference

Go to the source code of this file.

Classes

class  WeaponParticlesBase
 
class  OverheatingParticle
 

Functions

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)
 

Variables

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
 

Function Documentation

◆ CheckBoltStateCondition()

bool OnParticleCreated::CheckBoltStateCondition ( ItemBase weapon)

Definition at line 585 of file WeaponParticles.c.

◆ CheckHealthCondition()

bool OnParticleCreated::CheckHealthCondition ( int health_label)

Definition at line 598 of file WeaponParticles.c.

605{
609 int m_MuzzleIndex;
618 string m_OnlyIfBulletIs;
619 string m_OnlyIfWeaponIs;
620 string m_OverridePoint;
623
624 string m_Name;
625
626 //======================================
627 // PRELOAD EVERYTHING
628 //======================================
629
631 {
633
634 // ignoreIfSuppressed
635 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
636
637 // onlyIfBoltIsOpen
638 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
639
640 // illuminateWorld
641 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
642
643 m_MuzzleIndex = -1;
644 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
645 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
646
647 // onlyIfWeaponIs
648 m_OnlyIfWeaponIs = "";
649 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
650
651 // onlyIfBulletIs
652 m_OnlyIfBulletIs = "";
653 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
654
655 // onlyWithinHealthLabel[]
657 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
658
659 if (health_limit.Count() == 2)
660 {
663 }
664 else
665 {
666 // Disable this filter
669 }
670
671 // onlyWithinOverheatLimits[]
673 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
674
675 if (overheat_limit.Count() == 2)
676 {
679 }
680 else
681 {
682 // Disable this filter
685 }
686
687 // onlyWithinRainLimits[]
689 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
690
691 if (rain_limit.Count() == 2)
692 {
695 }
696 else
697 {
698 // Disable this filter
701 }
702
703 // overridePoint
704 m_OverridePoint = "";
705 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
706
707 if (m_OverridePoint == "")
708 m_OverridePoint = "Usti hlavne"; // default memory point name
709
710 // overrideParticle
711 string particle_name = "";
712 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
713
714 if (particle_name != "")
716 else
717 {
719 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
721 }
722
723 // overrideDirectionPoint
725 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
726
727 if (m_OverrideDirectionPoint == "")
728 {
729 // overrideDirectionVector
730 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
731
732 if (test_ori != vector.Zero)
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 // PLAY PARTICLES
752 //======================================
753 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
754 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
756 {
757 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
758 {
759 // Handle effect's parameters
760 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
761 {
763 {
764 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
765 {
766 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
767 {
768 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
769 {
770 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
771 {
772 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
773 {
774 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
775 {
776 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
777 {
778 // Get particle ID
780
782 {
783 // Get position of the particle
784 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
786
787 // Set orientation of the particle
789
790 // Create particle
793 }
794 else
795 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
796
797 // Create light
799 {
800 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
801 int randX = Math.RandomInt(0, 10);
802 if (randX > 8)
803 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
804 else if (randX > 4)
806 else
807 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
808 }
809 }
810 }
811 }
812 }
813 }
814 }
815 }
816 }
817 }
818 }
819 }
820
822 {
823
824 }
825
827 {
828
829 }
830
832 {
833
834 }
835
836
837 //==============================================
838 // HANDLE CONFIG PARAMETERS
839 //==============================================
840
841
842 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
844 {
846 {
848 WeaponStateBase current_state = wb.GetCurrentState();
849 return current_state.IsBoltOpen();
850 }
851
852 return true;
853 }
854
855 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
857 {
859 }
860
861 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
863 {
865 }
866
867 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
868 bool CheckRainCondition(float rain_coef)
869 {
871 }
872
873 // muzzleFlashParticle
875 {
876 int particle_id = -1;
877
878 string particle_file = "";
879 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
880 if (GetGame().ConfigGetText(cfg_path, particle_file))
882
883 // Config is accessed only once because the data is saved into a map for repeated access.
884
885 if (particle_id > 0 || m_OverrideParticle == -1)
886 {
887 if (particle_file == "")
888 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
889 else
890 {
892
893 if (particle_id == 0)
894 {
895 string devStr;
896#ifdef DEVELOPER
897 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
898#endif
899 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
900 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
901 }
902 }
903 }
904 else
906
907 return particle_id;
908 }
909
910 // OverrideDirectionPoint & OverrideDirectionVector
912 {
913 vector particle_ori = "0 0 0";
914 if (m_OverrideDirectionPoint != "")
915 {
916 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
918 particle_ori = target_pos.VectorToAngles();
919 }
920 else
921 {
922 if (m_OverrideDirectionVector != Vector(0, 0, 0))
924
925 if (muzzle_owner.IsInherited(ItemSuppressor))
926 {
927 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
928 }
929 }
930
931 return particle_ori;
932 }
933}
934
935// FIRE particles
937
938// BULLET EJECT particles
940
941// OVERHEATING particles
943{
945 {
946 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
947 }
948
950 {
951 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
952 weapon.KillAllOverheatingParticles();
953 }
954
956 {
958 }
959}
960
962{
964 int m_ParticleID;
968
971
973 {
974 m_Particle = p;
975 }
976
978 {
979 return m_Particle;
980 }
981
982 void SetOverheatingLimitMin(float min)
983 {
985 }
986
987 void SetOverheatingLimitMax(float max)
988 {
990 }
991
993 {
995 }
996
998 {
1000 }
1001
1003 {
1005 m_Parent = parent;
1008 }
1009
1010 int GetParticleID()
1011 {
1012 return m_ParticleID;
1013 }
1014
1016 {
1017 return m_Parent;
1018 }
1019
1021 {
1022 return m_LocalPos;
1023 }
1024
1026 {
1027 return m_LocalOri;
1028 }
1029}
void MuzzleFlashLight_1()
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
int particle_id
bool CheckRainCondition(float rain_coef)
float m_OnlyWithinOverheatLimitsMin
bool m_IlluminateWorld
vector m_OverrideDirectionVector
string m_Name
int m_OverrideParticle
string m_OverrideDirectionPoint
float m_OnlyWithinRainLimitsMax
class WeaponParticlesBase OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
bool m_OnlyIfBoltIsOpen
vector m_PositionOffset
string m_OnlyIfWeaponIs
void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
string m_OnlyIfBulletIs
int CheckParticleOverride(string ammoType)
int m_MuzzleIndex
float m_OnlyWithinRainLimitsMin
vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
bool CheckHealthCondition(int health_label)
bool m_IgnoreIfSuppressed
string m_OverridePoint
int m_OnlyWithinHealthLabelMin
bool CheckBoltStateCondition(ItemBase weapon)
float m_OnlyWithinOverheatLimitsMax
int m_OnlyWithinHealthLabelMax
bool CheckOverheatingCondition(float overheating_coef)
Definition EnMath.c:7
void SetOverheatingLimitMax(float max)
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
void SetOverheatingLimitMin(float min)
void RegisterParticle(Particle p)
Legacy way of using particles in the game.
Definition Particle.c:7
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
static bool IsValidId(int id)
Purely checks for an invalid number, does NOT mean it is actually registered.
static bool m_GunParticlesState
Definition gameplay.c:1478
represent weapon state base
Definition BulletHide.c:2
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:333
void OnDeactivate()
called when command ends
Definition human.c:1170
class HumanMovementState OnActivate()
HumanCommandScript fully scriptable command.
Definition human.c:1167

◆ CheckOrientationOverride()

vector OnParticleCreated::CheckOrientationOverride ( vector local_pos,
ItemBase muzzle_owner )

Definition at line 653 of file WeaponParticles.c.

660{
664 int m_MuzzleIndex;
673 string m_OnlyIfBulletIs;
674 string m_OnlyIfWeaponIs;
675 string m_OverridePoint;
678
679 string m_Name;
680
681 //======================================
682 // PRELOAD EVERYTHING
683 //======================================
684
686 {
688
689 // ignoreIfSuppressed
690 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
691
692 // onlyIfBoltIsOpen
693 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
694
695 // illuminateWorld
696 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
697
698 m_MuzzleIndex = -1;
699 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
700 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
701
702 // onlyIfWeaponIs
703 m_OnlyIfWeaponIs = "";
704 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
705
706 // onlyIfBulletIs
707 m_OnlyIfBulletIs = "";
708 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
709
710 // onlyWithinHealthLabel[]
712 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
713
714 if (health_limit.Count() == 2)
715 {
718 }
719 else
720 {
721 // Disable this filter
724 }
725
726 // onlyWithinOverheatLimits[]
728 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
729
730 if (overheat_limit.Count() == 2)
731 {
734 }
735 else
736 {
737 // Disable this filter
740 }
741
742 // onlyWithinRainLimits[]
744 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
745
746 if (rain_limit.Count() == 2)
747 {
750 }
751 else
752 {
753 // Disable this filter
756 }
757
758 // overridePoint
759 m_OverridePoint = "";
760 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
761
762 if (m_OverridePoint == "")
763 m_OverridePoint = "Usti hlavne"; // default memory point name
764
765 // overrideParticle
766 string particle_name = "";
767 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
768
769 if (particle_name != "")
771 else
772 {
774 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
776 }
777
778 // overrideDirectionPoint
780 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
781
782 if (m_OverrideDirectionPoint == "")
783 {
784 // overrideDirectionVector
785 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
786
787 if (test_ori != vector.Zero)
789 }
790
791 // positionOffset[]
793 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
794
795 if (v.Count() == 3)
796 {
797 float v1 = v.Get(0);
798 float v2 = v.Get(1);
799 float v3 = v.Get(2);
801 }
802 }
803
804
805 //======================================
806 // PLAY PARTICLES
807 //======================================
808 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
809 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
811 {
812 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
813 {
814 // Handle effect's parameters
815 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
816 {
818 {
819 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
820 {
821 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
822 {
823 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
824 {
825 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
826 {
827 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
828 {
829 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
830 {
831 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
832 {
833 // Get particle ID
835
837 {
838 // Get position of the particle
839 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
841
842 // Set orientation of the particle
844
845 // Create particle
848 }
849 else
850 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
851
852 // Create light
854 {
855 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
856 int randX = Math.RandomInt(0, 10);
857 if (randX > 8)
858 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
859 else if (randX > 4)
861 else
862 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
863 }
864 }
865 }
866 }
867 }
868 }
869 }
870 }
871 }
872 }
873 }
874 }
875
877 {
878
879 }
880
882 {
883
884 }
885
887 {
888
889 }
890
891
892 //==============================================
893 // HANDLE CONFIG PARAMETERS
894 //==============================================
895
896
897 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
899 {
901 {
903 WeaponStateBase current_state = wb.GetCurrentState();
904 return current_state.IsBoltOpen();
905 }
906
907 return true;
908 }
909
910 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
912 {
914 }
915
916 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
918 {
920 }
921
922 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
923 bool CheckRainCondition(float rain_coef)
924 {
926 }
927
928 // muzzleFlashParticle
930 {
931 int particle_id = -1;
932
933 string particle_file = "";
934 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
935 if (GetGame().ConfigGetText(cfg_path, particle_file))
937
938 // Config is accessed only once because the data is saved into a map for repeated access.
939
940 if (particle_id > 0 || m_OverrideParticle == -1)
941 {
942 if (particle_file == "")
943 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
944 else
945 {
947
948 if (particle_id == 0)
949 {
950 string devStr;
951#ifdef DEVELOPER
952 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
953#endif
954 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
955 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
956 }
957 }
958 }
959 else
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))
979
980 if (muzzle_owner.IsInherited(ItemSuppressor))
981 {
982 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
983 }
984 }
985
986 return particle_ori;
987 }
988}
989
990// FIRE particles
992
993// BULLET EJECT particles
995
996// OVERHEATING particles
998{
1000 {
1001 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
1002 }
1003
1005 {
1006 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
1007 weapon.KillAllOverheatingParticles();
1008 }
1009
1011 {
1013 }
1014}
1015
1017{
1019 int m_ParticleID;
1023
1026
1028 {
1029 m_Particle = p;
1030 }
1031
1033 {
1034 return m_Particle;
1035 }
1036
1037 void SetOverheatingLimitMin(float min)
1038 {
1040 }
1041
1042 void SetOverheatingLimitMax(float max)
1043 {
1045 }
1046
1048 {
1049 return m_OverheatingLimitMin;
1050 }
1051
1053 {
1054 return m_OverheatingLimitMax;
1055 }
1056
1058 {
1060 m_Parent = parent;
1063 }
1064
1065 int GetParticleID()
1066 {
1067 return m_ParticleID;
1068 }
1069
1071 {
1072 return m_Parent;
1073 }
1074
1076 {
1077 return m_LocalPos;
1078 }
1079
1081 {
1082 return m_LocalOri;
1083 }
1084}

◆ CheckOverheatingCondition()

bool OnParticleCreated::CheckOverheatingCondition ( float overheating_coef)

Definition at line 604 of file WeaponParticles.c.

611{
615 int m_MuzzleIndex;
624 string m_OnlyIfBulletIs;
625 string m_OnlyIfWeaponIs;
626 string m_OverridePoint;
629
630 string m_Name;
631
632 //======================================
633 // PRELOAD EVERYTHING
634 //======================================
635
637 {
639
640 // ignoreIfSuppressed
641 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
642
643 // onlyIfBoltIsOpen
644 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
645
646 // illuminateWorld
647 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
648
649 m_MuzzleIndex = -1;
650 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
651 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
652
653 // onlyIfWeaponIs
654 m_OnlyIfWeaponIs = "";
655 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
656
657 // onlyIfBulletIs
658 m_OnlyIfBulletIs = "";
659 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
660
661 // onlyWithinHealthLabel[]
663 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
664
665 if (health_limit.Count() == 2)
666 {
669 }
670 else
671 {
672 // Disable this filter
675 }
676
677 // onlyWithinOverheatLimits[]
679 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
680
681 if (overheat_limit.Count() == 2)
682 {
685 }
686 else
687 {
688 // Disable this filter
691 }
692
693 // onlyWithinRainLimits[]
695 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
696
697 if (rain_limit.Count() == 2)
698 {
701 }
702 else
703 {
704 // Disable this filter
707 }
708
709 // overridePoint
710 m_OverridePoint = "";
711 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
712
713 if (m_OverridePoint == "")
714 m_OverridePoint = "Usti hlavne"; // default memory point name
715
716 // overrideParticle
717 string particle_name = "";
718 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
719
720 if (particle_name != "")
722 else
723 {
725 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
727 }
728
729 // overrideDirectionPoint
731 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
732
733 if (m_OverrideDirectionPoint == "")
734 {
735 // overrideDirectionVector
736 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
737
738 if (test_ori != vector.Zero)
740 }
741
742 // positionOffset[]
744 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
745
746 if (v.Count() == 3)
747 {
748 float v1 = v.Get(0);
749 float v2 = v.Get(1);
750 float v3 = v.Get(2);
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 {
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
799 }
800 else
801 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
802
803 // Create light
805 {
806 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
807 int randX = Math.RandomInt(0, 10);
808 if (randX > 8)
809 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
810 else if (randX > 4)
812 else
813 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
814 }
815 }
816 }
817 }
818 }
819 }
820 }
821 }
822 }
823 }
824 }
825 }
826
828 {
829
830 }
831
833 {
834
835 }
836
838 {
839
840 }
841
842
843 //==============================================
844 // HANDLE CONFIG PARAMETERS
845 //==============================================
846
847
848 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
850 {
852 {
854 WeaponStateBase current_state = wb.GetCurrentState();
855 return current_state.IsBoltOpen();
856 }
857
858 return true;
859 }
860
861 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
863 {
865 }
866
867 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
869 {
871 }
872
873 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
874 bool CheckRainCondition(float rain_coef)
875 {
877 }
878
879 // muzzleFlashParticle
881 {
882 int particle_id = -1;
883
884 string particle_file = "";
885 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
886 if (GetGame().ConfigGetText(cfg_path, particle_file))
888
889 // Config is accessed only once because the data is saved into a map for repeated access.
890
891 if (particle_id > 0 || m_OverrideParticle == -1)
892 {
893 if (particle_file == "")
894 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
895 else
896 {
898
899 if (particle_id == 0)
900 {
901 string devStr;
902#ifdef DEVELOPER
903 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
904#endif
905 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
906 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
907 }
908 }
909 }
910 else
912
913 return particle_id;
914 }
915
916 // OverrideDirectionPoint & OverrideDirectionVector
918 {
919 vector particle_ori = "0 0 0";
920 if (m_OverrideDirectionPoint != "")
921 {
922 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
924 particle_ori = target_pos.VectorToAngles();
925 }
926 else
927 {
928 if (m_OverrideDirectionVector != Vector(0, 0, 0))
930
931 if (muzzle_owner.IsInherited(ItemSuppressor))
932 {
933 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
934 }
935 }
936
937 return particle_ori;
938 }
939}
940
941// FIRE particles
943
944// BULLET EJECT particles
946
947// OVERHEATING particles
949{
951 {
952 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
953 }
954
956 {
957 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
958 weapon.KillAllOverheatingParticles();
959 }
960
962 {
964 }
965}
966
968{
970 int m_ParticleID;
974
977
979 {
980 m_Particle = p;
981 }
982
984 {
985 return m_Particle;
986 }
987
988 void SetOverheatingLimitMin(float min)
989 {
991 }
992
993 void SetOverheatingLimitMax(float max)
994 {
996 }
997
999 {
1000 return m_OverheatingLimitMin;
1001 }
1002
1004 {
1005 return m_OverheatingLimitMax;
1006 }
1007
1009 {
1011 m_Parent = parent;
1014 }
1015
1016 int GetParticleID()
1017 {
1018 return m_ParticleID;
1019 }
1020
1022 {
1023 return m_Parent;
1024 }
1025
1027 {
1028 return m_LocalPos;
1029 }
1030
1032 {
1033 return m_LocalOri;
1034 }
1035}

◆ CheckParticleOverride()

int OnParticleCreated::CheckParticleOverride ( string ammoType)

Definition at line 616 of file WeaponParticles.c.

623{
627 int m_MuzzleIndex;
636 string m_OnlyIfBulletIs;
637 string m_OnlyIfWeaponIs;
638 string m_OverridePoint;
641
642 string m_Name;
643
644 //======================================
645 // PRELOAD EVERYTHING
646 //======================================
647
649 {
651
652 // ignoreIfSuppressed
653 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
654
655 // onlyIfBoltIsOpen
656 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
657
658 // illuminateWorld
659 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
660
661 m_MuzzleIndex = -1;
662 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
663 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
664
665 // onlyIfWeaponIs
666 m_OnlyIfWeaponIs = "";
667 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
668
669 // onlyIfBulletIs
670 m_OnlyIfBulletIs = "";
671 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
672
673 // onlyWithinHealthLabel[]
675 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
676
677 if (health_limit.Count() == 2)
678 {
681 }
682 else
683 {
684 // Disable this filter
687 }
688
689 // onlyWithinOverheatLimits[]
691 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
692
693 if (overheat_limit.Count() == 2)
694 {
697 }
698 else
699 {
700 // Disable this filter
703 }
704
705 // onlyWithinRainLimits[]
707 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
708
709 if (rain_limit.Count() == 2)
710 {
713 }
714 else
715 {
716 // Disable this filter
719 }
720
721 // overridePoint
722 m_OverridePoint = "";
723 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
724
725 if (m_OverridePoint == "")
726 m_OverridePoint = "Usti hlavne"; // default memory point name
727
728 // overrideParticle
729 string particle_name = "";
730 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
731
732 if (particle_name != "")
734 else
735 {
737 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
739 }
740
741 // overrideDirectionPoint
743 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
744
745 if (m_OverrideDirectionPoint == "")
746 {
747 // overrideDirectionVector
748 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
749
750 if (test_ori != vector.Zero)
752 }
753
754 // positionOffset[]
756 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
757
758 if (v.Count() == 3)
759 {
760 float v1 = v.Get(0);
761 float v2 = v.Get(1);
762 float v3 = v.Get(2);
764 }
765 }
766
767
768 //======================================
769 // PLAY PARTICLES
770 //======================================
771 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
772 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
774 {
775 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
776 {
777 // Handle effect's parameters
778 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
779 {
781 {
782 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
783 {
784 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
785 {
786 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
787 {
788 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
789 {
790 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
791 {
792 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
793 {
794 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
795 {
796 // Get particle ID
798
800 {
801 // Get position of the particle
802 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
804
805 // Set orientation of the particle
807
808 // Create particle
811 }
812 else
813 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
814
815 // Create light
817 {
818 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
819 int randX = Math.RandomInt(0, 10);
820 if (randX > 8)
821 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
822 else if (randX > 4)
824 else
825 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
826 }
827 }
828 }
829 }
830 }
831 }
832 }
833 }
834 }
835 }
836 }
837 }
838
840 {
841
842 }
843
845 {
846
847 }
848
850 {
851
852 }
853
854
855 //==============================================
856 // HANDLE CONFIG PARAMETERS
857 //==============================================
858
859
860 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
862 {
864 {
866 WeaponStateBase current_state = wb.GetCurrentState();
867 return current_state.IsBoltOpen();
868 }
869
870 return true;
871 }
872
873 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
875 {
877 }
878
879 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
881 {
883 }
884
885 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
886 bool CheckRainCondition(float rain_coef)
887 {
889 }
890
891 // muzzleFlashParticle
893 {
894 int particle_id = -1;
895
896 string particle_file = "";
897 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
898 if (GetGame().ConfigGetText(cfg_path, particle_file))
900
901 // Config is accessed only once because the data is saved into a map for repeated access.
902
903 if (particle_id > 0 || m_OverrideParticle == -1)
904 {
905 if (particle_file == "")
906 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
907 else
908 {
910
911 if (particle_id == 0)
912 {
913 string devStr;
914#ifdef DEVELOPER
915 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
916#endif
917 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
918 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
919 }
920 }
921 }
922 else
924
925 return particle_id;
926 }
927
928 // OverrideDirectionPoint & OverrideDirectionVector
930 {
931 vector particle_ori = "0 0 0";
932 if (m_OverrideDirectionPoint != "")
933 {
934 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
936 particle_ori = target_pos.VectorToAngles();
937 }
938 else
939 {
940 if (m_OverrideDirectionVector != Vector(0, 0, 0))
942
943 if (muzzle_owner.IsInherited(ItemSuppressor))
944 {
945 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
946 }
947 }
948
949 return particle_ori;
950 }
951}
952
953// FIRE particles
955
956// BULLET EJECT particles
958
959// OVERHEATING particles
961{
963 {
964 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
965 }
966
968 {
969 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
970 weapon.KillAllOverheatingParticles();
971 }
972
974 {
976 }
977}
978
980{
982 int m_ParticleID;
986
989
991 {
992 m_Particle = p;
993 }
994
996 {
997 return m_Particle;
998 }
999
1000 void SetOverheatingLimitMin(float min)
1001 {
1003 }
1004
1005 void SetOverheatingLimitMax(float max)
1006 {
1008 }
1009
1011 {
1012 return m_OverheatingLimitMin;
1013 }
1014
1016 {
1017 return m_OverheatingLimitMax;
1018 }
1019
1021 {
1023 m_Parent = parent;
1026 }
1027
1028 int GetParticleID()
1029 {
1030 return m_ParticleID;
1031 }
1032
1034 {
1035 return m_Parent;
1036 }
1037
1039 {
1040 return m_LocalPos;
1041 }
1042
1044 {
1045 return m_LocalOri;
1046 }
1047}

◆ CheckRainCondition()

bool OnParticleCreated::CheckRainCondition ( float rain_coef)

Definition at line 610 of file WeaponParticles.c.

617{
621 int m_MuzzleIndex;
630 string m_OnlyIfBulletIs;
631 string m_OnlyIfWeaponIs;
632 string m_OverridePoint;
635
636 string m_Name;
637
638 //======================================
639 // PRELOAD EVERYTHING
640 //======================================
641
643 {
645
646 // ignoreIfSuppressed
647 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
648
649 // onlyIfBoltIsOpen
650 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
651
652 // illuminateWorld
653 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
654
655 m_MuzzleIndex = -1;
656 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
657 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
658
659 // onlyIfWeaponIs
660 m_OnlyIfWeaponIs = "";
661 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
662
663 // onlyIfBulletIs
664 m_OnlyIfBulletIs = "";
665 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
666
667 // onlyWithinHealthLabel[]
669 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
670
671 if (health_limit.Count() == 2)
672 {
675 }
676 else
677 {
678 // Disable this filter
681 }
682
683 // onlyWithinOverheatLimits[]
685 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
686
687 if (overheat_limit.Count() == 2)
688 {
691 }
692 else
693 {
694 // Disable this filter
697 }
698
699 // onlyWithinRainLimits[]
701 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
702
703 if (rain_limit.Count() == 2)
704 {
707 }
708 else
709 {
710 // Disable this filter
713 }
714
715 // overridePoint
716 m_OverridePoint = "";
717 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
718
719 if (m_OverridePoint == "")
720 m_OverridePoint = "Usti hlavne"; // default memory point name
721
722 // overrideParticle
723 string particle_name = "";
724 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
725
726 if (particle_name != "")
728 else
729 {
731 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
733 }
734
735 // overrideDirectionPoint
737 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
738
739 if (m_OverrideDirectionPoint == "")
740 {
741 // overrideDirectionVector
742 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
743
744 if (test_ori != vector.Zero)
746 }
747
748 // positionOffset[]
750 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
751
752 if (v.Count() == 3)
753 {
754 float v1 = v.Get(0);
755 float v2 = v.Get(1);
756 float v3 = v.Get(2);
758 }
759 }
760
761
762 //======================================
763 // PLAY PARTICLES
764 //======================================
765 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
766 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
768 {
769 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
770 {
771 // Handle effect's parameters
772 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
773 {
775 {
776 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
777 {
778 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
779 {
780 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
781 {
782 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
783 {
784 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
785 {
786 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
787 {
788 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
789 {
790 // Get particle ID
792
794 {
795 // Get position of the particle
796 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
798
799 // Set orientation of the particle
801
802 // Create particle
805 }
806 else
807 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
808
809 // Create light
811 {
812 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
813 int randX = Math.RandomInt(0, 10);
814 if (randX > 8)
815 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
816 else if (randX > 4)
818 else
819 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
820 }
821 }
822 }
823 }
824 }
825 }
826 }
827 }
828 }
829 }
830 }
831 }
832
834 {
835
836 }
837
839 {
840
841 }
842
844 {
845
846 }
847
848
849 //==============================================
850 // HANDLE CONFIG PARAMETERS
851 //==============================================
852
853
854 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
856 {
858 {
860 WeaponStateBase current_state = wb.GetCurrentState();
861 return current_state.IsBoltOpen();
862 }
863
864 return true;
865 }
866
867 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
869 {
871 }
872
873 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
875 {
877 }
878
879 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
880 bool CheckRainCondition(float rain_coef)
881 {
883 }
884
885 // muzzleFlashParticle
887 {
888 int particle_id = -1;
889
890 string particle_file = "";
891 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
892 if (GetGame().ConfigGetText(cfg_path, particle_file))
894
895 // Config is accessed only once because the data is saved into a map for repeated access.
896
897 if (particle_id > 0 || m_OverrideParticle == -1)
898 {
899 if (particle_file == "")
900 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
901 else
902 {
904
905 if (particle_id == 0)
906 {
907 string devStr;
908#ifdef DEVELOPER
909 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
910#endif
911 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
912 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
913 }
914 }
915 }
916 else
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))
936
937 if (muzzle_owner.IsInherited(ItemSuppressor))
938 {
939 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
940 }
941 }
942
943 return particle_ori;
944 }
945}
946
947// FIRE particles
949
950// BULLET EJECT particles
952
953// OVERHEATING particles
955{
957 {
958 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
959 }
960
962 {
963 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
964 weapon.KillAllOverheatingParticles();
965 }
966
968 {
970 }
971}
972
974{
976 int m_ParticleID;
980
983
985 {
986 m_Particle = p;
987 }
988
990 {
991 return m_Particle;
992 }
993
994 void SetOverheatingLimitMin(float min)
995 {
997 }
998
999 void SetOverheatingLimitMax(float max)
1000 {
1002 }
1003
1005 {
1006 return m_OverheatingLimitMin;
1007 }
1008
1010 {
1011 return m_OverheatingLimitMax;
1012 }
1013
1015 {
1017 m_Parent = parent;
1020 }
1021
1022 int GetParticleID()
1023 {
1024 return m_ParticleID;
1025 }
1026
1028 {
1029 return m_Parent;
1030 }
1031
1033 {
1034 return m_LocalPos;
1035 }
1036
1038 {
1039 return m_LocalOri;
1040 }
1041}

◆ OnActivate()

void OnParticleCreated::OnActivate ( ItemBase weapon,
int muzzle_index,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )

Definition at line 497 of file WeaponParticles.c.

504{
508 int m_MuzzleIndex;
517 string m_OnlyIfBulletIs;
518 string m_OnlyIfWeaponIs;
519 string m_OverridePoint;
522
523 string m_Name;
524
525 //======================================
526 // PRELOAD EVERYTHING
527 //======================================
528
530 {
532
533 // ignoreIfSuppressed
534 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
535
536 // onlyIfBoltIsOpen
537 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
538
539 // illuminateWorld
540 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
541
542 m_MuzzleIndex = -1;
543 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
544 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
545
546 // onlyIfWeaponIs
547 m_OnlyIfWeaponIs = "";
548 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
549
550 // onlyIfBulletIs
551 m_OnlyIfBulletIs = "";
552 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
553
554 // onlyWithinHealthLabel[]
556 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
557
558 if (health_limit.Count() == 2)
559 {
562 }
563 else
564 {
565 // Disable this filter
568 }
569
570 // onlyWithinOverheatLimits[]
572 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
573
574 if (overheat_limit.Count() == 2)
575 {
578 }
579 else
580 {
581 // Disable this filter
584 }
585
586 // onlyWithinRainLimits[]
588 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
589
590 if (rain_limit.Count() == 2)
591 {
594 }
595 else
596 {
597 // Disable this filter
600 }
601
602 // overridePoint
603 m_OverridePoint = "";
604 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
605
606 if (m_OverridePoint == "")
607 m_OverridePoint = "Usti hlavne"; // default memory point name
608
609 // overrideParticle
610 string particle_name = "";
611 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
612
613 if (particle_name != "")
615 else
616 {
618 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
620 }
621
622 // overrideDirectionPoint
624 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
625
626 if (m_OverrideDirectionPoint == "")
627 {
628 // overrideDirectionVector
629 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
630
631 if (test_ori != vector.Zero)
633 }
634
635 // positionOffset[]
637 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
638
639 if (v.Count() == 3)
640 {
641 float v1 = v.Get(0);
642 float v2 = v.Get(1);
643 float v3 = v.Get(2);
645 }
646 }
647
648
649 //======================================
650 // PLAY PARTICLES
651 //======================================
652 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
653 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
655 {
656 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
657 {
658 // Handle effect's parameters
659 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
660 {
662 {
663 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
664 {
665 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
666 {
667 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
668 {
669 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
670 {
671 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
672 {
673 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
674 {
675 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
676 {
677 // Get particle ID
679
681 {
682 // Get position of the particle
683 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
685
686 // Set orientation of the particle
688
689 // Create particle
692 }
693 else
694 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
695
696 // Create light
698 {
699 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
700 int randX = Math.RandomInt(0, 10);
701 if (randX > 8)
702 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
703 else if (randX > 4)
705 else
706 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
707 }
708 }
709 }
710 }
711 }
712 }
713 }
714 }
715 }
716 }
717 }
718 }
719
721 {
722
723 }
724
726 {
727
728 }
729
731 {
732
733 }
734
735
736 //==============================================
737 // HANDLE CONFIG PARAMETERS
738 //==============================================
739
740
741 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
743 {
745 {
747 WeaponStateBase current_state = wb.GetCurrentState();
748 return current_state.IsBoltOpen();
749 }
750
751 return true;
752 }
753
754 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
756 {
758 }
759
760 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
762 {
764 }
765
766 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
767 bool CheckRainCondition(float rain_coef)
768 {
770 }
771
772 // muzzleFlashParticle
774 {
775 int particle_id = -1;
776
777 string particle_file = "";
778 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
779 if (GetGame().ConfigGetText(cfg_path, particle_file))
781
782 // Config is accessed only once because the data is saved into a map for repeated access.
783
784 if (particle_id > 0 || m_OverrideParticle == -1)
785 {
786 if (particle_file == "")
787 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
788 else
789 {
791
792 if (particle_id == 0)
793 {
794 string devStr;
795#ifdef DEVELOPER
796 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
797#endif
798 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
799 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
800 }
801 }
802 }
803 else
805
806 return particle_id;
807 }
808
809 // OverrideDirectionPoint & OverrideDirectionVector
811 {
812 vector particle_ori = "0 0 0";
813 if (m_OverrideDirectionPoint != "")
814 {
815 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
817 particle_ori = target_pos.VectorToAngles();
818 }
819 else
820 {
821 if (m_OverrideDirectionVector != Vector(0, 0, 0))
823
824 if (muzzle_owner.IsInherited(ItemSuppressor))
825 {
826 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
827 }
828 }
829
830 return particle_ori;
831 }
832}
833
834// FIRE particles
836
837// BULLET EJECT particles
839
840// OVERHEATING particles
842{
844 {
845 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
846 }
847
849 {
850 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
851 weapon.KillAllOverheatingParticles();
852 }
853
855 {
857 }
858}
859
861{
863 int m_ParticleID;
867
870
872 {
873 m_Particle = p;
874 }
875
877 {
878 return m_Particle;
879 }
880
881 void SetOverheatingLimitMin(float min)
882 {
884 }
885
886 void SetOverheatingLimitMax(float max)
887 {
889 }
890
892 {
894 }
895
897 {
899 }
900
902 {
904 m_Parent = parent;
907 }
908
909 int GetParticleID()
910 {
911 return m_ParticleID;
912 }
913
915 {
916 return m_Parent;
917 }
918
920 {
921 return m_LocalPos;
922 }
923
925 {
926 return m_LocalOri;
927 }
928}

◆ OnDeactivate()

override void OnDeactivate ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )

Definition at line 568 of file WeaponParticles.c.

575{
579 int m_MuzzleIndex;
588 string m_OnlyIfBulletIs;
589 string m_OnlyIfWeaponIs;
590 string m_OverridePoint;
593
594 string m_Name;
595
596 //======================================
597 // PRELOAD EVERYTHING
598 //======================================
599
601 {
603
604 // ignoreIfSuppressed
605 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
606
607 // onlyIfBoltIsOpen
608 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
609
610 // illuminateWorld
611 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
612
613 m_MuzzleIndex = -1;
614 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
615 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
616
617 // onlyIfWeaponIs
618 m_OnlyIfWeaponIs = "";
619 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
620
621 // onlyIfBulletIs
622 m_OnlyIfBulletIs = "";
623 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
624
625 // onlyWithinHealthLabel[]
627 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
628
629 if (health_limit.Count() == 2)
630 {
633 }
634 else
635 {
636 // Disable this filter
639 }
640
641 // onlyWithinOverheatLimits[]
643 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
644
645 if (overheat_limit.Count() == 2)
646 {
649 }
650 else
651 {
652 // Disable this filter
655 }
656
657 // onlyWithinRainLimits[]
659 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
660
661 if (rain_limit.Count() == 2)
662 {
665 }
666 else
667 {
668 // Disable this filter
671 }
672
673 // overridePoint
674 m_OverridePoint = "";
675 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
676
677 if (m_OverridePoint == "")
678 m_OverridePoint = "Usti hlavne"; // default memory point name
679
680 // overrideParticle
681 string particle_name = "";
682 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
683
684 if (particle_name != "")
686 else
687 {
689 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
691 }
692
693 // overrideDirectionPoint
695 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
696
697 if (m_OverrideDirectionPoint == "")
698 {
699 // overrideDirectionVector
700 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
701
702 if (test_ori != vector.Zero)
704 }
705
706 // positionOffset[]
708 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
709
710 if (v.Count() == 3)
711 {
712 float v1 = v.Get(0);
713 float v2 = v.Get(1);
714 float v3 = v.Get(2);
716 }
717 }
718
719
720 //======================================
721 // PLAY PARTICLES
722 //======================================
723 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
724 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
726 {
727 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
728 {
729 // Handle effect's parameters
730 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
731 {
733 {
734 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
735 {
736 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
737 {
738 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
739 {
740 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
741 {
742 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
743 {
744 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
745 {
746 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
747 {
748 // Get particle ID
750
752 {
753 // Get position of the particle
754 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
756
757 // Set orientation of the particle
759
760 // Create particle
763 }
764 else
765 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
766
767 // Create light
769 {
770 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
771 int randX = Math.RandomInt(0, 10);
772 if (randX > 8)
773 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
774 else if (randX > 4)
776 else
777 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
778 }
779 }
780 }
781 }
782 }
783 }
784 }
785 }
786 }
787 }
788 }
789 }
790
792 {
793
794 }
795
797 {
798
799 }
800
802 {
803
804 }
805
806
807 //==============================================
808 // HANDLE CONFIG PARAMETERS
809 //==============================================
810
811
812 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
814 {
816 {
818 WeaponStateBase current_state = wb.GetCurrentState();
819 return current_state.IsBoltOpen();
820 }
821
822 return true;
823 }
824
825 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
827 {
829 }
830
831 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
833 {
835 }
836
837 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
838 bool CheckRainCondition(float rain_coef)
839 {
841 }
842
843 // muzzleFlashParticle
845 {
846 int particle_id = -1;
847
848 string particle_file = "";
849 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
850 if (GetGame().ConfigGetText(cfg_path, particle_file))
852
853 // Config is accessed only once because the data is saved into a map for repeated access.
854
855 if (particle_id > 0 || m_OverrideParticle == -1)
856 {
857 if (particle_file == "")
858 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
859 else
860 {
862
863 if (particle_id == 0)
864 {
865 string devStr;
866#ifdef DEVELOPER
867 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
868#endif
869 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
870 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
871 }
872 }
873 }
874 else
876
877 return particle_id;
878 }
879
880 // OverrideDirectionPoint & OverrideDirectionVector
882 {
883 vector particle_ori = "0 0 0";
884 if (m_OverrideDirectionPoint != "")
885 {
886 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
888 particle_ori = target_pos.VectorToAngles();
889 }
890 else
891 {
892 if (m_OverrideDirectionVector != Vector(0, 0, 0))
894
895 if (muzzle_owner.IsInherited(ItemSuppressor))
896 {
897 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
898 }
899 }
900
901 return particle_ori;
902 }
903}
904
905// FIRE particles
907
908// BULLET EJECT particles
910
911// OVERHEATING particles
913{
915 {
916 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
917 }
918
920 {
921 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
922 weapon.KillAllOverheatingParticles();
923 }
924
926 {
928 }
929}
930
932{
934 int m_ParticleID;
938
941
943 {
944 m_Particle = p;
945 }
946
948 {
949 return m_Particle;
950 }
951
952 void SetOverheatingLimitMin(float min)
953 {
955 }
956
957 void SetOverheatingLimitMax(float max)
958 {
960 }
961
963 {
965 }
966
968 {
970 }
971
973 {
975 m_Parent = parent;
978 }
979
980 int GetParticleID()
981 {
982 return m_ParticleID;
983 }
984
986 {
987 return m_Parent;
988 }
989
991 {
992 return m_LocalPos;
993 }
994
996 {
997 return m_LocalOri;
998 }
999}

◆ OnParticleCreated()

void OnParticleCreated ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search,
Particle p )

Definition at line 1 of file WeaponParticles.c.

348 {
349 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
350 }

◆ OnUpdate()

override void OnUpdate ( ItemBase weapon,
string ammoType,
ItemBase muzzle_owner,
ItemBase suppressor,
string config_to_search )

Definition at line 573 of file WeaponParticles.c.

580{
584 int m_MuzzleIndex;
593 string m_OnlyIfBulletIs;
594 string m_OnlyIfWeaponIs;
595 string m_OverridePoint;
598
599 string m_Name;
600
601 //======================================
602 // PRELOAD EVERYTHING
603 //======================================
604
606 {
608
609 // ignoreIfSuppressed
610 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
611
612 // onlyIfBoltIsOpen
613 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
614
615 // illuminateWorld
616 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
617
618 m_MuzzleIndex = -1;
619 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
620 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
621
622 // onlyIfWeaponIs
623 m_OnlyIfWeaponIs = "";
624 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
625
626 // onlyIfBulletIs
627 m_OnlyIfBulletIs = "";
628 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
629
630 // onlyWithinHealthLabel[]
632 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
633
634 if (health_limit.Count() == 2)
635 {
638 }
639 else
640 {
641 // Disable this filter
644 }
645
646 // onlyWithinOverheatLimits[]
648 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
649
650 if (overheat_limit.Count() == 2)
651 {
654 }
655 else
656 {
657 // Disable this filter
660 }
661
662 // onlyWithinRainLimits[]
664 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
665
666 if (rain_limit.Count() == 2)
667 {
670 }
671 else
672 {
673 // Disable this filter
676 }
677
678 // overridePoint
679 m_OverridePoint = "";
680 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
681
682 if (m_OverridePoint == "")
683 m_OverridePoint = "Usti hlavne"; // default memory point name
684
685 // overrideParticle
686 string particle_name = "";
687 GetGame().ConfigGetText(string.Format("%1 overrideParticle", m_Name), particle_name);
688
689 if (particle_name != "")
691 else
692 {
694 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
696 }
697
698 // overrideDirectionPoint
700 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
701
702 if (m_OverrideDirectionPoint == "")
703 {
704 // overrideDirectionVector
705 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
706
707 if (test_ori != vector.Zero)
709 }
710
711 // positionOffset[]
713 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
714
715 if (v.Count() == 3)
716 {
717 float v1 = v.Get(0);
718 float v2 = v.Get(1);
719 float v3 = v.Get(2);
721 }
722 }
723
724
725 //======================================
726 // PLAY PARTICLES
727 //======================================
728 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
729 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
731 {
732 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
733 {
734 // Handle effect's parameters
735 if (PrtTest.m_GunParticlesState) // Check if particles are enabled by debug
736 {
738 {
739 if (CheckBoltStateCondition(weapon)) // onlyIfBoltIsOpen
740 {
741 if (!suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed)) // ignoreIfSuppressed
742 {
743 if (CheckHealthCondition(muzzle_owner.GetHealthLevel())) // onlyWithinHealthLabel
744 {
745 if (CheckOverheatingCondition(muzzle_owner.GetOverheatingCoef())) // onlyWithinOverheatLimits
746 {
747 if (CheckRainCondition(GetGame().GetWeather().GetRain().GetActual())) // onlyWithinRainLimits
748 {
749 if (m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType) // onlyIfBulletIs
750 {
751 if (m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType()) // onlyIfWeaponIs
752 {
753 // Get particle ID
755
757 {
758 // Get position of the particle
759 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
761
762 // Set orientation of the particle
764
765 // Create particle
768 }
769 else
770 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
771
772 // Create light
774 {
775 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
776 int randX = Math.RandomInt(0, 10);
777 if (randX > 8)
778 ScriptedLightBase.CreateLight(MuzzleFlashLight_2, global_pos);
779 else if (randX > 4)
781 else
782 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
783 }
784 }
785 }
786 }
787 }
788 }
789 }
790 }
791 }
792 }
793 }
794 }
795
797 {
798
799 }
800
802 {
803
804 }
805
807 {
808
809 }
810
811
812 //==============================================
813 // HANDLE CONFIG PARAMETERS
814 //==============================================
815
816
817 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
819 {
821 {
823 WeaponStateBase current_state = wb.GetCurrentState();
824 return current_state.IsBoltOpen();
825 }
826
827 return true;
828 }
829
830 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
832 {
834 }
835
836 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
838 {
840 }
841
842 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
843 bool CheckRainCondition(float rain_coef)
844 {
846 }
847
848 // muzzleFlashParticle
850 {
851 int particle_id = -1;
852
853 string particle_file = "";
854 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
855 if (GetGame().ConfigGetText(cfg_path, particle_file))
857
858 // Config is accessed only once because the data is saved into a map for repeated access.
859
860 if (particle_id > 0 || m_OverrideParticle == -1)
861 {
862 if (particle_file == "")
863 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
864 else
865 {
867
868 if (particle_id == 0)
869 {
870 string devStr;
871#ifdef DEVELOPER
872 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
873#endif
874 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
875 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
876 }
877 }
878 }
879 else
881
882 return particle_id;
883 }
884
885 // OverrideDirectionPoint & OverrideDirectionVector
887 {
888 vector particle_ori = "0 0 0";
889 if (m_OverrideDirectionPoint != "")
890 {
891 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
893 particle_ori = target_pos.VectorToAngles();
894 }
895 else
896 {
897 if (m_OverrideDirectionVector != Vector(0, 0, 0))
899
900 if (muzzle_owner.IsInherited(ItemSuppressor))
901 {
902 particle_ori = particle_ori + Vector(0, 0, 270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
903 }
904 }
905
906 return particle_ori;
907 }
908}
909
910// FIRE particles
912
913// BULLET EJECT particles
915
916// OVERHEATING particles
918{
920 {
921 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri);
922 }
923
925 {
926 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
927 weapon.KillAllOverheatingParticles();
928 }
929
931 {
933 }
934}
935
937{
939 int m_ParticleID;
943
946
948 {
949 m_Particle = p;
950 }
951
953 {
954 return m_Particle;
955 }
956
957 void SetOverheatingLimitMin(float min)
958 {
960 }
961
962 void SetOverheatingLimitMax(float max)
963 {
965 }
966
968 {
970 }
971
973 {
975 }
976
978 {
980 m_Parent = parent;
983 }
984
985 int GetParticleID()
986 {
987 return m_ParticleID;
988 }
989
991 {
992 return m_Parent;
993 }
994
996 {
997 return m_LocalPos;
998 }
999
1001 {
1002 return m_LocalOri;
1003 }
1004}

◆ WeaponParticlesBase()

void OnParticleCreated::WeaponParticlesBase ( ItemBase muzzle_owner,
string config_OnFire_entry )

Definition at line 372 of file WeaponParticles.c.

376 {
377 m_Particle = p;
378 }
379
381 {
382 return m_Particle;
383 }
384
385 void SetOverheatingLimitMin(float min)
386 {
387 m_OverheatingLimitMin = min;
388 }
389
390 void SetOverheatingLimitMax(float max)
391 {
392 m_OverheatingLimitMax = max;
393 }
394
395 float GetOverheatingLimitMin()
396 {
397 return m_OverheatingLimitMin;
398 }
399
400 float GetOverheatingLimitMax()
401 {
402 return m_OverheatingLimitMax;
403 }
404
405 void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
406 {
407 m_ParticleID = particle_id;
408 m_Parent = parent;
411 }
412
413 int GetParticleID()
414 {
415 return m_ParticleID;
416 }
417
418 Object GetParticleParent()
419 {
420 return m_Parent;
421 }
422
423 vector GetParticlePos()
424 {
425 return m_LocalPos;
426 }
427
428 vector GetParticleOri()
429 {
430 return m_LocalOri;
431 }
432}
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:86

Variable Documentation

◆ m_IgnoreIfSuppressed

bool m_IgnoreIfSuppressed

Definition at line 349 of file WeaponParticles.c.

◆ m_IlluminateWorld

bool m_IlluminateWorld

Definition at line 348 of file WeaponParticles.c.

◆ m_MuzzleIndex

int m_MuzzleIndex

Definition at line 351 of file WeaponParticles.c.

◆ m_Name

string m_Name

Definition at line 366 of file WeaponParticles.c.

◆ m_OnlyIfBoltIsOpen

bool m_OnlyIfBoltIsOpen

Definition at line 350 of file WeaponParticles.c.

◆ m_OnlyIfBulletIs

string m_OnlyIfBulletIs

Definition at line 360 of file WeaponParticles.c.

◆ m_OnlyIfWeaponIs

string m_OnlyIfWeaponIs

Definition at line 361 of file WeaponParticles.c.

◆ m_OnlyWithinHealthLabelMax

int m_OnlyWithinHealthLabelMax

Definition at line 354 of file WeaponParticles.c.

◆ m_OnlyWithinHealthLabelMin

int m_OnlyWithinHealthLabelMin

Definition at line 353 of file WeaponParticles.c.

◆ m_OnlyWithinOverheatLimitsMax

float m_OnlyWithinOverheatLimitsMax

Definition at line 356 of file WeaponParticles.c.

◆ m_OnlyWithinOverheatLimitsMin

float m_OnlyWithinOverheatLimitsMin

Definition at line 355 of file WeaponParticles.c.

◆ m_OnlyWithinRainLimitsMax

float m_OnlyWithinRainLimitsMax

Definition at line 358 of file WeaponParticles.c.

◆ m_OnlyWithinRainLimitsMin

float m_OnlyWithinRainLimitsMin

Definition at line 357 of file WeaponParticles.c.

◆ m_OverrideDirectionPoint

string m_OverrideDirectionPoint

Definition at line 359 of file WeaponParticles.c.

◆ m_OverrideDirectionVector

vector m_OverrideDirectionVector

Definition at line 363 of file WeaponParticles.c.

◆ m_OverrideParticle

int m_OverrideParticle

Definition at line 352 of file WeaponParticles.c.

◆ m_OverridePoint

string m_OverridePoint

Definition at line 362 of file WeaponParticles.c.

◆ m_PositionOffset

vector m_PositionOffset

Definition at line 364 of file WeaponParticles.c.