/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------| AT4 |-----------------------------------------------------------
//======================================= sDs|Aragon* =======================================================
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include "furien40/furien40.inc"
#include "furien40/furien40_weapons.inc"
new BloodSpray, BloodDrop, MSGID_WeaponList, MSGID_DeathMsg, MSGID_ScoreInfo, MSGID_CurWeapon, MSGID_SayText
#define AT4_WEAPONKEY 104
#define weapon_at4 "weapon_m249"
#define CSW_AT4 CSW_M249
#define AT4_CLASS "at4ex_rocket"
#define AT4_CLASS_LASERDOT "at4_laserdot"
new WPN_AT4[][] = {
/*Name*/ "AT4",
/*Acces*/ "2",
/*Level*/ "60",
/*Damage*/ "300",
/*Radius*/ "220",
/*KnockBack*/ "4"
},
AT4Model_V[] = "models/furien40_weapons/Primary/v_at4.mdl",
AT4Model_P[] = "models/furien40_weapons/Primary/p_at4.mdl",
AT4Model_W[] = "models/furien40_weapons/Primary/w_at4.mdl",
AT4Model_S[] = "models/furien40_weapons/Primary/s_at4.mdl",
AT4Model_L[] = "sprites/dot.spr",
AT4_WeaponList[] = "furien40_at4",
AT4_Sound[][] = {
"weapons/at4_shoot1.wav",
"weapons/at4_clipin1.wav",
"weapons/at4_clipin2.wav",
"weapons/at4_clipin3.wav",
"weapons/at4_draw.wav"
},
AT4_Generic[][] = {
"sprites/furien40_at4.txt",
"sprites/furien40_weapons/at4.spr"
},
AT4ID, at4_event, at4_smoke, at4_trail, at4_explode
public plugin_init() {
AT4ID = RegisterPrimary(WPN_AT4[0], WPN_AT4[1], WPN_AT4[2], AT4_WEAPONKEY, weapon_at4, CSW_AT4, AT4_WeaponList)
if(AT4ID == -1)
pause("ade");
register_clcmd(AT4_WeaponList, "Hook_AT4");
register_event("CurWeapon", "AT4_ViewModel", "be", "1=1");
register_event("WeapPickup","AT4_ViewModel","b","1=19");
register_forward(FM_SetModel, "AT4_WorldModel", 1);
register_forward(FM_UpdateClientData, "AT4_UpdateClientData_Post", 1);
register_forward(FM_PlaybackEvent, "AT4_PlaybackEvent");
register_forward(FM_PlayerPreThink, "AT4_PreThink");
register_forward(FM_CmdStart, "AT4_CmdStart");
RegisterHam(Ham_Item_AddToPlayer, weapon_at4, "AT4_AddToPlayer");
RegisterHam(Ham_Item_Deploy , weapon_at4, "AT4_Deploy_Post", 1);
RegisterHam(Ham_Item_Holster , weapon_at4, "AT4_Holster");
RegisterHam(Ham_Weapon_WeaponIdle, weapon_at4, "AT4_WeaponIdle")
RegisterHam(Ham_Weapon_PrimaryAttack, weapon_at4, "AT4_PrimaryAttack");
RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload");
RegisterHam(Ham_Weapon_Reload, weapon_at4, "AT4_Reload_Post", 1);
RegisterHam(Ham_Item_PostFrame, weapon_at4, "AT4_PostFrame");
register_think(AT4_CLASS, "AT4_Think");
register_think(AT4_CLASS_LASERDOT, "AT4_LaserDot_Think");
register_touch(AT4_CLASS, "*", "AT4_Touch");
MSGID_WeaponList = get_user_msgid("WeaponList")
MSGID_DeathMsg = get_user_msgid("DeathMsg")
MSGID_ScoreInfo = get_user_msgid("ScoreInfo")
MSGID_CurWeapon = get_user_msgid("CurWeapon")
MSGID_SayText = get_user_msgid("SayText")
}
public plugin_precache() {
register_forward(FM_PrecacheEvent, "AT4_PrecacheEvent_Post", 1);
BloodSpray = precache_model("sprites/bloodspray.spr");
BloodDrop = precache_model("sprites/blood.spr");
at4_smoke = precache_model("sprites/effects/rainsplash.spr");
at4_trail = precache_model("sprites/xbeam3.spr");
at4_explode = precache_model("sprites/furien40_weapons/explode.spr");
precache_model(AT4Model_V);
precache_model(AT4Model_P);
precache_model(AT4Model_W);
precache_model(AT4Model_S);
precache_model(AT4Model_L);
for(new i = 0; i < sizeof(AT4_Sound); i++)
engfunc(EngFunc_PrecacheSound, AT4_Sound[i]);
for(new i = 0; i < sizeof(AT4_Generic); i++)
engfunc(EngFunc_PrecacheGeneric, AT4_Generic[i]);
}
public plugin_natives() {
register_native("get_user_at4", "get_user_at4", 1);
register_native("set_user_at4", "set_user_at4", 1);
}
public AT4_ViewModel(id) {
if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
set_pev(id, pev_viewmodel2, AT4Model_V);
set_pev(id, pev_weaponmodel2, AT4Model_P);
set_pdata_int(id, 361, get_pdata_int(id, 361) | (1<<6));
message_begin(MSG_ONE_UNRELIABLE, MSGID_CurWeapon, _, id)
write_byte(1)
write_byte(CSW_AT4)
write_byte(-1)
message_end()
}
}
public AT4_WorldModel(entity, model[]) {
if(is_valid_ent(entity)) {
static ClassName[33];
entity_get_string(entity, EV_SZ_classname, ClassName, charsmax(ClassName));
if(equal(ClassName, "weaponbox")) {
new Owner = entity_get_edict(entity, EV_ENT_owner),
_AT4 = find_ent_by_owner(-1, weapon_at4, entity);
if(get_user_at4(Owner) && pev_valid(_AT4) && entity_get_int(_AT4, EV_INT_impulse) == AT4_WEAPONKEY) {
set_user_at4(Owner, false);
set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
entity_set_model(entity, AT4Model_W);
new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, Owner);
if(is_valid_ent(Laser))
remove_entity(Laser);
}
}
}
return FMRES_IGNORED;
}
public AT4_UpdateClientData_Post(id, sendweapons, cd_handle) {
if(is_user_alive(id) && is_user_connected(id) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id))
set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001);
return FMRES_IGNORED;
}
public AT4_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2) {
if(is_user_connected(invoker) && eventid == at4_event)
playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
return FMRES_IGNORED;
}
public AT4_PrecacheEvent_Post(type, const name[]) {
if (equal("events/m249.sc", name))
at4_event = get_orig_retval();
return FMRES_IGNORED;
}
public AT4_PreThink(id) {
if(is_user_alive(id) && is_user_connected(id)) {
if(get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
new _AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);
if(pev_valid(_AT4) && entity_get_int(_AT4, EV_INT_iuser1) == 1) {
new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
if(!is_valid_ent(Laser)) {
new at4_laser = create_entity("info_target");
if(is_valid_ent(at4_laser)) {
new Float:Origin[3], Float:Color[3];
fm_get_aim_origin(id, Origin);
Color[0] = 255.0, Color[1] =0.0, Color[2] = 0.0,
set_pev(at4_laser, pev_classname, AT4_CLASS_LASERDOT);
set_pev(at4_laser, pev_owner, id);
engfunc(EngFunc_SetModel, at4_laser, AT4Model_L);
set_pev(at4_laser, pev_renderfx, kRenderFxNoDissipation);
set_pev(at4_laser, pev_rendermode, kRenderGlow);
set_pev(at4_laser, pev_rendercolor, Color);
set_pev(at4_laser, pev_renderamt, 255.0);
set_pev(at4_laser, pev_light_level, 255.0);
set_pev(at4_laser, pev_scale, 1.0);
set_pev(at4_laser, pev_movetype, MOVETYPE_FLY);
set_pev(at4_laser, pev_nextthink, halflife_time() + 0.001);
}
}
}
}
}
}
public AT4_CmdStart(id, uc_handle, seed) {
if(is_user_alive(id) && is_user_connected(id)) {
new CurButton = get_uc(uc_handle, UC_Buttons);
if(CurButton & IN_ATTACK && get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
new _AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);
if(pev_valid(_AT4) && cs_get_weapon_ammo(_AT4) > 0 && !get_pdata_int(_AT4, 54, 4) && get_pdata_float(id, 83, 5) <= 0.0) {
set_weapon_anim(id, 1);
emit_sound(id, CHAN_WEAPON, AT4_Sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM);
AT4_Fire(id, entity_get_int(_AT4, EV_INT_iuser1) == 1 ? 1 : 0);
new Float:cl_pushangle[3];
cl_pushangle[0] = random_float(-8.0, -9.0), cl_pushangle[1] = 0.0, cl_pushangle[2] = 0.0;
set_pev(id, pev_punchangle, cl_pushangle);
cs_set_weapon_ammo(_AT4, cs_get_weapon_ammo(_AT4) - 1);
if(cs_get_weapon_ammo(_AT4) > 0 && !get_pdata_int(_AT4, 54, 4) && get_pdata_float(id, 83, 5) <= 0.0) {
set_pdata_float(id, 83, 0.3, 5);
set_pdata_float(_AT4, 48, 0.3, 4)
}
}
CurButton &= ~IN_ATTACK;
set_uc(uc_handle, UC_Buttons, CurButton);
}
if(CurButton & IN_ATTACK2 && !(pev(id, pev_oldbuttons) & IN_ATTACK2) && get_user_weapon(id) == CSW_AT4 && get_user_at4(id)) {
new _AT4 = fm_find_ent_by_owner(-1, weapon_at4, id);
if(pev_valid(_AT4) && cs_get_weapon_ammo(_AT4) > 0 && !get_pdata_int(_AT4, 54, 4) && get_pdata_float(id, 83, 5) <= 0.0) {
if(entity_get_int(_AT4, EV_INT_iuser1) == 1) {
entity_set_int(_AT4, EV_INT_iuser1, 0)
new Laser = find_ent_by_owner(-1, AT4_CLASS_LASERDOT, id);
if(is_valid_ent(Laser))
remove_entity(Laser);
}
else
entity_set_int(_AT4, EV_INT_iuser1, 1)
}
CurButton &= ~IN_ATTACK2;
set_uc(uc_handle, UC_Buttons, CurButton);
}
}
return FMRES_IGNORED;
}
public AT4_AddToPlayer(Weapon, id) {
if(is_valid_ent(Weapon) && is_user_connected(id) && entity_get_int(Weapon, EV_INT_impulse) == AT4_WEAPONKEY) {
set_user_at4(id, true);
WeaponList(id, CSW_AT4, AT4_WeaponList, 0)
entity_set_int(Weapon, EV_INT_impulse, 0);
}
else if(pev_valid(Weapon) && is_user_alive(id) && entity_get_int(id, EV_INT_impulse) == AT4_WEAPONKEY) {
ColorChat(id, "!t[!g%s!t]!g Clip:!t 1!g Damage:!t %s!g Radius:!t %s!g KnockBack:!t %s", WPN_AT4[0], WPN_AT4[3], WPN_AT4[4], WPN_AT4[5])
ColorChat(id, "!t[Module 2]!g Damage:!t %d!g Clip:!t 1!g Radius:!t %s!g KnockBack:!t %s", floatround(str_to_float(WPN_AT4[3]) * 0.60), WPN_AT4[4], WPN_AT4[5])
}
return HAM_IGNORED;
}
public AT4_Deploy_Post(Weapon) {
if(pev_valid(Weapon)) {
new Owner = get_pdata_cbase(Weapon, 41, 4);
if(is_user_alive(Owner) && get_user_at4(Owner)) {
set_pev(Owner, pev_viewmodel2, AT4Model_V);
set_pev(Owner, pev_weaponmodel2, AT4Model_P);
set_weapon_anim(Owner, 4)
set_pdata_float(Owner, 83, 1.2, 5);
set_pdata_float(Weapon, 48, 1.2, 4)
set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) | (1<<6));
}
}
return HAM_IGNORED;
}
public AT4_Holster(Weapon) {
if(pev_valid(Weapon)) {
new Owner = get_pdata_cbase(Weapon, 41, 4);
if(is_user_alive(Owner) && get_user_at4(Owner))
set_pdata_int(Owner, 361, get_pdata_int(Owner, 361) & ~ (1<<6));
}
return HAM_IGNORED;
}
public AT4_WeaponIdle(Weapon) {
if(pev_valid(Weapon)) {
new Owner = get_pdata_cbase(Weapon, 41, 4);
if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_float(Weapon, 48, 4) <= 0.1) {
set_pdata_float(Weapon, 48, 4.0, 4)
set_weapon_anim(Owner, 0)
}
}
return HAM_IGNORED;
}
public AT4_PrimaryAttack(Weapon) {
if(pev_valid(Weapon)) {
new Owner = get_pdata_cbase(Weapon, 41, 4);
if(is_user_alive(Owner) && get_user_at4(Owner))
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public AT4_Reload(Weapon) {
if(pev_valid(Weapon)) {
new Owner = get_pdata_cbase(Weapon, 41, 4);
if(is_user_alive(Owner) && get_user_at4(Owner)) {
if(cs_get_user_bpammo(Owner, CSW_AT4) <= 0 || get_pdata_int(Weapon, 51, 4) >= 1)
return HAM_SUPERCEDE;
}
}
return HAM_IGNORED;
}
public AT4_Reload_Post(Weapon) {
if(pev_valid(Weapon)) {
new Owner = get_pdata_cbase(Weapon, 41, 4);
if(is_user_alive(Owner) && get_user_at4(Owner)) {
if(cs_get_user_bpammo(Owner, CSW_AT4) <= 0 || get_pdata_int(Weapon, 51, 4) >= 1)
return HAM_SUPERCEDE;
set_pdata_float(Weapon, 48, 3.66, 4);
set_pdata_float(Owner, 83, 3.66, 5);
set_pdata_int(Weapon, 54, 1, 4);
set_weapon_anim(Owner, 3)
}
}
return HAM_IGNORED;
}
public AT4_PostFrame(Weapon) {
if(pev_valid(Weapon)) {
new Owner = get_pdata_cbase(Weapon, 41, 4);
if(is_user_alive(Owner) && get_user_at4(Owner) && get_pdata_int(Weapon, 54, 4) && get_pdata_float(Owner, 83, 5) <= 0.0) {
new Temp = min(1 - get_pdata_int(Weapon, 51, 4), cs_get_user_bpammo(Owner, CSW_AT4));
set_pdata_int(Weapon, 51, get_pdata_int(Weapon, 51, 4) + Temp, 4);
cs_set_user_bpammo(Owner, CSW_AT4, cs_get_user_bpammo(Owner, CSW_AT4) - Temp);
set_pdata_int(Weapon, 54, 0, 4);
}
}
return HAM_IGNORED;
}
public AT4_Fire(id, Type) {
new Rocket = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
if(pev_valid(Rocket)) {
new Float:Origin[3], Float:Angles[3], Float:Velocity[3];
engfunc(EngFunc_GetAttachment, id, 0, Origin);
pev(id, pev_v_angle, Angles)
set_pev(Rocket, pev_origin, Origin);
set_pev(Rocket, pev_solid, SOLID_TRIGGER);
set_pev(Rocket, pev_movetype, MOVETYPE_FLY);
set_pev(Rocket, pev_classname, AT4_CLASS);
if(Type) {
set_pev(Rocket, pev_fuser3, 0.60);
set_pev(Rocket, pev_iuser3, 1);
}
else {
set_pev(Rocket, pev_fuser3, 1.0);
set_pev(Rocket, pev_iuser3, 0);
}
set_pev(Rocket, pev_owner, id);
engfunc(EngFunc_SetModel, Rocket, AT4Model_S);
set_pev(Rocket, pev_mins, {-1.0, -1.0, -1.0});
set_pev(Rocket, pev_maxs, {1.0, 1.0, 1.0});
velocity_to_aim(id, Origin, 2000, Velocity)
vector_to_angle(Velocity, Angles)
set_pev(Rocket, pev_velocity, Velocity);
set_pev(Rocket, pev_angles, Angles);
set_pev(Rocket, pev_iuser4, 0);
set_pev(Rocket, pev_nextthink, halflife_time() + 0.1);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMFOLLOW); // TE id
write_short(Rocket); // entity:attachment to follow
write_short(at4_trail); // sprite index
write_byte(3); // life in 0.1's
write_byte(2); // line width in 0.1's
write_byte(255); // r
write_byte(255); // g
write_byte(255); // b
write_byte(200); // brightness
message_end();
}
}
public AT4_Think(Rocket) {
if(is_valid_ent(Rocket)) {
static Float:Origin[3];
pev(Rocket, pev_origin, Origin);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_SPRITE);
engfunc(EngFunc_WriteCoord, Origin[0]);
engfunc(EngFunc_WriteCoord, Origin[1]);
engfunc(EngFunc_WriteCoord, Origin[2]);
write_short(at4_smoke);
write_byte(2);
write_byte(200);
message_end();
if(pev(Rocket, pev_iuser3) == 1) {
if(pev(Rocket, pev_iuser4) == 0) {
new Victim = FindClosesEnemy(Rocket);
if(is_user_alive(Victim))
set_pev(Rocket, pev_iuser4, Victim);
}
else {
new Victim = pev(Rocket, pev_iuser4);
if(is_user_alive(Victim)) {
new Float:VictimOrigin[3], Float:Velocity[3], Float:Angles[3], Float:x;
pev(Victim, pev_origin, VictimOrigin);
Velocity[0] = VictimOrigin[0] - Origin[0]
Velocity[1] = VictimOrigin[1] - Origin[1]
Velocity[2] = VictimOrigin[2] - Origin[2]
x = floatsqroot(2000.0*2000.0 / (Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]))
Velocity[0] *= x
Velocity[1] *= x
Velocity[2] *= x
vector_to_angle(Velocity, Angles)
set_pev(Rocket, pev_velocity, Velocity);
set_pev(Rocket, pev_angles, Angles);
}
else
set_pev(Rocket, pev_iuser4, 0);
}
}
set_pev(Rocket, pev_nextthink, halflife_time() + 0.075);
}
}
public AT4_LaserDot_Think(LaserDot) {
if(is_valid_ent(LaserDot)) {
new Float:Origin[3],
Owner = pev(LaserDot, pev_owner);
if(is_user_alive(Owner) && get_user_weapon(Owner) == CSW_AT4 && get_user_at4(Owner)) {
fm_get_aim_origin(Owner, Origin);
set_pev(LaserDot, pev_origin, Origin);
set_pev(LaserDot, pev_nextthink, halflife_time() + 0.001);
}
else engfunc(EngFunc_RemoveEntity, LaserDot);
}
}
public AT4_Touch(Rocket, touch) {
if(is_valid_ent(Rocket) && touch != pev(Rocket, pev_owner)) {
new Float:RocketOrigin[3],
id = pev(Rocket, pev_owner)
pev(Rocket, pev_origin, RocketOrigin);
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
write_byte(TE_EXPLOSION);
engfunc(EngFunc_WriteCoord, RocketOrigin[0]);
engfunc(EngFunc_WriteCoord, RocketOrigin[1]);
engfunc(EngFunc_WriteCoord, RocketOrigin[2]);
write_short(at4_explode); // sprite index
write_byte(40); // scale in 0.1's
write_byte(30); // framerate
write_byte(0); // flags
message_end();
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_WORLDDECAL)
engfunc(EngFunc_WriteCoord, RocketOrigin[0])
engfunc(EngFunc_WriteCoord, RocketOrigin[1])
engfunc(EngFunc_WriteCoord, RocketOrigin[2])
write_byte(random_num(46, 48))
message_end()
new Victim = -1;
while((Victim = find_ent_in_sphere(Victim, RocketOrigin, str_to_float(WPN_AT4[4]))) != 0) {
static ClassName[32];
pev(Victim, pev_classname, ClassName, charsmax(ClassName));
if(equal(ClassName, "player") && is_user_connected(Victim) && is_user_alive(Victim)) {
if(!fm_get_user_godmode(Victim) && get_user_team(Victim) != get_user_team(id) && Victim != id) {
new Float:VictimOrigin[3], Float:Distance, Float:DistanceRatio, Float:Damage;
pev(Victim, pev_origin, VictimOrigin);
Distance = get_distance_f(RocketOrigin, VictimOrigin);
DistanceRatio = floatdiv(Distance, str_to_float(WPN_AT4[4]));
Damage = str_to_float(WPN_AT4[3]) - floatround(floatmul(str_to_float(WPN_AT4[3]), DistanceRatio));
Damage *= pev(Rocket, pev_fuser3)
if(Victim == touch)
Damage = str_to_float(WPN_AT4[3]) * pev(Rocket, pev_fuser3)
make_blood(Victim, floatround(Damage))
make_knockback(Victim, RocketOrigin, str_to_float(WPN_AT4[5])*Damage);
if(get_user_health(Victim) > Damage)
ExecuteHam(Ham_TakeDamage, Victim, id, id, Damage, DMG_BLAST);
else
death_message(id, Victim, "at4");
}
}
else if(is_valid_ent(Victim) && equal(ClassName, "func_breakable")) {
if(entity_get_float(Victim, EV_FL_health) <= str_to_float(WPN_AT4[3]))
force_use(id, Victim);
}
}
engfunc(EngFunc_RemoveEntity, Rocket);
}
}
public Hook_AT4(id) {
engclient_cmd(id, weapon_at4);
return PLUGIN_HANDLED
}
public get_user_at4(id)
return get_user_primary(id, AT4ID)
public set_user_at4(id, bool:at4)
set_user_primary(id, AT4ID, at4)
stock FindClosesEnemy(entid) {
new Float:Dist;
new Float:MaxDistance = 100.0;
for(new i = 1; i <= get_maxplayers(); i++){
if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(entid, i)
&& pev(entid, pev_owner) != i && cs_get_user_team(pev(entid, pev_owner)) != cs_get_user_team(i)) {
Dist = entity_range(entid, i);
if(Dist <= MaxDistance)
return i;
}
}
return 0;
}
stock bool:can_see_fm(entindex1, entindex2) {
if(!entindex1 || !entindex2)
return false;
if(pev_valid(entindex1) && pev_valid(entindex1)) {
new flags = pev(entindex1, pev_flags);
if(flags & EF_NODRAW || flags & FL_NOTARGET) {
return false;
}
new Float:lookerOrig[3];
new Float:targetBaseOrig[3];
new Float:targetOrig[3];
new Float:temp[3];
pev(entindex1, pev_origin, lookerOrig);
pev(entindex1, pev_view_ofs, temp);
lookerOrig[0] += temp[0];
lookerOrig[1] += temp[1];
lookerOrig[2] += temp[2];
pev(entindex2, pev_origin, targetBaseOrig);
pev(entindex2, pev_view_ofs, temp);
targetOrig[0] = targetBaseOrig[0] + temp[0];
targetOrig[1] = targetBaseOrig[1] + temp[1];
targetOrig[2] = targetBaseOrig[2] + temp[2];
engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); // checks the had of seen player
if(get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) {
return false;
}
else {
new Float:flFraction;
get_tr2(0, TraceResult:TR_flFraction, flFraction);
if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
return true;
}
else {
targetOrig[0] = targetBaseOrig[0];
targetOrig[1] = targetBaseOrig[1];
targetOrig[2] = targetBaseOrig[2];
engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); // checks the body of seen player
get_tr2(0, TraceResult:TR_flFraction, flFraction);
if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
return true;
}
else {
targetOrig[0] = targetBaseOrig[0];
targetOrig[1] = targetBaseOrig[1];
targetOrig[2] = targetBaseOrig[2] - 17.0;
engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0); // checks the legs of seen player
get_tr2(0, TraceResult:TR_flFraction, flFraction);
if(flFraction == 1.0 ||(get_tr2(0, TraceResult:TR_pHit) == entindex2)) {
return true;
}
}
}
}
}
return false;
}
stock WeaponList(id, CSW_WEAPON, const Weapon[], Flag=0) {
switch(CSW_WEAPON) {
case CSW_P228: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(9); // PrimaryAmmoID
write_byte(52); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(1); // SlotID (0...N)
write_byte(3); // NumberInSlot (1...N)
write_byte(CSW_P228); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_SCOUT: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(2); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(9); // NumberInSlot (1...N)
write_byte(CSW_SCOUT); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_HEGRENADE: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(12); // PrimaryAmmoID
write_byte(1); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(3); // SlotID (0...N)
write_byte(1); // NumberInSlot (1...N)
write_byte(CSW_HEGRENADE); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_XM1014: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(5); // PrimaryAmmoID
write_byte(32); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(12); // NumberInSlot (1...N)
write_byte(CSW_XM1014); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_C4: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(14); // PrimaryAmmoID
write_byte(1); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(4); // SlotID (0...N)
write_byte(3); // NumberInSlot (1...N)
write_byte(CSW_C4); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_MAC10: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(6); // PrimaryAmmoID
write_byte(100); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(13); // NumberInSlot (1...N)
write_byte(CSW_MAC10); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_AUG: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(4); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(14); // NumberInSlot (1...N)
write_byte(CSW_AUG); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_SMOKEGRENADE: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(13); // PrimaryAmmoID
write_byte(1); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(3); // SlotID (0...N)
write_byte(3); // NumberInSlot (1...N)
write_byte(CSW_SMOKEGRENADE); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_ELITE: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(10); // PrimaryAmmoID
write_byte(120); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(1); // SlotID (0...N)
write_byte(5); // NumberInSlot (1...N)
write_byte(CSW_ELITE); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_FIVESEVEN: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(7); // PrimaryAmmoID
write_byte(100); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(1); // SlotID (0...N)
write_byte(6); // NumberInSlot (1...N)
write_byte(CSW_FIVESEVEN); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_UMP45: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(6); // PrimaryAmmoID
write_byte(100); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(15); // NumberInSlot (1...N)
write_byte(CSW_UMP45); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_SG550: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(4); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(16); // NumberInSlot (1...N)
write_byte(CSW_SG550); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_GALIL: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(4); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(17); // NumberInSlot (1...N)
write_byte(CSW_GALIL); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_FAMAS: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(4); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(18); // NumberInSlot (1...N)
write_byte(CSW_FAMAS); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_USP: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(6); // PrimaryAmmoID
write_byte(100); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(1); // SlotID (0...N)
write_byte(4); // NumberInSlot (1...N)
write_byte(CSW_USP); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_GLOCK18: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(10); // PrimaryAmmoID
write_byte(120); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(1); // SlotID (0...N)
write_byte(2); // NumberInSlot (1...N)
write_byte(CSW_GLOCK18); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_AWP: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(1); // PrimaryAmmoID
write_byte(30); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(2); // NumberInSlot (1...N)
write_byte(CSW_AWP); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_MP5NAVY: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(10); // PrimaryAmmoID
write_byte(120); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(7); // NumberInSlot (1...N)
write_byte(CSW_MP5NAVY); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_M249: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(3); // PrimaryAmmoID
write_byte(200); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(4); // NumberInSlot (1...N)
write_byte(CSW_M249); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_M3: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(5); // PrimaryAmmoID
write_byte(32); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(5); // NumberInSlot (1...N)
write_byte(CSW_M3); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_M4A1: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(4); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(6); // NumberInSlot (1...N)
write_byte(CSW_M4A1); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_TMP: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(10); // PrimaryAmmoID
write_byte(120); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(11); // NumberInSlot (1...N)
write_byte(CSW_TMP); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_G3SG1: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(2); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(3); // NumberInSlot (1...N)
write_byte(CSW_G3SG1); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_FLASHBANG: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(11); // PrimaryAmmoID
write_byte(2); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(3); // SlotID (0...N)
write_byte(2); // NumberInSlot (1...N)
write_byte(CSW_FLASHBANG); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_DEAGLE: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(8); // PrimaryAmmoID
write_byte(35); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(1); // SlotID (0...N)
write_byte(1); // NumberInSlot (1...N)
write_byte(CSW_DEAGLE); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_SG552: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(4); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(10); // NumberInSlot (1...N)
write_byte(CSW_SG552); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_AK47: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(2); // PrimaryAmmoID
write_byte(90); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(1); // NumberInSlot (1...N)
write_byte(CSW_AK47); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_KNIFE: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(-1); // PrimaryAmmoID
write_byte(-1); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(2); // SlotID (0...N)
write_byte(1); // NumberInSlot (1...N)
write_byte(CSW_KNIFE); // WeaponID
write_byte(Flag); // Flags
message_end();
}
case CSW_P90: {
message_begin(MSG_ONE, MSGID_WeaponList, _, id);
write_string(Weapon); // WeaponName
write_byte(7); // PrimaryAmmoID
write_byte(100); // PrimaryAmmoMaxAmount
write_byte(-1); // SecondaryAmmoID
write_byte(-1); // SecondaryAmmoMaxAmount
write_byte(0); // SlotID (0...N)
write_byte(8); // NumberInSlot (1...N)
write_byte(CSW_P90); // WeaponID
write_byte(Flag); // Flags
message_end();
}
}
}
stock death_message(killer, victim, const WeaponName[]) {
if(is_user_connected(killer) && is_user_connected(victim)) {
set_msg_block(MSGID_DeathMsg, BLOCK_SET);
ExecuteHamB(Ham_Killed, victim, killer, 2);
set_msg_block(MSGID_DeathMsg, BLOCK_NOT);
make_deathmsg(killer, victim, 0, WeaponName);
cs_set_user_money(killer, cs_get_user_money(killer) + 300);
message_begin(MSG_BROADCAST, MSGID_ScoreInfo);
write_byte(killer); // id
write_short(pev(killer, pev_frags)); // frags
write_short(cs_get_user_deaths(killer)); // deaths
write_short(0); // class?
write_short(get_user_team(killer)); // team
message_end();
message_begin(MSG_BROADCAST, MSGID_ScoreInfo);
write_byte(victim); // id
write_short(pev(victim, pev_frags)); // frags
write_short(cs_get_user_deaths(victim)); // deaths
write_short(0); // class?
write_short(get_user_team(victim)); // team
message_end();
}
}
stock make_knockback(id, Float:origin[3], Float:maxspeed) {
if(is_user_alive(id)) {
new Float:Velocity[3], Float:Origin[3], Float:Distance[3], Float:Time;
entity_get_vector(id, EV_VEC_origin, Origin);
Distance[0] = Origin[0] - origin[0], Distance[1] = Origin[1] - origin[1], Distance[2] = Origin[2] - origin[2];
Time = (vector_distance(Origin,origin) / maxspeed);
Velocity[0] = Distance[0] / Time, Velocity[1] = Distance[1] / Time, Velocity[2] = Distance[2] / Time;
entity_set_vector(id, EV_VEC_velocity, Velocity);
}
}
stock make_blood(id, Amount) {
if(is_user_alive(id)) {
new BloodColor = ExecuteHam(Ham_BloodColor, id);
if(BloodColor != -1) {
new Float:Origin[3]
pev(id, pev_origin, Origin);
Amount *= 2; //according to HLSDK
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BLOODSPRITE);
write_coord(floatround(Origin[0]));
write_coord(floatround(Origin[1]));
write_coord(floatround(Origin[2]));
write_short(BloodSpray);
write_short(BloodDrop);
write_byte(BloodColor);
write_byte(min(max(3, Amount/10), 16));
message_end();
}
}
}
stock velocity_to_aim(id, Float:Origin[3], Speed, Float:Velocity[3]) {
new Float:AimOrigin[3]
fm_get_aim_origin(id, AimOrigin)
Velocity[0] = AimOrigin[0] - Origin[0]
Velocity[1] = AimOrigin[1] - Origin[1]
Velocity[2] = AimOrigin[2] - Origin[2]
new Float:X
X = floatsqroot(Speed*Speed / (Velocity[0]*Velocity[0] + Velocity[1]*Velocity[1] + Velocity[2]*Velocity[2]))
Velocity[0] *= X
Velocity[1] *= X
Velocity[2] *= X
}
stock set_weapon_anim(id, anim) {
if(is_user_connected(id)) {
set_pev(id, pev_weaponanim, anim);
message_begin(MSG_ONE, SVC_WEAPONANIM, _, id);
write_byte(anim);
write_byte(pev(id, pev_body));
message_end();
}
}
stock ColorChat(const id, const input[], any:...) {
new count = 1, players[32], msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4");
replace_all(msg, 190, "!y", "^1");
replace_all(msg, 190, "!t", "^3");
if(id) players[0] = id;
else get_players(players, count, "ch"); {
for(new i = 0; i < count; i++) {
if(is_user_connected(players[i])) {
message_begin(MSG_ONE_UNRELIABLE, MSGID_SayText, _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}