Senior Member
Join Date: Jun 2014
Location: Morroco
|
04-09-2015
, 10:20
Re: Movetype_walk
|
#10
|
Quote:
Originally Posted by Shiina.Mashiro
maybe it's not your code but at least you must know which is the entity think part :/
btw try with MOVETYPE_STEP or MOVETYPE_PUSHSTEP, if the error still occur you can give me the entity think part
|
It's working with other MOVETYPES , STep , pushtep , fly , bounce etc .. but not WALK , here's the full code
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#define TASK_COOLDOWN 7208
#define TASK_REMOVE 8072
#define ID_REMOVE (taskid - TASK_REMOVE)
const MAX_SPAWN = 32
new g_cooldown
new g_spawncount
new g_dead[256]
new g_follow
new const g_NpcClassName[] = "ent_npc"
new const g_NpcModel[] = "models/narutomod/wall.mdl"
new const g_NpcSoundPain[][] =
{
"barney/ba_pain1.wav"
}
new const g_NpcSoundDeath[][] =
{
"barney/ba_die1.wav"
}
new spr_blood_drop, spr_blood_spray
public plugin_precache()
{
spr_blood_drop = precache_model("sprites/blood.spr")
spr_blood_spray = precache_model("sprites/bloodspray.spr")
new i
for(i = 0 ; i < sizeof g_NpcSoundPain ; i++) precache_sound(g_NpcSoundPain[i]);
for(i = 0 ; i < sizeof g_NpcSoundDeath ; i++) precache_sound(g_NpcSoundDeath[i]);
precache_model(g_NpcModel)
}
public plugin_init()
{
register_plugin("Bouncing Barney", "1.0", "Mazza")
register_clcmd("say /npc", "clcmd_npc")
register_clcmd("say /follow", "clcmd_follow")
RegisterHam(Ham_TakeDamage, "info_target", "npc_TakeDamage")
RegisterHam(Ham_Killed, "info_target", "npc_Killed")
RegisterHam(Ham_Think, "info_target", "npc_Think")
RegisterHam(Ham_TraceAttack, "info_target", "npc_TraceAttack")
}
public clcmd_npc(id)
{
if(g_cooldown) return PLUGIN_HANDLED;
if(g_spawncount >= MAX_SPAWN)
{
client_print(id, print_chat, "[EntTest] Max [%i] spawns has been reach.", MAX_SPAWN)
return PLUGIN_HANDLED;
}
g_cooldown = 1
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if(!pev_valid(ent)) return PLUGIN_HANDLED;
set_pev(ent, pev_classname, g_NpcClassName)
set_pev(ent, pev_netname, "Barney")
new Float: origin[3], Float: angle[3], Float: velocity[3]
pev(id, pev_origin, origin)
origin[2] += 80.0
engfunc(EngFunc_SetOrigin, ent, origin)
pev(id, pev_angles, angle)
angle[0] = 0.0
set_pev(ent, pev_angles, angle)
set_pev(ent, pev_takedamage, 1.0)
set_pev(ent, pev_health, 100.0)
set_pev(ent, pev_gravity, 1.0)
set_pev(ent, pev_movetype, MOVETYPE_PUSHSTEP)
set_pev(ent, pev_solid, SOLID_SLIDEBOX)
set_pev(ent, pev_controller_0, 125)
set_pev(ent, pev_controller_1, 125)
set_pev(ent, pev_controller_2, 125)
set_pev(ent, pev_controller_3, 125)
engfunc(EngFunc_SetModel, ent, g_NpcModel)
engfunc(EngFunc_SetSize, ent, {-12.0, -12.0, 0.0 }, { 12.0, 12.0, 75.0 })
velocity_by_aim(id, 800, velocity)
set_pev(ent, pev_velocity, velocity)
g_spawncount += 1
set_pev(ent, pev_nextthink, get_gametime() + 0.5)
set_task(1.0, "ResetCooldown", TASK_COOLDOWN)
return PLUGIN_HANDLED;
}
public clcmd_follow(id)
{
g_follow = id
return PLUGIN_HANDLED;
}
public npc_TraceAttack(iEnt, attacker, Float: damage, Float: direction[3], trace, damageBits)
{
if(!pev_valid(iEnt)) return;
new className[32]
pev(iEnt, pev_classname, className, charsmax(className))
if(!equali(className, g_NpcClassName)) return;
new Float: end[3]
get_tr2(trace, TR_vecEndPos, end)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BLOODSPRITE)
engfunc(EngFunc_WriteCoord, end[0])
engfunc(EngFunc_WriteCoord, end[1])
engfunc(EngFunc_WriteCoord, end[2])
write_short(spr_blood_spray)
write_short(spr_blood_drop)
write_byte(247) // color index
write_byte(random_num(1, 5)) // size
message_end()
}
public npc_TakeDamage(iEnt, inflictor, attacker, Float:damage, bits)
{
new className[32]
pev(iEnt, pev_classname, className, charsmax(className))
if(!equali(className, g_NpcClassName)) return;
Util_PlayAnimation(iEnt, random_num(13, 17), 1.25)
emit_sound(iEnt, CHAN_VOICE, g_NpcSoundPain[random(sizeof g_NpcSoundPain)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
public npc_Killed(iEnt)
{
new className[32]
pev(iEnt, pev_classname, className, charsmax(className))
if(!equali(className, g_NpcClassName)) return HAM_IGNORED;
g_dead[iEnt] = 1
Util_PlayAnimation(iEnt, random_num(25, 30))
set_pev(iEnt, pev_solid, SOLID_NOT)
emit_sound(iEnt, CHAN_VOICE, g_NpcSoundDeath[random(sizeof g_NpcSoundDeath)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
set_task(2.0, "RemoveDeadEntity", iEnt+TASK_REMOVE)
return HAM_SUPERCEDE;
}
public npc_Think(iEnt)
{
if(!pev_valid(iEnt)) return;
static className[32]
pev(iEnt, pev_classname, className, charsmax(className))
if(!equali(className, g_NpcClassName)) return;
if(g_dead[iEnt]) return;
if(is_user_alive(g_follow)) entity_set_aim(iEnt, g_follow);
set_pev(iEnt, pev_nextthink, get_gametime() + 0.5)
}
public ResetCooldown(taskid)
{
g_cooldown = 0
}
public RemoveDeadEntity(taskid)
{
if(!pev_valid(ID_REMOVE)) return;
engfunc(EngFunc_RemoveEntity, ID_REMOVE)
g_spawncount -= 1
g_dead[ID_REMOVE] = 0
}
entity_set_aim(ent, player)
{
static Float:origin[3], Float:ent_origin[3], Float:angles[3]
pev(player, pev_origin, origin)
pev(ent, pev_origin, ent_origin)
xs_vec_sub(origin, ent_origin, origin)
xs_vec_normalize(origin, origin)
vector_to_angle(origin, angles)
angles[0] = 0.0
set_pev(ent, pev_angles, angles)
set_velocity(ent, angles)
}
set_velocity(ent, Float:angles[3])
{
static Float: Direction[3]
angle_vector(angles, ANGLEVECTOR_FORWARD, Direction)
xs_vec_mul_scalar(Direction, 400.0, Direction) // 215 speed
set_pev(ent, pev_velocity, Direction)
// Run Sequence
if(pev(ent, pev_sequence) != 5) Util_PlayAnimation(ent, 5);
}
Util_PlayAnimation(index, sequence, Float: framerate = 1.0)
{
set_pev(index, pev_animtime, get_gametime())
set_pev(index, pev_framerate, framerate)
set_pev(index, pev_frame, 0.0)
set_pev(index, pev_sequence, sequence)
}
BTW , How is it possible to Remove them using public logevent round end ? Ty
__________________
|
|