[Library] ESF Game FX Codes

YEA
✔️ HL Verified
Joined
Oct 31, 2014
Messages
201
Best answers
0
Location
CHINA
Not hard coding but useful I believe. I post them here because when I'm gonna add some FX into my plugin, I just need to take a look here, and hope this library would help some people who's tired of coding some troublesome FX or wanna make FX in not ECX plugin. :scared:

If you have some beautiful Game FX, here you can share them as well :D

PS. These 10 FXs for now. Feel free I will update some new FX in the future if there's still someone needs. -_- OK here we go:



Multiple Lightning:

PHP:
new MultiLightning

public MultiLightningFX(id)
{
	new vec[3]
	get_user_origin(id, vec)
	emit_sound(id, CHAN_STATIC, "FX/Lightning.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) //play the sound file
	for(new i; i < 5; i++) //how many lightnings depends on how big the const 'i' is.
	{
		message_begin(MSG_PVS, SVC_TEMPENTITY)
		write_byte(TE_BEAMENTPOINT)
		write_short(id) //start entity
		write_coord(vec[0] + random_num(-200, 200)) //end position X
		write_coord(vec[1] + random_num(-200, 200)) //end position Y
		write_coord(vec[2] + random_num(-200, 200)) //end position Z
		write_short(MultiLightning) //set SPR file
		write_byte(2) //starting frame
		write_byte(10) //frame rate in 0.1's
		write_byte(6) //life in 0.1's
		write_byte(10) //line width in 0.1's
		write_byte(100) //noise amplitude in 0.01's
		write_byte(36) //R
		write_byte(70) //G
		write_byte(232) //B
		write_byte(230) //brightness
		write_byte(30) //scroll speed in 0.1's
		message_end( );
	}
		set_task(1.5, "MultiLightningFX", id)
}

public plugin_precache()
{
	precache_sound("FX/Lightning.wav")
	MultiLightning = precache_model( "sprites/lgtning.spr" );
}
Character Lightning:

PHP:
new LightningA
new LightningB

public CharLightning(id)
{
	new origin[3], Float: vec[3]
	get_user_origin(id, origin)
	pev(id, pev_velocity, vec)

	if(vector_length(vec) < 15.0)
	{
	emit_sound(id, CHAN_STATIC, "FX/Lightning.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) //play the sound file
	if(random_num(1, 2) == 1)
	{
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]) // x
	write_coord(origin[1]) // y
	write_coord(origin[2]) // z
	write_short(LightningA) // sprite
	write_byte(4) // scale
	write_byte(200) // brightness
	message_end()
	}
	else
	{
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]) // x
	write_coord(origin[1]) // y
	write_coord(origin[2]) // z
	write_short(LightningB) // sprite
	write_byte(2) // scale
	write_byte(200) // brightness
	message_end()
	}
	set_task(2.0, "CharLightning", id)
	}
	else
	{
	set_task(2.0, "CharLightning", id)
	}
}

public plugin_precache()
{
	precache_sound("FX/Lightning.wav")
	LightningA = precache_model("sprites/FX/LightningA.spr")
	LightningB = precache_model("sprites/FX/LightningB.spr")
}
(dynamic)Lightning Aura:

PHP:
new AuraBallFX[33]

public LightningAura(id)
{
	new Float: org[3]
	pev(id, pev_origin, org)
	AuraBallFX[id] = create_entity( "env_sprite" );
	engfunc( EngFunc_SetModel, AuraBallFX[id], "sprites/FX/AuraBall.spr" ); //set spr file
	set_rendering( AuraBallFX[id], kRenderFxNone, 180, 180, 180, kRenderTransAdd, 255 ) //set rendering
	set_pev( AuraBallFX[id], pev_origin, org );
	DispatchKeyValue( AuraBallFX[id], "scale", "0.3") //size
	DispatchKeyValue( AuraBallFX[id], "framerate", "9.0"); //frame rate
	DispatchSpawn(AuraBallFX[id]) //show this spr
}

public plugin_precache()
{
	precache_model("sprites/FX/AuraBall.spr")
}
Power Wave:

PHP:
new PowerWave

public PowerWaveFX(id)
{
	new origin[3]
	get_user_origin(id, origin)
	emit_sound(id, CHAN_STATIC, "FX/ChargePush.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_BEAMTORUS)
	write_coord(origin[0]) //Position X
	write_coord(origin[1]) //Position Y
	write_coord(origin[2]) //Position Z
	write_coord(origin[0] + 66) //Axis X
	write_coord(origin[1] + 66) //Axis Y
	write_coord(origin[2] + 150)  //Axis Z
	write_short(PowerWave) //set the spr file
	write_byte(255)  //starting frame
	write_byte(255)  //frame rate in 0.1's
	write_byte(10)  //life in 0.1's
	write_byte(10)  //line width in 0.1's
	write_byte(0)  //noise amplitude in 0.01's
	write_byte(180) //R
	write_byte(145) //G
	write_byte(120) //B
	write_byte(30) //Brightness
	write_byte(1) //scroll speed in 0.1's
	message_end()

	for(new i = 0; i < 30; i++)
	{
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_BEAMCYLINDER)
	write_coord(origin[0]) //Position X
	write_coord(origin[1]) //Position Y
	write_coord(origin[2]) //Position Z
	write_coord(origin[0] + 66) //Axis X
	write_coord(origin[1] + 66) //Axis Y
	write_coord(origin[2] + 150)  //Axis Z
	write_short(PowerWave) //set the spr file
	write_byte(255) //starting frame
	write_byte(255) //frame rate in 0.1's
	write_byte(10) //life in 0.1's
	write_byte(10) //line width in 0.1's
	write_byte(0) //noise amplitude in 0.01's
	write_byte(180) //R
	write_byte(145) //G
	write_byte(120) //B
	write_byte(30) //Brightness
	write_byte(1) //scroll speed in 0.1's
	message_end()
	}
}

public plugin_precache()
{
	precache_sound("FX/ChargePush.wav")
	PowerWave = precache_model("sprites/white.spr")
}
Screen Shake:

PHP:
public ScreenShakeFX(id)
{
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, id) 
	write_short((1<<12)*1) // amplitude
	write_short((1<<12)*1) // duration 
	write_short((1<<12)*1) // frequency
	message_end() 
}
Sprite Rays:

PHP:
new SpriteRays

public SpriteRaysFX( id )
{
	for(new i; i < 30; i++)
	{
		new org[3];
		get_user_origin(id, org);
		message_begin( MSG_PVS, SVC_TEMPENTITY, org );
		write_byte( TE_BEAMENTPOINT );
		write_short( id ); //start entity
		write_coord( org[0] + random_num(-200, 200)); //end position X
		write_coord( org[1] + random_num(-200, 200)); //end position Y
		write_coord( org[2] + random_num(-200, 200)); //end positon Z
		write_short( SpriteRays ); //set spr file
		write_byte( 3 ); //starting frame
		write_byte( 10 ); //frame rate in 0.1's
		write_byte( 10 ); //life in 0.1's
		write_byte( 7 ); //line width in 0.1's
		write_byte( 0 ); //noise amplitude in 0.01's
		write_byte( 150 ); //R
		write_byte( 255 ); //G
		write_byte( 255 ); //B
		write_byte( 255 ); //Brightness
		write_byte( 10 ); //scroll speed in 0.1's
		message_end( );
	}
	set_task(1.0, "SpriteRaysFX", id) 
}

public plugin_precache()
{
	SpriteRays = precache_model( "sprites/lgtning.spr" );
}
Cloud Sphere:

PHP:
new CloudSphere

public CloudSphereFX( id )
{
	for(new i; i < 30; i++)
	{
		new org[3];
		get_user_origin(id, org);
		message_begin( MSG_PVS, SVC_TEMPENTITY, org );
		write_byte( TE_BEAMENTPOINT );
		write_short( id ); //start entity
		write_coord( org[0] + random_num(-200, 200)); //end position X
		write_coord( org[1] + random_num(-200, 200)); //end position Y
		write_coord( org[2] + random_num(-200, 200)); //end positon Z
		write_short( CloudSphere ); //set spr file
		write_byte( 3 ); //starting frame
		write_byte( 5 ); //frame rate in 0.1's
		write_byte( 30 ); //life in 0.1's
		write_byte( 255 ); //line width in 0.1's
		write_byte( 0 ); //noise amplitude in 0.01's
		write_byte( 10 ); //R
		write_byte( 10 ); //G
		write_byte( 10 ); //B
		write_byte( 250 ); //Brightness
		write_byte( 20 ); //scroll speed in 0.1's
		message_end( );
	}
	set_task(0.5, "CloudSphereFX", id) 
}

public plugin_precache()
{
	CloudSphere = precache_model( "sprites/stmbal1.spr" );
}
Lightning Field:

PHP:
public LightningFieldFX( id )
{
	for(new i; i < 5; i++)
	{
		new org[3];
		get_user_origin(id, org);

		new RandomNum[2]
		RandomNum[0] = random_num(-200, 200)
		RandomNum[1] = random_num(-200, 200)
		message_begin( MSG_PVS, SVC_TEMPENTITY, org );
		write_byte( TE_BEAMPOINTS );
		write_coord( org[0] + RandomNum[0]); //start position X
		write_coord( org[1] + RandomNum[1]); //start position Y
		write_coord( org[2] + 1000); //start position Z
		write_coord( org[0] + RandomNum[0]); //end position X
		write_coord( org[1] + RandomNum[1]); //end position Y
		write_coord( org[2] - 1000); //end positon Z
		write_short( LightningField ); //set spr file
		write_byte( 10 ); //starting frame
		write_byte( 15 ); //frame rate in 0.1's
		write_byte( 14 ); //life in 0.1's
		write_byte( 150 ); //line width in 0.1's
		write_byte( 0 ); //noise amplitude in 0.01's
		write_byte( 200 ); //R
		write_byte( 180 ); //G
		write_byte( 255 ); //B
		write_byte( 255 ); //Brightness
		write_byte( 15 ); //scroll speed in 0.1's
		message_end( );
	}
	//set_task(2.0, "LightningFieldFX", id) //show this FX again
}

public plugin_precache()
{
	LightningField = precache_model( "sprites/lgtning.spr" );
}
PowerRing:

PHP:
new PowerRing

public PowerRingFX(id)
{
	new org[3]
	get_user_origin(id,org)
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY,org)
	write_byte( TE_BEAMCYLINDER )
	write_coord(org[0]) //Position X
	write_coord(org[1]) //Position Y
	write_coord(org[2]) //Position Z
	write_coord(org[0]) //Axis X
	write_coord(org[1]) //Axis Y
	write_coord(org[2] + 80) //Axis Z
	write_short( PowerRing ) //set the spr file
	write_byte( 30 ) //starting frame
	write_byte( 50 ) //frame rate in 0.1's
	write_byte( 24 ) //life in 0.1's
	write_byte( 20 ) //line width in 0.1's
	write_byte( 0 ) //noise amplitude in 0.01's
	write_byte( 180 ) //R
	write_byte( 255 ) //G
	write_byte( 255 ) //B
	write_byte( 255 ) //Brightness
	write_byte( 0 ) //scroll speed in 0.1's
	message_end()
}

public plugin_precache()
{
	PowerRing = precache_model("sprites/lgtning.spr");
}
Screen Fade:

PHP:
public ScreenFade(id) 
{
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, id);
	write_short((1<<12) * 10) //Timer
	write_short(1<<12)
	write_short(0)
	write_byte(222) //R
	write_byte(231) //G
	write_byte(50) //B
	write_byte(200) //Alpha
	message_end()
}
Needed FX files: View attachment ESF FX Library.rar
 
Last edited:
New Member
Joined
Jun 12, 2009
Messages
69
Best answers
0
Power wave and screen shake seems useful, might use them , thanks and great job.
 
Member
✔️ HL Verified
🚂 Steam Linked
🌟 Senior Member
Joined
Oct 9, 2010
Messages
424
Best answers
0
Location
Las Vegas, Nevada
Very nice! I've been working on learning modeling and coding for the past two months and have been eager to make some changes to ESF.
 

Users who are viewing this thread

Top Bottom