Plugin Available rifle

Unpaid Requests, Public Plugins
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 560
Joined: 3 Years Ago
Has thanked: 20 times
Been thanked: 2 times
Contact:

rifle

#1

Post by czirimbolo » 1 Year Ago

I am testing new guns in our mod, please can someone help to convert this gun?

Code: Select all

#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <xs>
#include <fun>

#define PLUGIN "[CS1.6] UT3: Shock Rifle"
#define VERSION "1.0"
#define AUTHOR "Dias Pendragon"

#define DAMAGE_A 110 // 550 for Zombie
#define DAMAGE_B 75 // 400
#define AMMO 100
#define SPEED_A 1.0
#define RECOIL 1.0
#define RELOAD_TIME 3.0

#define SHOCKRIFLE_RADIUS 1024.0

#define ENERGY_CLASSNAME "shockenergy"
#define ENERGY_SPEED 500.0
#define ENERGY_RADIUS 140.0

#define CSW_SHOCKRIFLE CSW_AK47
#define weapon_shockrifle "weapon_ak47"

// Data Config
#define MODEL_V "models/v_shockrifle.mdl"
#define MODEL_P "models/p_shockrifle.mdl"
#define MODEL_W "models/w_shockrifle.mdl"

#define WEAPON_CODE 11032016
#define WEAPON_EVENT "events/ak47.sc"
#define MODEL_W_OLD "models/w_ak47.mdl"

new const WeaponSounds[6][] =
{
	"weapons/shockrifle_shoot.wav",
	"weapons/shockrifle_shoot2.wav",
	"weapons/shockrifle_exp.wav",
	"weapons/shockrifle_exp2.wav",
	"weapons/shockrifle_flying.wav",
	"weapons/shockrifle_draw.wav"
}

new const WeaponResources[4][] =
{
	"sprites/shockrifle_light.spr",
	"sprites/shockrifle_ball.spr",
	"sprites/shockrifle_exp.spr",
	"sprites/shockrifle_expb.spr"
}

enum
{
	ANIME_IDLE = 0, // 5.2
	ANIME_HOLSTER, // 0.45
	ANIME_DRAW, // 0.45
	ANIME_SHOOT, // 0.4
	ANIME_SHOOT2 // 1.0
}

enum
{
	TEAM_T = 1,
	TEAM_CT
}

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

// Safety
new g_HamBot
new g_IsConnected, g_IsAlive, g_PlayerWeapon[33]

// Main Vars
new g_Had_ShockRifle, Float:g_Recoil[33][3], g_OldWeapon[33], Float:g_LightningEffect[33], Float:EnergyDelay[33]
new g_MsgCurWeapon, g_Event_ShockRifle, g_EnergyExp_SprId, g_EnergyExp2_SprId, g_Trail_SprID, m_spriteTexture, Float:FireSound[33]
new g_Muzzleflash_Ent, g_Muzzleflash, g_MaxPlayers, g_MsgAmmoX, g_Ring_SprID

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	// Safety
	Register_SafetyFunc()
	
	// Event & ENGINE
	register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
	register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
	register_think(ENERGY_CLASSNAME, "fw_Think_Energy")
	register_touch(ENERGY_CLASSNAME, "*", "fw_Touch_Energy")
	
	// Forwards
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
	register_forward(FM_SetModel, "fw_SetModel")	
	register_forward(FM_CmdStart, "fw_CmdStart")
	register_forward(FM_AddToFullPack, "fw_AddToFullPack_Post", 1)
	register_forward(FM_CheckVisibility, "fw_CheckVisibility")
	
	// Hams
	RegisterHam(Ham_Item_Deploy, weapon_shockrifle, "fw_Item_Deploy_Post", 1)	
	RegisterHam(Ham_Item_AddToPlayer, weapon_shockrifle, "fw_Item_AddToPlayer_Post", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_shockrifle, "fw_Weapon_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_shockrifle, "fw_Weapon_PrimaryAttack_Post", 1)
	
	RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")	
	
	// Cache
	g_MaxPlayers = get_maxplayers()
	g_MsgAmmoX = get_user_msgid("AmmoX")
	g_MsgCurWeapon = get_user_msgid("CurWeapon")
	
	// Get
	register_clcmd("say /shock", "Get_ShockRifle")
}

public plugin_precache()
{
	precache_model(MODEL_V)
	precache_model(MODEL_P)
	precache_model(MODEL_W)
	
	for(new i = 0; i < sizeof(WeaponSounds); i++)
		precache_sound(WeaponSounds[i])
	
	precache_model(WeaponResources[0])
	precache_model(WeaponResources[1])
	g_EnergyExp_SprId = precache_model(WeaponResources[2])
	g_EnergyExp2_SprId = precache_model(WeaponResources[3])
	
	register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
	g_Trail_SprID = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr")
	g_Ring_SprID = precache_model("sprites/shockwave.spr")
	m_spriteTexture = precache_model("sprites/lgtning.spr" )
	
	// Muzzleflash
	g_Muzzleflash_Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	engfunc(EngFunc_SetModel, g_Muzzleflash_Ent, WeaponResources[0])
	set_pev(g_Muzzleflash_Ent, pev_scale, 0.3)
	
	set_pev(g_Muzzleflash_Ent, pev_rendermode, kRenderTransTexture)
	set_pev(g_Muzzleflash_Ent, pev_renderamt, 0.0)
}

public fw_PrecacheEvent_Post(type, const name[])
{
	if(equal(WEAPON_EVENT, name)) g_Event_ShockRifle = get_orig_retval()		
}

public client_putinserver(id)
{
        Safety_Connected(id)
	
	if(!g_HamBot && is_user_bot(id))
	{
		g_HamBot = 1
		set_task(0.1, "Register_HamBot", id)
	}
}
 
public Register_HamBot(id)
{
	Register_SafetyFuncBot(id)
	RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack_Player")	
}
 
public client_disconnect(id)
{
        Safety_Disconnected(id)
}

public Get_ShockRifle(id)
{
	// Give
	Set_BitVar(g_Had_ShockRifle, id)
	give_item(id, weapon_shockrifle)
	
	// Clip & Ammo
	static Ent; Ent = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
	if(!pev_valid(Ent)) return
	
	cs_set_weapon_ammo(Ent, 30)
	cs_set_user_bpammo(id, CSW_SHOCKRIFLE, AMMO)
	
	update_ammo(id, -1, AMMO)
}

public Remove_ShockRifle(id)
{
	UnSet_BitVar(g_Had_ShockRifle, id)
}

public update_ammo(id, Ammo, BpAmmo)
{
	message_begin(MSG_ONE_UNRELIABLE, g_MsgCurWeapon, _, id)
	write_byte(1)
	write_byte(CSW_SHOCKRIFLE)
	write_byte(Ammo)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, g_MsgAmmoX, _, id)
	write_byte(1)
	write_byte(BpAmmo)
	message_end()
	
	cs_set_user_bpammo(id, CSW_SHOCKRIFLE, BpAmmo)
}

public Event_NewRound()
{
	remove_entity_name(ENERGY_CLASSNAME)
}

public Event_CurWeapon(id)
{
	static CSWID; CSWID = read_data(2)
	static Ent; Ent = fm_get_user_weapon_entity(id, CSWID)
	if(!pev_valid(Ent)) return

	if((CSWID == CSW_SHOCKRIFLE && g_OldWeapon[id] != CSW_SHOCKRIFLE) && Get_BitVar(g_Had_ShockRifle, id))
	{
		cs_set_weapon_ammo(Ent, 30)
		update_ammo(id, -1, cs_get_user_bpammo(id, CSWID))
	} else if((CSWID == CSW_SHOCKRIFLE && g_OldWeapon[id] == CSW_SHOCKRIFLE) && Get_BitVar(g_Had_ShockRifle, id)) {
		static Ent; Ent = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
		if(!pev_valid(Ent))
		{
			g_OldWeapon[id] = get_user_weapon(id)
			return
		}
		
		set_pdata_float(Ent, 46, SPEED_A, 4)
		set_pdata_float(Ent, 47, SPEED_A, 4)
		
		cs_set_weapon_ammo(Ent, 30)
		update_ammo(id, -1, cs_get_user_bpammo(id, CSWID))
	} else if(CSWID != CSW_SHOCKRIFLE && g_OldWeapon[id] == CSW_SHOCKRIFLE) {
		
	}
	
	g_OldWeapon[id] = get_user_weapon(id)
}

public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
	if(!is_alive(id))
		return FMRES_IGNORED	
	if(get_user_weapon(id) == CSW_SHOCKRIFLE && Get_BitVar(g_Had_ShockRifle, id))
		set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001) 
	
	return FMRES_HANDLED
}

public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if (!is_connected(invoker))
		return FMRES_IGNORED	
	if(get_player_weapon(invoker) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, invoker))
		return FMRES_IGNORED
	if(eventid != g_Event_ShockRifle)
		return FMRES_IGNORED
	
	engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)

	Set_WeaponAnim(invoker, ANIME_SHOOT)
	emit_sound(invoker, CHAN_WEAPON, WeaponSounds[0], 1.0, 0.4, 0, 94 + random_num(0, 15))
	
	static Ent; Ent = fm_get_user_weapon_entity(invoker, CSW_SHOCKRIFLE)
	if(!pev_valid(Ent)) return FMRES_SUPERCEDE
	
	static Ammo; Ammo = cs_get_user_bpammo(invoker, CSW_SHOCKRIFLE)
	if(Ammo > 0)
	{
		cs_set_weapon_ammo(Ent, 30)
		update_ammo(invoker, -1, Ammo - 1)
		
		ShockRifle_Shoot(invoker)
	}

	return FMRES_SUPERCEDE
}

public fw_SetModel(entity, model[])
{
	if(!pev_valid(entity))
		return FMRES_IGNORED
	
	static Classname[32]
	pev(entity, pev_classname, Classname, sizeof(Classname))
	
	if(!equal(Classname, "weaponbox"))
		return FMRES_IGNORED
	
	static iOwner
	iOwner = pev(entity, pev_owner)
	
	if(equal(model, MODEL_W_OLD))
	{
		static weapon; weapon = find_ent_by_owner(-1, weapon_shockrifle, entity)
		
		if(!pev_valid(weapon))
			return FMRES_IGNORED;
		
		if(Get_BitVar(g_Had_ShockRifle, iOwner))
		{
			set_pev(weapon, pev_impulse, WEAPON_CODE)
			engfunc(EngFunc_SetModel, entity, MODEL_W)
		
			Remove_ShockRifle(iOwner)
			
			return FMRES_SUPERCEDE
		}
	}

	return FMRES_IGNORED;
}

public fw_CmdStart(id, uc_handle, seed)
{
	if (!is_alive(id))
		return FMRES_IGNORED
	if(get_player_weapon(id) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, id))
		return FMRES_IGNORED
		
	static Button; Button = get_uc(uc_handle, UC_Buttons)	
	if(Button & IN_ATTACK)
	{	
		if(cs_get_user_bpammo(id, CSW_SHOCKRIFLE) <= 0)
		{
			Button &= ~IN_ATTACK
			set_uc(uc_handle, UC_Buttons, Button)
			
			return FMRES_SUPERCEDE
		}
	}
	if(Button & IN_ATTACK2)
	{
		if(get_pdata_float(id, 83, 5) > 0.0) 
			return FMRES_IGNORED
		static Ammo; Ammo = cs_get_user_bpammo(id, CSW_SHOCKRIFLE)
		if(Ammo < 2) return FMRES_IGNORED
			
		if(get_gametime() - 1.0 > EnergyDelay[id])
		{
			cs_set_user_bpammo(id, CSW_SHOCKRIFLE, Ammo - 2)
				
			static entwpn; entwpn = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
			if(!pev_valid(entwpn)) set_pdata_float(entwpn, 48, 1.0, 4)
			
			Set_PlayerNextAttack(id, 0.25)
			
			Set_WeaponAnim(id, ANIME_SHOOT2)
			emit_sound(id, CHAN_WEAPON, WeaponSounds[1], 1.0, 0.4, 0, 94 + random_num(0, 15))
			
			Energy_ShootEffect(id)
			Set_BitVar(g_Muzzleflash, id)
			
			Create_EnergyBall(id)
			EnergyDelay[id] = get_gametime()
		}
	}
	
	return FMRES_IGNORED
}

public Create_EnergyBall(id)
{
	static Float:StartOrigin[3], Float:TargetOrigin[3], Float:MyVelocity[3], Float:VecLength
	
	Get_Position(id, 48.0, 8.0, -8.0, StartOrigin)
	Get_Position(id, 1024.0, 0.0, 0.0, TargetOrigin)
	
	pev(id, pev_velocity, MyVelocity)
	VecLength = vector_length(MyVelocity)
	
	if(VecLength) 
	{
		TargetOrigin[0] += random_float(-16.0, 16.0); TargetOrigin[1] += random_float(-16.0, 16.0); TargetOrigin[2] += random_float(-16.0, 16.0)
	} else {
		TargetOrigin[0] += random_float(-8.0, 8.0); TargetOrigin[1] += random_float(-8.0, 8.0); TargetOrigin[2] += random_float(-8.0, 8.0)
	}
	
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
	if(!pev_valid(Ent)) return
	
	// Set info for ent
	set_pev(Ent, pev_movetype, MOVETYPE_BOUNCE)
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 200.0)
	set_pev(Ent, pev_iuser1, id) // Better than pev_owner
	set_pev(Ent, pev_iuser2, Get_SpecialTeam(id, cs_get_user_team(id)))
	set_pev(Ent, pev_fuser1, get_gametime() + 3.0)
	set_pev(Ent, pev_scale, 0.2)
	set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
	
	entity_set_string(Ent, EV_SZ_classname, ENERGY_CLASSNAME)
	engfunc(EngFunc_SetModel, Ent, WeaponResources[1])
	set_pev(Ent, pev_mins, Float:{-8.0, -8.0, -12.0})
	set_pev(Ent, pev_maxs, Float:{8.0, 8.0, 12.0})
	set_pev(Ent, pev_origin, StartOrigin)
	set_pev(Ent, pev_gravity, 0.001)
	set_pev(Ent, pev_solid, SOLID_BBOX)
	set_pev(Ent, pev_frame, 0.0)
	
	static Float:Velocity[3]
	get_speed_vector(StartOrigin, TargetOrigin, ENERGY_SPEED, Velocity)
	set_pev(Ent, pev_velocity, Velocity)	

	emit_sound(Ent, CHAN_BODY, WeaponSounds[4], 1.0, 0.4, 0, 94 + random_num(0, 15))
}

public fw_Think_Energy(Ent)
{
	if(!pev_valid(Ent)) 
		return
	
	static Float:fFrame; pev(Ent, pev_frame, fFrame)
	
	fFrame += 1.5
	if(fFrame >= 6.0) fFrame = 0.0
	
	set_pev(Ent, pev_frame, fFrame)
	set_pev(Ent, pev_nextthink, get_gametime() + 0.1)

	// time remove
	static Float:fTimeRemove; pev(Ent, pev_fuser1, fTimeRemove)
	if(get_gametime() >= fTimeRemove)
	{
		Energy_Explosion(Ent, 0)
		engfunc(EngFunc_RemoveEntity, Ent)
		
		return
	}
}

public fw_Touch_Energy(Ent, ID)
{
	if(!pev_valid(Ent) || !pev_valid(ID))
		return
		
	static Classname[32]; pev(ID, pev_classname, Classname, 31)
	if(equal(Classname, ENERGY_CLASSNAME))
	{
		Energy_Explosion(Ent, 0)
		Energy_Explosion(ID, 0)
		
		engfunc(EngFunc_RemoveEntity, Ent)
		engfunc(EngFunc_RemoveEntity, ID)
	
		return
	} else if(is_alive(ID)) {
		Energy_Explosion(Ent, 0)
		engfunc(EngFunc_RemoveEntity, Ent)
	}
}

public Energy_Explosion(Ent, Massive)
{
	static Float:Origin[3]; pev(Ent, pev_origin, Origin)
	static Owner; Owner = pev(Ent, pev_iuser1)
	
	if(!is_connected(Owner)) return
	static Weapon; Weapon = fm_get_user_weapon_entity(Owner, CSW_SHOCKRIFLE)
	if(!pev_valid(Weapon)) return
	
	if(!Massive)
	{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_EXPLOSION)
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		write_short(g_EnergyExp_SprId)
		write_byte(random_num(4, 6))
		write_byte(random_num(35, 45))
		write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
		message_end()	
		
		engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
		write_byte(TE_BEAMCYLINDER) // TE id
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2] + 70.0)
		write_short(g_Ring_SprID) // sprite
		write_byte(0) // startframe
		write_byte(0) // framerate
		write_byte(5) // life
		write_byte(10) // width
		write_byte(100) // noise
		write_byte(0) // red
		write_byte(127) // green
		write_byte(255) // blue
		write_byte(200) // brightness
		write_byte(0) // speed
		message_end()
		
		engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
		write_byte(TE_BEAMCYLINDER) // TE id
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2] + 60.0)
		write_short(g_Ring_SprID) // sprite
		write_byte(0) // startframe
		write_byte(0) // framerate
		write_byte(5) // life
		write_byte(10) // width
		write_byte(100) // noise
		write_byte(255) // red
		write_byte(255) // green
		write_byte(255) // blue
		write_byte(200) // brightness
		write_byte(0) // speed
		message_end()
		
		for(new i = 0; i < g_MaxPlayers; i++)
		{
			if(!is_alive(i))
				continue
			if(i == Owner)
				continue
			if(entity_range(Ent, i) > ENERGY_RADIUS)
				continue
				
			ExecuteHamB(Ham_TakeDamage, i, Weapon, Owner, float(DAMAGE_B), DMG_SHOCK)
		}
		
		emit_sound(Ent, CHAN_BODY, WeaponSounds[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	} else {
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_EXPLOSION)
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		write_short(g_EnergyExp_SprId)
		write_byte(random_num(13, 17))
		write_byte(random_num(25, 35))
		write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
		message_end()	
		
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_EXPLOSION)
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		write_short(g_EnergyExp2_SprId)
		write_byte(random_num(17, 23))
		write_byte(random_num(25, 35))
		write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
		message_end()	
		
		engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
		write_byte(TE_BEAMCYLINDER) // TE id
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2] + 100.0)
		write_short(g_Ring_SprID) // sprite
		write_byte(0) // startframe
		write_byte(0) // framerate
		write_byte(5) // life
		write_byte(10) // width
		write_byte(100) // noise
		write_byte(0) // red
		write_byte(127) // green
		write_byte(255) // blue
		write_byte(200) // brightness
		write_byte(0) // speed
		message_end()
		
		engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
		write_byte(TE_BEAMCYLINDER) // TE id
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2])
		engfunc(EngFunc_WriteCoord, Origin[0])
		engfunc(EngFunc_WriteCoord, Origin[1])
		engfunc(EngFunc_WriteCoord, Origin[2] + 80.0)
		write_short(g_Ring_SprID) // sprite
		write_byte(0) // startframe
		write_byte(0) // framerate
		write_byte(5) // life
		write_byte(10) // width
		write_byte(100) // noise
		write_byte(255) // red
		write_byte(255) // green
		write_byte(255) // blue
		write_byte(200) // brightness
		write_byte(0) // speed
		message_end()
		
		for(new i = 0; i < g_MaxPlayers; i++)
		{
			if(!is_alive(i))
				continue
			if(i == Owner)
				continue
			if(entity_range(Ent, i) > ENERGY_RADIUS * 2.0)
				continue
				
			ExecuteHamB(Ham_TakeDamage, i, Weapon, Owner, float(DAMAGE_B) * 2.0, DMG_SHOCK)
		}
		
		emit_sound(Ent, CHAN_BODY, WeaponSounds[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		emit_sound(Ent, CHAN_STATIC, WeaponSounds[3], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
}

public client_PostThink(id)
{
	if(!is_alive(id))
		return
	if(get_player_weapon(id) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, id))
		return
	
	if(get_gametime() - 0.1 > g_LightningEffect[id])
	{	
		message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
		write_byte(TE_BEAMENTS)
		write_short(id | 0x2000) // start entity
		write_short(id | 0x3000) // end entity
		write_short(m_spriteTexture) //beam model
		write_byte(0) // framerate
		write_byte(0) // framerate
		write_byte(1) // life
		write_byte(25)  // width
		write_byte(30)   // noise
		write_byte(0)   // r, g, b
		write_byte(127)   // r, g, b
		write_byte(255)   // r, g, b
		write_byte(255)	// brightness
		write_byte(200)		// speed 
		message_end()
		
		message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
		write_byte(TE_BEAMENTS)
		write_short(id | 0x2000) // start entity
		write_short(id | 0x3000) // end entity
		write_short(m_spriteTexture) //beam model
		write_byte(0) // framerate
		write_byte(0) // framerate
		write_byte(1) // life
		write_byte(12)  // width
		write_byte(30)   // noise
		write_byte(255)   // r, g, b
		write_byte(255)   // r, g, b
		write_byte(255)   // r, g, b
		write_byte(255)	// brightness
		write_byte(200)		// speed 
		message_end()
		
		g_LightningEffect[id] = get_gametime()
	}
}

public Get_SpecialTeam(Ent, CsTeams:Team)
{
	if(Team == CS_TEAM_T) return TEAM_T
	else if(Team == CS_TEAM_CT) return TEAM_CT
	
	return 0
}

public CsTeams:Get_EnergyTeam(Ent)
{
	if(pev(Ent, pev_iuser2) == TEAM_T) return CS_TEAM_T
	else if(pev(Ent, pev_iuser2) == TEAM_CT) return CS_TEAM_CT
	
	return CS_TEAM_UNASSIGNED
}

public ShockRifle_Shoot(id)
{
	static Float:Origin[3]; pev(id, pev_origin, Origin); Origin[2] += 26.0
	static Float:Target[3]; Get_Position(id, SHOCKRIFLE_RADIUS, 0.0, 0.0, Target)
	static Float:Start[3]; Get_Position(id, 48.0, 8.0, -6.0, Start)
	
	static Trace; Trace = create_tr2()
	engfunc(EngFunc_TraceLine, Origin, Target, DONT_IGNORE_MONSTERS, id, Trace)
	
	static Float:EndPos[3]; get_tr2(Trace, TR_vecEndPos, EndPos)
	
	// Effect
	Energy_ShootEffect(id) // Gun
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMPOINTS)
	write_coord_f(Start[0]) 
	write_coord_f(Start[1]) 
	write_coord_f(Start[2]) 
	write_coord_f(EndPos[0]) 
	write_coord_f(EndPos[1]) 
	write_coord_f(EndPos[2]) 
	write_short(m_spriteTexture)
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(5) // life
	write_byte(140)  // width
	write_byte(0)   // noise
	write_byte(0)   // r, g, b
	write_byte(127)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(255)		// speed
	message_end()
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMPOINTS)
	write_coord_f(Start[0]) 
	write_coord_f(Start[1]) 
	write_coord_f(Start[2]) 
	write_coord_f(EndPos[0]) 
	write_coord_f(EndPos[1]) 
	write_coord_f(EndPos[2]) 
	write_short(m_spriteTexture)
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(5) // life
	write_byte(70)  // width
	write_byte(0)   // noise
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(255)		// speed
	message_end()
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMPOINTS)
	write_coord_f(Start[0]) 
	write_coord_f(Start[1]) 
	write_coord_f(Start[2]) 
	write_coord_f(EndPos[0]) 
	write_coord_f(EndPos[1]) 
	write_coord_f(EndPos[2]) 
	write_short(m_spriteTexture)
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(7) // life
	write_byte(70)  // width
	write_byte(0)   // noise
	write_byte(0)   // r, g, b
	write_byte(127)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(255)		// speed
	message_end()
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMPOINTS)
	write_coord_f(Start[0]) 
	write_coord_f(Start[1]) 
	write_coord_f(Start[2]) 
	write_coord_f(EndPos[0]) 
	write_coord_f(EndPos[1]) 
	write_coord_f(EndPos[2]) 
	write_short(m_spriteTexture)
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(7) // life
	write_byte(35)  // width
	write_byte(0)   // noise
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(255)		// speed
	message_end()
	
	static Hit; Hit = get_tr2(Trace, TR_pHit)
	
	if(pev_valid(Hit))
	{
		static Classname[32]; pev(Hit, pev_classname, Classname, 31)
		if(equal(Classname, ENERGY_CLASSNAME))
		{
			Energy_Explosion(Hit, 1)
			engfunc(EngFunc_RemoveEntity, Hit)
			
			return
		}
		
		if(is_alive(Hit))
		{
			static Weapon; Weapon = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
			if(pev_valid(Weapon)) 
			{
				ExecuteHamB(Ham_TakeDamage, Hit, Weapon, id, float(DAMAGE_A), DMG_SHOCK)
			}
		}
	}
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, EndPos[0])
	engfunc(EngFunc_WriteCoord, EndPos[1])
	engfunc(EngFunc_WriteCoord, EndPos[2] - 10.0)
	write_short(g_EnergyExp_SprId)
	write_byte(random_num(3, 7))
	write_byte(random_num(35, 45))
	write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
	message_end()	
	
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, EndPos[0])
	engfunc(EngFunc_WriteCoord, EndPos[1])
	engfunc(EngFunc_WriteCoord, EndPos[2])
	engfunc(EngFunc_WriteCoord, EndPos[0])
	engfunc(EngFunc_WriteCoord, EndPos[1])
	engfunc(EngFunc_WriteCoord, EndPos[2] + 50.0)
	write_short(g_Ring_SprID) // sprite
	write_byte(0) // startframe
	write_byte(0) // framerate
	write_byte(5) // life
	write_byte(10) // width
	write_byte(100) // noise
	write_byte(0) // red
	write_byte(127) // green
	write_byte(255) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
	
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, EndPos[0])
	engfunc(EngFunc_WriteCoord, EndPos[1])
	engfunc(EngFunc_WriteCoord, EndPos[2])
	engfunc(EngFunc_WriteCoord, EndPos[0])
	engfunc(EngFunc_WriteCoord, EndPos[1])
	engfunc(EngFunc_WriteCoord, EndPos[2] + 40.0)
	write_short(g_Ring_SprID) // sprite
	write_byte(0) // startframe
	write_byte(0) // framerate
	write_byte(5) // life
	write_byte(10) // width
	write_byte(100) // noise
	write_byte(255) // red
	write_byte(255) // green
	write_byte(255) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
}

public Energy_ShootEffect(id)
{
	// Effect
	message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
	write_byte(TE_BEAMENTS)
	write_short(id | 0x2000) // start entity
	write_short(id | 0x3000) // end entity
	write_short(m_spriteTexture) //beam model
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(10) // life
	write_byte(50)  // width
	write_byte(75)   // noise
	write_byte(0)   // r, g, b
	write_byte(127)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(200)		// speed 
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
	write_byte(TE_BEAMENTS)
	write_short(id | 0x2000) // start entity
	write_short(id | 0x3000) // end entity
	write_short(m_spriteTexture) //beam model
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(10) // life
	write_byte(25)  // width
	write_byte(75)   // noise
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(200)		// speed 
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
	write_byte(TE_BEAMENTS)
	write_short(id | 0x2000) // start entity
	write_short(id | 0x3000) // end entity
	write_short(m_spriteTexture) //beam model
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(12) // life
	write_byte(30)  // width
	write_byte(35)   // noise
	write_byte(0)   // r, g, b
	write_byte(127)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(200)		// speed 
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
	write_byte(TE_BEAMENTS)
	write_short(id | 0x2000) // start entity
	write_short(id | 0x3000) // end entity
	write_short(m_spriteTexture) //beam model
	write_byte(0) // framerate
	write_byte(0) // framerate
	write_byte(12) // life
	write_byte(15)  // width
	write_byte(35)   // noise
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)   // r, g, b
	write_byte(255)	// brightness
	write_byte(200)		// speed 
	message_end()
}

public fw_AddToFullPack_Post(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
{
	if(iEnt == g_Muzzleflash_Ent)
	{
		if(Get_BitVar(g_Muzzleflash, iHost))
		{
			set_es(esState, ES_Frame, float(random_num(0, 2)))
				
			set_es(esState, ES_RenderMode, kRenderTransAdd)
			set_es(esState, ES_RenderAmt, 255.0)
			
			UnSet_BitVar(g_Muzzleflash, iHost)
		}
			
		set_es(esState, ES_Skin, iHost)
		set_es(esState, ES_Body, 1)
		set_es(esState, ES_AimEnt, iHost)
		set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
	} 
}

public fw_CheckVisibility(iEntity, pSet)
{
	if(iEntity == g_Muzzleflash_Ent)
	{
		forward_return(FMV_CELL, 1)
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public fw_Item_Deploy_Post(Ent)
{
	if(pev_valid(Ent) != 2)
		return
	static Id; Id = get_pdata_cbase(Ent, 41, 4)
	if(get_pdata_cbase(Id, 373) != Ent)
		return
	if(!Get_BitVar(g_Had_ShockRifle, Id))
		return
	
	set_pev(Id, pev_viewmodel2, MODEL_V)
	set_pev(Id, pev_weaponmodel2, MODEL_P)
	
	Set_WeaponAnim(Id, ANIME_DRAW)
	
	Set_PlayerNextAttack(Id, 0.5)
	Set_WeaponIdleTime(Id, CSW_SHOCKRIFLE, 0.45)
}

public fw_Item_AddToPlayer_Post(Ent, id)
{
	if(!pev_valid(Ent))
		return HAM_IGNORED
		
	if(pev(Ent, pev_impulse) == WEAPON_CODE)
	{
		Set_BitVar(g_Had_ShockRifle, id)
		set_pev(Ent, pev_impulse, 0)
	}
	
	return HAM_HANDLED	
}

public fw_Weapon_PrimaryAttack(Ent)
{
	static id; id = pev(Ent, pev_owner)
	if(!is_alive(id))
		return
	if(!Get_BitVar(g_Had_ShockRifle, id))
		return

	pev(id, pev_punchangle, g_Recoil[id])
}

public fw_Weapon_PrimaryAttack_Post(Ent)
{
	static id; id = pev(Ent, pev_owner)
	if(!is_alive(id))
		return
	if(!Get_BitVar(g_Had_ShockRifle, id))
		return

	static Float:Push[3]
	pev(id, pev_punchangle, Push)
	xs_vec_sub(Push, g_Recoil[id], Push)
	
	xs_vec_mul_scalar(Push, RECOIL, Push)
	xs_vec_add(Push, g_Recoil[id], Push)
	
	set_pev(id, pev_punchangle, Push)
	Set_BitVar(g_Muzzleflash, id)
	
	Set_PlayerNextAttack(id, SPEED_A)
}

public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
{
	if(!is_connected(Attacker))
		return HAM_IGNORED	
	if(get_player_weapon(Attacker) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, Attacker))
		return HAM_IGNORED
		
	// ZERO
	static Float:flEnd[3]; set_tr2(Ptr, TR_vecEndPos, flEnd)
	return HAM_SUPERCEDE
}

public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
{
	if(!is_connected(Attacker))
		return HAM_IGNORED	
	if(get_player_weapon(Attacker) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, Attacker))
		return HAM_IGNORED

	// ZERO
	static Float:flEnd[3]; set_tr2(Ptr, TR_vecEndPos, flEnd)
	return HAM_SUPERCEDE
}

/* ===============================
------------- SAFETY -------------
=================================*/
public Register_SafetyFunc()
{
	register_event("CurWeapon", "Safety_CurWeapon", "be", "1=1")
	
	RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
	RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
}

public Register_SafetyFuncBot(id)
{
	RegisterHamFromEntity(Ham_Spawn, id, "fw_Safety_Spawn_Post", 1)
	RegisterHamFromEntity(Ham_Killed, id, "fw_Safety_Killed_Post", 1)
}

public Safety_Connected(id)
{
	Set_BitVar(g_IsConnected, id)
	UnSet_BitVar(g_IsAlive, id)
	
	g_PlayerWeapon[id] = 0
}

public Safety_Disconnected(id)
{
	UnSet_BitVar(g_IsConnected, id)
	UnSet_BitVar(g_IsAlive, id)
	
	g_PlayerWeapon[id] = 0
}

public Safety_CurWeapon(id)
{
	if(!is_alive(id))
		return
		
	static CSW; CSW = read_data(2)
	if(g_PlayerWeapon[id] != CSW) g_PlayerWeapon[id] = CSW
}

public fw_Safety_Spawn_Post(id)
{
	if(!is_user_alive(id))
		return
		
	Set_BitVar(g_IsAlive, id)
}

public fw_Safety_Killed_Post(id)
{
	UnSet_BitVar(g_IsAlive, id)
}

public is_connected(id)
{
	if(!(1 <= id <= 32))
		return 0
	if(!Get_BitVar(g_IsConnected, id))
		return 0

	return 1
}

public is_alive(id)
{
	if(!is_connected(id))
		return 0
	if(!Get_BitVar(g_IsAlive, id))
		return 0
		
	return 1
}

public get_player_weapon(id)
{
	if(!is_alive(id))
		return 0
	
	return g_PlayerWeapon[id]
}

/* ===============================
--------- END OF SAFETY  ---------
=================================*/

stock Set_WeaponAnim(id, anim)
{
	set_pev(id, pev_weaponanim, anim)
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
	write_byte(anim)
	write_byte(pev(id, pev_body))
	message_end()
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock Set_WeaponIdleTime(id, WeaponId ,Float:TimeIdle)
{
	static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
	if(!pev_valid(entwpn)) 
		return
		
	set_pdata_float(entwpn, 46, TimeIdle, 4)
	set_pdata_float(entwpn, 47, TimeIdle, 4)
	set_pdata_float(entwpn, 48, TimeIdle, 4)
}

stock Set_PlayerNextAttack(id, Float:nexttime)
{
	set_pdata_float(id, 83, nexttime, 5)
}

stock Get_Position(id,Float:forw, Float:right, Float:up, Float:vStart[])
{
	static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(id, pev_origin, vOrigin)
	pev(id, pev_view_ofs,vUp) //for player
	xs_vec_add(vOrigin,vUp,vOrigin)
	pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
	
	angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
	angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
	angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
	
	vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1042\\ f0\\ fs16 \n\\ par }
*/
This gun have /get command. Please can you remove it and make it showing in item menu. Many thanks
Image

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 648
Joined: 3 Years Ago
Location: Egypt
Has thanked: 35 times
Been thanked: 50 times
Age: 20
Contact:

#2

Post by Mohamed Alaa » 1 Year Ago

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <cstrike>
  5. #include <xs>
  6. #include <fun>
  7.  
  8. #define PLUGIN "[CS1.6] UT3: Shock Rifle"
  9. #define VERSION "1.0"
  10. #define AUTHOR "Dias Pendragon"
  11.  
  12. #define DAMAGE_A 110 // 550 for Zombie
  13. #define DAMAGE_B 75 // 400
  14. #define AMMO 100
  15. #define SPEED_A 1.0
  16. #define RECOIL 1.0
  17. #define RELOAD_TIME 3.0
  18.  
  19. #define SHOCKRIFLE_RADIUS 1024.0
  20.  
  21. #define ENERGY_CLASSNAME "shockenergy"
  22. #define ENERGY_SPEED 500.0
  23. #define ENERGY_RADIUS 140.0
  24.  
  25. #define CSW_SHOCKRIFLE CSW_AK47
  26. #define weapon_shockrifle "weapon_ak47"
  27.  
  28. // Data Config
  29. #define MODEL_V "models/v_shockrifle.mdl"
  30. #define MODEL_P "models/p_shockrifle.mdl"
  31. #define MODEL_W "models/w_shockrifle.mdl"
  32.  
  33. #define WEAPON_CODE 11032016
  34. #define WEAPON_EVENT "events/ak47.sc"
  35. #define MODEL_W_OLD "models/w_ak47.mdl"
  36.  
  37. new const WeaponSounds[6][] =
  38. {
  39.     "weapons/shockrifle_shoot.wav",
  40.     "weapons/shockrifle_shoot2.wav",
  41.     "weapons/shockrifle_exp.wav",
  42.     "weapons/shockrifle_exp2.wav",
  43.     "weapons/shockrifle_flying.wav",
  44.     "weapons/shockrifle_draw.wav"
  45. }
  46.  
  47. new const WeaponResources[4][] =
  48. {
  49.     "sprites/shockrifle_light.spr",
  50.     "sprites/shockrifle_ball.spr",
  51.     "sprites/shockrifle_exp.spr",
  52.     "sprites/shockrifle_expb.spr"
  53. }
  54.  
  55. enum
  56. {
  57.     ANIME_IDLE = 0, // 5.2
  58.     ANIME_HOLSTER, // 0.45
  59.     ANIME_DRAW, // 0.45
  60.     ANIME_SHOOT, // 0.4
  61.     ANIME_SHOOT2 // 1.0
  62. }
  63.  
  64. enum
  65. {
  66.     TEAM_T = 1,
  67.     TEAM_CT
  68. }
  69.  
  70. // MACROS
  71. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
  72. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
  73. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
  74.  
  75. // Safety
  76. new g_HamBot
  77. new g_IsConnected, g_IsAlive, g_PlayerWeapon[33]
  78.  
  79. // Main Vars
  80. new g_Had_ShockRifle, Float:g_Recoil[33][3], g_OldWeapon[33], Float:g_LightningEffect[33], Float:EnergyDelay[33]
  81. new g_MsgCurWeapon, g_Event_ShockRifle, g_EnergyExp_SprId, g_EnergyExp2_SprId, g_Trail_SprID, m_spriteTexture, Float:FireSound[33]
  82. new g_Muzzleflash_Ent, g_Muzzleflash, g_MaxPlayers, g_MsgAmmoX, g_Ring_SprID
  83. new g_iItemID
  84.  
  85. public plugin_init()
  86. {
  87.     register_plugin(PLUGIN, VERSION, AUTHOR)
  88.    
  89.     // Safety
  90.     Register_SafetyFunc()
  91.    
  92.     // Event & ENGINE
  93.     register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
  94.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  95.     register_think(ENERGY_CLASSNAME, "fw_Think_Energy")
  96.     register_touch(ENERGY_CLASSNAME, "*", "fw_Touch_Energy")
  97.    
  98.     // Forwards
  99.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  100.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  101.     register_forward(FM_SetModel, "fw_SetModel")   
  102.     register_forward(FM_CmdStart, "fw_CmdStart")
  103.     register_forward(FM_AddToFullPack, "fw_AddToFullPack_Post", 1)
  104.     register_forward(FM_CheckVisibility, "fw_CheckVisibility")
  105.    
  106.     // Hams
  107.     RegisterHam(Ham_Item_Deploy, weapon_shockrifle, "fw_Item_Deploy_Post", 1)  
  108.     RegisterHam(Ham_Item_AddToPlayer, weapon_shockrifle, "fw_Item_AddToPlayer_Post", 1)
  109.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_shockrifle, "fw_Weapon_PrimaryAttack")
  110.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_shockrifle, "fw_Weapon_PrimaryAttack_Post", 1)
  111.    
  112.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
  113.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")
  114.    
  115.     // Cache
  116.     g_MaxPlayers = get_member_game(m_nMaxPlayers)
  117.     g_MsgAmmoX = get_user_msgid("AmmoX")
  118.     g_MsgCurWeapon = get_user_msgid("CurWeapon")
  119.    
  120.     g_iItemID = ze_register_item("Shock", 0, 0)
  121. }
  122.  
  123. public ze_select_item_pre(id, itemid)
  124. {
  125.     if (itemid != g_iItemID)
  126.         return ZE_ITEM_AVAILABLE
  127.  
  128.     if (ze_is_user_zombie(id))
  129.         return ZE_ITEM_DONT_SHOW
  130.  
  131.     return ZE_ITEM_AVAILABLE
  132. }
  133.  
  134. public ze_select_item_post(id, itemid)
  135. {
  136.     if (itemid != g_iItemID)
  137.         return
  138.  
  139.     Get_ShockRifle(id)
  140. }
  141.  
  142. public plugin_precache()
  143. {
  144.     precache_model(MODEL_V)
  145.     precache_model(MODEL_P)
  146.     precache_model(MODEL_W)
  147.    
  148.     for(new i = 0; i < sizeof(WeaponSounds); i++)
  149.         precache_sound(WeaponSounds[i])
  150.    
  151.     precache_model(WeaponResources[0])
  152.     precache_model(WeaponResources[1])
  153.     g_EnergyExp_SprId = precache_model(WeaponResources[2])
  154.     g_EnergyExp2_SprId = precache_model(WeaponResources[3])
  155.    
  156.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  157.     g_Trail_SprID = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr")
  158.     g_Ring_SprID = precache_model("sprites/shockwave.spr")
  159.     m_spriteTexture = precache_model("sprites/lgtning.spr" )
  160.    
  161.     // Muzzleflash
  162.     g_Muzzleflash_Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  163.    
  164.     engfunc(EngFunc_SetModel, g_Muzzleflash_Ent, WeaponResources[0])
  165.     set_pev(g_Muzzleflash_Ent, pev_scale, 0.3)
  166.    
  167.     set_pev(g_Muzzleflash_Ent, pev_rendermode, kRenderTransTexture)
  168.     set_pev(g_Muzzleflash_Ent, pev_renderamt, 0.0)
  169. }
  170.  
  171. public fw_PrecacheEvent_Post(type, const name[])
  172. {
  173.     if(equal(WEAPON_EVENT, name)) g_Event_ShockRifle = get_orig_retval()       
  174. }
  175.  
  176. public client_putinserver(id)
  177. {
  178.         Safety_Connected(id)
  179.    
  180.     if(!g_HamBot && is_user_bot(id))
  181.     {
  182.         g_HamBot = 1
  183.         set_task(0.1, "Register_HamBot", id)
  184.     }
  185. }
  186.  
  187. public Register_HamBot(id)
  188. {
  189.     Register_SafetyFuncBot(id)
  190.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack_Player")
  191. }
  192.  
  193. public client_disconnected(id)
  194. {
  195.         Safety_Disconnected(id)
  196. }
  197.  
  198. public Get_ShockRifle(id)
  199. {
  200.     // Give
  201.     Set_BitVar(g_Had_ShockRifle, id)
  202.     give_item(id, weapon_shockrifle)
  203.    
  204.     // Clip & Ammo
  205.     static Ent; Ent = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
  206.     if(!pev_valid(Ent)) return
  207.    
  208.     cs_set_weapon_ammo(Ent, 30)
  209.     cs_set_user_bpammo(id, CSW_SHOCKRIFLE, AMMO)
  210.    
  211.     update_ammo(id, -1, AMMO)
  212. }
  213.  
  214. public Remove_ShockRifle(id)
  215. {
  216.     UnSet_BitVar(g_Had_ShockRifle, id)
  217. }
  218.  
  219. public update_ammo(id, Ammo, BpAmmo)
  220. {
  221.     message_begin(MSG_ONE_UNRELIABLE, g_MsgCurWeapon, _, id)
  222.     write_byte(1)
  223.     write_byte(CSW_SHOCKRIFLE)
  224.     write_byte(Ammo)
  225.     message_end()
  226.    
  227.     message_begin(MSG_ONE_UNRELIABLE, g_MsgAmmoX, _, id)
  228.     write_byte(1)
  229.     write_byte(BpAmmo)
  230.     message_end()
  231.    
  232.     cs_set_user_bpammo(id, CSW_SHOCKRIFLE, BpAmmo)
  233. }
  234.  
  235. public Event_NewRound()
  236. {
  237.     remove_entity_name(ENERGY_CLASSNAME)
  238. }
  239.  
  240. public Event_CurWeapon(id)
  241. {
  242.     static CSWID; CSWID = read_data(2)
  243.     static Ent; Ent = fm_get_user_weapon_entity(id, CSWID)
  244.     if(!pev_valid(Ent)) return
  245.  
  246.     if((CSWID == CSW_SHOCKRIFLE && g_OldWeapon[id] != CSW_SHOCKRIFLE) && Get_BitVar(g_Had_ShockRifle, id))
  247.     {
  248.         cs_set_weapon_ammo(Ent, 30)
  249.         update_ammo(id, -1, cs_get_user_bpammo(id, CSWID))
  250.     } else if((CSWID == CSW_SHOCKRIFLE && g_OldWeapon[id] == CSW_SHOCKRIFLE) && Get_BitVar(g_Had_ShockRifle, id)) {
  251.         static Ent; Ent = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
  252.         if(!pev_valid(Ent))
  253.         {
  254.             g_OldWeapon[id] = get_user_weapon(id)
  255.             return
  256.         }
  257.        
  258.         set_pdata_float(Ent, 46, SPEED_A, 4)
  259.         set_pdata_float(Ent, 47, SPEED_A, 4)
  260.        
  261.         cs_set_weapon_ammo(Ent, 30)
  262.         update_ammo(id, -1, cs_get_user_bpammo(id, CSWID))
  263.     } else if(CSWID != CSW_SHOCKRIFLE && g_OldWeapon[id] == CSW_SHOCKRIFLE) {
  264.        
  265.     }
  266.    
  267.     g_OldWeapon[id] = get_user_weapon(id)
  268. }
  269.  
  270. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  271. {
  272.     if(!is_alive(id))
  273.         return FMRES_IGNORED   
  274.     if(get_user_weapon(id) == CSW_SHOCKRIFLE && Get_BitVar(g_Had_ShockRifle, id))
  275.         set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  276.    
  277.     return FMRES_HANDLED
  278. }
  279.  
  280. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  281. {
  282.     if (!is_connected(invoker))
  283.         return FMRES_IGNORED   
  284.     if(get_player_weapon(invoker) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, invoker))
  285.         return FMRES_IGNORED
  286.     if(eventid != g_Event_ShockRifle)
  287.         return FMRES_IGNORED
  288.    
  289.     engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  290.  
  291.     Set_WeaponAnim(invoker, ANIME_SHOOT)
  292.     emit_sound(invoker, CHAN_WEAPON, WeaponSounds[0], 1.0, 0.4, 0, 94 + random_num(0, 15))
  293.    
  294.     static Ent; Ent = fm_get_user_weapon_entity(invoker, CSW_SHOCKRIFLE)
  295.     if(!pev_valid(Ent)) return FMRES_SUPERCEDE
  296.    
  297.     static Ammo; Ammo = cs_get_user_bpammo(invoker, CSW_SHOCKRIFLE)
  298.     if(Ammo > 0)
  299.     {
  300.         cs_set_weapon_ammo(Ent, 30)
  301.         update_ammo(invoker, -1, Ammo - 1)
  302.        
  303.         ShockRifle_Shoot(invoker)
  304.     }
  305.  
  306.     return FMRES_SUPERCEDE
  307. }
  308.  
  309. public fw_SetModel(entity, model[])
  310. {
  311.     if(!pev_valid(entity))
  312.         return FMRES_IGNORED
  313.    
  314.     static Classname[32]
  315.     pev(entity, pev_classname, Classname, sizeof(Classname))
  316.    
  317.     if(!equal(Classname, "weaponbox"))
  318.         return FMRES_IGNORED
  319.    
  320.     static iOwner
  321.     iOwner = pev(entity, pev_owner)
  322.    
  323.     if(equal(model, MODEL_W_OLD))
  324.     {
  325.         static weapon; weapon = find_ent_by_owner(-1, weapon_shockrifle, entity)
  326.        
  327.         if(!pev_valid(weapon))
  328.             return FMRES_IGNORED;
  329.        
  330.         if(Get_BitVar(g_Had_ShockRifle, iOwner))
  331.         {
  332.             set_pev(weapon, pev_impulse, WEAPON_CODE)
  333.             engfunc(EngFunc_SetModel, entity, MODEL_W)
  334.        
  335.             Remove_ShockRifle(iOwner)
  336.            
  337.             return FMRES_SUPERCEDE
  338.         }
  339.     }
  340.  
  341.     return FMRES_IGNORED;
  342. }
  343.  
  344. public fw_CmdStart(id, uc_handle, seed)
  345. {
  346.     if (!is_alive(id))
  347.         return FMRES_IGNORED
  348.     if(get_player_weapon(id) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, id))
  349.         return FMRES_IGNORED
  350.        
  351.     static Button; Button = get_uc(uc_handle, UC_Buttons)  
  352.     if(Button & IN_ATTACK)
  353.     {  
  354.         if(cs_get_user_bpammo(id, CSW_SHOCKRIFLE) <= 0)
  355.         {
  356.             Button &= ~IN_ATTACK
  357.             set_uc(uc_handle, UC_Buttons, Button)
  358.            
  359.             return FMRES_SUPERCEDE
  360.         }
  361.     }
  362.     if(Button & IN_ATTACK2)
  363.     {
  364.         if(get_pdata_float(id, 83, 5) > 0.0)
  365.             return FMRES_IGNORED
  366.         static Ammo; Ammo = cs_get_user_bpammo(id, CSW_SHOCKRIFLE)
  367.         if(Ammo < 2) return FMRES_IGNORED
  368.            
  369.         if(get_gametime() - 1.0 > EnergyDelay[id])
  370.         {
  371.             cs_set_user_bpammo(id, CSW_SHOCKRIFLE, Ammo - 2)
  372.                
  373.             static entwpn; entwpn = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
  374.             if(!pev_valid(entwpn)) set_pdata_float(entwpn, 48, 1.0, 4)
  375.            
  376.             Set_PlayerNextAttack(id, 0.25)
  377.            
  378.             Set_WeaponAnim(id, ANIME_SHOOT2)
  379.             emit_sound(id, CHAN_WEAPON, WeaponSounds[1], 1.0, 0.4, 0, 94 + random_num(0, 15))
  380.            
  381.             Energy_ShootEffect(id)
  382.             Set_BitVar(g_Muzzleflash, id)
  383.            
  384.             Create_EnergyBall(id)
  385.             EnergyDelay[id] = get_gametime()
  386.         }
  387.     }
  388.    
  389.     return FMRES_IGNORED
  390. }
  391.  
  392. public Create_EnergyBall(id)
  393. {
  394.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:MyVelocity[3], Float:VecLength
  395.    
  396.     Get_Position(id, 48.0, 8.0, -8.0, StartOrigin)
  397.     Get_Position(id, 1024.0, 0.0, 0.0, TargetOrigin)
  398.    
  399.     pev(id, pev_velocity, MyVelocity)
  400.     VecLength = vector_length(MyVelocity)
  401.    
  402.     if(VecLength)
  403.     {
  404.         TargetOrigin[0] += random_float(-16.0, 16.0); TargetOrigin[1] += random_float(-16.0, 16.0); TargetOrigin[2] += random_float(-16.0, 16.0)
  405.     } else {
  406.         TargetOrigin[0] += random_float(-8.0, 8.0); TargetOrigin[1] += random_float(-8.0, 8.0); TargetOrigin[2] += random_float(-8.0, 8.0)
  407.     }
  408.    
  409.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
  410.     if(!pev_valid(Ent)) return
  411.    
  412.     // Set info for ent
  413.     set_pev(Ent, pev_movetype, MOVETYPE_BOUNCE)
  414.     set_pev(Ent, pev_rendermode, kRenderTransAdd)
  415.     set_pev(Ent, pev_renderamt, 200.0)
  416.     set_pev(Ent, pev_iuser1, id) // Better than pev_owner
  417.     set_pev(Ent, pev_iuser2, Get_SpecialTeam(id, cs_get_user_team(id)))
  418.     set_pev(Ent, pev_fuser1, get_gametime() + 3.0)
  419.     set_pev(Ent, pev_scale, 0.2)
  420.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  421.    
  422.     entity_set_string(Ent, EV_SZ_classname, ENERGY_CLASSNAME)
  423.     engfunc(EngFunc_SetModel, Ent, WeaponResources[1])
  424.     set_pev(Ent, pev_mins, Float:{-8.0, -8.0, -12.0})
  425.     set_pev(Ent, pev_maxs, Float:{8.0, 8.0, 12.0})
  426.     set_pev(Ent, pev_origin, StartOrigin)
  427.     set_pev(Ent, pev_gravity, 0.001)
  428.     set_pev(Ent, pev_solid, SOLID_BBOX)
  429.     set_pev(Ent, pev_frame, 0.0)
  430.    
  431.     static Float:Velocity[3]
  432.     get_speed_vector(StartOrigin, TargetOrigin, ENERGY_SPEED, Velocity)
  433.     set_pev(Ent, pev_velocity, Velocity)   
  434.  
  435.     emit_sound(Ent, CHAN_BODY, WeaponSounds[4], 1.0, 0.4, 0, 94 + random_num(0, 15))
  436. }
  437.  
  438. public fw_Think_Energy(Ent)
  439. {
  440.     if(!pev_valid(Ent))
  441.         return
  442.    
  443.     static Float:fFrame; pev(Ent, pev_frame, fFrame)
  444.    
  445.     fFrame += 1.5
  446.     if(fFrame >= 6.0) fFrame = 0.0
  447.    
  448.     set_pev(Ent, pev_frame, fFrame)
  449.     set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
  450.  
  451.     // time remove
  452.     static Float:fTimeRemove; pev(Ent, pev_fuser1, fTimeRemove)
  453.     if(get_gametime() >= fTimeRemove)
  454.     {
  455.         Energy_Explosion(Ent, 0)
  456.         engfunc(EngFunc_RemoveEntity, Ent)
  457.        
  458.         return
  459.     }
  460. }
  461.  
  462. public fw_Touch_Energy(Ent, ID)
  463. {
  464.     if(!pev_valid(Ent) || !pev_valid(ID))
  465.         return
  466.        
  467.     static Classname[32]; pev(ID, pev_classname, Classname, 31)
  468.     if(equal(Classname, ENERGY_CLASSNAME))
  469.     {
  470.         Energy_Explosion(Ent, 0)
  471.         Energy_Explosion(ID, 0)
  472.        
  473.         engfunc(EngFunc_RemoveEntity, Ent)
  474.         engfunc(EngFunc_RemoveEntity, ID)
  475.    
  476.         return
  477.     } else if(is_alive(ID)) {
  478.         Energy_Explosion(Ent, 0)
  479.         engfunc(EngFunc_RemoveEntity, Ent)
  480.     }
  481. }
  482.  
  483. public Energy_Explosion(Ent, Massive)
  484. {
  485.     static Float:Origin[3]; pev(Ent, pev_origin, Origin)
  486.     static Owner; Owner = pev(Ent, pev_iuser1)
  487.    
  488.     if(!is_connected(Owner)) return
  489.     static Weapon; Weapon = fm_get_user_weapon_entity(Owner, CSW_SHOCKRIFLE)
  490.     if(!pev_valid(Weapon)) return
  491.    
  492.     if(!Massive)
  493.     {
  494.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  495.         write_byte(TE_EXPLOSION)
  496.         engfunc(EngFunc_WriteCoord, Origin[0])
  497.         engfunc(EngFunc_WriteCoord, Origin[1])
  498.         engfunc(EngFunc_WriteCoord, Origin[2])
  499.         write_short(g_EnergyExp_SprId)
  500.         write_byte(random_num(4, 6))
  501.         write_byte(random_num(35, 45))
  502.         write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
  503.         message_end()  
  504.        
  505.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  506.         write_byte(TE_BEAMCYLINDER) // TE id
  507.         engfunc(EngFunc_WriteCoord, Origin[0])
  508.         engfunc(EngFunc_WriteCoord, Origin[1])
  509.         engfunc(EngFunc_WriteCoord, Origin[2])
  510.         engfunc(EngFunc_WriteCoord, Origin[0])
  511.         engfunc(EngFunc_WriteCoord, Origin[1])
  512.         engfunc(EngFunc_WriteCoord, Origin[2] + 70.0)
  513.         write_short(g_Ring_SprID) // sprite
  514.         write_byte(0) // startframe
  515.         write_byte(0) // framerate
  516.         write_byte(5) // life
  517.         write_byte(10) // width
  518.         write_byte(100) // noise
  519.         write_byte(0) // red
  520.         write_byte(127) // green
  521.         write_byte(255) // blue
  522.         write_byte(200) // brightness
  523.         write_byte(0) // speed
  524.         message_end()
  525.        
  526.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  527.         write_byte(TE_BEAMCYLINDER) // TE id
  528.         engfunc(EngFunc_WriteCoord, Origin[0])
  529.         engfunc(EngFunc_WriteCoord, Origin[1])
  530.         engfunc(EngFunc_WriteCoord, Origin[2])
  531.         engfunc(EngFunc_WriteCoord, Origin[0])
  532.         engfunc(EngFunc_WriteCoord, Origin[1])
  533.         engfunc(EngFunc_WriteCoord, Origin[2] + 60.0)
  534.         write_short(g_Ring_SprID) // sprite
  535.         write_byte(0) // startframe
  536.         write_byte(0) // framerate
  537.         write_byte(5) // life
  538.         write_byte(10) // width
  539.         write_byte(100) // noise
  540.         write_byte(255) // red
  541.         write_byte(255) // green
  542.         write_byte(255) // blue
  543.         write_byte(200) // brightness
  544.         write_byte(0) // speed
  545.         message_end()
  546.        
  547.         for(new i = 0; i < g_MaxPlayers; i++)
  548.         {
  549.             if(!is_alive(i))
  550.                 continue
  551.             if(i == Owner)
  552.                 continue
  553.             if(entity_range(Ent, i) > ENERGY_RADIUS)
  554.                 continue
  555.                
  556.             ExecuteHamB(Ham_TakeDamage, i, Weapon, Owner, float(DAMAGE_B), DMG_SHOCK)
  557.         }
  558.        
  559.         emit_sound(Ent, CHAN_BODY, WeaponSounds[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  560.     } else {
  561.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  562.         write_byte(TE_EXPLOSION)
  563.         engfunc(EngFunc_WriteCoord, Origin[0])
  564.         engfunc(EngFunc_WriteCoord, Origin[1])
  565.         engfunc(EngFunc_WriteCoord, Origin[2])
  566.         write_short(g_EnergyExp_SprId)
  567.         write_byte(random_num(13, 17))
  568.         write_byte(random_num(25, 35))
  569.         write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
  570.         message_end()  
  571.        
  572.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  573.         write_byte(TE_EXPLOSION)
  574.         engfunc(EngFunc_WriteCoord, Origin[0])
  575.         engfunc(EngFunc_WriteCoord, Origin[1])
  576.         engfunc(EngFunc_WriteCoord, Origin[2])
  577.         write_short(g_EnergyExp2_SprId)
  578.         write_byte(random_num(17, 23))
  579.         write_byte(random_num(25, 35))
  580.         write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
  581.         message_end()  
  582.        
  583.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  584.         write_byte(TE_BEAMCYLINDER) // TE id
  585.         engfunc(EngFunc_WriteCoord, Origin[0])
  586.         engfunc(EngFunc_WriteCoord, Origin[1])
  587.         engfunc(EngFunc_WriteCoord, Origin[2])
  588.         engfunc(EngFunc_WriteCoord, Origin[0])
  589.         engfunc(EngFunc_WriteCoord, Origin[1])
  590.         engfunc(EngFunc_WriteCoord, Origin[2] + 100.0)
  591.         write_short(g_Ring_SprID) // sprite
  592.         write_byte(0) // startframe
  593.         write_byte(0) // framerate
  594.         write_byte(5) // life
  595.         write_byte(10) // width
  596.         write_byte(100) // noise
  597.         write_byte(0) // red
  598.         write_byte(127) // green
  599.         write_byte(255) // blue
  600.         write_byte(200) // brightness
  601.         write_byte(0) // speed
  602.         message_end()
  603.        
  604.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  605.         write_byte(TE_BEAMCYLINDER) // TE id
  606.         engfunc(EngFunc_WriteCoord, Origin[0])
  607.         engfunc(EngFunc_WriteCoord, Origin[1])
  608.         engfunc(EngFunc_WriteCoord, Origin[2])
  609.         engfunc(EngFunc_WriteCoord, Origin[0])
  610.         engfunc(EngFunc_WriteCoord, Origin[1])
  611.         engfunc(EngFunc_WriteCoord, Origin[2] + 80.0)
  612.         write_short(g_Ring_SprID) // sprite
  613.         write_byte(0) // startframe
  614.         write_byte(0) // framerate
  615.         write_byte(5) // life
  616.         write_byte(10) // width
  617.         write_byte(100) // noise
  618.         write_byte(255) // red
  619.         write_byte(255) // green
  620.         write_byte(255) // blue
  621.         write_byte(200) // brightness
  622.         write_byte(0) // speed
  623.         message_end()
  624.        
  625.         for(new i = 0; i < g_MaxPlayers; i++)
  626.         {
  627.             if(!is_alive(i))
  628.                 continue
  629.             if(i == Owner)
  630.                 continue
  631.             if(entity_range(Ent, i) > ENERGY_RADIUS * 2.0)
  632.                 continue
  633.                
  634.             ExecuteHamB(Ham_TakeDamage, i, Weapon, Owner, float(DAMAGE_B) * 2.0, DMG_SHOCK)
  635.         }
  636.        
  637.         emit_sound(Ent, CHAN_BODY, WeaponSounds[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  638.         emit_sound(Ent, CHAN_STATIC, WeaponSounds[3], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  639.     }
  640. }
  641.  
  642. public client_PostThink(id)
  643. {
  644.     if(!is_alive(id))
  645.         return
  646.     if(get_player_weapon(id) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, id))
  647.         return
  648.    
  649.     if(get_gametime() - 0.1 > g_LightningEffect[id])
  650.     {  
  651.         message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  652.         write_byte(TE_BEAMENTS)
  653.         write_short(id | 0x2000) // start entity
  654.         write_short(id | 0x3000) // end entity
  655.         write_short(m_spriteTexture) //beam model
  656.         write_byte(0) // framerate
  657.         write_byte(0) // framerate
  658.         write_byte(1) // life
  659.         write_byte(25)  // width
  660.         write_byte(30)   // noise
  661.         write_byte(0)   // r, g, b
  662.         write_byte(127)   // r, g, b
  663.         write_byte(255)   // r, g, b
  664.         write_byte(255) // brightness
  665.         write_byte(200)     // speed
  666.         message_end()
  667.        
  668.         message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  669.         write_byte(TE_BEAMENTS)
  670.         write_short(id | 0x2000) // start entity
  671.         write_short(id | 0x3000) // end entity
  672.         write_short(m_spriteTexture) //beam model
  673.         write_byte(0) // framerate
  674.         write_byte(0) // framerate
  675.         write_byte(1) // life
  676.         write_byte(12)  // width
  677.         write_byte(30)   // noise
  678.         write_byte(255)   // r, g, b
  679.         write_byte(255)   // r, g, b
  680.         write_byte(255)   // r, g, b
  681.         write_byte(255) // brightness
  682.         write_byte(200)     // speed
  683.         message_end()
  684.        
  685.         g_LightningEffect[id] = get_gametime()
  686.     }
  687. }
  688.  
  689. public Get_SpecialTeam(Ent, CsTeams:Team)
  690. {
  691.     if(Team == CS_TEAM_T) return TEAM_T
  692.     else if(Team == CS_TEAM_CT) return TEAM_CT
  693.    
  694.     return 0
  695. }
  696.  
  697. public CsTeams:Get_EnergyTeam(Ent)
  698. {
  699.     if(pev(Ent, pev_iuser2) == TEAM_T) return CS_TEAM_T
  700.     else if(pev(Ent, pev_iuser2) == TEAM_CT) return CS_TEAM_CT
  701.    
  702.     return CS_TEAM_UNASSIGNED
  703. }
  704.  
  705. public ShockRifle_Shoot(id)
  706. {
  707.     static Float:Origin[3]; pev(id, pev_origin, Origin); Origin[2] += 26.0
  708.     static Float:Target[3]; Get_Position(id, SHOCKRIFLE_RADIUS, 0.0, 0.0, Target)
  709.     static Float:Start[3]; Get_Position(id, 48.0, 8.0, -6.0, Start)
  710.    
  711.     static Trace; Trace = create_tr2()
  712.     engfunc(EngFunc_TraceLine, Origin, Target, DONT_IGNORE_MONSTERS, id, Trace)
  713.    
  714.     static Float:EndPos[3]; get_tr2(Trace, TR_vecEndPos, EndPos)
  715.    
  716.     // Effect
  717.     Energy_ShootEffect(id) // Gun
  718.    
  719.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  720.     write_byte(TE_BEAMPOINTS)
  721.     write_coord_f(Start[0])
  722.     write_coord_f(Start[1])
  723.     write_coord_f(Start[2])
  724.     write_coord_f(EndPos[0])
  725.     write_coord_f(EndPos[1])
  726.     write_coord_f(EndPos[2])
  727.     write_short(m_spriteTexture)
  728.     write_byte(0) // framerate
  729.     write_byte(0) // framerate
  730.     write_byte(5) // life
  731.     write_byte(140)  // width
  732.     write_byte(0)   // noise
  733.     write_byte(0)   // r, g, b
  734.     write_byte(127)   // r, g, b
  735.     write_byte(255)   // r, g, b
  736.     write_byte(255) // brightness
  737.     write_byte(255)     // speed
  738.     message_end()
  739.    
  740.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  741.     write_byte(TE_BEAMPOINTS)
  742.     write_coord_f(Start[0])
  743.     write_coord_f(Start[1])
  744.     write_coord_f(Start[2])
  745.     write_coord_f(EndPos[0])
  746.     write_coord_f(EndPos[1])
  747.     write_coord_f(EndPos[2])
  748.     write_short(m_spriteTexture)
  749.     write_byte(0) // framerate
  750.     write_byte(0) // framerate
  751.     write_byte(5) // life
  752.     write_byte(70)  // width
  753.     write_byte(0)   // noise
  754.     write_byte(255)   // r, g, b
  755.     write_byte(255)   // r, g, b
  756.     write_byte(255)   // r, g, b
  757.     write_byte(255) // brightness
  758.     write_byte(255)     // speed
  759.     message_end()
  760.    
  761.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  762.     write_byte(TE_BEAMPOINTS)
  763.     write_coord_f(Start[0])
  764.     write_coord_f(Start[1])
  765.     write_coord_f(Start[2])
  766.     write_coord_f(EndPos[0])
  767.     write_coord_f(EndPos[1])
  768.     write_coord_f(EndPos[2])
  769.     write_short(m_spriteTexture)
  770.     write_byte(0) // framerate
  771.     write_byte(0) // framerate
  772.     write_byte(7) // life
  773.     write_byte(70)  // width
  774.     write_byte(0)   // noise
  775.     write_byte(0)   // r, g, b
  776.     write_byte(127)   // r, g, b
  777.     write_byte(255)   // r, g, b
  778.     write_byte(255) // brightness
  779.     write_byte(255)     // speed
  780.     message_end()
  781.    
  782.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  783.     write_byte(TE_BEAMPOINTS)
  784.     write_coord_f(Start[0])
  785.     write_coord_f(Start[1])
  786.     write_coord_f(Start[2])
  787.     write_coord_f(EndPos[0])
  788.     write_coord_f(EndPos[1])
  789.     write_coord_f(EndPos[2])
  790.     write_short(m_spriteTexture)
  791.     write_byte(0) // framerate
  792.     write_byte(0) // framerate
  793.     write_byte(7) // life
  794.     write_byte(35)  // width
  795.     write_byte(0)   // noise
  796.     write_byte(255)   // r, g, b
  797.     write_byte(255)   // r, g, b
  798.     write_byte(255)   // r, g, b
  799.     write_byte(255) // brightness
  800.     write_byte(255)     // speed
  801.     message_end()
  802.    
  803.     static Hit; Hit = get_tr2(Trace, TR_pHit)
  804.    
  805.     if(pev_valid(Hit))
  806.     {
  807.         static Classname[32]; pev(Hit, pev_classname, Classname, 31)
  808.         if(equal(Classname, ENERGY_CLASSNAME))
  809.         {
  810.             Energy_Explosion(Hit, 1)
  811.             engfunc(EngFunc_RemoveEntity, Hit)
  812.            
  813.             return
  814.         }
  815.        
  816.         if(is_alive(Hit))
  817.         {
  818.             static Weapon; Weapon = fm_get_user_weapon_entity(id, CSW_SHOCKRIFLE)
  819.             if(pev_valid(Weapon))
  820.             {
  821.                 ExecuteHamB(Ham_TakeDamage, Hit, Weapon, id, float(DAMAGE_A), DMG_SHOCK)
  822.             }
  823.         }
  824.     }
  825.    
  826.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  827.     write_byte(TE_EXPLOSION)
  828.     engfunc(EngFunc_WriteCoord, EndPos[0])
  829.     engfunc(EngFunc_WriteCoord, EndPos[1])
  830.     engfunc(EngFunc_WriteCoord, EndPos[2] - 10.0)
  831.     write_short(g_EnergyExp_SprId)
  832.     write_byte(random_num(3, 7))
  833.     write_byte(random_num(35, 45))
  834.     write_byte(TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES)
  835.     message_end()  
  836.    
  837.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  838.     write_byte(TE_BEAMCYLINDER) // TE id
  839.     engfunc(EngFunc_WriteCoord, EndPos[0])
  840.     engfunc(EngFunc_WriteCoord, EndPos[1])
  841.     engfunc(EngFunc_WriteCoord, EndPos[2])
  842.     engfunc(EngFunc_WriteCoord, EndPos[0])
  843.     engfunc(EngFunc_WriteCoord, EndPos[1])
  844.     engfunc(EngFunc_WriteCoord, EndPos[2] + 50.0)
  845.     write_short(g_Ring_SprID) // sprite
  846.     write_byte(0) // startframe
  847.     write_byte(0) // framerate
  848.     write_byte(5) // life
  849.     write_byte(10) // width
  850.     write_byte(100) // noise
  851.     write_byte(0) // red
  852.     write_byte(127) // green
  853.     write_byte(255) // blue
  854.     write_byte(200) // brightness
  855.     write_byte(0) // speed
  856.     message_end()
  857.    
  858.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0)
  859.     write_byte(TE_BEAMCYLINDER) // TE id
  860.     engfunc(EngFunc_WriteCoord, EndPos[0])
  861.     engfunc(EngFunc_WriteCoord, EndPos[1])
  862.     engfunc(EngFunc_WriteCoord, EndPos[2])
  863.     engfunc(EngFunc_WriteCoord, EndPos[0])
  864.     engfunc(EngFunc_WriteCoord, EndPos[1])
  865.     engfunc(EngFunc_WriteCoord, EndPos[2] + 40.0)
  866.     write_short(g_Ring_SprID) // sprite
  867.     write_byte(0) // startframe
  868.     write_byte(0) // framerate
  869.     write_byte(5) // life
  870.     write_byte(10) // width
  871.     write_byte(100) // noise
  872.     write_byte(255) // red
  873.     write_byte(255) // green
  874.     write_byte(255) // blue
  875.     write_byte(200) // brightness
  876.     write_byte(0) // speed
  877.     message_end()
  878. }
  879.  
  880. public Energy_ShootEffect(id)
  881. {
  882.     // Effect
  883.     message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  884.     write_byte(TE_BEAMENTS)
  885.     write_short(id | 0x2000) // start entity
  886.     write_short(id | 0x3000) // end entity
  887.     write_short(m_spriteTexture) //beam model
  888.     write_byte(0) // framerate
  889.     write_byte(0) // framerate
  890.     write_byte(10) // life
  891.     write_byte(50)  // width
  892.     write_byte(75)   // noise
  893.     write_byte(0)   // r, g, b
  894.     write_byte(127)   // r, g, b
  895.     write_byte(255)   // r, g, b
  896.     write_byte(255) // brightness
  897.     write_byte(200)     // speed
  898.     message_end()
  899.    
  900.     message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  901.     write_byte(TE_BEAMENTS)
  902.     write_short(id | 0x2000) // start entity
  903.     write_short(id | 0x3000) // end entity
  904.     write_short(m_spriteTexture) //beam model
  905.     write_byte(0) // framerate
  906.     write_byte(0) // framerate
  907.     write_byte(10) // life
  908.     write_byte(25)  // width
  909.     write_byte(75)   // noise
  910.     write_byte(255)   // r, g, b
  911.     write_byte(255)   // r, g, b
  912.     write_byte(255)   // r, g, b
  913.     write_byte(255) // brightness
  914.     write_byte(200)     // speed
  915.     message_end()
  916.    
  917.     message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  918.     write_byte(TE_BEAMENTS)
  919.     write_short(id | 0x2000) // start entity
  920.     write_short(id | 0x3000) // end entity
  921.     write_short(m_spriteTexture) //beam model
  922.     write_byte(0) // framerate
  923.     write_byte(0) // framerate
  924.     write_byte(12) // life
  925.     write_byte(30)  // width
  926.     write_byte(35)   // noise
  927.     write_byte(0)   // r, g, b
  928.     write_byte(127)   // r, g, b
  929.     write_byte(255)   // r, g, b
  930.     write_byte(255) // brightness
  931.     write_byte(200)     // speed
  932.     message_end()
  933.    
  934.     message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  935.     write_byte(TE_BEAMENTS)
  936.     write_short(id | 0x2000) // start entity
  937.     write_short(id | 0x3000) // end entity
  938.     write_short(m_spriteTexture) //beam model
  939.     write_byte(0) // framerate
  940.     write_byte(0) // framerate
  941.     write_byte(12) // life
  942.     write_byte(15)  // width
  943.     write_byte(35)   // noise
  944.     write_byte(255)   // r, g, b
  945.     write_byte(255)   // r, g, b
  946.     write_byte(255)   // r, g, b
  947.     write_byte(255) // brightness
  948.     write_byte(200)     // speed
  949.     message_end()
  950. }
  951.  
  952. public fw_AddToFullPack_Post(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
  953. {
  954.     if(iEnt == g_Muzzleflash_Ent)
  955.     {
  956.         if(Get_BitVar(g_Muzzleflash, iHost))
  957.         {
  958.             set_es(esState, ES_Frame, float(random_num(0, 2)))
  959.                
  960.             set_es(esState, ES_RenderMode, kRenderTransAdd)
  961.             set_es(esState, ES_RenderAmt, 255.0)
  962.            
  963.             UnSet_BitVar(g_Muzzleflash, iHost)
  964.         }
  965.            
  966.         set_es(esState, ES_Skin, iHost)
  967.         set_es(esState, ES_Body, 1)
  968.         set_es(esState, ES_AimEnt, iHost)
  969.         set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
  970.     }
  971. }
  972.  
  973. public fw_CheckVisibility(iEntity, pSet)
  974. {
  975.     if(iEntity == g_Muzzleflash_Ent)
  976.     {
  977.         forward_return(FMV_CELL, 1)
  978.         return FMRES_SUPERCEDE
  979.     }
  980.    
  981.     return FMRES_IGNORED
  982. }
  983.  
  984. public fw_Item_Deploy_Post(Ent)
  985. {
  986.     if(pev_valid(Ent) != 2)
  987.         return
  988.     static Id; Id = get_pdata_cbase(Ent, 41, 4)
  989.     if(get_pdata_cbase(Id, 373) != Ent)
  990.         return
  991.     if(!Get_BitVar(g_Had_ShockRifle, Id))
  992.         return
  993.    
  994.     set_pev(Id, pev_viewmodel2, MODEL_V)
  995.     set_pev(Id, pev_weaponmodel2, MODEL_P)
  996.    
  997.     Set_WeaponAnim(Id, ANIME_DRAW)
  998.    
  999.     Set_PlayerNextAttack(Id, 0.5)
  1000.     Set_WeaponIdleTime(Id, CSW_SHOCKRIFLE, 0.45)
  1001. }
  1002.  
  1003. public fw_Item_AddToPlayer_Post(Ent, id)
  1004. {
  1005.     if(!pev_valid(Ent))
  1006.         return HAM_IGNORED
  1007.        
  1008.     if(pev(Ent, pev_impulse) == WEAPON_CODE)
  1009.     {
  1010.         Set_BitVar(g_Had_ShockRifle, id)
  1011.         set_pev(Ent, pev_impulse, 0)
  1012.     }
  1013.    
  1014.     return HAM_HANDLED 
  1015. }
  1016.  
  1017. public fw_Weapon_PrimaryAttack(Ent)
  1018. {
  1019.     static id; id = pev(Ent, pev_owner)
  1020.     if(!is_alive(id))
  1021.         return
  1022.     if(!Get_BitVar(g_Had_ShockRifle, id))
  1023.         return
  1024.  
  1025.     pev(id, pev_punchangle, g_Recoil[id])
  1026. }
  1027.  
  1028. public fw_Weapon_PrimaryAttack_Post(Ent)
  1029. {
  1030.     static id; id = pev(Ent, pev_owner)
  1031.     if(!is_alive(id))
  1032.         return
  1033.     if(!Get_BitVar(g_Had_ShockRifle, id))
  1034.         return
  1035.  
  1036.     static Float:Push[3]
  1037.     pev(id, pev_punchangle, Push)
  1038.     xs_vec_sub(Push, g_Recoil[id], Push)
  1039.    
  1040.     xs_vec_mul_scalar(Push, RECOIL, Push)
  1041.     xs_vec_add(Push, g_Recoil[id], Push)
  1042.    
  1043.     set_pev(id, pev_punchangle, Push)
  1044.     Set_BitVar(g_Muzzleflash, id)
  1045.    
  1046.     Set_PlayerNextAttack(id, SPEED_A)
  1047. }
  1048.  
  1049. public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  1050. {
  1051.     if(!is_connected(Attacker))
  1052.         return HAM_IGNORED 
  1053.     if(get_player_weapon(Attacker) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, Attacker))
  1054.         return HAM_IGNORED
  1055.        
  1056.     // ZERO
  1057.     static Float:flEnd[3]; set_tr2(Ptr, TR_vecEndPos, flEnd)
  1058.     return HAM_SUPERCEDE
  1059. }
  1060.  
  1061. public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  1062. {
  1063.     if(!is_connected(Attacker))
  1064.         return HAM_IGNORED 
  1065.     if(get_player_weapon(Attacker) != CSW_SHOCKRIFLE || !Get_BitVar(g_Had_ShockRifle, Attacker))
  1066.         return HAM_IGNORED
  1067.  
  1068.     // ZERO
  1069.     static Float:flEnd[3]; set_tr2(Ptr, TR_vecEndPos, flEnd)
  1070.     return HAM_SUPERCEDE
  1071. }
  1072.  
  1073. /* ===============================
  1074. ------------- SAFETY -------------
  1075. =================================*/
  1076. public Register_SafetyFunc()
  1077. {
  1078.     register_event("CurWeapon", "Safety_CurWeapon", "be", "1=1")
  1079.    
  1080.     RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
  1081.     RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
  1082. }
  1083.  
  1084. public Register_SafetyFuncBot(id)
  1085. {
  1086.     RegisterHamFromEntity(Ham_Spawn, id, "fw_Safety_Spawn_Post", 1)
  1087.     RegisterHamFromEntity(Ham_Killed, id, "fw_Safety_Killed_Post", 1)
  1088. }
  1089.  
  1090. public Safety_Connected(id)
  1091. {
  1092.     Set_BitVar(g_IsConnected, id)
  1093.     UnSet_BitVar(g_IsAlive, id)
  1094.    
  1095.     g_PlayerWeapon[id] = 0
  1096. }
  1097.  
  1098. public Safety_Disconnected(id)
  1099. {
  1100.     UnSet_BitVar(g_IsConnected, id)
  1101.     UnSet_BitVar(g_IsAlive, id)
  1102.    
  1103.     g_PlayerWeapon[id] = 0
  1104. }
  1105.  
  1106. public Safety_CurWeapon(id)
  1107. {
  1108.     if(!is_alive(id))
  1109.         return
  1110.        
  1111.     static CSW; CSW = read_data(2)
  1112.     if(g_PlayerWeapon[id] != CSW) g_PlayerWeapon[id] = CSW
  1113. }
  1114.  
  1115. public fw_Safety_Spawn_Post(id)
  1116. {
  1117.     if(!is_user_alive(id))
  1118.         return
  1119.        
  1120.     Set_BitVar(g_IsAlive, id)
  1121. }
  1122.  
  1123. public fw_Safety_Killed_Post(id)
  1124. {
  1125.     UnSet_BitVar(g_IsAlive, id)
  1126. }
  1127.  
  1128. public is_connected(id)
  1129. {
  1130.     if(!(1 <= id <= 32))
  1131.         return 0
  1132.     if(!Get_BitVar(g_IsConnected, id))
  1133.         return 0
  1134.  
  1135.     return 1
  1136. }
  1137.  
  1138. public is_alive(id)
  1139. {
  1140.     if(!is_connected(id))
  1141.         return 0
  1142.     if(!Get_BitVar(g_IsAlive, id))
  1143.         return 0
  1144.        
  1145.     return 1
  1146. }
  1147.  
  1148. public get_player_weapon(id)
  1149. {
  1150.     if(!is_alive(id))
  1151.         return 0
  1152.    
  1153.     return g_PlayerWeapon[id]
  1154. }
  1155.  
  1156. /* ===============================
  1157. --------- END OF SAFETY  ---------
  1158. =================================*/
  1159.  
  1160. stock Set_WeaponAnim(id, anim)
  1161. {
  1162.     set_pev(id, pev_weaponanim, anim)
  1163.    
  1164.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  1165.     write_byte(anim)
  1166.     write_byte(pev(id, pev_body))
  1167.     message_end()
  1168. }
  1169.  
  1170. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  1171. {
  1172.     new_velocity[0] = origin2[0] - origin1[0]
  1173.     new_velocity[1] = origin2[1] - origin1[1]
  1174.     new_velocity[2] = origin2[2] - origin1[2]
  1175.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  1176.     new_velocity[0] *= num
  1177.     new_velocity[1] *= num
  1178.     new_velocity[2] *= num
  1179.    
  1180.     return 1;
  1181. }
  1182.  
  1183. stock Set_WeaponIdleTime(id, WeaponId ,Float:TimeIdle)
  1184. {
  1185.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  1186.     if(!pev_valid(entwpn))
  1187.         return
  1188.        
  1189.     set_pdata_float(entwpn, 46, TimeIdle, 4)
  1190.     set_pdata_float(entwpn, 47, TimeIdle, 4)
  1191.     set_pdata_float(entwpn, 48, TimeIdle, 4)
  1192. }
  1193.  
  1194. stock Set_PlayerNextAttack(id, Float:nexttime)
  1195. {
  1196.     set_pdata_float(id, 83, nexttime, 5)
  1197. }
  1198.  
  1199. stock Get_Position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  1200. {
  1201.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  1202.    
  1203.     pev(id, pev_origin, vOrigin)
  1204.     pev(id, pev_view_ofs,vUp) //for player
  1205.     xs_vec_add(vOrigin,vUp,vOrigin)
  1206.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  1207.    
  1208.     angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
  1209.     angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
  1210.     angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
  1211.    
  1212.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  1213.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  1214.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  1215. }
  1216. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  1217. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1042\\ f0\\ fs16 \n\\ par }
  1218. */
These users thanked the author Mohamed Alaa for the post:
czirimbolo (1 Year Ago)
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 560
Joined: 3 Years Ago
Has thanked: 20 times
Been thanked: 2 times
Contact:

#3

Post by czirimbolo » 1 Year Ago

Work, thanks!
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest