AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bot AI (https://forums.alliedmods.net/showthread.php?t=48213)

Rolnaaba 12-07-2006 11:00

bot AI
 
I read the Perfect NPC tutorial and I created the bot, but how can I create the "AI". Make it run recognize enimies ect. as if it were a player?
My script to create the bots:
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <fakemeta> public plugin_init() {     register_plugin("[Nca] Bots", "0.1", "Rolnaaba");     register_concmd("nca_addbot", "spawn_bots", ADMIN_KICK, "usage: nca_addbot");     register_think("nca_bot","bot_think"); } public spawn_bots(id, level, cid) {     if(!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED;     new ent = engfunc(EngFunc_CreateFakeClient,"Onna");     //check creation     if(!ent) {         console_print(id,"[AMXX] Failed to create NPC");         return PLUGIN_CONTINUE;     }     //give ent an origin     new Float:origin[3];     entity_get_vector(id,EV_VEC_origin,origin); //get your origin     entity_set_origin(ent,origin); //set origin     //jump to test     origin[2] += 300.0; //raise origin     entity_set_origin(id,origin); //set higher origin     //make solid     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); //set size     entity_set_int(ent,EV_INT_solid, 2); //set solid     //gives health/makes killable     entity_set_float(ent,EV_FL_takedamage,1.0); //damage it takes per hit     entity_set_float(ent,EV_FL_health,110.0); //health to start with     //set model/classname (for think and stuff)     entity_set_string(ent,EV_SZ_classname,"nca_bot"); //set class name     entity_set_model(ent,"models/onna.mdl"); //set model     //set animations     entity_set_float(ent,EV_FL_animtime,2.0); //tim for anim.     entity_set_float(ent,EV_FL_framerate,1.0); //frame rate     entity_set_int(ent,EV_INT_sequence,0);     give_weapon(ent);     //tell to think     entity_set_float(ent,EV_FL_nextthink,halflife_time() + 0.01);         return PLUGIN_CONTINUE; } public give_weapon(ent) {     //gives weapon     new entWeapon = create_entity("info_target"); //create weapon entity     entity_set_string(entWeapon, EV_SZ_classname, "nca_bot_weapon"); //set weapon class name         entity_set_int(entWeapon, EV_INT_movetype, MOVETYPE_FOLLOW); //movetype of the weapon         entity_set_int(entWeapon, EV_INT_solid, SOLID_NOT); //solidity (you can run through their gun like in real game)         entity_set_edict(entWeapon, EV_ENT_aiment, ent);         entity_set_model(entWeapon, "models/p_gauss.mdl"); //set model } public bot_think(ent) {     /* Here is where I would put run/recognition     but dunno exatly what to do */     //set re-think     entity_set_float(ent,EV_FL_nextthink,halflife_time() + 0.01); }
I toyed with
Code:

engfunc(EngFunc_RunPlayerMove)
but I dunno the correct usage of that and I believe that it will only make them move for a certain amount of time...looked at other bot mods but havent found one that creates the bots and runs a think for me to look at

Orangutanz 12-07-2006 12:58

Re: bot AI
 
Ok since Simon Logic has asked about something similar regarding Bots, I might release my work-in-progress script.

You will have to bare in mind its a work in progress and not complete, the main thing that myself and DevconeS want to implement is some form of easy to use navigation system.

Don't assume you can't do much with it, since I've already created Football Bots for Football Mod (Formally known as SoccerMod). Its not great but hey, least they try and play football :mrgreen:

Rolnaaba 12-07-2006 13:04

Re: bot AI
 
I was thinking of using RunPLayerMove and when the volocety of the ent is zero (meaning they are running against a wall) make a 45 degree turn, and all the while of doing this check the aiming of said ent, if the ent aims at someone who is not of the team the ent is on to fire but I dont know how to make them fire AND this would be an extremely crude way to make a bot

Orangutanz 12-07-2006 13:18

Re: bot AI
 
Does this work: register_think("nca_bot","bot_think")
I'd be very :shock: if it does since 99% if not 100% of bot coders actually get it to work based on StartFrame.

Code:
/* AMXX Bot [API] * * Copyright © 2006, Space Headed Productions * * This file is provided as is (no warranties). * */ enum bot_data {     bot_int_start,     bot_buttons,     bot_impulse,     bot_int_end,     bot_float_start,     bot_forward_move,     bot_side_move,     bot_up_move,     bot_float_end } enum bot_chat {     chat_all,     chat_team,     chat_radio } forward bot_think(id); // Checks whether its AMXX Bot native is_bot(id); // Creates a bot by given name and joins a team if specified native create_bot(const name[], team=0); // Removes a bot by id native remove_bot(id); native get_bot_data(id, bot_data:member, {Float,_}:...); native set_bot_data(id, bot_data:member, {Float,_}:...); // Sets the bots angles to the given origin native set_bot_angles(id, Float:origin[3]); native set_bot_voice(id, const wavefile[], pitch=100, Float:duration=1.0); native set_bot_chat(id, bot_chat:member, const text[]);
This is our current set of natives available you can use, like I said previously its not complete don't know exactly what is missing/required.

I'm unsure if our Team thing will work when you create a bot on NS since it has a Ready Room, not a standard menu for selecting a team.

Rolnaaba 12-07-2006 13:57

Re: bot AI
 
so by simply doing this:
Code:
register_clcmd("say addbot", "spawn_bot")   public spawn_bot() {      create_bot(BoB) }
it will create a bot and assign a team (for CS 1.6)

Orangutanz 12-07-2006 14:07

Re: bot AI
 
Well that would make it spectator but that is the principle of it.
create_bot("Bob", 1)

Would make Bob BOT (ROFL) spawn on the Terrorist team.

Rolnaaba 12-07-2006 16:21

Re: bot AI
 
lol wow thats ... um ... easy compared to what I was trying to do lol.

dutchmeat 12-08-2006 04:47

Re: bot AI
 
Like i said on the NCA's forum, this is pointless, you still have to make an entire AI, since this 'Playermove' of the 'create_bot' is only a copy of your own movements.
you could say that this 'bot' is just an controlable npc.

Rolnaaba 12-08-2006 10:46

Re: bot AI
 
realy didnt know that [/sarcasm] I want to learn how to code the AI, as I said earlier:
Quote:

Originally Posted by Rolnaaba
but how can I create the "AI". Make it run recognize enimies ect. as if it were a player?


dutchmeat 12-08-2006 11:03

Re: bot AI
 
I suggest you first take a study AI, and then start coding.

but if you do want to let them 'seach enemies',
Let them spin arround, and look in get_user_aiming if there's a classname "player" in that field.


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

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