File size: 3,771 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
class FlareSimulation : Managed
{
protected Particle m_ParMainFire;
protected EffectSound m_BurningSound;
protected FlareLight m_FlareLight;
const static float MAX_FARLIGHT_DIST = 40;
const static float MIN_FARLIGHT_DIST = 5;
static ref NoiseParams m_NoisePar; // Contains the noise data ( template and strength )
float m_LastNoiseTime = -1;
float m_NoiseTimer = 0;
const float NOISE_DELAY = 5; // How much time between two consecutive noise pings
static protected typename m_ScriptedLight;
static protected int m_ParticleId;
void FlareSimulation()
{
m_ScriptedLight = FlareLight;
m_ParticleId = ParticleList.FLAREPROJ_ACTIVATE;
}
void OnActivation(Entity flare)
{
if ( !GetGame().IsServer() || !GetGame().IsMultiplayer() )
{
m_FlareLight = FlareLight.Cast( ScriptedLightBase.CreateLight( m_ScriptedLight, Vector(0,0,0) ) );
if ( m_FlareLight )
m_FlareLight.AttachOnObject( flare );
if (m_ParMainFire)
m_ParMainFire.Stop();
m_ParMainFire = ParticleManager.GetInstance().PlayOnObject( m_ParticleId, flare );
m_ParMainFire.SetWiggle( 7, 0.3 );
flare.PlaySoundSetLoop( m_BurningSound, "roadflareLoop_SoundSet", 0, 0 );
}
if ( GetGame().IsServer() )
{
// Create and load noise parameters
m_NoisePar = new NoiseParams();
m_NoisePar.LoadFromPath("cfgWeapons Flaregun_Base NoiseFlare");
}
}
void OnTermination(Entity flare)
{
//MiscGameplayFunctions.GenerateAINoiseAtPosition(flare.GetPosition(), NOISE_DELAY, m_NoisePar);
}
void OnFire( Entity flare)
{
//m_ParMainFire = ParticleManager.GetInstance().PlayOnObject( ParticleList.FLAREPROJ_FIRE, flare);
//m_ParMainFire.SetWiggle( 7, 0.3);
}
void Simulate( Entity flare )
{
DayZPlayer player = GetGame().GetPlayer();
if ( player )
vector playerPos = player.GetPosition();
float dist = vector.DistanceSq(flare.GetPosition(), playerPos);
if ( ( dist <= MAX_FARLIGHT_DIST * MAX_FARLIGHT_DIST ) && ( dist > MIN_FARLIGHT_DIST * MIN_FARLIGHT_DIST ) )
m_ParMainFire.SetParameter( 0, EmitorParam.SIZE, MiscGameplayFunctions.Normalize(dist, MAX_FARLIGHT_DIST * MAX_FARLIGHT_DIST) );
if ( dist <= MIN_FARLIGHT_DIST * MIN_FARLIGHT_DIST )
TurnOffDistantLight();
//CastFlareAINoise( flare.GetPosition() );
}
void CastFlareAINoise( vector position )
{
if ( m_LastNoiseTime < 0 )
m_LastNoiseTime = GetGame().GetTime() * 0.0033;
float delta_time = GetGame().GetTime() * 0.0033 - m_LastNoiseTime;
m_LastNoiseTime = GetGame().GetTime() * 0.0033;
m_NoiseTimer += delta_time;
if ( m_NoiseTimer >= NOISE_DELAY )
{
MiscGameplayFunctions.GenerateAINoiseAtPosition(position, NOISE_DELAY, m_NoisePar);
m_NoiseTimer = 0;
}
}
void TurnOffDistantLight()
{
if (m_ParMainFire)
{
m_ParMainFire.SetParameter(0, EmitorParam.LIFETIME, 0);
m_ParMainFire.SetParameter(0, EmitorParam.LIFETIME_RND, 0);
m_ParMainFire.SetParameter(0, EmitorParam.REPEAT, 0);
m_ParMainFire.SetParameter(0, EmitorParam.SIZE, 0);
}
}
void ~FlareSimulation()
{
if (m_ParMainFire)
m_ParMainFire.Stop();
if (m_BurningSound)
m_BurningSound.SoundStop();
if (m_FlareLight)
m_FlareLight.FadeOut();
}
}
class FlareSimulation_Red : FlareSimulation
{
void FlareSimulation_Red()
{
m_ScriptedLight = FlareLightRed;
m_ParticleId = ParticleList.FLAREPROJ_ACTIVATE_RED;
}
}
class FlareSimulation_Green : FlareSimulation
{
void FlareSimulation_Green()
{
m_ScriptedLight = FlareLightGreen;
m_ParticleId = ParticleList.FLAREPROJ_ACTIVATE_GREEN;
}
}
class FlareSimulation_Blue : FlareSimulation
{
void FlareSimulation_Blue()
{
m_ScriptedLight = FlareLightBlue;
m_ParticleId = ParticleList.FLAREPROJ_ACTIVATE_BLUE;
}
} |