Ola queria saber como faço para meu NPC dar packs?
NPC ALIEN
NPC Witch
NPC ALIEN
Código:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include < xs >
#define NAME "AlienBoss Special For Zombie-Mod.Ru"
#define VERSION "Public"
#define AUTHOR "Alexander.3 / Edit: Optimist"
const alien_hp = 25000
const boss_speed = 200
const Float:prepare_time = 15.0
const dmg_attack = 50
const dmg_ms = 50
const dmg_sw = 50
static Float:Origin[3]
static g_Alien
static g_BossTarget
static VictimID
static Float:g_Health
static Ability
new const Resource[][] = {
"models/npc/alien/alien.mdl",
"sprites/blood.spr",
"sprites/bloodspray.spr",
"sprites/npc/hp.spr",
"sprites/shockwave.spr", // 4
"sprites/npc/alien/fluxing.spr" // 5
}
new const g_AlienSound[][] =
{
"zombie_plague/boss_death.wav",
"zombie_plague/boss_dash.wav",
"zombie_plague/boss_swing.wav",
"zombie_plague/boss_shokwave.wav"
}
new const g_CountSound[][] =
{
"zombie_plague/vox/1.wav",
"zombie_plague/vox/2.wav",
"zombie_plague/vox/3.wav",
"zombie_plague/vox/4.wav",
"zombie_plague/vox/5.wav",
"zombie_plague/vox/6.wav",
"zombie_plague/vox/7.wav",
"zombie_plague/vox/8.wav",
"zombie_plague/vox/9.wav",
"zombie_plague/vox/10.wav"
}
static g_Resource[sizeof Resource]
enum {
IDLE,
WALK,
MS,
ATTACK,
SW
}
public plugin_precache()
{
new i;
for(i = 0 ; i < sizeof g_CountSound ; i++)
precache_sound(g_CountSound[i]);
for(i = 0 ; i < sizeof g_AlienSound ; i++)
precache_sound(g_AlienSound[i]);
for(new i; i <= charsmax(Resource); i++)
g_Resource[i] = precache_model(Resource[i])
}
public plugin_init() {
register_plugin(NAME, VERSION, AUTHOR)
register_clcmd("say /create", "create", ADMIN_RCON)
register_clcmd("say /spawn", "spawn", ADMIN_RCON)
register_think("AlienBossik", "Think_Boss")
register_think("HP", "Think_HP")
register_touch("AlienBossik", "player", "Touch_Boss")
RegisterHam(Ham_TakeDamage, "info_target", "TakeDamage", ADMIN_RCON)
RegisterHam(Ham_TraceAttack, "info_target", "TraceAttack", ADMIN_RCON)
}
public RandomAbility(taskid) {
if (Ability != WALK)
return
switch(random(2)) {
case 0: Ability = MS
case 1: Ability = SW
}
}
public create(id)
if (get_user_flags(id) & ADMIN_RCON)
{
pev(id, pev_origin, Origin)
}
public spawn(id)
{
if (get_user_flags(id) & ADMIN_RCON)
{
g_Alien = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
new HPspr = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
engfunc(EngFunc_SetModel, g_Alien, Resource[0])
engfunc(EngFunc_SetSize, g_Alien, { -32.0, -32.0, -36.0 }, { 32.0, 32.0, 96.0 })
engfunc(EngFunc_SetOrigin, g_Alien, Origin)
set_pev(g_Alien, pev_classname, "AlienBossik")
set_pev(g_Alien, pev_solid, SOLID_BBOX)
set_pev(g_Alien, pev_movetype, MOVETYPE_PUSHSTEP)
set_pev(g_Alien, pev_takedamage, DAMAGE_NO)
set_pev(g_Alien, pev_health, float(alien_hp))
set_pev(g_Alien, pev_deadflag, DEAD_NO)
set_pev(g_Alien, pev_nextthink, get_gametime() + prepare_time)
Ability = IDLE
Anim(g_Alien, 2)
static Float:Origin[3]
pev(g_Alien, pev_origin, Origin)
Origin[2] += 200.0
engfunc(EngFunc_SetOrigin, HPspr, Origin)
engfunc(EngFunc_SetModel, HPspr, Resource[3])
entity_set_float(HPspr, EV_FL_scale, 0.5)
set_pev(HPspr, pev_classname, "HP")
set_pev(HPspr, pev_solid, SOLID_NOT)
set_pev(HPspr, pev_movetype, MOVETYPE_NOCLIP)
set_pev(HPspr, pev_frame, 100.0)
set_pev(HPspr, pev_nextthink, get_gametime() + prepare_time)
}
}
public Think_Boss(Ent)
{
if (pev(Ent, pev_deadflag) == DEAD_DYING)
return
static bool:one
switch ( Ability ) {
case IDLE: {
Ability = WALK
set_task(10.0, "RandomAbility", 1337, _, _, "b")
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
return
}
case WALK: {
static Float:Origin[3], Float:Origin2[3], Float:Vector[3], Float:Angle[3]
if (!is_user_alive(g_BossTarget)) {
g_BossTarget = GetRandomAlive(random_num(1, GetAliveCount()))
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
return
}
if (one) {
set_pev(Ent, pev_movetype, MOVETYPE_PUSHSTEP)
Anim(Ent, 3)
one = false
}
pev(Ent, pev_origin, Origin)
pev(g_BossTarget, pev_origin, Origin2)
xs_vec_sub(Origin2, Origin, Vector)
vector_to_angle(Vector, Angle)
new Float:num = floatsqroot(float(boss_speed)*float(boss_speed) / (Vector[0]*Vector[0] + Vector[1]*Vector[1] + Vector[2]*Vector[2]))
Vector[0] *= num
Vector[1] *= num
Vector[2] ? (Vector[2] = 0.0) : (Vector[2] *= num)
set_pev(Ent, pev_velocity, Vector)
Angle[0] = 0.0
Angle[2] = 0.0
set_pev(Ent, pev_angles, Angle)
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
return
}
case ATTACK: {
static num
switch (num) {
case 0: {
Anim(Ent, 6)
num++
set_pev(Ent, pev_nextthink, get_gametime() + 1.0)
return
}
case 1: {
static Float:OriginA[3], Float:OriginA2[3], Float:LenA, Float:Vector[3], Float:Velocity[3]
pev(g_Alien, pev_origin, OriginA)
pev(VictimID, pev_origin, OriginA2)
xs_vec_sub(OriginA2, OriginA, Velocity)
xs_vec_sub(OriginA, OriginA2, Vector)
LenA = xs_vec_len(Vector)
if (LenA <= 170) {
xs_vec_normalize(Velocity, Velocity)
Velocity[2] = 0.5
xs_vec_mul_scalar(Velocity, 1000.0, Velocity)
ExecuteHamB(Ham_TakeDamage, VictimID, 0, VictimID, float(dmg_attack), DMG_BULLET)
ScreenFade(VictimID, 3, {255, 0, 0}, 120)
ScreenShake(VictimID)
set_pev(VictimID, pev_velocity, Velocity)
emit_sound(Ent, CHAN_VOICE, g_AlienSound[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
}
num = 0
one = true
Ability = WALK
set_pev(Ent, pev_nextthink, get_gametime() + 0.2)
}
case MS: {
static num, Float:Origin[3], Float:Origin2[3], Float:Vector[3], Float:Angle[3]
switch ( num ) {
case 0: {
new MS_Attack = GetRandomAlive(random_num(1, GetAliveCount()))
pev(MS_Attack, pev_origin, Origin)
pev(Ent, pev_origin, Origin2)
xs_vec_sub(Origin, Origin2, Vector)
vector_to_angle(Vector, Angle)
xs_vec_normalize(Vector, Vector)
xs_vec_mul_scalar(Vector, 2000.0, Vector)
Angle[0] = 0.0
Angle[2] = 0.0
Vector[2] = 0.0
set_pev(Ent, pev_angles, Angle)
set_pev(Ent, pev_movetype, MOVETYPE_NONE)
Anim(Ent, 7)
set_pev(Ent, pev_nextthink, get_gametime() + 1.0)
num++
return
}
case 1: {
set_pev(Ent, pev_movetype, MOVETYPE_FLY)
set_pev(Ent, pev_velocity, Vector)
set_pev(Ent, pev_nextthink, get_gametime() + 1.0)
num++
return
}
}
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
num = 0
Ability = WALK
one = true
return
}
case SW: {
static num, FluxSpr, Float:Origin[3], sw_random
switch ( num ) {
case 0: {
sw_random = random(3)
Anim(Ent, 2)
FluxSpr = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
pev(Ent, pev_origin, Origin)
Origin[2] += 70
engfunc(EngFunc_SetOrigin, FluxSpr, Origin)
engfunc(EngFunc_SetModel, FluxSpr, Resource[5])
set_pev(FluxSpr, pev_solid, SOLID_NOT)
set_pev(FluxSpr, pev_movetype, MOVETYPE_NOCLIP)
switch(sw_random) {
case 0: {
set_rendering(FluxSpr, kRenderFxFadeSlow, 255, 0, 0, kRenderTransAdd, 255)
set_rendering(Ent, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 30)
}
case 1: {
set_rendering(FluxSpr, kRenderFxFadeSlow, 255, 255, 0, kRenderTransAdd, 255)
set_rendering(Ent, kRenderFxGlowShell, 255, 255, 0, kRenderNormal, 30)
}
case 2: {
set_rendering(FluxSpr, kRenderFxFadeSlow, 0, 0, 255, kRenderTransAdd, 255)
set_rendering(Ent, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 30)
}
}
set_pev(FluxSpr, pev_framerate, 5.0)
dllfunc(DLLFunc_Spawn, FluxSpr)
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
num++
return
}
case 1..10: {
for(new id = 1; id <= get_maxplayers(); id++) {
if (!is_user_alive(id))
continue
static Float:OriginSW[3], Float:OriginSW2[3], Float:Vector[3]
pev(Ent, pev_origin, OriginSW)
pev(id, pev_origin, OriginSW2)
xs_vec_sub(OriginSW, OriginSW2, Vector)
xs_vec_normalize(Vector, Vector)
xs_vec_mul_scalar(Vector, 800.0, Vector)
set_pev(id, pev_velocity, Vector)
set_pev(Ent, pev_nextthink, get_gametime() + 0.2)
num++
return
}
}
case 11: {
engfunc(EngFunc_RemoveEntity, FluxSpr)
Anim(Ent, 5)
set_pev(Ent, pev_nextthink, get_gametime() + 2.2)
num++
return
}
case 12: {
static Float:Orig[3]
pev(Ent, pev_origin, Orig)
set_rendering(Ent)
switch (sw_random) {
case 0: ShockWave(Orig, 5, 35, 1000.0, {255, 0, 0}) // 450
case 1: ShockWave(Orig, 5, 35, 1000.0, {255, 255, 0})
case 2: ShockWave(Orig, 5, 35, 1000.0, {0, 0, 255})
}
for(new id = 1; id <= get_maxplayers(); id++) {
if (!is_user_alive(id))
continue
if (pev(id, pev_flags) & FL_ONGROUND) {
static Float:gOrigin[3], Float:Vec[3], Float:Len
pev(id, pev_origin, gOrigin)
xs_vec_sub(Orig, gOrigin, Vec)
Len = xs_vec_len(Vec)
if (Len <= 450.0) {
switch (sw_random) {
case 0: user_kill(id)
case 1: {
ScreenFade(id, 5, {255, 0, 0}, 120)
ExecuteHamB(Ham_TakeDamage, id, 0, id, float(dmg_sw), DMG_SONIC)
ScreenShake(id)
}
case 2: {
client_cmd(id, "drop")
ScreenShake(id)
}
}
}
}
}
Ability = WALK
one = true
num = 0
set_pev(Ent, pev_nextthink, get_gametime() + 0.2)
return
}
}
}
}
}
public Think_HP(Ent) {
static Float:Origin[3], num
pev(g_Alien, pev_origin, Origin)
Origin[2] += 200.0
set_pev(Ent, pev_origin, Origin)
switch ( num ) {
case 0: {
Anim(g_Alien, 3)
set_pev(g_Alien, pev_takedamage, DAMAGE_YES)
num++
}
case 1: {
static Float:frame
frame = g_Health * 100.0 / float(alien_hp)
if (frame)
set_pev(Ent, pev_frame, frame)
if (pev(g_Alien, pev_deadflag) == DEAD_DYING) {
engfunc(EngFunc_RemoveEntity, Ent)
return
}
}
}
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
}
public TraceAttack(victim, attacker, Float:damage, Float:direction[3], th, dt) {
static Float:End[3], ClassName[32]
pev(victim, pev_classname, ClassName, charsmax(ClassName))
if (equal(ClassName, "AlienBossik")) {
get_tr2(th, TR_vecEndPos, End)
Blood(End)
}
}
public TakeDamage(victim, weapon, attacker, Float:damage, damagetype) {
static ClassName[32]
pev(victim, pev_classname, ClassName, charsmax(ClassName))
if (equal(ClassName, "AlienBossik")) {
pev(victim, pev_health, g_Health)
if (g_Health <= damage) {
Anim(victim, 1)
set_pev(victim, pev_movetype, MOVETYPE_FLY)
set_pev(victim, pev_solid, SOLID_NOT)
set_pev(victim, pev_velocity, {0.0, 0.0, 0.0})
set_pev(victim, pev_deadflag, DEAD_DYING)
remove_task(1337)
return HAM_SUPERCEDE
}
}
return HAM_HANDLED
}
public Touch_Boss(Ent, WorldEnt) {
if (Ability == MS) {
static victim = -1, Float:Origin[3]
pev(Ent, pev_origin, Origin)
while((victim = engfunc(EngFunc_FindEntityInSphere, victim, Origin, 400.0)) != 0) {
if (!is_user_alive(victim))
continue
ExecuteHamB(Ham_TakeDamage, victim, 0, victim, float(dmg_ms), DMG_BULLET)
}
}
if (Ability == WALK) {
Ability = ATTACK
VictimID = WorldEnt
}
}
stock Blood(Float:Orig[3]) {
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BLOODSPRITE);
engfunc(EngFunc_WriteCoord, Orig[0])
engfunc(EngFunc_WriteCoord, Orig[1])
engfunc(EngFunc_WriteCoord, Orig[2])
write_short(g_Resource[1])
write_short(g_Resource[2])
write_byte(218)
write_byte(random_num(1, 2))
message_end();
}
stock Anim(ent, sequence) {
set_pev(ent, pev_sequence, sequence)
set_pev(ent, pev_animtime, halflife_time())
set_pev(ent, pev_framerate, 1.0)
}
stock ShockWave(Float:Orig[3], Life, Width, Float:Radius, Color[3]) {
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Orig, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, Orig[0]) // x
engfunc(EngFunc_WriteCoord, Orig[1]) // y
engfunc(EngFunc_WriteCoord, Orig[2]-40.0) // z
engfunc(EngFunc_WriteCoord, Orig[0]) // x axis
engfunc(EngFunc_WriteCoord, Orig[1]) // y axis
engfunc(EngFunc_WriteCoord, Orig[2]+Radius) // z axis
write_short(g_Resource[4]) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(Life) // life (4)
write_byte(Width) // width (20)
write_byte(0) // noise
write_byte(Color[0]) // red
write_byte(Color[1]) // green
write_byte(Color[2]) // blue
write_byte(255) // brightness
write_byte(0) // speed
message_end()
}
stock ScreenFade(id, Timer, Colors[3], Alpha) {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, id);
write_short((1<<12) * Timer)
write_short(1<<12)
write_short(0)
write_byte(Colors[0])
write_byte(Colors[1])
write_byte(Colors[2])
write_byte(Alpha)
message_end()
}
stock ScreenShake(id) {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, id);
write_short(1<<14)
write_short(1<<12)
write_short(2<<12)
message_end();
}
GetRandomAlive(target_index) { // :3
new iAlive
for (new id = 1; id <= get_maxplayers(); id++) {
if (is_user_alive(id)) iAlive++
if (iAlive == target_index) return id
}
return -1
}
GetAliveCount() { // ^^
new iAlive
for (new id = 1; id <= get_maxplayers(); id++) if (is_user_alive(id)) iAlive++
return iAlive
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par }
*/
Código:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#define PLUGIN "NPC"
#define VERSION "1.0"
#define AUTHOR "Dias"
#define NPC_CLASSNAME "witch"
#define NPC_HEALTH 1000.0
#define TASK_CRY 11111
#define TASK_STARTATTACK 11112
#define TASK_ATTACKING 11113
#define TASK_AURA 11114
#define MAX_WITCH 3
const MAX_NPC = 512
new npc_modelindex, g_hamnpc, Float:g_myorigin[3], g_ena
new const npc_model[] = "models/player/witch_npc/witch_npc.mdl"
new npc_victim[MAX_NPC]
new g_think[MAX_NPC], g_madness[MAX_NPC]
new cache_blood, cache_bloodspray
// spawns & way points
new const SPAWNS_FILE[] = "%s/npc_witch/%s.cfg"
const MAX_SPAWNS = 128
new Float:g_spawns[MAX_SPAWNS][3], g_total_spawns
enum
{
THINK_DEATH = 1,
THINK_REMOVE
}
new const witch_cry[][] = {
"npc_witch/witch_llora_1.wav",
"npc_witch/witch_llora_2.wav",
"npc_witch/witch_llora_3.wav"
}
new const witch_madness[][] = {
"npc_witch/female_ls_d_madscream01.wav",
"npc_witch/female_ls_d_madscream02.wav",
"npc_witch/female_ls_d_madscream03.wav"
}
new const witch_startattack[][] = {
"npc_witch/female_distantscream1.wav",
"npc_witch/female_distantscream2.wav"
}
new const witch_death[][] = {
"npc_witch/female_death_1.wav",
"npc_witch/headshot_death_1.wav",
"npc_witch/headshot_death_2.wav",
"npc_witch/headshot_death_3.wav"
}
new const witch_pain[][] = {
"npc_witch/witch_pain_1.wav",
"npc_witch/witch_pain_2.wav",
"npc_witch/witch_pain_3.wav"
}
new const killed_by_witch[] = "npc_witch/killed_by_witch.wav"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /witch_criar", "event_newround")
register_clcmd("say /witch_nacer", "get_origin")
}
public plugin_precache()
{
npc_modelindex = engfunc(EngFunc_PrecacheModel, npc_model)
cache_blood = engfunc(EngFunc_PrecacheModel, "sprites/blood.spr")
cache_bloodspray = engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr")
new i
for(i = 0; i < sizeof(witch_cry); i++)
engfunc(EngFunc_PrecacheSound, witch_cry[i])
for(i = 0; i < sizeof(witch_madness); i++)
engfunc(EngFunc_PrecacheSound, witch_madness[i])
for(i = 0; i < sizeof(witch_startattack); i++)
engfunc(EngFunc_PrecacheSound, witch_startattack[i])
for(i = 0; i < sizeof(witch_death); i++)
engfunc(EngFunc_PrecacheSound, witch_death[i])
for(i = 0; i < sizeof(witch_pain); i++)
engfunc(EngFunc_PrecacheSound, witch_pain[i])
engfunc(EngFunc_PrecacheSound, killed_by_witch)
load_spawn_points()
}
public event_newround(id)
{
create_npc()
client_print(id, print_chat, "Pronto")
}
stock collect_spawn(Float:origin[3])
{
for (new i=1; i<=g_total_spawns*3; i++)
{
origin = g_spawns[random(g_total_spawns)]
if (check_spawn(origin)) return 1;
}
return 0;
}
stock check_spawn(Float:origin[3])
{
new Float:originE[3], Float:origin1[3], Float:origin2[3]
new ent = -1
while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", NPC_CLASSNAME)) != 0)
{
pev(ent, pev_origin, originE)
// xoy
origin1 = origin
origin2 = originE
origin1[2] = origin2[2] = 0.0
if (vector_distance(origin1, origin2) <= 2 * 16.0)
{
// oz
origin1 = origin
origin2 = originE
origin1[0] = origin2[0] = origin1[1] = origin2[1] = 0.0
if (vector_distance(origin1, origin2) <= 36.0) return 0;
}
}
return 1;
}
// load spawn points
load_spawn_points()
{
// Check for spawns points of the current map
new cfgdir[32], mapname[32], filepath[100], linedata[64]
get_configsdir(cfgdir, charsmax(cfgdir))
get_mapname(mapname, charsmax(mapname))
formatex(filepath, charsmax(filepath), SPAWNS_FILE, cfgdir, mapname)
// Load spawns points
if (file_exists(filepath))
{
new file = fopen(filepath,"rt"), row[4][6]
while (file && !feof(file))
{
fgets(file, linedata, charsmax(linedata))
// invalid spawn
if(!linedata[0] || str_count(linedata,' ') < 2) continue;
// get spawn point data
parse(linedata,row[0],5,row[1],5,row[2],5,row[3],5)
// origin
if (g_total_spawns<MAX_SPAWNS)
{
g_spawns[g_total_spawns][0] = floatstr(row[1])
g_spawns[g_total_spawns][1] = floatstr(row[2])
g_spawns[g_total_spawns][2] = floatstr(row[3])
g_total_spawns++
}
}
if (file) fclose(file)
}
}
stock str_count(const str[], searchchar)
{
new count, i, len = strlen(str)
for (i = 0; i <= len; i++)
{
if(str[i] == searchchar)
count++
}
return count;
}
public get_origin(id)
{
g_ena = 1
pev(id, pev_origin, g_myorigin)
}
public create_npc()
{
new ent = create_entity("info_target")
dllfunc(DLLFunc_Spawn, ent)
entity_set_string(ent, EV_SZ_classname, NPC_CLASSNAME)
static Float:Origin[3]
collect_spawn(Origin)
if(g_ena)
{
entity_set_origin(ent, g_myorigin)
} else {
entity_set_origin(ent, Origin)
}
set_pev(ent, pev_health, NPC_HEALTH)
entity_set_model(ent, npc_model)
entity_set_int(ent, EV_INT_modelindex, npc_modelindex)
entity_set_int(ent, EV_INT_solid, SOLID_SLIDEBOX)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY)
entity_set_float(ent, EV_FL_animtime, get_gametime())
entity_set_float(ent, EV_FL_framerate,1.0)
entity_set_float(ent, EV_FL_gravity, 1.0)
entity_set_float(ent, EV_FL_takedamage, 1.0)
entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.1)
new Float:maxs[3] = {16.0,16.0,36.0}
new Float:mins[3] = {-16.0,-16.0,-36.0}
entity_set_size(ent, mins, maxs)
entity_set_byte(ent, EV_BYTE_controller1, 125)
entity_set_byte(ent, EV_BYTE_controller2, 125)
entity_set_byte(ent, EV_BYTE_controller3, 125)
entity_set_byte(ent, EV_BYTE_controller4, 125)
set_task(0.1, "make_aura", ent+TASK_AURA, _, _, "b")
g_madness[ent] = 0
g_think[ent] = 0
npc_victim[ent] = 0
drop_to_floor(ent)
set_task(5.0, "witch_do_cry", ent+TASK_CRY, _, _, "b")
if (!g_hamnpc)
{
RegisterHamFromEntity(Ham_TakeDamage, ent, "fw_TakeDamage")
RegisterHamFromEntity(Ham_Think, ent, "fw_think")
RegisterHamFromEntity(Ham_Touch, ent, "fw_touch")
g_hamnpc = 1
}
}
public witch_do_cry(ent)
{
ent -= TASK_CRY
if(g_think[ent] == THINK_DEATH || g_think[ent] == THINK_REMOVE || g_madness[ent] != 0)
{
remove_task(ent+TASK_CRY)
return
}
emit_sound(ent, CHAN_AUTO, witch_cry[random_num(0, charsmax(witch_cry))], 1.0, ATTN_NORM, 0, PITCH_NORM)
}
public make_aura(ent)
{
ent -= TASK_AURA
if(g_think[ent] == THINK_DEATH || g_think[ent] == THINK_REMOVE)
{
remove_task(ent+TASK_AURA)
return
}
static Float:origin[3]
pev(ent, pev_origin, origin)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(27)
write_coord(floatround(origin[0]))
write_coord(floatround(origin[1]))
write_coord(floatround(origin[2]))
write_byte(10)
write_byte(255)
write_byte(0)
write_byte(0)
write_byte(100)
write_byte(60)
message_end()
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if (victim == attacker)
return HAM_IGNORED
if (!pev_valid(victim) || !pev_valid(attacker))
return HAM_IGNORED
if (is_user_connected(victim) && is_user_connected(attacker))
return HAM_SUPERCEDE
if(zp_get_user_zombie(attacker))
return FMRES_IGNORED
new classname[32]
pev(victim, pev_classname, classname, charsmax(classname))
if (equal(classname, NPC_CLASSNAME))
{
if (g_think[victim] == THINK_DEATH || g_think[victim] == THINK_REMOVE) return HAM_SUPERCEDE
// get aim
new aimOrigin[3], target, body
get_user_origin(attacker, aimOrigin, 3)
get_user_aiming(attacker, target, body)
// fix hit body damage
if (!(damage_type & DMG_BULLET)) damage = float(get_damage_body(body, damage))
// set new damage
SetHamParamFloat(4, damage)
// create block sprites
if (damage_type & DMG_BULLET)
create_blood(aimOrigin)
emit_sound(victim, CHAN_AUTO, witch_pain[random_num(0, charsmax(witch_pain))], 1.0, ATTN_NORM, 0, PITCH_NORM)
// NPC die
if (0.0 < pev(victim, pev_health) <= damage)
{
set_pev(victim, pev_health, 0.0)
static Float:reset[3]
entity_set_size(victim, reset, reset)
entity_set_vector(victim, EV_VEC_velocity, reset)
set_anim(victim, 128)
emit_sound(victim, CHAN_AUTO, witch_death[random_num(0, charsmax(witch_death))], 1.0, ATTN_NORM, 0, PITCH_NORM)
g_think[victim] = THINK_DEATH
return HAM_SUPERCEDE
}
else
{
set_anim(victim, 127)
if(!g_madness[victim])
{
npc_victim[victim] = attacker
static name[32]
get_user_name(attacker, name, sizeof(name))
client_print(0, print_chat, "%s Mexeu com a Witch !!", name)
g_madness[victim] = 2
emit_sound(victim, CHAN_AUTO, witch_startattack[random_num(0, charsmax(witch_startattack))], 1.0, ATTN_NORM, 0, PITCH_NORM)
set_task(3.0, "start_attack", victim+TASK_STARTATTACK)
set_task(1.5, "witch_do_madness", victim+TASK_ATTACKING, _, _, "b")
}
}
}
return HAM_IGNORED
}
public start_attack(ent)
{
ent -= TASK_STARTATTACK
g_madness[ent] = 1
}
public witch_do_madness(ent)
{
ent -= TASK_ATTACKING
if(g_think[ent] == THINK_DEATH || g_think[ent] == THINK_REMOVE || g_madness[ent] != 1)
{
remove_task(ent+TASK_ATTACKING)
return
}
emit_sound(ent, CHAN_AUTO, witch_madness[random_num(0, charsmax(witch_madness))], 1.0, ATTN_NORM, 0, PITCH_NORM)
}
public fw_think(ent)
{
if(g_think[ent] == THINK_DEATH || g_think[ent] == THINK_REMOVE)
return HAM_IGNORED
if(g_madness[ent] == 2)
{
set_anim(ent, 1)
} else if(g_madness[ent] == 1) {
static victim
victim = npc_victim[ent]
static Float:Origin[3], Float:VicOrigin[3], Float:distance
pev(ent, pev_origin, Origin)
pev(victim, pev_origin, VicOrigin)
distance = get_distance_f(Origin, VicOrigin)
if(is_user_alive(victim))
{
if(distance <= 60.0)
{
new Float:Ent_Origin[3], Float:Vic_Origin[3]
pev(ent, pev_origin, Ent_Origin)
pev(victim, pev_origin, Vic_Origin)
witch_attack(ent, victim)
} else {
set_anim(ent, 4)
new Float:Ent_Origin[3], Float:Vic_Origin[3]
pev(ent, pev_origin, Ent_Origin)
pev(victim, pev_origin, Vic_Origin)
npc_turntotarget(ent, Ent_Origin, victim, Vic_Origin)
hook_ent(ent, victim)
entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.5)
}
} else {
g_madness[ent] = 0
set_task(5.0, "witch_do_cry", ent+TASK_CRY, _, _, "b")
remove_task(ent+TASK_ATTACKING)
}
} else if(!g_madness[ent]) {
set_anim(ent, 0)
}
entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.1)
return HAM_HANDLED
}
public fw_touch(witch, id)
{
if(g_think[witch] == THINK_DEATH || g_think[witch] == THINK_REMOVE)
return HAM_IGNORED
if(!is_user_alive(id))
return HAM_IGNORED
if(g_madness[witch] != 1)
return HAM_IGNORED
set_anim(witch, 85)
user_kill(id)
emit_sound(id, CHAN_AUTO, killed_by_witch, 1.0, ATTN_NORM, 0, PITCH_NORM)
static name[32]
get_user_name(id, name, sizeof(name))
client_print(0, print_chat, "%s Foi assasinado pela Witch !!", name)
return HAM_HANDLED
}
public witch_attack(ent, victim)
{
set_anim(ent, 85)
emit_sound(victim, CHAN_AUTO, killed_by_witch, 1.0, ATTN_NORM, 0, PITCH_NORM)
user_kill(victim)
static name[32]
get_user_name(victim, name, sizeof(name))
client_print(0, print_chat, "%s Foi assasinado pela Witch !!", name)
}
stock set_anim(ent, anim)
{
if (pev(ent, pev_sequence) != anim)
{
entity_set_float(ent, EV_FL_animtime, get_gametime())
entity_set_int(ent, EV_INT_sequence, anim)
}
}
stock create_blood(const origin[3])
{
// Show some blood :)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BLOODSPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(cache_bloodspray)
write_short(cache_blood)
write_byte(75)
write_byte(5)
message_end()
}
stock get_damage_body(body, Float:damage)
{
switch (body)
{
case HIT_HEAD: damage *= 4.0
case HIT_STOMACH: damage *= 1.25
case HIT_LEFTLEG: damage *= 0.75
case HIT_RIGHTLEG: damage *= 0.75
default: damage *= 1.0
}
return floatround(damage);
}
stock npc_turntotarget(ent, Float:Ent_Origin[3], target, Float:Vic_Origin[3])
{
if(target)
{
new Float:newAngle[3]
entity_get_vector(ent, EV_VEC_angles, newAngle)
new Float:x = Vic_Origin[0] - Ent_Origin[0]
new Float:z = Vic_Origin[1] - Ent_Origin[1]
new Float:radians = floatatan(z/x, radian)
newAngle[1] = radians * (180 / 3.14)
if (Vic_Origin[0] < Ent_Origin[0])
newAngle[1] -= 180.0
entity_set_vector(ent, EV_VEC_angles, newAngle)
}
}
stock hook_ent(ent, victim)
{
static Float:fl_Velocity[3]
static Float:VicOrigin[3], Float:EntOrigin[3]
static Float:Speed
pev(ent, pev_origin, EntOrigin)
pev(victim, pev_origin, VicOrigin)
Speed = 400.0
static Float:distance_f
distance_f = get_distance_f(EntOrigin, VicOrigin)
if (distance_f > 60.0)
{
new Float:fl_Time = distance_f / Speed
fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
} else {
fl_Velocity[0] = 0.0
fl_Velocity[1] = 0.0
fl_Velocity[2] = 0.0
}
entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
}