@@ -43,18 +43,21 @@ ConVar ebot_use_radio("ebot_use_radio", "1");
43
43
ConVar ebot_anti_block (" ebot_anti_block" , " 0" );
44
44
ConVar ebot_zm_dark_mode (" ebot_zm_dark_mode" , " 0" );
45
45
ConVar ebot_force_flashlight (" ebot_force_flashlight" , " 0" );
46
- ConVar ebot_use_flare (" ebot_zombie_mode_use_flares " , " 1" );
46
+ ConVar ebot_use_flare (" ebot_zm_use_flares " , " 1" );
47
47
ConVar ebot_chat_percent (" ebot_chat_percent" , " 20" );
48
48
ConVar ebot_eco_rounds (" ebot_eco_rounds" , " 1" );
49
49
50
50
ConVar ebot_chatter_path (" ebot_chatter_path" , " radio/bot" );
51
51
52
+ /* ConVar ebot_enable_lasermine("ebot_enable_lasermine", "0");
53
+ ConVar ebot_lasermine_max("ebot_lasermine_max", "2");
54
+ ConVar ebot_lasermine_classname("ebot_lasermine_classname", "zp_lasermine");*/
55
+
52
56
// this function get the current message from the bots message queue
53
57
int Bot::GetMessageQueue (void )
54
58
{
55
59
int message = m_messageQueue[m_actMessageIndex++];
56
60
m_actMessageIndex &= 0x1f ; // wraparound
57
-
58
61
return message;
59
62
}
60
63
@@ -66,18 +69,16 @@ void Bot::PushMessageQueue(int message)
66
69
// notify other bots of the spoken text otherwise, bots won't respond to other bots (network messages aren't sent from bots)
67
70
int entityIndex = GetIndex ();
68
71
69
- for (const auto & client : g_clients )
72
+ for (int i = 0 ; i < engine-> GetMaxClients (); i++ )
70
73
{
71
- Bot* otherBot = g_botManager->GetBot (client. ent );
74
+ Bot* otherBot = g_botManager->GetBot (i );
72
75
if (otherBot != nullptr && otherBot->pev != pev)
73
76
{
74
- if (IsAlive ( GetEntity ()) == otherBot->m_notKilled )
77
+ if (m_notKilled == IsAlive ( otherBot->GetEntity ()) )
75
78
{
76
79
otherBot->m_sayTextBuffer .entityIndex = entityIndex;
77
80
strcpy (otherBot->m_sayTextBuffer .sayText , m_tempStrings);
78
81
}
79
-
80
- otherBot->m_sayTextBuffer .timeNextChat = engine->GetTime () + otherBot->m_sayTextBuffer .chatDelay ;
81
82
}
82
83
}
83
84
}
@@ -176,13 +177,6 @@ bool Bot::IsEnemyViewable(edict_t* entity, bool setEnemy, bool checkOnly)
176
177
if (m_damageTime < engine->GetTime ())
177
178
m_backCheckEnemyTime = engine->GetTime () + engine->RandomFloat (0 .5f , 1 .5f );
178
179
}
179
- else if (IsDeathmatchMode ())
180
- {
181
- if (!FNullEnt (m_enemy))
182
- return false ;
183
-
184
- m_backCheckEnemyTime = engine->GetTime () + float (50 / m_skill);
185
- }
186
180
else if (GetGameMod () == MODE_ZP)
187
181
m_backCheckEnemyTime = engine->GetTime () + engine->RandomFloat (0 .15f , 0 .5f );
188
182
else
@@ -439,6 +433,19 @@ void Bot::ZmCampPointAction(int mode)
439
433
}
440
434
}
441
435
436
+ /* int Bot::GetLasermineCount(void)
437
+ {
438
+ int count = 0;
439
+ edict_t* lasermine = nullptr;
440
+ while (!FNullEnt(lasermine = FIND_ENTITY_BY_CLASSNAME(lasermine, ebot_lasermine_classname.GetString())))
441
+ {
442
+ if (lasermine->v.owner == GetEntity())
443
+ count++;
444
+ }
445
+
446
+ return count;
447
+ }*/
448
+
442
449
void Bot::AvoidEntity (void )
443
450
{
444
451
if (IsZombieMode () || FNullEnt (m_avoidEntity) || (m_avoidEntity->v .flags & FL_ONGROUND) || (m_avoidEntity->v .effects & EF_NODRAW))
@@ -493,7 +500,7 @@ void Bot::AvoidEntity(void)
493
500
494
501
if (strcmp (STRING (entity->v .classname ), " grenade" ) == 0 )
495
502
{
496
- if (strcmp (STRING (entity->v .model ) + 9 , " flashbang.mdl" ) == 0 && GetGameMod () != MODE_BASE && ! IsDeathmatchMode () )
503
+ if (IsZombieMode () && strcmp (STRING (entity->v .model ) + 9 , " flashbang.mdl" ) == 0 )
497
504
continue ;
498
505
499
506
if (strcmp (STRING (entity->v .model ) + 9 , " hegrenade.mdl" ) == 0 && (GetTeam (entity->v .owner ) == m_team && entity->v .owner != GetEntity ()))
@@ -1953,7 +1960,7 @@ void Bot::SetConditions(void)
1953
1960
else if (m_heardSoundTime < engine->GetTime ())
1954
1961
m_states &= ~STATE_HEARENEMY;
1955
1962
1956
- if (FNullEnt (m_enemy) && !FNullEnt (m_lastEnemy) && m_lastEnemyOrigin != nullvec && ( GetGameMod () == MODE_BASE || IsDeathmatchMode () ) && (pev->origin - m_lastEnemyOrigin).GetLength () < 1600 .0f )
1963
+ if (FNullEnt (m_enemy) && !FNullEnt (m_lastEnemy) && m_lastEnemyOrigin != nullvec && ! IsZombieMode ( ) && (pev->origin - m_lastEnemyOrigin).GetLength () < 1600 .0f )
1957
1964
{
1958
1965
TraceResult tr;
1959
1966
TraceLine (EyePosition (), m_lastEnemyOrigin, true , true , GetEntity (), &tr);
@@ -2744,6 +2751,13 @@ bool Bot::ReactOnEnemy(void)
2744
2751
{
2745
2752
m_isEnemyReachable = false ;
2746
2753
2754
+ if (pev->flags & FL_DUCKING)
2755
+ {
2756
+ if (enemyDistance < 32 .0f )
2757
+ m_isEnemyReachable = true ;
2758
+ goto last;
2759
+ }
2760
+
2747
2761
// end of the path, before repathing check the distance if we can reach to enemy
2748
2762
if (m_navNode == nullptr )
2749
2763
{
@@ -2756,22 +2770,16 @@ bool Bot::ReactOnEnemy(void)
2756
2770
m_isEnemyReachable = true ;
2757
2771
goto last;
2758
2772
}
2773
+ else if (g_waypoint->GetPath (ownIndex)->flags & WAYPOINT_FALLRISK)
2774
+ goto last;
2759
2775
else if (IsVisibleForKnifeAttack (enemyHead, GetEntity ()))
2760
2776
{
2761
- if (pev->flags & FL_DUCKING)
2762
- {
2763
- if (enemyDistance <= 48 .0f )
2764
- m_isEnemyReachable = true ;
2765
- }
2766
- else
2767
- {
2768
- float radius = 48 .0f ;
2769
- if (IsValidWaypoint (ownIndex) && !(currentWaypoint->flags & WAYPOINT_FALLCHECK))
2770
- radius += currentWaypoint->radius ;
2777
+ float radius = 128 .0f ;
2778
+ if (IsValidWaypoint (ownIndex) && !(currentWaypoint->flags & WAYPOINT_FALLCHECK))
2779
+ radius += currentWaypoint->radius ;
2771
2780
2772
- if (enemyDistance > radius)
2773
- m_isEnemyReachable = true ;
2774
- }
2781
+ if (enemyDistance > radius)
2782
+ m_isEnemyReachable = true ;
2775
2783
2776
2784
goto last;
2777
2785
}
@@ -2792,30 +2800,37 @@ bool Bot::ReactOnEnemy(void)
2792
2800
}
2793
2801
else if (pev->flags & FL_DUCKING && m_enemy->v .flags & FL_DUCKING) // danger...
2794
2802
{
2795
- if (enemyDistance <= (fabsf (m_enemy->v .speed ) + 300 .0f ))
2803
+ extern ConVar ebot_zp_escape_distance;
2804
+ if (enemyDistance <= fabsf (m_enemy->v .speed ) + ebot_zp_escape_distance.GetFloat ())
2796
2805
{
2797
2806
m_isEnemyReachable = true ;
2798
2807
goto last;
2799
2808
}
2800
2809
}
2810
+ else if (g_waypoint->GetPath (ownIndex)->flags & WAYPOINT_FALLRISK)
2811
+ goto last;
2801
2812
else if (GetCurrentTask ()->taskID == TASK_CAMP)
2802
2813
{
2803
2814
if (enemyIndex == m_zhCampPointIndex)
2804
2815
m_isEnemyReachable = true ;
2805
- else if (enemyDistance <= ( fabsf (m_enemy-> v . speed ) + 300 . 0f ))
2816
+ else
2806
2817
{
2807
- for (int j = 0 ; j < Const_MaxPathIndex; j++)
2818
+ extern ConVar ebot_zp_escape_distance;
2819
+ if (enemyDistance <= fabsf (m_enemy->v .speed ) + ebot_zp_escape_distance.GetFloat ())
2808
2820
{
2809
- Vector origin = GetBottomOrigin (GetEntity ());
2821
+ for (int j = 0 ; j < Const_MaxPathIndex; j++)
2822
+ {
2823
+ Vector origin = GetBottomOrigin (GetEntity ());
2810
2824
2811
- TraceResult tr;
2812
- TraceLine (Vector (origin.x , origin.y , (origin.z + 10 .0f )), enemyHead, true , false , GetEntity (), &tr);
2825
+ TraceResult tr;
2826
+ TraceLine (Vector (origin.x , origin.y , (origin.z + 10 .0f )), enemyHead, true , false , GetEntity (), &tr);
2813
2827
2814
- auto enemyWaypoint = g_waypoint->GetPath (enemyIndex);
2815
- if (tr.flFraction == 1 .0f && enemyWaypoint->index [j] == ownIndex && !(enemyWaypoint->connectionFlags [j] & PATHFLAG_JUMP))
2816
- {
2817
- m_isEnemyReachable = true ;
2818
- break ;
2828
+ auto enemyWaypoint = g_waypoint->GetPath (enemyIndex);
2829
+ if (tr.flFraction == 1 .0f && enemyWaypoint->index [j] == ownIndex && !(enemyWaypoint->connectionFlags [j] & PATHFLAG_JUMP))
2830
+ {
2831
+ m_isEnemyReachable = true ;
2832
+ break ;
2833
+ }
2819
2834
}
2820
2835
}
2821
2836
}
@@ -2830,7 +2845,8 @@ bool Bot::ReactOnEnemy(void)
2830
2845
TraceLine (Vector (origin.x , origin.y , (origin.z + 10 .0f )), enemyHead, true , false , GetEntity (), &tr);
2831
2846
2832
2847
// human improve
2833
- if (enemyDistance <= (fabsf (m_enemy->v .speed ) + 300 .0f ) && tr.flFraction == 1 .0f )
2848
+ extern ConVar ebot_zp_escape_distance;
2849
+ if (enemyDistance <= fabsf (m_enemy->v .speed ) + ebot_zp_escape_distance.GetFloat () && tr.flFraction == 1 .0f )
2834
2850
m_isEnemyReachable = true ;
2835
2851
else
2836
2852
m_isEnemyReachable = false ;
@@ -3635,7 +3651,10 @@ void Bot::ChooseAimDirection(void)
3635
3651
}
3636
3652
3637
3653
if (flags & AIM_OVERRIDE)
3654
+ {
3655
+ m_aimStopTime = 0 .0f ;
3638
3656
m_lookAt = m_camp;
3657
+ }
3639
3658
else if (flags & AIM_GRENADE)
3640
3659
m_lookAt = m_throw + Vector (0 .0f , 0 .0f , 1 .0f * m_grenade.z );
3641
3660
else if (flags & AIM_ENEMY)
@@ -4418,13 +4437,62 @@ void Bot::RunTask(void)
4418
4437
const float timeToBlowUp = GetBombTimeleft ();
4419
4438
float defuseRemainingTime = m_hasDefuser ? 7 .0f : 12 .0f - engine->GetTime ();
4420
4439
4421
- switch (GetCurrentTask ()->taskID )
4440
+ auto x = GetCurrentTask ()->taskID ;
4441
+ /* /if (x == TASK_PLACELASER)
4442
+ {
4443
+ if (m_laserminePosition == nullvec)
4444
+ {
4445
+ TaskComplete();
4446
+ return;
4447
+ }
4448
+
4449
+ if (m_lasermineCount >= ebot_lasermine_max.GetInt())
4450
+ {
4451
+ TaskComplete();
4452
+ return;
4453
+ }
4454
+
4455
+ int currentCount = m_lasermineCount;
4456
+ bool moveTowards = false;
4457
+ float distance = (pev->origin - m_laserminePosition).GetLength();
4458
+
4459
+ if (distance <= 300.0f)
4460
+ {
4461
+ m_aimFlags |= AIM_OVERRIDE;
4462
+ m_camp = m_laserminePosition;
4463
+
4464
+ if (distance <= 80.0f)
4465
+ {
4466
+ moveTowards = true;
4467
+ m_moveSpeed = GetWalkSpeed();
4468
+ FakeClientCommand(GetEntity(), "+setlaser");
4469
+ m_lasermineCount = GetLasermineCount();
4470
+ }
4471
+ }
4472
+ else
4473
+ m_aimFlags |= AIM_NAVPOINT;
4474
+
4475
+ if (!moveTowards)
4476
+ {
4477
+ int index = g_waypoint->FindNearest(m_laserminePosition);
4478
+ if (IsValidWaypoint(index))
4479
+ FindPath(m_currentWaypointIndex, index);
4480
+ else
4481
+ TaskComplete();
4482
+ }
4483
+
4484
+ if (currentCount != m_lasermineCount)
4485
+ TaskComplete();
4486
+
4487
+ return;
4488
+ }*/
4489
+
4490
+ switch (x)
4422
4491
{
4423
4492
// normal task
4424
4493
case TASK_NORMAL:
4425
4494
TaskNormal (destIndex, i, src);
4426
4495
break ;
4427
-
4428
4496
// bot sprays messy logos all over the place...
4429
4497
case TASK_SPRAYLOGO:
4430
4498
m_aimFlags |= AIM_ENTITY;
@@ -4624,7 +4692,7 @@ void Bot::RunTask(void)
4624
4692
4625
4693
// plain attacking
4626
4694
case TASK_FIGHTENEMY:
4627
- if (IsZombieMode ())
4695
+ if (IsZombieMode () && !m_isZombieBot )
4628
4696
{
4629
4697
TaskNormal (i, destIndex, src);
4630
4698
return ;
@@ -4726,7 +4794,7 @@ void Bot::RunTask(void)
4726
4794
4727
4795
// camping behaviour
4728
4796
case TASK_GOINGFORCAMP:
4729
- if ((m_isZombieBot || (IsZombieMode () && g_waypoint->m_zmHmPoints .IsEmpty ()) || ( IsDeathmatchMode () && pev-> health > pev-> max_health / 1.6 ) )
4797
+ if ((m_isZombieBot || (IsZombieMode () && g_waypoint->m_zmHmPoints .IsEmpty ()))
4730
4798
|| (GetGameMod () == MODE_BASE && (g_mapType & MAP_CS) && m_team == TEAM_COUNTER && HasHostage ())
4731
4799
|| (!IsZombieMode () && !FNullEnt (m_enemy) && m_currentWeapon == WEAPON_KNIFE)
4732
4800
|| (m_personality == PERSONALITY_CAREFUL && GetGameMod () == MODE_BASE && !FNullEnt (m_enemy) && m_numFriendsLeft < m_numEnemiesLeft)
@@ -5431,6 +5499,7 @@ void Bot::RunTask(void)
5431
5499
5432
5500
RemoveCertainTask (TASK_FIGHTENEMY);
5433
5501
5502
+ extern ConVar ebot_zp_escape_distance;
5434
5503
if (IsZombieMode () && !FNullEnt (m_enemy))
5435
5504
{
5436
5505
if (m_isZombieBot)
@@ -5440,7 +5509,7 @@ void Bot::RunTask(void)
5440
5509
m_moveSpeed = pev->maxspeed ;
5441
5510
m_moveToGoal = false ;
5442
5511
}
5443
- else if ((GetEntityOrigin (m_enemy) - pev->origin ).GetLength () <= ( fabsf (m_enemy->v .speed ) + 300 . 0f ))
5512
+ else if ((GetEntityOrigin (m_enemy) - pev->origin ).GetLength () <= fabsf (m_enemy->v .speed ) + ebot_zp_escape_distance. GetFloat ( ))
5444
5513
{
5445
5514
destination = GetEntityOrigin (m_enemy);
5446
5515
m_destOrigin = destination;
@@ -5538,6 +5607,7 @@ void Bot::RunTask(void)
5538
5607
5539
5608
RemoveCertainTask (TASK_FIGHTENEMY);
5540
5609
5610
+ extern ConVar ebot_zp_escape_distance;
5541
5611
if (IsZombieMode () && !FNullEnt (m_enemy))
5542
5612
{
5543
5613
if (m_isZombieBot)
@@ -5547,7 +5617,7 @@ void Bot::RunTask(void)
5547
5617
m_moveSpeed = pev->maxspeed ;
5548
5618
m_moveToGoal = false ;
5549
5619
}
5550
- else if ((GetEntityOrigin (m_enemy) - pev->origin ).GetLength () <= ( fabsf (m_enemy->v .speed ) + 300 .0f ) )
5620
+ else if ((GetEntityOrigin (m_enemy) - pev->origin ).GetLength () <= fabsf (m_enemy->v .speed ) + 300 .0f )
5551
5621
{
5552
5622
destination = GetEntityOrigin (m_enemy);
5553
5623
m_destOrigin = destination;
@@ -6527,7 +6597,7 @@ void Bot::BotAI(void)
6527
6597
{
6528
6598
m_checkKnifeSwitch = false ;
6529
6599
6530
- if (GetGameMod () == MODE_BASE && IsDeathmatchMode ())
6600
+ if (! IsZombieMode ())
6531
6601
{
6532
6602
if (ebot_spraypaints.GetBool () && engine->RandomInt (1 , 10 ) < 2 )
6533
6603
PushTask (TASK_SPRAYLOGO, TASKPRI_SPRAYLOGO, -1 , engine->GetTime () + 1 .0f , false );
@@ -6646,7 +6716,7 @@ void Bot::BotAI(void)
6646
6716
if (m_currentWeapon == WEAPON_KNIFE)
6647
6717
SelectBestWeapon ();
6648
6718
6649
- if (m_isEnemyReachable && !FNullEnt (m_enemy))
6719
+ if (!FNullEnt (m_enemy) && m_isEnemyReachable )
6650
6720
{
6651
6721
m_moveToGoal = false ; // don't move to goal
6652
6722
m_navTimeset = engine->GetTime ();
@@ -6812,9 +6882,10 @@ void Bot::BotAI(void)
6812
6882
}
6813
6883
else
6814
6884
m_isBlocked = CheckCloseAvoidance (directionNormal);
6885
+
6815
6886
m_isStuck = false ;
6816
6887
6817
- if ((m_moveSpeed <= - 10 || m_moveSpeed >= 10 || m_strafeSpeed >= 10 || m_strafeSpeed <= - 10 ) && m_lastCollTime < engine->GetTime ())
6888
+ if ((m_moveSpeed >= 10 || m_strafeSpeed >= 10 ) && m_lastCollTime < engine->GetTime ())
6818
6889
{
6819
6890
if (m_damageTime >= engine->GetTime ())
6820
6891
{
@@ -7208,6 +7279,7 @@ bool Bot::HasHostage(void)
7208
7279
return true ;
7209
7280
}
7210
7281
}
7282
+
7211
7283
return false ;
7212
7284
}
7213
7285
@@ -7508,7 +7580,7 @@ void Bot::MoveToVector(Vector to)
7508
7580
if (!IsValidWaypoint (m_currentWaypointIndex))
7509
7581
{
7510
7582
// we dont have a current waypoint, try find nearest
7511
- int index = m_isStuck ? g_waypoint->FindNearest (pev->origin , 9999 .0f , -1 , GetEntity ()) : FindWaypoint ( false );
7583
+ int index = m_isStuck ? FindWaypoint ( false ) : g_waypoint->FindNearest (pev->origin , 9999 .0f , -1 , GetEntity ());
7512
7584
if (IsValidWaypoint (index))
7513
7585
FindPath (index, g_waypoint->FindNearest (to));
7514
7586
@@ -7694,7 +7766,7 @@ bool Bot::OutOfBombTimer(void)
7694
7766
7695
7767
void Bot::ReactOnSound (void )
7696
7768
{
7697
- if (GetGameMod () != MODE_BASE && ! IsDeathmatchMode ())
7769
+ if (IsZombieMode ())
7698
7770
return ;
7699
7771
7700
7772
if (!m_isSlowThink)
0 commit comments