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

◆ CheckOrientationOverride()

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

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

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
713 void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
714 {
715 m_Name = config_OnFire_entry;
716
717 // ignoreIfSuppressed
718 m_IgnoreIfSuppressed = g_Game.ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
719
720 // onlyIfBoltIsOpen
721 m_OnlyIfBoltIsOpen = g_Game.ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
722
723 // illuminateWorld
724 m_IlluminateWorld = g_Game.ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
725
726 m_MuzzleIndex = -1;
727 if (g_Game.ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
728 {
729 m_MuzzleIndex = g_Game.ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
730 }
731
732 // onlyIfWeaponIs
733 m_OnlyIfWeaponIs = "";
734 g_Game.ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
735
736 // onlyIfBulletIs
737 m_OnlyIfBulletIs = "";
738 g_Game.ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
739
740 // onlyWithinHealthLabel[]
741 array<float> health_limit = new array<float>;
742 g_Game.ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
743
744 if (health_limit.Count() == 2)
745 {
746 m_OnlyWithinHealthLabelMin = health_limit.Get(0);
747 m_OnlyWithinHealthLabelMax = health_limit.Get(1);
748 }
749 else
750 {
751 // Disable this filter
754 }
755
756 // onlyWithinOverheatLimits[]
757 array<float> overheat_limit = new array<float>;
758 g_Game.ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
759
760 if (overheat_limit.Count() == 2)
761 {
762 m_OnlyWithinOverheatLimitsMin = overheat_limit.Get(0);
763 m_OnlyWithinOverheatLimitsMax = overheat_limit.Get(1);
764 }
765 else
766 {
767 // Disable this filter
770 }
771
772 // onlyWithinRainLimits[]
773 array<float> rain_limit = new array<float>;
774 g_Game.ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
775
776 if (rain_limit.Count() == 2)
777 {
778 m_OnlyWithinRainLimitsMin = rain_limit.Get(0);
779 m_OnlyWithinRainLimitsMax = rain_limit.Get(1);
780 }
781 else
782 {
783 // Disable this filter
786 }
787
788 // overridePoint
789 m_OverridePoint = "";
790 g_Game.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 g_Game.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'",
807 config_OnFire_entry), ErrorExSeverity.INFO);
808 }
809
810 // overrideDirectionPoint
812 g_Game.ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
813
814 if (m_OverrideDirectionPoint == "")
815 {
816 // overrideDirectionVector
817 vector test_ori = g_Game.ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
818
819 if (test_ori != vector.Zero)
820 {
821 m_OverrideDirectionVector = test_ori;
822 }
823 }
824
825 // positionOffset[]
827 g_Game.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);
834 m_PositionOffset = Vector(v1, v2, v3);
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.
845 void OnActivate(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
846 {
847 if ( !g_Game.IsServer() || !g_Game.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( g_Game.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
869 int particle_id = CheckParticleOverride(ammoType);
870
872 {
873 // Get position of the particle
874 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
875 local_pos += m_PositionOffset;
876
877 // Set orientation of the particle
878 vector particle_ori = CheckOrientationOverride(local_pos, muzzle_owner);
879
880 // Create particle
881 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
882 OnParticleCreated(weapon, ammoType, muzzle_owner, suppressor, config_to_search, p);
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 )
897 ScriptedLightBase.CreateLight( MuzzleFlashLight_1, global_pos );
898 else
899 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
900 }
901 }
902 }
903 }
904 }
905 }
906 }
907 }
908 }
909 }
910 }
911 }
912
913 void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
914 {
915
916 }
917
918 void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
919 {
920
921 }
922
923 void OnUpdate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
924 {
925
926 }
927
928
929 //==============================================
930 // HANDLE CONFIG PARAMETERS
931 //==============================================
932
933
934 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
936 {
937 if ( m_OnlyIfBoltIsOpen )
938 {
939 Weapon_Base wb = Weapon_Base.Cast( weapon );
940 WeaponStateBase current_state = wb.GetCurrentState();
941 return current_state.IsBoltOpen();
942 }
943
944 return true;
945 }
946
947 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
948 bool CheckHealthCondition(int health_label)
949 {
950 return ( (health_label >= m_OnlyWithinHealthLabelMin) && (health_label <= m_OnlyWithinHealthLabelMax) );
951 }
952
953 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
954 bool CheckOverheatingCondition(float overheating_coef)
955 {
956 return ( (overheating_coef >= m_OnlyWithinOverheatLimitsMin) && (overheating_coef <= m_OnlyWithinOverheatLimitsMax) );
957 }
958
959 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
960 bool CheckRainCondition(float rain_coef)
961 {
962 return ( (rain_coef >= m_OnlyWithinRainLimitsMin) && (rain_coef <= m_OnlyWithinRainLimitsMax) );
963 }
964
965 // muzzleFlashParticle
966 int CheckParticleOverride(string ammoType)
967 {
968 int particle_id = -1;
969
970 string particle_file = "";
971 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
972 if (g_Game.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
1007 vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
1008 {
1009 vector particle_ori = "0 0 0";
1010 if (m_OverrideDirectionPoint != "")
1011 {
1012 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
1013 target_pos = vector.Direction(local_pos, target_pos);
1014 particle_ori = target_pos.VectorToAngles();
1015 }
1016 else
1017 {
1018 if (m_OverrideDirectionVector != Vector(0, 0, 0))
1019 {
1020 particle_ori = m_OverrideDirectionVector;
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
1034class WeaponParticlesOnFire : WeaponParticlesBase {}
1035
1036// BULLET EJECT particles
1037class WeaponParticlesOnBulletCasingEject : WeaponParticlesBase {}
1038
1039// OVERHEATING particles
1040class WeaponParticlesOnOverheating: WeaponParticlesBase
1041{
1042 override void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
1043 {
1044 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
1045 }
1046
1047 override void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
1048 {
1049 if ( !g_Game.IsServer() || !g_Game.IsMultiplayer() )
1050 {
1051 weapon.KillAllOverheatingParticles();
1052 }
1053 }
1054
1055 override void OnUpdate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
1056 {
1057 OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
1058 }
1059}
1060
1062{
1063 Particle m_Particle;
1064 int m_ParticleID;
1066 vector m_LocalPos;
1067 vector m_LocalOri;
1068
1071
1072 void RegisterParticle( Particle p)
1073 {
1074 m_Particle = p;
1075 }
1076
1077 Particle GetParticle()
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
1102 void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
1103 {
1105 m_Parent = parent;
1106 m_LocalPos = local_pos;
1107 m_LocalOri = local_ori;
1108 }
1109
1110 int GetParticleID()
1111 {
1112 return m_ParticleID;
1113 }
1114
1116 {
1117 return m_Parent;
1118 }
1119
1120 vector GetParticlePos()
1121 {
1122 return m_LocalPos;
1123 }
1124
1125 vector GetParticleOri()
1126 {
1127 return m_LocalOri;
1128 }
1129}
string m_Name
Определения 3_Game/DayZ/InventoryItemType.c:34
DayZGame g_Game
Определения DayZGame.c:3942
class GP5GasMask extends MaskBase ItemBase
void MuzzleFlashLight_1()
Определения MuzzleFlashLight.c:24
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
int particle_id
Определения SmokeSimulation.c:28
void OnActivate()
Определения Trap_LandMine.c:67
bool CheckRainCondition(float rain_coef)
Определения WeaponParticles.c:634
void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения WeaponParticles.c:592
float m_OnlyWithinOverheatLimitsMin
Определения WeaponParticles.c:370
bool m_IlluminateWorld
Определения WeaponParticles.c:363
vector m_OverrideDirectionVector
Определения WeaponParticles.c:378
int m_OverrideParticle
Определения WeaponParticles.c:367
string m_OverrideDirectionPoint
Определения WeaponParticles.c:374
float m_OnlyWithinRainLimitsMax
Определения WeaponParticles.c:373
class WeaponParticlesBase OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
Определения WeaponParticles.c:362
bool m_OnlyIfBoltIsOpen
Определения WeaponParticles.c:365
vector m_PositionOffset
Определения WeaponParticles.c:379
string m_OnlyIfWeaponIs
Определения WeaponParticles.c:376
void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
Определения WeaponParticles.c:387
string m_OnlyIfBulletIs
Определения WeaponParticles.c:375
int CheckParticleOverride(string ammoType)
Определения WeaponParticles.c:640
int m_MuzzleIndex
Определения WeaponParticles.c:366
float m_OnlyWithinRainLimitsMin
Определения WeaponParticles.c:372
vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
Определения WeaponParticles.c:681
bool CheckHealthCondition(int health_label)
Определения WeaponParticles.c:622
bool m_IgnoreIfSuppressed
Определения WeaponParticles.c:364
string m_OverridePoint
Определения WeaponParticles.c:377
int m_OnlyWithinHealthLabelMin
Определения WeaponParticles.c:368
bool CheckBoltStateCondition(ItemBase weapon)
Определения WeaponParticles.c:609
float m_OnlyWithinOverheatLimitsMax
Определения WeaponParticles.c:371
int m_OnlyWithinHealthLabelMax
Определения WeaponParticles.c:369
bool CheckOverheatingCondition(float overheating_coef)
Определения WeaponParticles.c:628
Определения EnMath.c:7
vector m_LocalPos
Определения WeaponParticles.c:386
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
float m_OverheatingLimitMax
Определения WeaponParticles.c:390
vector GetParticleOri()
Определения WeaponParticles.c:445
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
Object GetParticleParent()
Определения WeaponParticles.c:435
int m_ParticleID
Определения WeaponParticles.c:384
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Object m_Parent
Определения WeaponParticles.c:385
Particle m_Particle
Определения WeaponParticles.c:383
float m_OverheatingLimitMin
Определения WeaponParticles.c:389
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
int GetParticleID()
Определения WeaponParticles.c:430
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
vector GetParticlePos()
Определения WeaponParticles.c:440
vector m_LocalOri
Определения WeaponParticles.c:387
vector m_DefaultPos
Used for Wiggle API, to restore after unparenting.
Определения Particle.c:33
vector m_DefaultOri
Used for Wiggle API, to restore after unparenting.
Определения Particle.c:31
int GetParticleID()
Gets particle id.
Определения Particle.c:297
Legacy way of using particles in the game.
Определения Particle.c:7
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
Определения ParticleList.c:506
static bool IsValidId(int id)
Purely checks for an invalid number, does NOT mean it is actually registered.
Определения ParticleList.c:476
Определения ParticleList.c:12
static bool m_GunParticlesState
Определения gameplay.c:1538
Определения gameplay.c:1537
shorthand
Определения BoltActionRifle_Base.c:6
void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения WeaponParticles.c:238
void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
Определения WeaponParticles.c:233
bool IsBoltOpen()
Определения WeaponStateBase.c:163
represent weapon state base
Определения BulletHide.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:123
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Определения EnConvert.c:233
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
Определения EnConvert.c:119
class LOD Object
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
proto native void OnUpdate()
Определения 3_Game/DayZ/tools/tools.c:349