#1 |
Les dejo este código que armé hace bastante, es una Scout mejorada, dispara mas rápido, al atacar crea un efecto droga en la victima y lanza un rayo láser en cada disparo, la velocidad de disparo se cambia desde aquí:
Los colores del rayo láser se configuran desde aquí:
Son colores RGB.
Si mal no recuerdo el efecto droga funcionaba algunas veces, tal vez mas tarde mejore un poco el código y arreglo sus problemas ^^
Código:
El model no lo tengo, así que lo cambian ustedes v:
Código PHP:
gCvarVelocidadDisparo = register_cvar("wd_velocidad_disparo", "0.1");
Los colores del rayo láser se configuran desde aquí:
Código PHP:
const LaserWeapon = 0;
const LaserWeapon1 = 255;
const LaserWeapon2 = 255;
Si mal no recuerdo el efecto droga funcionaba algunas veces, tal vez mas tarde mejore un poco el código y arreglo sus problemas ^^
Código:
Código PHP:
/* =========================================================================================== */
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
new const RegisterPlugin[][] = { "Weapon Drug", "1.0", "Skylar" };
/* =========================================================================================== */
#define weapon_drug "weapon_scout"
#define CSW_DRUG CSW_SCOUT
new bool: gWeaponDrug[33];
new Trie:gClassSprite;
new gLaser;
new gCvarVelocidadDisparo;
new const gModelWeapon[] = "models/WeaponDrug/vWeaponDrug.mdl";
const LaserWeapon = 0;
const LaserWeapon1 = 255;
const LaserWeapon2 = 255;
public plugin_precache()
{
gClassSprite = TrieCreate();
TrieSetCell(gClassSprite, "worldspawn", 1);
TrieSetCell(gClassSprite, "player", 1);
precache_model(gModelWeapon);
gLaser = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr");
}
public plugin_init()
{
register_plugin(RegisterPlugin[0], RegisterPlugin[1], RegisterPlugin[2]);
register_concmd("get_drug", "SetDrug");
register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0");
RegisterHam(Ham_TakeDamage, "player", "ham_TakeDamage");
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_scout", "ham_PrimaryAttack", 1);
RegisterHam(Ham_TraceAttack, "worldspawn", "ham_TraceAttack", true);
RegisterHam(Ham_TraceAttack, "player", "ham_TraceAttack", true);
RegisterHam(Ham_Item_Deploy, weapon_drug, "ham_Item_Deploy", true);
gCvarVelocidadDisparo = register_cvar("wd_velocidad_disparo", "0.1");
}
public client_putinserver(id) gWeaponDrug[id] = false;
public client_disconnect(id) gWeaponDrug[id] = false;
public SetDrug(id)
{
if (!is_user_alive(id)) return;
gWeaponDrug[id] = true;
give_item(id, weapon_drug);
cs_set_user_bpammo(id, CSW_DRUG, 90);
}
public event_RoundStart()
{
for(new id = 1 ; id <= get_maxplayers() ; id++)
{
if (!is_user_connected(id)) continue;
gWeaponDrug[id] = false;
}
}
public ham_TakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
{
if (attacker == victim || !is_user_connected(attacker)) return;
if (cs_get_user_team(attacker) == cs_get_user_team(victim)) return;
if (gWeaponDrug[attacker])
SetEffectDrug(victim);
}
public ham_PrimaryAttack(DrugWeapon)
{
new id = get_pdata_cbase(DrugWeapon, 41, 4);
if (!is_user_alive(id)) return HAM_IGNORED;
if (gWeaponDrug[id])
{
static Float:flRate;
flRate = get_pcvar_float(gCvarVelocidadDisparo);
set_pdata_float(DrugWeapon, 46, flRate, 4)
set_pdata_float(DrugWeapon, 47, flRate, 4);
set_pdata_float(DrugWeapon, 48, flRate, 4);
}
return HAM_IGNORED;
}
public ham_TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damage_type)
{
new gWeapon = get_user_weapon(attacker);
new Float:vecEndPos[3];
get_tr2(tracehandle, TR_vecEndPos, vecEndPos);
if (gWeapon == CSW_DRUG && gWeaponDrug[attacker])
{
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecEndPos, 0);
write_byte(TE_BEAMENTPOINT);
engfunc(EngFunc_WriteCoord, vecEndPos[0]);
engfunc(EngFunc_WriteCoord, vecEndPos[1]);
engfunc(EngFunc_WriteCoord, vecEndPos[2]);
write_short(gLaser);
write_byte(0);
write_byte(0);
write_byte(1);
write_byte(10);
write_byte(0);
write_byte(LaserWeapon);
write_byte(LaserWeapon1);
write_byte(LaserWeapon2);
write_byte(128);
write_byte(0);
message_end();
}
return HAM_HANDLED;
}
public ham_Item_Deploy(Weapon)
{
static gOwner; gOwner = get_weapon_ent_owner(Weapon);
if (!pev_valid(gOwner) || !is_user_alive(gOwner)) return;
static gWeaponD; gWeaponD= cs_get_weapon_id(Weapon);
if (gWeaponD == CSW_DRUG && gWeaponDrug[gOwner])
set_pev(gOwner, pev_viewmodel2, gModelWeapon);
else if (gWeaponD == CSW_DRUG || !gWeaponDrug[gOwner])
return;
}
public SetEffectDrug(id)
{
new gWeaponD = read_data(2);
if (gWeaponD == CSW_DRUG && gWeaponDrug[id])
{
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, id);
write_short((1<<12));
write_short(0);
write_short(0x0000);
write_byte(0);
write_byte(0);
write_byte(180);
write_byte(200);
message_end();
new Float:fVec[3]
fVec[0] = random_float(50.0, 150.0);
fVec[1] = random_float(50.0, 150.0);
fVec[2] = random_float(50.0, 150.0);
set_pev(id, pev_punchangle, fVec);
}
}
stock get_weapon_ent_owner( ent )
{
if (~pev_valid(ent) & 2) return -1;
return get_pdata_cbase(ent, 41, 4);
}
El model no lo tengo, así que lo cambian ustedes v: