Nuclide
Software Development Kit for id Technology (BETA)
Bot.h
1/*
2 * Copyright (c) 2016-2023 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
17#define COST_INFINITE 99999
18
25#define BOTROUTE_DESTINATION -1
27#define BOTROUTE_END -2
28
30typedef enum
31{
32 BOT_PERSONALITY_NORMAL,
33 BOT_PERSONALITY_AGRESSIVE,
34 BOT_PERSONALITY_DEFENSIVE
36
38typedef enum
39{
40 BOT_STATE_IDLE,
41 BOT_STATE_PATROLLING,
42 BOT_STATE_DEFENDING,
43 BOT_STATE_ATTACKING,
44 BOT_STATE_FLEEING
46
53{
54public:
55
56 void ncBot(void);
57
58#ifdef SERVER
59 virtual void SetState(botstate_t);
60 virtual botstate_t GetState(void);
61 virtual botpersonality_t GetPersonality(void);
62
63 virtual float GetForwardSpeed(void);
64 virtual float GetSideSpeed(void);
65 virtual float GetBackSpeed(void);
66
67 virtual void ChatSay(string);
68 virtual void ChatSayTeam(string);
69 virtual void Pain(entity, entity, int, vector, vector, int);
70 virtual void RouteClear(void);
71 virtual void WeaponThink(void);
72 virtual void WeaponAttack(void);
73 virtual void SeeThink(void);
74 virtual void BrainThink(int, int);
75 virtual void RunAI(void);
76 virtual void CreateObjective(void);
77 virtual void CheckRoute(void);
78 virtual void BotPreFrame(void);
79 virtual void BotPostFrame(void);
80 virtual void AddedItemCallback(ncItem);
81 virtual void UseButton(void);
82 virtual void SetEnemy(entity);
83 virtual float GetRunSpeed(void);
84 virtual float GetWalkSpeed(void);
85 nonvirtual void ForceWeaponAttack(vector, float);
86
87 virtual void SetName(string);
88#endif
89
90
91#ifdef SERVER
92private:
93 /* routing */
94 float m_flLastDist;
95
96 float m_flNodeGiveup;
97 entity m_eDestination;
98
99 /* combat */
100 entity m_eTarget;
101 int m_iAttackMode;
102 float m_flAttackTime;
103
104 /* items */
105 int m_iOldItems;
106
107 /* visual */
108 float m_flSeeTime;
109
110 /* personality and state */
111 botstate_t m_bsState;
112 botpersonality_t m_bpPersonality;
113
114 /* cache, these are just here so we won't have to calc them often */
115 float m_flEnemyDist;
116 weapontype_t m_wtWeaponType;
117 vector m_vecLastPOI;
118 float m_flForceWeaponAttack;
119 vector m_vecForceWeaponAttackPos;
120#endif
121};
122
123#ifdef SERVER
125entity Bot_AddQuick(void);
126void BotLib_Init(void);
127void BotLib_Shutdown(void);
128
130void
132{
133 vector x = hsvToRGB(random() * 360, 100, 100);
134 float top = x[2] + (x[1] << 8) + (x[0] << 16);
135 x = hsvToRGB(random() * 360, 100, 100);
136 float bottom = x[2] + (x[1] << 8) + (x[0] << 16);
137 forceinfokey(target, "topcolor", sprintf("0x%x", top));
138 forceinfokey(target, "bottomcolor", sprintf("0x%x", bottom));
139}
140#endif
141 // end of bot
This entity class represents an object with choreographed/free-form movement.
Definition: Actor.h:93
A virtual multiplayer opponent.
Definition: Bot.h:53
virtual void ChatSayTeam(string)
Definition: chat.qc:24
virtual void UseButton(void)
Definition: Bot.qc:117
virtual void SetState(botstate_t)
Definition: Bot.qc:53
virtual float GetRunSpeed(void)
Definition: Bot.qc:71
virtual botpersonality_t GetPersonality(void)
Definition: Bot.qc:59
virtual void SetName(string)
Definition: Bot.qc:556
virtual float GetForwardSpeed(void)
Overridable: Returns the desired maximum forward movement speed.
Definition: Bot.qc:77
virtual void WeaponThink(void)
Definition: combat.qc:59
virtual botstate_t GetState(void)
Definition: Bot.qc:47
virtual void WeaponAttack(void)
Definition: combat.qc:81
virtual void CheckRoute(void)
Definition: Bot.qc:211
virtual float GetSideSpeed(void)
Overridable: Returns the desired maximum side movement speed.
Definition: Bot.qc:83
virtual void SetEnemy(entity)
Definition: combat.qc:47
virtual void AddedItemCallback(ncItem)
Definition: Bot.qc:546
virtual float GetBackSpeed(void)
Overridable: Returns the desired maximum backwardss movement speed.
Definition: Bot.qc:89
virtual void Pain(entity, entity, int, vector, vector, int)
Called whenever the entity receives damage.
Definition: combat.qc:18
virtual void BrainThink(int, int)
Definition: Bot.qc:102
virtual void RunAI(void)
Definition: Bot.qc:317
virtual void BotPreFrame(void)
Definition: Bot.qc:536
virtual void BotPostFrame(void)
Definition: Bot.qc:541
virtual float GetWalkSpeed(void)
Definition: Bot.qc:65
nonvirtual void ForceWeaponAttack(vector, float)
Definition: combat.qc:137
void ncBot(void)
Definition: Bot.qc:18
virtual void RouteClear(void)
When called, will wipe any memory of an ongoing route.
Definition: Bot.qc:95
virtual void CreateObjective(void)
Definition: Bot.qc:311
virtual void ChatSay(string)
Definition: chat.qc:18
virtual void SeeThink(void)
Definition: Bot.qc:146
This entity class represents inventory items, weapons.
Definition: Item.h:138
void BotLib_Shutdown(void)
Definition: Bot.qc:634
entity Bot_AddQuick(void)
Adds a bot to the game with some basic info.
Definition: cmd.qc:36
botpersonality_t
Bot Personality.
Definition: Bot.h:31
void Bot_RandomColormap(ncBot target)
Applies random custom colors to the given bot entity.
Definition: Bot.h:131
void BotLib_Init(void)
Definition: Bot.qc:621
botstate_t
Bot State.
Definition: Bot.h:39