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

◆ OnActivate()

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

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

526{
530 int m_MuzzleIndex;
539 string m_OnlyIfBulletIs;
540 string m_OnlyIfWeaponIs;
541 string m_OverridePoint;
544
545 string m_Name;
546
547 //======================================
548 // PRELOAD EVERYTHING
549 //======================================
550
551 void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
552 {
553 m_Name = config_OnFire_entry;
554
555 // ignoreIfSuppressed
556 m_IgnoreIfSuppressed = GetGame().ConfigGetFloat(string.Format("%1 ignoreIfSuppressed", m_Name));
557
558 // onlyIfBoltIsOpen
559 m_OnlyIfBoltIsOpen = GetGame().ConfigGetFloat(string.Format("%1 onlyIfBoltIsOpen", m_Name));
560
561 // illuminateWorld
562 m_IlluminateWorld = GetGame().ConfigGetFloat(string.Format("%1 illuminateWorld", m_Name));
563
564 m_MuzzleIndex = -1;
565 if (GetGame().ConfigIsExisting(string.Format("%1 muzzleIndex", m_Name)))
566 {
567 m_MuzzleIndex = GetGame().ConfigGetInt(string.Format("%1 muzzleIndex", m_Name));
568 }
569
570 // onlyIfWeaponIs
571 m_OnlyIfWeaponIs = "";
572 GetGame().ConfigGetText(string.Format("%1 onlyIfWeaponIs", m_Name), m_OnlyIfWeaponIs);
573
574 // onlyIfBulletIs
575 m_OnlyIfBulletIs = "";
576 GetGame().ConfigGetText(string.Format("%1 onlyIfBulletIs", m_Name), m_OnlyIfBulletIs);
577
578 // onlyWithinHealthLabel[]
579 array<float> health_limit = new array<float>;
580 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinHealthLabel", m_Name), health_limit);
581
582 if (health_limit.Count() == 2)
583 {
584 m_OnlyWithinHealthLabelMin = health_limit.Get(0);
585 m_OnlyWithinHealthLabelMax = health_limit.Get(1);
586 }
587 else
588 {
589 // Disable this filter
592 }
593
594 // onlyWithinOverheatLimits[]
595 array<float> overheat_limit = new array<float>;
596 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinOverheatLimits", m_Name), overheat_limit);
597
598 if (overheat_limit.Count() == 2)
599 {
600 m_OnlyWithinOverheatLimitsMin = overheat_limit.Get(0);
601 m_OnlyWithinOverheatLimitsMax = overheat_limit.Get(1);
602 }
603 else
604 {
605 // Disable this filter
608 }
609
610 // onlyWithinRainLimits[]
611 array<float> rain_limit = new array<float>;
612 GetGame().ConfigGetFloatArray(string.Format("%1 onlyWithinRainLimits", m_Name), rain_limit);
613
614 if (rain_limit.Count() == 2)
615 {
616 m_OnlyWithinRainLimitsMin = rain_limit.Get(0);
617 m_OnlyWithinRainLimitsMax = rain_limit.Get(1);
618 }
619 else
620 {
621 // Disable this filter
624 }
625
626 // overridePoint
627 m_OverridePoint = "";
628 GetGame().ConfigGetText(string.Format("%1 overridePoint", m_Name), m_OverridePoint);
629
630 if (m_OverridePoint == "")
631 m_OverridePoint = "Usti hlavne"; // default memory point name
632
633 // overrideParticle
634 string particle_name = "";
635 GetGame().ConfigGetText( string.Format("%1 overrideParticle", m_Name), particle_name);
636
637 if (particle_name != "")
638 {
640 }
641 else
642 {
644 ErrorEx(string.Format("'%1' does not contain a definition for 'overrideparticle'",
645 config_OnFire_entry), ErrorExSeverity.INFO);
646 }
647
648 // overrideDirectionPoint
650 GetGame().ConfigGetText(string.Format("%1 overrideDirectionPoint", m_Name), m_OverrideDirectionPoint);
651
652 if (m_OverrideDirectionPoint == "")
653 {
654 // overrideDirectionVector
655 vector test_ori = GetGame().ConfigGetVector(string.Format("%1 overrideDirectionVector", m_Name));
656
657 if (test_ori != vector.Zero)
658 {
659 m_OverrideDirectionVector = test_ori;
660 }
661 }
662
663 // positionOffset[]
665 GetGame().ConfigGetFloatArray(string.Format("%1 positionOffset", m_Name), v);
666
667 if (v.Count() == 3)
668 {
669 float v1 = v.Get(0);
670 float v2 = v.Get(1);
671 float v3 = v.Get(2);
672 m_PositionOffset = Vector(v1, v2, v3);
673 }
674 }
675
676
677
678 //======================================
679 // PLAY PARTICLES
680 //======================================
681 // It is important to know that this block of script is called for weapons and muzzle attachments alike.
682 // Thus weapon == muzzle_owner when this is called for a weapon, and weapon != muzzle_owner when this is called for a suppressor.
683 void OnActivate(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
684 {
685 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
686 {
687 // Handle effect's parameters
688 if ( PrtTest.m_GunParticlesState ) // Check if particles are enabled by debug
689 {
690 if ( m_MuzzleIndex == -1 || m_MuzzleIndex == muzzle_index )
691 {
692 if ( CheckBoltStateCondition(weapon) ) // onlyIfBoltIsOpen
693 {
694 if ( !suppressor || suppressor.IsRuined() || !(m_IgnoreIfSuppressed) ) // ignoreIfSuppressed
695 {
696 if ( CheckHealthCondition( muzzle_owner.GetHealthLevel() ) ) // onlyWithinHealthLabel
697 {
698 if ( CheckOverheatingCondition( muzzle_owner.GetOverheatingCoef() ) ) // onlyWithinOverheatLimits
699 {
700 if ( CheckRainCondition( GetGame().GetWeather().GetRain().GetActual() ) ) // onlyWithinRainLimits
701 {
702 if ( m_OnlyIfBulletIs == "" || m_OnlyIfBulletIs == ammoType ) // onlyIfBulletIs
703 {
704 if ( m_OnlyIfWeaponIs == "" || m_OnlyIfWeaponIs == weapon.GetType() ) // onlyIfWeaponIs
705 {
706 // Get particle ID
707 int particle_id = CheckParticleOverride(ammoType);
708
710 {
711 // Get position of the particle
712 vector local_pos = muzzle_owner.GetSelectionPositionLS(m_OverridePoint);
713 local_pos += m_PositionOffset;
714
715 // Set orientation of the particle
716 vector particle_ori = CheckOrientationOverride(local_pos, muzzle_owner);
717
718 // Create particle
719 Particle p = ParticleManager.GetInstance().PlayOnObject( particle_id, muzzle_owner, local_pos, particle_ori );
720 OnParticleCreated(weapon, ammoType, muzzle_owner, suppressor, config_to_search, p);
721 }
722 else
723 {
724 ErrorEx(string.Format("No valid particle found for: '%1'", m_Name));
725 }
726
727 // Create light
729 {
730 vector global_pos = muzzle_owner.ModelToWorld(local_pos + Vector(-0.2, 0, 0));
731 int randX = Math.RandomInt( 0,10 );
732 if ( randX > 8 )
733 ScriptedLightBase.CreateLight( MuzzleFlashLight_2, global_pos );
734 else if ( randX > 4 )
735 ScriptedLightBase.CreateLight( MuzzleFlashLight_1, global_pos );
736 else
737 ScriptedLightBase.CreateLight(MuzzleFlashLight, global_pos);
738 }
739 }
740 }
741 }
742 }
743 }
744 }
745 }
746 }
747 }
748 }
749 }
750
751 void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
752 {
753
754 }
755
756 void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
757 {
758
759 }
760
761 void OnUpdate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
762 {
763
764 }
765
766
767 //==============================================
768 // HANDLE CONFIG PARAMETERS
769 //==============================================
770
771
772 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
774 {
775 if ( m_OnlyIfBoltIsOpen )
776 {
777 Weapon_Base wb = Weapon_Base.Cast( weapon );
778 WeaponStateBase current_state = wb.GetCurrentState();
779 return current_state.IsBoltOpen();
780 }
781
782 return true;
783 }
784
785 // OnlyWithinHealthLabelMin & OnlyWithinHealthLabelMax
786 bool CheckHealthCondition(int health_label)
787 {
788 return ( (health_label >= m_OnlyWithinHealthLabelMin) && (health_label <= m_OnlyWithinHealthLabelMax) );
789 }
790
791 // OnlyWithinOverheatLimitsMin & OnlyWithinOverheatLimitsMax
792 bool CheckOverheatingCondition(float overheating_coef)
793 {
794 return ( (overheating_coef >= m_OnlyWithinOverheatLimitsMin) && (overheating_coef <= m_OnlyWithinOverheatLimitsMax) );
795 }
796
797 // OnlyWithinRainLimitsMin & OnlyWithinRainLimitsMax
798 bool CheckRainCondition(float rain_coef)
799 {
800 return ( (rain_coef >= m_OnlyWithinRainLimitsMin) && (rain_coef <= m_OnlyWithinRainLimitsMax) );
801 }
802
803 // muzzleFlashParticle
804 int CheckParticleOverride(string ammoType)
805 {
806 int particle_id = -1;
807
808 string particle_file = "";
809 string cfg_path = "CfgAmmo " + ammoType + " muzzleFlashParticle";
810 if (GetGame().ConfigGetText( cfg_path, particle_file))
812
813 // Config is accessed only once because the data is saved into a map for repeated access.
814
815 if ( particle_id > 0 || m_OverrideParticle == -1)
816 {
817 if (particle_file == "")
818 {
819 ErrorEx(string.Format("Cannot spawn particle effect because item %1 is missing config parameter muzzleFlashParticle!", ammoType), ErrorExSeverity.INFO);
820 }
821 else
822 {
824
825 if (particle_id == 0)
826 {
827 string devStr;
828 #ifdef DEVELOPER
829 devStr = " Make sure it's registered there and then rebuild Scripts and Graphics PBOs.";
830 #endif
831 ErrorEx(string.Format("Cannot play particle effect with name %1 because no such file is registered in ParticleList.c!%2", particle_file, devStr));
832 m_OverrideParticle = particle_id; // Prevents another appearence of the above error.
833 }
834 }
835 }
836 else
837 {
839 }
840
841 return particle_id;
842 }
843
844 // OverrideDirectionPoint & OverrideDirectionVector
845 vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
846 {
847 vector particle_ori = "0 0 0";
848 if (m_OverrideDirectionPoint != "")
849 {
850 vector target_pos = muzzle_owner.GetSelectionPositionLS(m_OverrideDirectionPoint);
851 target_pos = vector.Direction(local_pos, target_pos);
852 particle_ori = target_pos.VectorToAngles();
853 }
854 else
855 {
856 if (m_OverrideDirectionVector != Vector(0, 0, 0))
857 {
858 particle_ori = m_OverrideDirectionVector;
859 }
860
861 if (muzzle_owner.IsInherited(ItemSuppressor))
862 {
863 particle_ori = particle_ori + Vector(0,0,270); // This rotation is necesarry due to suppressors being rotated into ground in their p3d files
864 }
865 }
866
867 return particle_ori;
868 }
869}
870
871// FIRE particles
872class WeaponParticlesOnFire : WeaponParticlesBase {}
873
874// BULLET EJECT particles
875class WeaponParticlesOnBulletCasingEject : WeaponParticlesBase {}
876
877// OVERHEATING particles
878class WeaponParticlesOnOverheating: WeaponParticlesBase
879{
880 override void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
881 {
882 muzzle_owner.RegisterOverheatingParticle(p, m_OnlyWithinOverheatLimitsMin, m_OnlyWithinOverheatLimitsMax, p.GetParticleID(), muzzle_owner, p.m_DefaultPos, p.m_DefaultOri );
883 }
884
885 override void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
886 {
887 if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
888 {
889 weapon.KillAllOverheatingParticles();
890 }
891 }
892
893 override void OnUpdate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
894 {
895 OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
896 }
897}
898
900{
901 Particle m_Particle;
902 int m_ParticleID;
904 vector m_LocalPos;
905 vector m_LocalOri;
906
909
910 void RegisterParticle( Particle p)
911 {
912 m_Particle = p;
913 }
914
915 Particle GetParticle()
916 {
917 return m_Particle;
918 }
919
920 void SetOverheatingLimitMin(float min)
921 {
923 }
924
925 void SetOverheatingLimitMax(float max)
926 {
928 }
929
931 {
933 }
934
936 {
938 }
939
940 void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
941 {
943 m_Parent = parent;
944 m_LocalPos = local_pos;
945 m_LocalOri = local_ori;
946 }
947
948 int GetParticleID()
949 {
950 return m_ParticleID;
951 }
952
954 {
955 return m_Parent;
956 }
957
958 vector GetParticlePos()
959 {
960 return m_LocalPos;
961 }
962
963 vector GetParticleOri()
964 {
965 return m_LocalOri;
966 }
967}
class GP5GasMask extends MaskBase ItemBase
void MuzzleFlashLight_1()
Определения MuzzleFlashLight.c:24
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
int particle_id
Определения SmokeSimulation.c:28
class SyncedValue m_Name
void OnActivate()
Определения Trap_LandMine.c:67
bool CheckRainCondition(float rain_coef)
Определения WeaponParticles.c:634
void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения WeaponParticles.c:592
float m_OnlyWithinOverheatLimitsMin
Определения WeaponParticles.c:370
bool m_IlluminateWorld
Определения WeaponParticles.c:363
vector m_OverrideDirectionVector
Определения WeaponParticles.c:378
int m_OverrideParticle
Определения WeaponParticles.c:367
string m_OverrideDirectionPoint
Определения WeaponParticles.c:374
float m_OnlyWithinRainLimitsMax
Определения WeaponParticles.c:373
class WeaponParticlesBase OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
Определения WeaponParticles.c:362
bool m_OnlyIfBoltIsOpen
Определения WeaponParticles.c:365
vector m_PositionOffset
Определения WeaponParticles.c:379
string m_OnlyIfWeaponIs
Определения WeaponParticles.c:376
void WeaponParticlesBase(ItemBase muzzle_owner, string config_OnFire_entry)
Определения WeaponParticles.c:387
string m_OnlyIfBulletIs
Определения WeaponParticles.c:375
int CheckParticleOverride(string ammoType)
Определения WeaponParticles.c:640
int m_MuzzleIndex
Определения WeaponParticles.c:366
float m_OnlyWithinRainLimitsMin
Определения WeaponParticles.c:372
vector CheckOrientationOverride(vector local_pos, ItemBase muzzle_owner)
Определения WeaponParticles.c:681
bool CheckHealthCondition(int health_label)
Определения WeaponParticles.c:622
bool m_IgnoreIfSuppressed
Определения WeaponParticles.c:364
string m_OverridePoint
Определения WeaponParticles.c:377
int m_OnlyWithinHealthLabelMin
Определения WeaponParticles.c:368
bool CheckBoltStateCondition(ItemBase weapon)
Определения WeaponParticles.c:609
float m_OnlyWithinOverheatLimitsMax
Определения WeaponParticles.c:371
int m_OnlyWithinHealthLabelMax
Определения WeaponParticles.c:369
bool CheckOverheatingCondition(float overheating_coef)
Определения WeaponParticles.c:628
proto native vector ConfigGetVector(string path)
Get vector value from config on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
Определения InventoryItem.c:731
Определения EnMath.c:7
vector m_LocalPos
Определения WeaponParticles.c:386
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
float m_OverheatingLimitMax
Определения WeaponParticles.c:390
vector GetParticleOri()
Определения WeaponParticles.c:445
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
Object GetParticleParent()
Определения WeaponParticles.c:435
int m_ParticleID
Определения WeaponParticles.c:384
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Object m_Parent
Определения WeaponParticles.c:385
Particle m_Particle
Определения WeaponParticles.c:383
float m_OverheatingLimitMin
Определения WeaponParticles.c:389
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
int GetParticleID()
Определения WeaponParticles.c:430
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
vector GetParticlePos()
Определения WeaponParticles.c:440
vector m_LocalOri
Определения WeaponParticles.c:387
vector m_DefaultPos
Used for Wiggle API, to restore after unparenting.
Определения Particle.c:33
vector m_DefaultOri
Used for Wiggle API, to restore after unparenting.
Определения Particle.c:31
int GetParticleID()
Gets particle id.
Определения Particle.c:297
Legacy way of using particles in the game.
Определения Particle.c:7
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
Определения ParticleList.c:500
static bool IsValidId(int id)
Purely checks for an invalid number, does NOT mean it is actually registered.
Определения ParticleList.c:470
Определения ParticleList.c:12
static bool m_GunParticlesState
Определения gameplay.c:1538
Определения gameplay.c:1537
shorthand
Определения BoltActionRifle_Base.c:6
void OnDeactivate(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения WeaponParticles.c:238
void OnParticleCreated(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search, Particle p)
Определения WeaponParticles.c:233
bool IsBoltOpen()
Определения WeaponStateBase.c:163
represent weapon state base
Определения BulletHide.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:110
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Определения EnConvert.c:220
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
Определения EnConvert.c:106
class LOD Object
proto native CGame GetGame()
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
proto native void OnUpdate()
Определения tools.c:349