Raised This Month: $ Target: $400
 0% 

help! how to make npc walk,and attack player


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
1023168216
Member
Join Date: Jun 2013
Location: Tokyo
Old 07-20-2013 , 23:11   help! how to make npc walk,and attack player
Reply With Quote #1

i created npc by the code successfully,but i cant walk and cant attack player. how to do it?anyone knows it? pls help me~
Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
enum {
	Anim_NONE = 0,
	Anim_IDLE,
	Anim_WALK,
	Anim_RUN,
	Anim_ATTACK,
	Anim_DIE1,
	Anim_DIE2,
	Anim_DIE3,
	Anim_DIE4
}
public plugin_init()
{
	register_plugin("Zombie Attack!", "1.0", "Alexander Mathiasen")
	register_think("npc_zombie", "zombie_think")
	register_clcmd("create_zombie", "zombie_spawn")
}
public plugin_precache() {
	precache_model("models/NPC/ZOMBIE.mdl")
}
public zombie_spawn(id) {
	new Float: origin[3]
	entity_get_vector(id, EV_VEC_origin, origin)
	new eZombie = create_entity("info_target")
	origin[1] += 50.0
	entity_set_origin(eZombie, origin)
	entity_set_float(eZombie, EV_FL_takedamage, 1.0)
	entity_set_float(eZombie, EV_FL_health, 100.0)
	entity_set_string(eZombie, EV_SZ_classname, "npc_zombie")
	entity_set_model(eZombie, "models/NPC/ZOMBIE.mdl")
	entity_set_int(eZombie, EV_INT_solid, 2)
	entity_set_byte(eZombie,EV_BYTE_controller1, 125)
	entity_set_byte(eZombie,EV_BYTE_controller2, 125)	 
	entity_set_byte(eZombie,EV_BYTE_controller3, 125)
	entity_set_byte(eZombie,EV_BYTE_controller4, 125)
	new Float:maxs[3] = {16.0,16.0,36.0}
	new Float:mins[3] = {-16.0,-16.0,-36.0}
	entity_set_size(eZombie, mins, maxs)
	play_animation(eZombie, Anim_IDLE)
	entity_set_float(eZombie, EV_FL_nextthink, halflife_time() + 0.01)
	engfunc(EngFunc_WalkMove, id, 0.5, 50.0, WALKMOVE_NORMAL)
	drop_to_floor(eZombie)
	return 1
}
stock play_animation(id, sequence)
{
	entity_set_float(id, EV_FL_animtime, get_gametime())
	entity_set_float(id, EV_FL_framerate, 1.0)
	entity_set_int(id, EV_INT_sequence, sequence)
}
public zombie_think(ent) {
	return HAM_IGNORED
}
stock NPC_FindNearestPlayer(npc_ent,Float:ShortestDistance = 800.0) {
	new Float:PlayerOrigin[3],Float:Distance,NearestPlayer=0
	new players[32],playerCount,Float:fOrigin[3]
	pev(npc_ent,pev_origin,fOrigin)
	get_players(players,playerCount,"ah")
	for(new i=0;i<playerCount;i++) {
		pev(players[i],pev_origin,PlayerOrigin)
		Distance = vector_distance(PlayerOrigin,fOrigin)
		if(Distance <= ShortestDistance) {
			ShortestDistance = Distance
			NearestPlayer = players[i]
			break
		}
	}
	return NearestPlayer
}
1023168216 is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode