Raised This Month: $51 Target: $400
 12% 

Bots Attack NPC


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DavidJr
Senior Member
Join Date: Apr 2012
Old 04-08-2014 , 07:33   Bots Attack NPC
Reply With Quote #1

Hi, as the title said I'd like to know how to make bots define that NPC is their enemy? This is my NPC code.

PHP Code:
new const ZOMBIE_CLASSNAME[] = "zombie_npc";
new const 
ZOMBIE_MODEL[] = "models/zombie_survival/zombie1.mdl";


public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_logevent("LogEvent_RoundStart"2"1=Round_Start");
    
    
register_think(ZOMBIE_CLASSNAME"fwd_Think"); // Zombies attack players
}

public 
LogEvent_RoundStart()
{
    
Load_Npc();
}

Load_Npc() 

    
//Get the correct filepath and mapname 
    
new szConfigDir[256], szFile[256], szNpcDir[256];
    
    
get_configsdir(szConfigDircharsmax(szConfigDir));
    
    new 
szMapName[32];
    
get_mapname(szMapNamecharsmax(szMapName));
    
    
formatex(szNpcDircharsmax(szFile),  "%s/zombie_survival"szConfigDir);
    
formatex(szFilecharsmax(szFile),  "%s/%s.cfg"szNpcDirszMapName);
    
    
//If the map config file does not exist we will make one
    
if (!file_exists(szFile))
    {
        
//return PLUGIN_HANDLED_MAIN;
        //write_file(szFile, "");
    
}
    
    
//Variables to store when reading our file
    
new szFileOrigin[3][32];
    new 
sOrigin[128], sAngle[128], Float:fOrigin[3], Float:fAngles[3];
    new 
iLineiLengthsBuffer[256];
    
    
//When we are reading our file...
    
while (read_file(szFileiLine++, sBuffercharsmax(sBuffer), iLength))
    {
        
//Move to next line if the line is commented
        
if((sBuffer[0]== ';') || !iLength)
            continue;
        
        
//Split our line so we have origin and angle. The split is the vertical bar character
        
strtok(sBuffersOrigincharsmax(sOrigin), sAnglecharsmax(sAngle), '|'0);
        
        
//Store the X, Y and Z axis to our variables made earlier
        
parse(sOriginszFileOrigin[0], charsmax(szFileOrigin[]), szFileOrigin[1], charsmax(szFileOrigin[]), szFileOrigin[2], charsmax(szFileOrigin[]));
        
        
fOrigin[0] = str_to_float(szFileOrigin[0]);
        
fOrigin[1] = str_to_float(szFileOrigin[1]);
        
fOrigin[2] = str_to_float(szFileOrigin[2]);
        
        
//Store the yawn angle
        
fAngles[1] = str_to_float(sAngle[1]);
        
//Keep reading the file until the end
        
SpawnNpc(iLinefOriginfAngles);
    }
    return 
PLUGIN_CONTINUE;
}

SpawnNpc(iEntFloat:flOrigin[3], Float:flAngle[3])
{
    
iEnt create_entity("info_target");
    
    
entity_set_string(iEntEV_SZ_classnameZOMBIE_CLASSNAME);
    
    
entity_set_model(iEntZOMBIE_MODEL);
    
entity_set_int(iEntEV_INT_solidSOLID_SLIDEBOX);
    
entity_set_int(iEntEV_INT_movetypeMOVETYPE_PUSHSTEP);
    
entity_set_int(iEntEV_INT_flagsFL_MONSTER);
    
    
entity_set_vector(iEntEV_VEC_anglesflAngle);
    
entity_set_vector(iEntEV_VEC_originflOrigin);
    
    
entity_set_byte(iEntEV_BYTE_controller1125);
    
entity_set_byte(iEntEV_BYTE_controller2125);
    
entity_set_byte(iEntEV_BYTE_controller3125);
    
entity_set_byte(iEntEV_BYTE_controller4125);
    
    
entity_set_float(iEntEV_FL_animtime2.0);
    
entity_set_float(iEntEV_FL_framerate1.0);
    
entity_set_float(iEntEV_FL_health200.0);
    
entity_set_float(iEntEV_FL_takedamage1.0);
    
entity_set_float(iEntEV_FL_dmg_takeDAMAGE_YES);
    
entity_set_float(iEntEV_FL_gravity20.0);
    
entity_set_vector(iEntEV_VEC_velocityFloat:{100.0100.0100.0});
    
    new 
Float:maxs[3] = {16.016.036.0};
    new 
Float:mins[3] = {-16.0, -16.0, -36.0};
    
entity_set_size(iEntminsmaxs);
    
    
entity_set_int(iEntEV_INT_sequence0);
    
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 2.0);

I ever tried by checking the distance between bots and npc if it is in bots' range, then set the bots' angles and execute Ham_Weapon_PrimaryAttack. It worked but it uses CPU usage and causes lag. Any solution to control bots?
__________________
What are you looking for here?
DavidJr is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 05-20-2014 , 19:50   Re: Bots Attack NPC
Reply With Quote #2

More than 14 days, can I bump more than 1?

Is this impossible?
__________________
What are you looking for here?
DavidJr is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-20-2014 , 23:26   Re: Bots Attack NPC
Reply With Quote #3

Well, its not possible to make bots attack your costom entity.
They even dont want to attack breakable entities.

I guess they only way is to force them to attack by messing with their angles and stuff you tried.
.Dare Devil. is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 05-21-2014 , 00:34   Re: Bots Attack NPC
Reply With Quote #4

I believe it can be reached by hooking the engine
__________________
What are you looking for here?
DavidJr is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 05-21-2014 , 02:53   Re: Bots Attack NPC
Reply With Quote #5

What kind of bots are? PODBots? CZero Bots?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 05-21-2014 , 03:34   Re: Bots Attack NPC
Reply With Quote #6

four bots, they are PODBots, CZero Bots, ZBot and yapBOT
__________________
What are you looking for here?
DavidJr 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 05:55.


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