Raised This Month: $ Target: $400
 0% 

My NPC/BOT Plugin - first one - not working =/


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Zamma
Member
Join Date: May 2004
Old 10-28-2006 , 06:23   My NPC/BOT Plugin - first one - not working =/
Reply With Quote #1

I was trying the tutorial to make an NPC but im having a few problems:

IF i want to make a fake client and use the engfunc it doesnt work - no one is added.

IF i use the create entity i have a few problems with the box of the model. The player spawns - drops half way in the ground (up to chest) and u can move and shoot through him...

The mod is NATURAL SELECTION and here is my coding:

Code:
#include <amxmodx>
#include <amxmisc>
#include <ns>
#include <ns2amx>
#include <fakemeta>
#include <engine>
#include <fun>

#define PLUGIN "BOT_TEST"
#define VERSION "1.0"
#define AUTHOR "George"

new bothealth
new botcurrenthealth
//new fullid
new TagColour[3] = { 250,10,10 }

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("amx_create_bot", "CreateBot")
	register_think("npc_bot","npc_think")
	// Add your code here...
}

public plugin_precache(){
	
    precache_model("models/player/soldier/soldier.mdl")
    precache_model("models/p_shotgun.mdl")
}

public CreateBot(id){
	
//	new ent = engfunc(EngFunc_CreateFakeClient,"NSBot")
	new ent = create_entity("info_target")
	new Float:entorigin[3]
	
//	id = fullid
	
//	engfunc(EngFunc_CreateFakeClient,"NSBot") = ent

	entity_get_vector(id,EV_VEC_origin,entorigin)
	//entity_set_origin(ent,entorigin);
	engfunc(EngFunc_SetOrigin, ent, entorigin)

	entorigin[2] += 300.0
	entity_set_origin(id,entorigin)
	
	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_int(ent,EV_INT_solid, SOLID_BBOX)
	
	entity_set_edict(ent, EV_ENT_owner, id)
	
	entity_set_float(ent,EV_FL_takedamage,1.0)
	entity_set_float(ent,EV_FL_health,100.0)
	
	entity_set_string(ent,EV_SZ_classname,"npc_bot");
	entity_set_model(ent,"models/player/soldier/soldier.mdl");
	
	entity_set_float(ent,EV_FL_animtime,2.0)
	entity_set_float(ent,EV_FL_framerate,1.0)
	entity_set_int(ent,EV_INT_sequence,0);
	entity_set_float(ent,EV_FL_nextthink,halflife_time() + 0.01)
	drop_to_floor(ent)
//	give_weapon(ent)
	
	return 1;
}

public npc_think(id){
	
//	new Float:porigin[3]
//	new Float:eorigin[3]
//	new player[64]
	
//	pev(id, pev_owner, player)
	
//	entity_get_vector(player,EV_VEC_origin,porigin)
//	entity_get_vector(id,EV_VEC_origin,eorigin)
//	if( entity_range(id,player) < 1000 ){
//		entity_get_vector(player,EV_VEC_origin,porigin)
//		strip_user_weapons(player)

	glow(id, TagColour[0], TagColour[1], TagColour[2], 1)
		
	
	entity_set_float(id,EV_FL_nextthink,halflife_time() + 0.01)
	return PLUGIN_CONTINUE
}

public give_weapon(ent)
{
        new entWeapon = create_entity("info_target")

        entity_set_string(entWeapon, EV_SZ_classname, "npc_shotgun")

        entity_set_int(entWeapon, EV_INT_movetype, MOVETYPE_FOLLOW)
        entity_set_int(entWeapon, EV_INT_solid, SOLID_NOT)
        entity_set_edict(entWeapon, EV_ENT_aiment, ent)
        entity_set_model(entWeapon, "models/p_shotgun.mdl") 
}

public glow(id, r, g, b, on)
{
	if(on == 1) {
	set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
	set_pev(id,pev_renderamt,2.0)
	}
	else if(!on) {
		set_rendering(id, kRenderFxNone, r, g, b,  kRenderNormal, 255)
		set_pev(id,pev_renderamt,2.0)
	}
	else if(on == 10) {
		set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
		set_pev(id,pev_renderamt,50.0)
	}
}
Zamma is offline
 



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 04:57.


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