Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
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
Zamma
Member
Join Date: May 2004
Old 10-28-2006 , 10:11   Re: My NPC/BOT Plugin - first one - not working =/
Reply With Quote #2

I have worked out the bot is half way in the floor becuz of DROP_TO_FLOOR.

BUT

this doesnt explain why it has no hitbox - i can walk through it =/
Zamma is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 10-28-2006 , 11:41   Re: My NPC/BOT Plugin - first one - not working =/
Reply With Quote #3

You need to make it solid: set_pev(bot,pev_solid,2)

Test it a lot with increase the
new Float:maxs[3] = {16.0,16.0,36.0}
new Float:mins[3] = {-16.0,-16.0,-36.0}
range and some solid values.To test the boxes,give the bot another team id as you and shoot to him.

@Zenith77:I have see,but somtimes are problems with set solid and the hitboxes
(i think its only an NS problem)

And thats very very bad,a virus has destroyed my ns bot Plugin.
__________________

Last edited by schnitzelmaker; 10-28-2006 at 11:49.
schnitzelmaker is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-28-2006 , 11:42   Re: My NPC/BOT Plugin - first one - not working =/
Reply With Quote #4

Code:
entity_set_int(ent,EV_INT_solid, SOLID_BBOX)

He did.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Zamma
Member
Join Date: May 2004
Old 10-28-2006 , 11:52   Re: My NPC/BOT Plugin - first one - not working =/
Reply With Quote #5

mmm maybe using pev instead wud be better? or no difference?
Zamma is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-28-2006 , 11:53   Re: My NPC/BOT Plugin - first one - not working =/
Reply With Quote #6

They do the exact same thing.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 10-28-2006 , 11:58   Re: My NPC/BOT Plugin - first one - not working =/
Reply With Quote #7

pev = fakemeta
entity_set = engine

But both do the same.(but is better to write a plugin engine or fakemeta only)

And here a good example how create a bot:http://forums.alliedmods.net/showthread.php?p=255078
__________________

Last edited by schnitzelmaker; 10-28-2006 at 12:01.
schnitzelmaker is offline
Zamma
Member
Join Date: May 2004
Old 10-28-2006 , 12:11   Re: My NPC/BOT Plugin - first one - not working =/
Reply With Quote #8

Yeah ive use thats to get my player on and to give him a name

but still - no hitbox =/
Zamma is offline
Reply



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