2020-04-22 03:31:28 -07:00
|
|
|
/*
|
2024-01-01 21:20:02 -08:00
|
|
|
* Copyright (c) 2016-2023 Vera Visions LLC.
|
2020-04-22 03:31:28 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2022-07-07 09:10:14 -07:00
|
|
|
*/
|
2020-04-22 03:31:28 -07:00
|
|
|
|
2020-12-22 22:53:43 -08:00
|
|
|
#define COST_INFINITE 99999
|
2024-01-01 21:20:02 -08:00
|
|
|
|
|
|
|
/** The desired target destination has been reached. */
|
2022-03-11 11:40:43 -08:00
|
|
|
#define BOTROUTE_DESTINATION -1
|
2024-01-01 21:20:02 -08:00
|
|
|
/** Unloading of the route in progress. */
|
2022-03-11 11:40:43 -08:00
|
|
|
#define BOTROUTE_END -2
|
2020-12-22 22:53:43 -08:00
|
|
|
|
2024-01-01 21:20:02 -08:00
|
|
|
/** Bot Personality */
|
2022-03-11 11:40:43 -08:00
|
|
|
typedef enum
|
2020-04-22 03:31:28 -07:00
|
|
|
{
|
2024-01-01 21:20:02 -08:00
|
|
|
BOT_PERSONALITY_NORMAL, /**< this bot will be dynamic */
|
|
|
|
BOT_PERSONALITY_AGRESSIVE, /**< this bot will always prefer to be attacking */
|
|
|
|
BOT_PERSONALITY_DEFENSIVE /**< this bot will always prefer to stay behind */
|
2022-03-11 11:40:43 -08:00
|
|
|
} botpersonality_t;
|
|
|
|
|
2024-01-01 21:20:02 -08:00
|
|
|
/** Bot State */
|
2022-03-11 11:40:43 -08:00
|
|
|
typedef enum
|
|
|
|
{
|
2024-01-01 21:20:02 -08:00
|
|
|
BOT_STATE_IDLE, /**< this should rarely happen */
|
|
|
|
BOT_STATE_PATROLLING, /**< this is basically most deathmatch cases */
|
|
|
|
BOT_STATE_DEFENDING, /**< this is for when bots stay put and stay around spawn, or their teams goalitem */
|
|
|
|
BOT_STATE_ATTACKING, /**< this is for when bots go to the enemy spawn, or to the enemy team's goalitem */
|
|
|
|
BOT_STATE_FLEEING /**< this is for when the AI should just get as far away as possible */
|
2022-03-11 11:40:43 -08:00
|
|
|
} botstate_t;
|
2020-04-22 03:31:28 -07:00
|
|
|
|
2024-03-02 00:40:08 -08:00
|
|
|
/** A virtual multiplayer opponent. Base class for all bots.
|
2024-01-01 21:20:02 -08:00
|
|
|
*/
|
Add a whole bunch of new bot features, including bot profiles.
Developers: the internal class `bot` is now `NSBot`, and an entityDef
of the old name will be instantiated instead.
Override defs/bot.def in your mod and make it use any custom spawnclass
you wish. Now games don't have to override `addbot` or `bot_add` inside
the multiplayer game rules.
There's also more console commands. Clients now have access to:
addBot, killAllBots, killClass [classname], killMovables, trigger [targetname], input [entnum] [input] [data], listBotProfiles, listTargets, teleport [targetname], teleportToClass [classname], respawnEntities, spawn
2024-01-26 19:22:14 -08:00
|
|
|
class NSBot:player
|
2020-04-22 03:31:28 -07:00
|
|
|
{
|
2020-12-22 22:53:43 -08:00
|
|
|
/* routing */
|
|
|
|
int m_iNodes;
|
|
|
|
int m_iCurNode;
|
|
|
|
nodeslist_t *m_pRoute;
|
|
|
|
float m_flNodeGiveup;
|
|
|
|
float m_flLastDist;
|
|
|
|
entity m_eDestination;
|
|
|
|
vector m_vecLastNode;
|
|
|
|
|
|
|
|
/* combat */
|
|
|
|
entity m_eTarget;
|
2020-12-25 22:27:34 -08:00
|
|
|
int m_iAttackMode;
|
|
|
|
float m_flAttackTime;
|
|
|
|
|
|
|
|
/* items */
|
|
|
|
int m_iOldItems;
|
|
|
|
|
|
|
|
/* visual */
|
|
|
|
float m_flSeeTime;
|
2020-12-22 22:53:43 -08:00
|
|
|
|
2022-03-11 11:40:43 -08:00
|
|
|
/* personality and state */
|
|
|
|
botstate_t m_bsState;
|
|
|
|
botpersonality_t m_bpPersonality;
|
|
|
|
|
2022-03-08 21:50:30 -08:00
|
|
|
/* cache, these are just here so we won't have to calc them often */
|
|
|
|
float m_flEnemyDist;
|
|
|
|
weapontype_t m_wtWeaponType;
|
2022-03-13 17:10:12 -07:00
|
|
|
vector m_vecLastPOI;
|
2023-10-11 00:55:07 -07:00
|
|
|
float m_flForceWeaponAttack;
|
|
|
|
vector m_vecForceWeaponAttackPos;
|
2022-03-08 21:50:30 -08:00
|
|
|
|
Add a whole bunch of new bot features, including bot profiles.
Developers: the internal class `bot` is now `NSBot`, and an entityDef
of the old name will be instantiated instead.
Override defs/bot.def in your mod and make it use any custom spawnclass
you wish. Now games don't have to override `addbot` or `bot_add` inside
the multiplayer game rules.
There's also more console commands. Clients now have access to:
addBot, killAllBots, killClass [classname], killMovables, trigger [targetname], input [entnum] [input] [data], listBotProfiles, listTargets, teleport [targetname], teleportToClass [classname], respawnEntities, spawn
2024-01-26 19:22:14 -08:00
|
|
|
void(void) NSBot;
|
2020-12-22 22:53:43 -08:00
|
|
|
|
2022-03-11 11:40:43 -08:00
|
|
|
virtual void(botstate_t) SetState;
|
|
|
|
virtual botstate_t(void) GetState;
|
|
|
|
virtual botpersonality_t(void) GetPersonality;
|
|
|
|
|
2021-05-12 06:42:20 -07:00
|
|
|
virtual void(string) ChatSay;
|
|
|
|
virtual void(string) ChatSayTeam;
|
2020-12-25 22:27:34 -08:00
|
|
|
virtual void(void) Pain;
|
|
|
|
virtual void(void) RouteClear;
|
|
|
|
virtual void(void) WeaponThink;
|
|
|
|
virtual void(void) WeaponAttack;
|
|
|
|
virtual void(void) SeeThink;
|
|
|
|
virtual void(int, int) BrainThink;
|
2020-12-22 22:53:43 -08:00
|
|
|
virtual void(void) RunAI;
|
2021-05-12 06:42:20 -07:00
|
|
|
virtual void(void) CreateObjective;
|
2020-12-22 22:53:43 -08:00
|
|
|
virtual void(void) CheckRoute;
|
2020-12-25 22:27:34 -08:00
|
|
|
virtual void(void) PreFrame;
|
|
|
|
virtual void(void) PostFrame;
|
2021-03-26 23:48:46 -07:00
|
|
|
virtual void(void) UseButton;
|
2022-03-08 21:50:30 -08:00
|
|
|
virtual void(entity) SetEnemy;
|
|
|
|
virtual float(void) GetRunSpeed;
|
|
|
|
virtual float(void) GetWalkSpeed;
|
2023-10-11 00:55:07 -07:00
|
|
|
nonvirtual void ForceWeaponAttack(vector, float);
|
2022-05-24 15:32:37 -07:00
|
|
|
|
|
|
|
virtual void(string) SetName;
|
2020-04-22 03:31:28 -07:00
|
|
|
};
|
2020-07-09 01:42:34 -07:00
|
|
|
|
2024-01-01 21:20:02 -08:00
|
|
|
/** Adds a bot to the game with some basic info. Returns the resulting entity. __NULL__ if unavailable. */
|
2020-07-09 01:42:34 -07:00
|
|
|
entity Bot_AddQuick(void);
|
2022-03-15 19:33:11 -07:00
|
|
|
|
2024-01-01 21:20:02 -08:00
|
|
|
/** Applies random custom colors to the given bot entity. */
|
2022-03-15 19:33:11 -07:00
|
|
|
void
|
Add a whole bunch of new bot features, including bot profiles.
Developers: the internal class `bot` is now `NSBot`, and an entityDef
of the old name will be instantiated instead.
Override defs/bot.def in your mod and make it use any custom spawnclass
you wish. Now games don't have to override `addbot` or `bot_add` inside
the multiplayer game rules.
There's also more console commands. Clients now have access to:
addBot, killAllBots, killClass [classname], killMovables, trigger [targetname], input [entnum] [input] [data], listBotProfiles, listTargets, teleport [targetname], teleportToClass [classname], respawnEntities, spawn
2024-01-26 19:22:14 -08:00
|
|
|
Bot_RandomColormap(NSBot target)
|
2022-03-15 19:33:11 -07:00
|
|
|
{
|
|
|
|
vector x = hsv2rgb(random() * 360, 100, 100);
|
|
|
|
float top = x[2] + (x[1] << 8) + (x[0] << 16);
|
|
|
|
x = hsv2rgb(random() * 360, 100, 100);
|
|
|
|
float bottom = x[2] + (x[1] << 8) + (x[0] << 16);
|
|
|
|
forceinfokey(target, "topcolor", sprintf("0x%x", top));
|
|
|
|
forceinfokey(target, "bottomcolor", sprintf("0x%x", bottom));
|
|
|
|
}
|