AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   My NPC/BOT Plugin - first one - not working =/ (https://forums.alliedmods.net/showthread.php?t=46507)

Zamma 10-28-2006 06:23

My NPC/BOT Plugin - first one - not working =/
 
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 10-28-2006 10:11

Re: My NPC/BOT Plugin - first one - not working =/
 
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 =/

schnitzelmaker 10-28-2006 11:41

Re: My NPC/BOT Plugin - first one - not working =/
 
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.

Zenith77 10-28-2006 11:42

Re: My NPC/BOT Plugin - first one - not working =/
 
Code:
entity_set_int(ent,EV_INT_solid, SOLID_BBOX)

He did.

Zamma 10-28-2006 11:52

Re: My NPC/BOT Plugin - first one - not working =/
 
mmm maybe using pev instead wud be better? or no difference?

Zenith77 10-28-2006 11:53

Re: My NPC/BOT Plugin - first one - not working =/
 
They do the exact same thing.

schnitzelmaker 10-28-2006 11:58

Re: My NPC/BOT Plugin - first one - not working =/
 
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

Zamma 10-28-2006 12:11

Re: My NPC/BOT Plugin - first one - not working =/
 
Yeah ive use thats to get my player on and to give him a name

but still - no hitbox =/


All times are GMT -4. The time now is 04:57.

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