11/06/2019, 08:14 PM
(Última modificación: 11/06/2019, 08:17 PM por Reverant. Edited 1 time in total.)
Buenas, vi las cucurachas de Mario Ar.., y esta buenisimo para reirse un rato..
Pero hay manera de asignarle un valor X cuando individualmente las matas? Es decir una recompenza, como dinero.
Pero hay manera de asignarle un valor X cuando individualmente las matas? Es decir una recompenza, como dinero.
Código PHP:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#define PLUGIN "NPC Cucarachas"
#define VERSION "1.2"
const Float:SPEED = 120.0 // Velocidad
const Float:VIDA = 10.0 // Demasiada vida = cucarachas mutantes (?
const Float:SALTO = 200.0 // Maxima velocidad que puede obtener una cucaracha al saltar. (0.0 = no salta)
const Float:DAMAGE = 10.0 // Daño de la cuca agresiva
const Float:RADIO = 300.0 // Radio de vision de la cucaracha agresiva
const CANTIDAD_BLOOD = 4 // Cantidad de 'sangre' (?
#define USAR_GLOW // Elimina la linea si no quieres que las cucarachas tengan un glow.
new const CLASSNAME[] = "CUCARACHA";
new const MODEL[] = "models/roach.mdl";
new const SONIDO_SPLASH[] = "roach/rch_smash.wav";
new const SONIDO_DMG[] = "roach/rch_die.wav";
new const SONIDO_ATTACK[] = "roach/rch_walk.wav";
#pragma semicolon 1
enum _:SPRS
{
SPR_BLOOD = 0,
SPR_BLOODSPRAY
};
enum _:MODOS_CUCAS
{
MC_ESTUPIDA = 0,
MC_ASTUTA,
MC_AGRESIVA
};
const Float:TRACE_DIST = 20.0; //Bugfix
new g_model, g_reg, g_sprindex[SPRS];
public plugin_precache()
{
precache_sound(SONIDO_SPLASH);
precache_sound(SONIDO_DMG);
precache_sound(SONIDO_ATTACK);
g_model = precache_model(MODEL);
g_sprindex[SPR_BLOOD] = precache_model("sprites/blood.spr");
g_sprindex[SPR_BLOODSPRAY] = precache_model("sprites/bloodspray.spr");
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "Mario AR.");
register_clcmd("cuca", "clcmd_roach");
register_clcmd("say /cuca", "clcmd_cuca");
register_touch(CLASSNAME, "player", "fw_Touch");
register_think(CLASSNAME, "fw_Think");
register_event("HLTV", "event_HLTV", "a", "1=0", "2=0");
}
public clcmd_cuca(id)
{
new Float:origin[3];
entity_get_vector(id, EV_VEC_origin, origin);
origin[0] = Float:origin[0] + random_float(-50.0, 50.0);
origin[1] = Float:origin[1] + random_float(-50.0, 50.0);
create_roach(origin, MC_AGRESIVA);
return PLUGIN_HANDLED_MAIN;
}
public clcmd_roach(id)
{
new Float:origin[3];
entity_get_vector(id, EV_VEC_origin, origin);
origin[0] = Float:origin[0] + random_float(-50.0, 50.0);
origin[1] = Float:origin[1] + random_float(-50.0, 50.0);
new arg[2];
read_argv(1, arg, 1);
create_roach(origin, str_to_num(arg)-1);
return PLUGIN_HANDLED_MAIN;
}
public event_HLTV()
{
new ent = -1;
while ((ent = find_ent_by_class(ent, CLASSNAME)) > 0)
remove_entity(ent);
}
public fw_Think(ent)
{
if (!is_valid_ent(ent))
return PLUGIN_CONTINUE;
static Float:velocity[3], Float:origin[3], Float:originT[3];
static Float:spd, Float:lenght, Float:fraction, trace;
switch (entity_get_int(ent, EV_INT_iuser1))
{
case MC_ESTUPIDA:
{
spd = random_float(0.0, SPEED);
velocity[0] = random_num(0, 1) ? spd : -spd; // Por alguna razon, random() sale casi siempre 0, es mejor random_num
velocity[1] = random_num(0, 1) ? floatsqroot(SPEED*SPEED - spd*spd) : 0.0 - floatsqroot(SPEED*SPEED - spd*spd);
//velocity[2] = random(25) ? 0.0 : SALTO;
entity_set_vector(ent, EV_VEC_velocity, velocity);
vector_to_angle(velocity, velocity);
entity_set_vector(ent, EV_VEC_angles, velocity);
entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.4);
}
case MC_ASTUTA:
{
entity_get_vector(ent, EV_VEC_origin, origin);
entity_get_vector(ent, EV_VEC_velocity, velocity);
lenght = xs_vec_len(origin);
originT[0] = origin[0] + (TRACE_DIST * origin[0] / lenght);
originT[1] = origin[1] + (TRACE_DIST * origin[1] / lenght);
originT[2] = origin[2] + 2.0; // Bugfix
origin[0] = origin[0] - (2.0 * origin[0] / lenght);
origin[1] = origin[1] - (2.0 * origin[1] / lenght);
engfunc(EngFunc_TraceLine, origin, originT, IGNORE_MONSTERS, ent, trace);
get_tr2(trace, TR_flFraction, fraction);
if (fraction == 1.0)
{
velocity[0] = velocity[0] + random_float(-SPEED/4.0, SPEED/4.0);
velocity[1] = velocity[1] > 0.0 ? floatsqroot(SPEED*SPEED - spd*spd) : 0.0 - floatsqroot(SPEED*SPEED - spd*spd);
//velocity[2] = random(25) ? 0.0 : SALTO;
}
else
{
spd = random_float(0.0, SPEED/2.0);
velocity[0] = random_num(0, 1) ? spd : -spd; // Por alguna razon, random() sale casi siempre 0, es mejor random_num
velocity[1] = random_num(0, 1) ? floatsqroot(SPEED*SPEED - spd*spd) : 0.0 - floatsqroot(SPEED*SPEED - spd*spd);
//velocity[2] = random(25) ? 0.0 : SALTO;
}
entity_set_vector(ent, EV_VEC_velocity, velocity);
vector_to_angle(velocity, velocity);
entity_set_vector(ent, EV_VEC_angles, velocity);
entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.3);
}
case MC_AGRESIVA:
{
static victim;
entity_get_vector(ent, EV_VEC_origin, origin);
if ((victim = entity_get_int(ent, EV_INT_iuser2)) == -1)
{
victim = -1;
while ((victim = find_ent_in_sphere(victim, origin, RADIO)) > 0)
{
if (is_user_alive(victim))
break;
}
}
else
{
entity_set_int(ent, EV_INT_iuser2, --victim);
victim = 0;
}
if (!(1 <= victim <= 32))
{
entity_get_vector(ent, EV_VEC_velocity, velocity);
lenght = xs_vec_len(origin);
originT[0] = origin[0] + (TRACE_DIST * origin[0] / lenght);
originT[1] = origin[1] + (TRACE_DIST * origin[1] / lenght);
originT[2] = origin[2] + 2.0; // Bugfix
origin[0] = origin[0] - (2.0 * origin[0] / lenght);
origin[1] = origin[1] - (2.0 * origin[1] / lenght);
engfunc(EngFunc_TraceLine, origin, originT, IGNORE_MONSTERS, ent, trace);
get_tr2(trace, TR_flFraction, fraction);
if (fraction == 1.0)
{
velocity[0] = velocity[0] + random_float(-SPEED/4.0, SPEED/4.0);
velocity[1] = velocity[1] > 0.0 ? floatsqroot(SPEED*SPEED - spd*spd) : 0.0 - floatsqroot(SPEED*SPEED - spd*spd);
//velocity[2] = random(25) ? 0.0 : SALTO;
}
else
{
spd = random_float(0.0, SPEED/2.0);
velocity[0] = random_num(0, 1) ? spd : -spd; // Por alguna razon, random() sale casi siempre 0, es mejor random_num
velocity[1] = random_num(0, 1) ? floatsqroot(SPEED*SPEED - spd*spd) : 0.0 - floatsqroot(SPEED*SPEED - spd*spd);
//velocity[2] = random(25) ? 0.0 : SALTO;
}
entity_set_vector(ent, EV_VEC_velocity, velocity);
vector_to_angle(velocity, velocity);
entity_set_vector(ent, EV_VEC_angles, velocity);
}
else
{
entity_get_vector(victim, EV_VEC_origin, originT);
lenght = xs_vec_len(origin);
origin[0] = origin[0] - (2.0 * origin[0] / lenght);
origin[1] = origin[1] - (2.0 * origin[1] / lenght);
origin[2] = origin[2] - 1.0;
engfunc(EngFunc_TraceLine, origin, originT, IGNORE_MONSTERS, ent, trace);
get_tr2(trace, TR_flFraction, fraction);
if (fraction == 1.0)
{
velocity[0] = originT[0] - origin[0];
velocity[1] = originT[1] - origin[1];
velocity[2] = originT[2] - origin[2];
vector_to_angle(velocity, velocity);
entity_set_vector(ent, EV_VEC_angles, velocity);
angle_vector(velocity, ANGLEVECTOR_FORWARD, velocity);
xs_vec_normalize(velocity, velocity);
xs_vec_mul_scalar(velocity, SPEED, velocity);
if (get_distance_f(origin, originT) > 50.0)
velocity[2] = 0.0;
else
velocity[2] = SALTO;
entity_set_vector(ent, EV_VEC_velocity, velocity);
}
else
{
spd = random_float(0.0, SPEED/2.0);
velocity[0] = random_num(0, 1) ? spd : -spd; // Por alguna razon, random() sale casi siempre 0, es mejor random_num
velocity[1] = random_num(0, 1) ? floatsqroot(SPEED*SPEED - spd*spd) : 0.0 - floatsqroot(SPEED*SPEED - spd*spd);
//velocity[2] = random(25) ? 0.0 : SALTO;
entity_set_vector(ent, EV_VEC_velocity, velocity);
vector_to_angle(velocity, velocity);
entity_set_vector(ent, EV_VEC_angles, velocity);
}
}
entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.2);
}
}
return PLUGIN_CONTINUE;
}
public fw_Touch(touched, toucher)
{
if (!is_valid_ent(touched))
return PLUGIN_CONTINUE;
if (entity_get_int(touched, EV_INT_iuser1) == MC_AGRESIVA && entity_get_int(touched, EV_INT_iuser2) == -1 && is_user_alive(toucher))
{
ExecuteHam(Ham_TakeDamage, toucher, touched, touched, DAMAGE, DMG_SLASH);
emit_sound(touched, CHAN_VOICE, SONIDO_ATTACK, 1.0, ATTN_NORM, 0, PITCH_NORM);
entity_set_int(touched, EV_INT_iuser2, 10); // Delay para el proximo ataque
}
if (entity_get_int(touched, EV_INT_flags) & FL_ONGROUND)
{
static Float:origin[3];
entity_get_vector(touched, EV_VEC_origin, origin);
UTIL_BloodDrips(origin);
emit_sound(touched, CHAN_VOICE, SONIDO_SPLASH, 1.0, ATTN_NORM, 0, PITCH_NORM);
ExecuteHam(Ham_Killed, touched, toucher, 0);
}
return PLUGIN_CONTINUE;
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damagebits)
{
if (!is_valid_ent(victim))
return HAM_IGNORED;
emit_sound(victim, CHAN_VOICE, SONIDO_DMG, 1.0, ATTN_NORM, 0, PITCH_NORM);
static Float:origin[3];
entity_get_vector(victim, EV_VEC_origin, origin);
UTIL_BloodDrips(origin);
return HAM_IGNORED;
}
public fw_Killed(victim, attacker)
{
if (!is_valid_ent(victim))
return HAM_IGNORED;
new Float:origin[3], Float:direction[3];
entity_get_vector(victim, EV_VEC_origin, origin);
xs_vec_set(direction, random_float(-1.0, 1.0), random_float(-1.0, 1.0), random_float(0.0, 1.0));
FX_StreakSplash(origin, direction, 5, 16, 50, 200);
return HAM_IGNORED;
}
create_roach(Float:origin[3], modo)
{
new ent = create_entity("info_target");
entity_set_origin(ent, origin);
entity_set_string(ent, EV_SZ_classname, CLASSNAME);
entity_set_model(ent, MODEL);
entity_set_int(ent, EV_INT_movetype, MOVETYPE_BOUNCE);
entity_set_int(ent, EV_INT_solid, SOLID_SLIDEBOX);
// Un poco más grandes para que no sea tan jodido pisarlas...
entity_set_size(ent, Float:{ -2.0, -2.0, 0.0 }, Float:{ 2.0, 2.0, 1.0 });
entity_set_int(ent, EV_INT_modelindex, g_model);
entity_set_int(ent, EV_INT_sequence, 0);
entity_set_float(ent, EV_FL_animtime, get_gametime());
entity_set_float(ent, EV_FL_framerate, 1.0);
entity_set_float(ent, EV_FL_takedamage, 1.0);
entity_set_float(ent, EV_FL_health, VIDA);
entity_set_float(ent, EV_FL_gravity, 0.6);
entity_set_float(ent, EV_FL_friction, 0.8);
entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.1);
#if defined USAR_GLOW
static const RGB_COLORS[][3] =
{
{ 150, 170, 200 }, // Blanco
{ 255, 0, 0 }, // Rojo
{ 0, 255, 0 }, // Verde
{ 0, 0, 255 }, // Azul
{ 255, 255, 0 }, // Amarillo
{ 0, 250, 250 }, // Celeste
{ 170, 50, 100 }, // Magenta
{ 100, 50, 200 }, // Morado
{ 255, 150, 100 } // Naranja
};
new rdn = random(sizeof(RGB_COLORS));
set_rendering(ent, kRenderFxGlowShell, RGB_COLORS[rdn][0], RGB_COLORS[rdn][1], RGB_COLORS[rdn][2], kRenderNormal, 25);
#endif
if (!(MC_ESTUPIDA <= modo < MODOS_CUCAS))
modo = MC_ESTUPIDA;
entity_set_int(ent, EV_INT_iuser1, modo); // Indicador de cucaracha
drop_to_floor(ent);
if (!g_reg)
{
RegisterHamFromEntity(Ham_TakeDamage, ent, "fw_TakeDamage", 1);
RegisterHamFromEntity(Ham_Killed, ent, "fw_Killed", 1);
g_reg = 1;
}
}
// De HL Snarks
FX_StreakSplash( const Float:Origin[ 3 ], const Float:Direction[ 3 ], const Color, const Count, const Speed, const VelocityRange )
{
#define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) )
#define write_coord_f(%1) ( engfunc ( EngFunc_WriteCoord, %1 ) )
message_begin_f( MSG_PVS, SVC_TEMPENTITY, Origin, 0);
write_byte( TE_STREAK_SPLASH );
write_coord_f( Origin[ 0 ] );
write_coord_f( Origin[ 1 ] );
write_coord_f( Origin[ 2 ] );
write_coord_f( Direction[ 0 ] );
write_coord_f( Direction[ 1 ] );
write_coord_f( Direction[ 2 ] );
write_byte( min( Color, 255 ) );
write_short( Count );
write_short( Speed );
write_short( VelocityRange );// random velocity modifier
message_end();
}
UTIL_BloodDrips(Float:Origin[3])
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BLOODSPRITE);
engfunc(EngFunc_WriteCoord, Origin[0]);
engfunc(EngFunc_WriteCoord, Origin[1]);
engfunc(EngFunc_WriteCoord, Origin[2]);
write_short(g_sprindex[SPR_BLOOD]);
write_short(g_sprindex[SPR_BLOODSPRAY]);
write_byte(195);
write_byte(CANTIDAD_BLOOD);
message_end();
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang10250\\ f0\\ fs16 \n\\ par }
*/