Skip to content

Commit b5bfe67

Browse files
authored
Add files via upload
1 parent d37a465 commit b5bfe67

File tree

8 files changed

+169
-213
lines changed

8 files changed

+169
-213
lines changed

source/basecode.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ ConVar ebot_restrictweapons("ebot_restrict_weapons", "");
4040
ConVar ebot_camp_min("ebot_camp_time_min", "16");
4141
ConVar ebot_camp_max("ebot_camp_time_max", "48");
4242
ConVar ebot_use_radio("ebot_use_radio", "1");
43-
ConVar ebot_anti_block("ebot_anti_block", "0");
4443
ConVar ebot_force_flashlight("ebot_force_flashlight", "0");
4544
ConVar ebot_use_flare("ebot_zm_use_flares", "1");
4645
ConVar ebot_chat_percent("ebot_chat_percent", "20");
4746
ConVar ebot_eco_rounds("ebot_eco_rounds", "1");
4847
ConVar ebot_avoid_grenades("ebot_avoid_grenades", "1");
48+
ConVar ebot_breakable_health_limit("ebot_breakable_health_limit", "3000.0");
4949

5050
ConVar ebot_chatter_path("ebot_chatter_path", "radio/bot");
5151

@@ -730,7 +730,7 @@ void Bot::FindItem(void)
730730
if (g_entityId[i] == -1 || g_entityAction[i] != 3)
731731
continue;
732732

733-
if (m_team != g_entityTeam[i] && g_entityTeam[i] != 2)
733+
if (g_entityTeam[i] != 2 && m_team != g_entityTeam[i])
734734
continue;
735735

736736
if (ent != INDEXENT(g_entityId[i]))
@@ -5795,7 +5795,11 @@ void Bot::RunTask(void)
57955795
// is bot facing the breakable?
57965796
if (GetShootingConeDeviation(GetEntity(), &m_breakable) >= 0.90f)
57975797
{
5798-
m_moveSpeed = 0.0f;
5798+
if (m_isZombieBot || m_currentWeapon == WEAPON_KNIFE)
5799+
m_moveSpeed = pev->maxspeed;
5800+
else
5801+
m_moveSpeed = 0.0f;
5802+
57995803
m_strafeSpeed = 0.0f;
58005804
m_wantsToFire = true;
58015805
m_shootTime = engine->GetTime();
@@ -7302,7 +7306,7 @@ bool Bot::IsShootableBreakable(edict_t* ent)
73027306
if (FNullEnt(ent))
73037307
return false;
73047308

7305-
if (FClassnameIs(ent, "func_breakable") || (FClassnameIs(ent, "func_pushable") && (ent->v.spawnflags & SF_PUSH_BREAKABLE)) || (FClassnameIs(ent, "func_wall") && ent->v.health <= 500))
7309+
if ((FClassnameIs(ent, "func_breakable") || (FClassnameIs(ent, "func_pushable") && (ent->v.spawnflags & SF_PUSH_BREAKABLE)) || FClassnameIs(ent, "func_wall")) && ent->v.health <= ebot_breakable_health_limit.GetFloat())
73067310
{
73077311
if (ent->v.takedamage != DAMAGE_NO && ent->v.impulse <= 0 && !(ent->v.flags & FL_WORLDBRUSH) && !(ent->v.spawnflags & SF_BREAK_TRIGGER_ONLY))
73087312
return (ent->v.movetype == MOVETYPE_PUSH || ent->v.movetype == MOVETYPE_PUSHSTEP);
@@ -7314,7 +7318,7 @@ bool Bot::IsShootableBreakable(edict_t* ent)
73147318
// this function is gets called when bot enters a buyzone, to allow bot to buy some stuff
73157319
void Bot::EquipInBuyzone(int iBuyCount)
73167320
{
7317-
static float lastEquipTime = 0.0f;
7321+
static float lastEquipTime = 0.0f;
73187322

73197323
// if bot is in buy zone, try to buy ammo for this weapon...
73207324
if (lastEquipTime + 15.0f < engine->GetTime() && m_inBuyZone && g_timeRoundStart + engine->RandomFloat(10.0f, 20.0f) + engine->GetBuyTime() < engine->GetTime() && !g_bombPlanted && m_moneyAmount > 700)

source/chatlib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void Bot::ChatSay(bool teamSay, const char* text, ...)
463463
if (FNullEnt(client.ent))
464464
continue;
465465

466-
if (!(client.flags & CFLAG_USED) || client.ent == GetEntity() || client.flags & FL_FAKECLIENT)
466+
if (!(client.flags & CFLAG_USED) || client.ent == GetEntity())
467467
continue;
468468

469469
if (teamSay && client.team != m_team)

source/combat.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
ConVar ebot_escape("ebot_zombie_escape_mode", "0");
2828
ConVar ebot_zp_use_grenade_percent("ebot_zm_use_grenade_percent", "10");
2929
ConVar ebot_zp_escape_distance("ebot_zm_escape_distance", "300");
30-
ConVar ebot_zombie_speed_factor("ebot_zombie_speed_factor", "0.5");
30+
ConVar ebot_zombie_speed_factor("ebot_zombie_speed_factor", "0.54");
3131
ConVar ebot_sb_mode("ebot_sb_mode", "0");
3232

3333
int Bot::GetNearbyFriendsNearPosition(Vector origin, int radius)
@@ -896,9 +896,9 @@ bool Bot::KnifeAttack(float attackDistance)
896896

897897
if (kaMode > 0)
898898
{
899-
float distanceSkipZ = (pev->origin - GetEntityOrigin(entity)).GetLength2D();
899+
float distanceSkipZ = (pev->origin - GetEntityOrigin(entity)).GetLengthSquared2D();
900900

901-
if (pev->origin.z > GetEntityOrigin(entity).z && distanceSkipZ < 64.0f)
901+
if (pev->origin.z > GetEntityOrigin(entity).z && distanceSkipZ < SquaredF(64.0f))
902902
{
903903
pev->button |= IN_DUCK;
904904
m_campButtons |= IN_DUCK;
@@ -909,7 +909,7 @@ bool Bot::KnifeAttack(float attackDistance)
909909
pev->button &= ~IN_DUCK;
910910
m_campButtons &= ~IN_DUCK;
911911

912-
if (pev->origin.z + 150.0f < GetEntityOrigin(entity).z && distanceSkipZ < 300.0f)
912+
if (pev->origin.z + 150.0f < GetEntityOrigin(entity).z && distanceSkipZ < SquaredF(300.0f))
913913
pev->button |= IN_JUMP;
914914
}
915915

@@ -970,9 +970,9 @@ void Bot::FocusEnemy(void)
970970
if (m_enemySurpriseTime > engine->GetTime())
971971
return;
972972

973-
float distance = (m_lookAt - EyePosition()).GetLength2D(); // how far away is the enemy scum?
973+
float distance = (m_lookAt - EyePosition()).GetLengthSquared2D(); // how far away is the enemy scum?
974974

975-
if (distance < 128)
975+
if (distance < SquaredF(128.0f))
976976
{
977977
if (m_currentWeapon == WEAPON_KNIFE)
978978
{
@@ -1270,7 +1270,7 @@ void Bot::CombatFight(void)
12701270
}
12711271
}
12721272

1273-
if (m_jumpTime + 10.0f < engine->GetTime() && !IsOnLadder() && ChanceOf(m_isReloading ? 5 : 2) && pev->velocity.GetLength2D() > float(m_skill + 50.0f) && !UsesSniper())
1273+
if (m_jumpTime + 10.0f < engine->GetTime() && !IsOnLadder() && ChanceOf(m_isReloading ? 5 : 2) && pev->velocity.GetLength2D() > float(m_skill + 50) && !UsesSniper())
12741274
pev->button |= IN_JUMP;
12751275

12761276
if (m_moveSpeed > 0.0f && distance > SquaredF(512.0f) && m_currentWeapon != WEAPON_KNIFE)

source/engine.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
//
2424

2525
#include <core.h>
26-
#include <random>
2726

2827
ConVar::ConVar(const char* name, const char* initval, VarType type)
2928
{

source/interface.cpp

Lines changed: 132 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,79 @@ int BotCommandHandler_O(edict_t* ent, const String& arg0, const String& arg1, co
105105
else if (stricmp(arg0, "fillserver") == 0 || stricmp(arg0, "fill") == 0)
106106
g_botManager->FillServer(atoi(arg1), IsNullString(arg2) ? -1 : atoi(arg2), IsNullString(arg3) ? -1 : atoi(arg3), IsNullString(arg4) ? -1 : atoi(arg4));
107107

108+
// set entity action with command
109+
else if (stricmp(arg0, "setentityaction") == 0)
110+
{
111+
int index = atoi(arg1);
112+
int team = atoi(arg2);
113+
int action = atoi(arg3);
114+
115+
int i;
116+
if (index == -1)
117+
{
118+
for (i = 0; i < entityNum; i++)
119+
SetEntityActionData(i);
120+
121+
ServerPrintNoTag("[E-Bot] Set Entity Action - Delete All - Done");
122+
return 1;
123+
}
124+
125+
edict_t* entity = INDEXENT(index);
126+
if (FNullEnt(entity) || !IsAlive(entity))
127+
{
128+
ServerPrintNoTag("[E-Bot] Set Entity Action - Entity is NULL or not alive - Done");
129+
return -1;
130+
}
131+
132+
if (IsValidPlayer(entity))
133+
{
134+
ServerPrintNoTag("[E-Bot] Set Entity Action - Cannot set the player - Done");
135+
return -1;
136+
}
137+
138+
for (i = 0; i < entityNum; i++)
139+
{
140+
if (g_entityId[i] == index)
141+
{
142+
if (action != -1)
143+
{
144+
if (team != g_entityTeam[i] || action != g_entityAction[i])
145+
{
146+
SetEntityActionData(i, index, team, action);
147+
ServerPrintNoTag("[E-Bot] Set Entity Action - Change ID: %d Team: %d Action: %d - Done", index, team, action);
148+
}
149+
else
150+
ServerPrintNoTag("[E-Bot] Set Entity Action - Don't Need Change ID: %d - Not Change - Done", index);
151+
}
152+
else
153+
{
154+
SetEntityActionData(i);
155+
ServerPrintNoTag("[E-Bot] Set Entity Action - Delete ID: %d - Done", index);
156+
}
157+
158+
return 1;
159+
}
160+
}
161+
162+
if (action == -1)
163+
{
164+
ServerPrintNoTag("[E-Bot] Set Entity Action - Cannot Delete ID: %d - Not Find - Done", index);
165+
return -1;
166+
}
167+
168+
for (i = 0; i < entityNum; i++)
169+
{
170+
if (g_entityId[i] == -1)
171+
{
172+
SetEntityActionData(i, index, team, action);
173+
return 1;
174+
}
175+
}
176+
177+
ServerPrintNoTag("[E-Bot] Cannot Add Entity Action - Unknow Error - Done");
178+
return -1;
179+
}
180+
108181
// swap counter-terrorist and terrorist teams
109182
else if (stricmp(arg0, "swaptteams") == 0 || stricmp(arg0, "swap") == 0)
110183
{
@@ -288,46 +361,6 @@ int BotCommandHandler_O(edict_t* ent, const String& arg0, const String& arg1, co
288361
}
289362
}
290363

291-
// sets mesh for waypoint
292-
else if (stricmp(arg0, "setmesh") == 0)
293-
{
294-
if (IsNullString(arg1))
295-
ClientPrint(ent, print_withtag, "Please set mesh <number>");
296-
else if (FNullEnt(g_hostEntity))
297-
ClientPrint(ent, print_withtag, "Please try this in lan game");
298-
else
299-
{
300-
int index = g_waypoint->FindNearest(GetEntityOrigin(g_hostEntity), 75.0f);
301-
if (IsValidWaypoint(index))
302-
{
303-
g_waypoint->GetPath(index)->campStartX = fabsf(static_cast <float> (atof(arg1)));
304-
ClientPrint(ent, print_withtag, "Waypoint mesh set to %d", static_cast <int> (g_waypoint->GetPath(index)->campStartX));
305-
}
306-
else
307-
ClientPrint(ent, print_withtag, "Waypoint is not valid");
308-
}
309-
}
310-
311-
// sets gravity for waypoint
312-
else if (stricmp(arg0, "setgravity") == 0)
313-
{
314-
if (IsNullString(arg1))
315-
ClientPrint(ent, print_withtag, "Please set gravity <number>");
316-
else if (FNullEnt(g_hostEntity))
317-
ClientPrint(ent, print_withtag, "Please try this in lan game");
318-
else
319-
{
320-
int index = g_waypoint->FindNearest(GetEntityOrigin(g_hostEntity), 75.0f);
321-
if (IsValidWaypoint(index))
322-
{
323-
g_waypoint->GetPath(index)->campStartY = fabsf(static_cast <float> (atof(arg1)));
324-
ClientPrint(ent, print_withtag, "Waypoint gravity set to %f", g_waypoint->GetPath(index)->campStartY);
325-
}
326-
else
327-
ClientPrint(ent, print_withtag, "Waypoint is not valid");
328-
}
329-
}
330-
331364
// displays main bot menu
332365
else if (stricmp(arg0, "botmenu") == 0 || stricmp(arg0, "menu") == 0)
333366
DisplayMenuToClient(ent, &g_menus[0]);
@@ -478,6 +511,42 @@ int BotCommandHandler_O(edict_t* ent, const String& arg0, const String& arg1, co
478511
DisplayMenuToClient(g_hostEntity, &g_menus[12]);
479512
}
480513

514+
// sets mesh for waypoint
515+
else if (stricmp(arg1, "setmesh") == 0)
516+
{
517+
if (IsNullString(arg2))
518+
ClientPrint(ent, print_withtag, "Please set mesh <number>");
519+
else
520+
{
521+
int index = g_waypoint->FindNearest(GetEntityOrigin(g_hostEntity), 75.0f);
522+
if (IsValidWaypoint(index))
523+
{
524+
g_waypoint->GetPath(index)->campStartX = fabsf(static_cast <float> (atof(arg2)));
525+
ClientPrint(ent, print_withtag, "Waypoint mesh set to %d", static_cast <int> (g_waypoint->GetPath(index)->campStartX));
526+
}
527+
else
528+
ClientPrint(ent, print_withtag, "Waypoint is not valid");
529+
}
530+
}
531+
532+
// sets gravity for waypoint
533+
else if (stricmp(arg1, "setgravity") == 0)
534+
{
535+
if (IsNullString(arg2))
536+
ClientPrint(ent, print_withtag, "Please set gravity <number>");
537+
else
538+
{
539+
int index = g_waypoint->FindNearest(GetEntityOrigin(g_hostEntity), 75.0f);
540+
if (IsValidWaypoint(index))
541+
{
542+
g_waypoint->GetPath(index)->campStartY = fabsf(static_cast <float> (atof(arg2)));
543+
ClientPrint(ent, print_withtag, "Waypoint gravity set to %f", g_waypoint->GetPath(index)->campStartY);
544+
}
545+
else
546+
ClientPrint(ent, print_withtag, "Waypoint is not valid");
547+
}
548+
}
549+
481550
// creates basic waypoints on the map (ladder/spawn points/goals)
482551
else if (stricmp(arg1, "addbasic") == 0)
483552
{
@@ -2789,7 +2858,7 @@ void JustAStuff(void)
27892858
edict_t* player = INDEXENT(i);
27902859

27912860
// code below is executed only on dedicated server
2792-
if (!FNullEnt(player) && (player->v.flags & FL_CLIENT) && !(player->v.flags & FL_FAKECLIENT))
2861+
if (!FNullEnt(player) && (player->v.flags & FL_CLIENT))
27932862
{
27942863
const char* password = ebot_password.GetString();
27952864
const char* key = ebot_password_key.GetString();
@@ -2846,38 +2915,36 @@ void JustAStuff(void)
28462915
static float secondTimer = 0.0;
28472916
void FrameThread(void)
28482917
{
2849-
if (g_analyzewaypoints)
2850-
g_waypoint->Analyze();
2851-
2852-
if (ebot_lockzbot.GetBool())
2853-
{
2854-
if (CVAR_GET_FLOAT("bot_quota") > 0)
2855-
{
2856-
CVAR_SET_FLOAT("ebot_quota", CVAR_GET_FLOAT("bot_quota"));
2857-
ServerPrint("ebot_lockzbot is 1, you cannot add Z-Bot");
2858-
ServerPrint("You can input ebot_lockzbot unlock add Z-Bot");
2859-
ServerPrint("But, If you have use AMXX plug-in or Zombie Mod, I think this is not good choice");
2860-
CVAR_SET_FLOAT("bot_quota", 0);
2861-
}
2862-
}
2863-
28642918
if (secondTimer < engine->GetTime())
28652919
{
28662920
LoadEntityData();
28672921
JustAStuff();
28682922

2869-
float time = 0.64f;
2870-
if (g_waypointOn)
2871-
time = 1.0f;
2923+
if (g_bombPlanted)
2924+
g_waypoint->SetBombPosition();
28722925

2873-
secondTimer = AddTime(time);
2874-
}
2926+
if (ebot_lockzbot.GetBool())
2927+
{
2928+
if (CVAR_GET_FLOAT("bot_quota") > 0)
2929+
{
2930+
CVAR_SET_FLOAT("ebot_quota", CVAR_GET_FLOAT("bot_quota"));
2931+
ServerPrint("ebot_lockzbot is 1, you cannot add Z-Bot");
2932+
ServerPrint("You can input ebot_lockzbot unlock add Z-Bot");
2933+
ServerPrint("But, If you have use AMXX plug-in or Zombie Mod, I think this is not good choice");
2934+
CVAR_SET_FLOAT("bot_quota", 0);
2935+
}
2936+
}
28752937

2876-
if (g_bombPlanted)
2877-
g_waypoint->SetBombPosition();
2938+
secondTimer = AddTime(1.0f);
2939+
}
2940+
else
2941+
{
2942+
// keep bot number up to date
2943+
g_botManager->MaintainBotQuota();
28782944

2879-
// keep bot number up to date
2880-
g_botManager->MaintainBotQuota();
2945+
if (g_analyzewaypoints)
2946+
g_waypoint->Analyze();
2947+
}
28812948
}
28822949

28832950
void StartFrame(void)

0 commit comments

Comments
 (0)