appreciated if any1 can help +rep
tried hooking death and takedamage by HAM
PHP Code:
RegisterHam(Ham_TakeDamage, "npc_lychon", "hook_TakeDamage")
RegisterHam(Ham_Killed, "npc_lychon", "Fwd_Ham_Killed");
did i make any error/mistake?
PHP Code:
public Fwd_Ham_Killed(ent)
{
new classname[32]
pev(ent, pev_classname, classname, 31)
if(!is_user_alive(ent) && equal(classname, "npc_lychon"))
{
client_print(0,print_chat,"[TEST] NPC DIED.")
entity_set_int(ent,EV_INT_sequence,random_num(9,10))
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
the test npc died message didnt appear and the NPC still disappears once its HP reach 0 and i cant make any death animation =/
PHP Code:
public hook_TakeDamage(ent)
{
client_print(0,print_chat,"[TEST] Damage recieved by entity.")
new classname[32]
pev(ent, pev_classname, classname, 31)
new origin[3]
get_user_origin(ent,origin)
new hitpoint, weapon
get_user_attacker(ent,weapon,hitpoint)
if(equal(classname, "npc_lychon"))
{
switch(hitpoint)
{
case 1:
{
get_user_origin(ent,origin,1)
}
case 2:
{
origin[2] += 25
}
case 3:
{
origin[2] += 10
}
case 4:
{
origin[2] += 10
origin[0] += 5
origin[1] += 5
}
case 5:
{
origin[2] += 10
origin[0] -= 5
origin[1] -= 5
}
case 6:
{
origin[2] -= 10
origin[0] += 5
origin[1] += 5
}
case 7:
{
origin[2] -= 10
origin[0] -= 5
origin[1] -= 5
}
}
client_print(0,print_chat,"[TEST] Making 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(blood)
write_short(blood)
write_byte(78)
write_byte(10)
message_end()
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BLOODSPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(blood)
write_short(blood)
write_byte(78)
write_byte(12)
message_end()
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BLOODSPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(blood)
write_short(blood)
write_byte(78)
write_byte(15)
message_end()
}
}
both test damage recieve and blood making messages didnt appear
and I try to make it think and show knifing animation , havnt coded the damage yet but it has some errors.
im trying to make it knife the nearest person next to it
PHP Code:
public npc_think(ent)
{
new npcorigin[3]
get_user_origin(ent, npcorigin)
new closestTarget = 0, Float:closestDistance, Float:distance, Float:closestOrigin[3], Float:playerOrigin[3]
for (new i = 1; i <= MAX_PLAYERS; i++)
{
if (!is_user_connected(i) || !is_user_alive(i)) // temporarily dont check team:
continue
get_user_origin(i, playerOrigin)
distance = vector_distance(npcorigin, playerOrigin)
closestOrigin = playerOrigin
if (distance < closestDistance || closestTarget == 0)
{
closestTarget = i
closestDistance = distance
}
}
if (closestTarget) {
new rand = random_num(1,3)
{
switch(rand)
{
case 1:{entity_set_int(ent,EV_INT_sequence,5);} // making animation but didnt see any
case 2:{entity_set_int(ent,EV_INT_sequence,6);}
case 3:{entity_set_int(ent,EV_INT_sequence,7);}
}
}
}
}
I didnt see the animation