Skip to content

Commit 27421cd

Browse files
committed
TDM Team Shoot partially repaired
1 parent 789694a commit 27421cd

File tree

19 files changed

+74
-68
lines changed

19 files changed

+74
-68
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Supported Mods
1919
RCBot versions
2020
--------------
2121

22-
V 1.51-beta6
22+
V 1.51-beta7
2323
---------
2424

2525
* added: Enhanced performance and stability
@@ -49,7 +49,6 @@ V 1.51-beta6
4949
* TODO: To improve on how to allow bots climb ladders more properly
5050
* TODO: To prevent bots from team shooting in Team Deathmatch mode for HLDM, Op4DM, DMC and TS
5151
* TODO: To prevent bots in TS v3.0 on firing empty rounds and lying proning on floors
52-
* TODO: To bring back the TS v3.0 stunt dive code that was working previously
5352
* TODO: To allow bots in Op4 to use Grapple by using the "Fly" waypoint
5453
* TODO: To add proper support for S&I, AHL, FLF and WizWars
5554

dlls/basemonster.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ class CBaseMonster : public CBaseToggle
783783
virtual BOOL FInViewCone(Vector* pOrigin);// see if given location is in monster's view cone
784784
void TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecDir, TraceResult* ptr, int bitsDamageType) override;
785785
void MakeDamageBloodDecal(int cCount, float flNoise, TraceResult* ptr, const Vector& vecDir);
786-
virtual BOOL IsAlive() override { return pev->deadflag != DEAD_DEAD; }
786+
BOOL IsAlive() override { return pev->deadflag != DEAD_DEAD; }
787787
};
788788

789789
#endif

dlls/bits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class CBits
7979
int size() const;
8080

8181
private:
82-
int m_iNumBits;
82+
unsigned int m_iNumBits;
8383
unsigned char* m_cBits;
84-
int m_iSize; // bits' mem size
84+
//int m_iSize; // bits' mem size
8585
};
8686

8787
#endif

dlls/bot.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8412,8 +8412,8 @@ void CBot::WorkMoveDirection()
84128412

84138413
// botmans code! (me maths suxorz...sorta)
84148414
const float radians = fAngle * static_cast<float>(M_PI) / 180.0f; // degrees to radians
8415-
float flMove = std::cos(radians);
8416-
float flSide = std::sin(radians);
8415+
const float flMove = std::cos(radians);
8416+
const float flSide = std::sin(radians);
84178417
//
84188418

84198419
/* // <-- add extra slash to uncomment this code
@@ -16374,7 +16374,7 @@ if ( !HasUser4Mask(MASK_UPGRADE_9) )
1637416374
}
1637516375
}
1637616376

16377-
BOOL CBot::CanFly()
16377+
BOOL CBot::CanFly() const
1637816378
{
1637916379
return IsLerk() || (IsMarine() && HasJetPack())
1638016380
|| ((gBotGlobals.IsMod(MOD_GEARBOX) && HasWeapon(static_cast<int>(GearboxWeapon::GRAPPLE)))

dlls/bot.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class CBotReputations
372372

373373
CClient* GetRandomClient(int iRep) const;
374374

375-
void WriteToFile(int iBotProfile, CBotReputation* pRep);
375+
static void WriteToFile(int iBotProfile, CBotReputation* pRep);
376376

377377
void RemoveSaveRep(int iBotProfile, int iPlayerRepId);
378378

@@ -3079,7 +3079,7 @@ class CBot
30793079

30803080
edict_t* getSentry() const;
30813081

3082-
BOOL CanBuild(edict_t* pEdict, int* metal = nullptr);
3082+
static BOOL CanBuild(edict_t* pEdict, int* metal = nullptr);
30833083

30843084
const char* getLookTaskDescription() const
30853085
{
@@ -3123,7 +3123,7 @@ class CBot
31233123
CPerceptron* dec_stunt;
31243124
edict_t* m_pElectricEnemy;
31253125

3126-
BOOL isInAnimate(edict_t* pEntity);
3126+
static BOOL isInAnimate(edict_t* pEntity);
31273127

31283128
BOOL isFriendly(edict_t* pEntity) const;
31293129

@@ -3895,7 +3895,7 @@ class CBot
38953895
// that the bot doesn't want to avoid.
38963896
BOOL CanAvoid(edict_t* pEntity, float fDistanceToEntity, float fAvoidDistance) const;
38973897

3898-
void ChangeAngles(float* fSpeed, float* fIdeal, float* fCurrent, float* fUpdate);
3898+
static void ChangeAngles(float* fSpeed, float* fIdeal, float* fCurrent, float* fUpdate);
38993899

39003900
BOOL IsOnLadder() const
39013901
{
@@ -3908,7 +3908,7 @@ class CBot
39083908
}
39093909

39103910
// if bot can fly, this will return true
3911-
BOOL CanFly();
3911+
BOOL CanFly() const;
39123912
/*{
39133913
return IsMarine() && HasJetPack() || IsLerk();
39143914
}*/
@@ -4704,7 +4704,7 @@ class CClients
47044704

47054705
void ClientDisconnected(edict_t* pPlayer);
47064706

4707-
void ClientDisconnected(CClient* pClient);
4707+
static void ClientDisconnected(CClient* pClient);
47084708

47094709
CClient* GetClientByIndex(int iIndex)
47104710
{
@@ -5572,7 +5572,7 @@ class CBotCam
55725572

55735573
BOOL TuneIn(edict_t* pPlayer) const;
55745574

5575-
void TuneOff(edict_t* pPlayer);
5575+
static void TuneOff(edict_t* pPlayer);
55765576

55775577
BOOL IsWorking() const;
55785578

@@ -5782,7 +5782,7 @@ class CTFCFlags
57825782
m_Flags.Pop();
57835783
}
57845784

5785-
edict_t* getFlag(int team, int active_goal)
5785+
static edict_t* getFlag(int team, int active_goal)
57865786
{
57875787
return nullptr;
57885788
}

dlls/bot_ga.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void CBotGAValues::crossOver(IIndividual* other)
7272

7373
CBotGAValues* vother = static_cast<CBotGAValues*>(other);
7474

75-
int i;
75+
unsigned int i;
7676

7777
for (i = 0; i < iPoint; i++)
7878
{
@@ -298,7 +298,7 @@ void CBitsGAValues::crossOver(IIndividual* other)
298298
// mutate some values
299299
void CBitsGAValues::mutate()
300300
{
301-
for (int i = 0; i < m_theBits->numBits(); i++)
301+
for (unsigned int i = 0; i < m_theBits->numBits(); i++)
302302
{
303303
if (RANDOM_FLOAT(0.0f, 1.0f) < CGA::g_fMutateRate)
304304
{

dlls/bot_nn.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ NN::NN(int iNumHiddenLayers, int iNumInputs, int iNumNeuronsPerHiddenLayer, int
6363
m_Layers.emplace_back(new NNLayer(iNumOutputs, iNumNeuronsPerHiddenLayer));
6464
}
6565

66-
void NN::setWeights(std::vector<ga_value>* weights) const
66+
void NN::setWeights(const std::vector<ga_value>* weights) const
6767
{
68-
unsigned short int w = 0;
68+
unsigned int w = 0;
6969

7070
for (const NNLayer* l : m_Layers)
7171
{
72-
for (unsigned short int j = 0; j < l->numNeurons(); j++)
72+
for (unsigned int j = 0; j < l->numNeurons(); j++)
7373
{
7474
CPerceptron* n = l->getNeuron(j);
7575

76-
for (unsigned short int k = 0; k < n->numWeights(); k++)
76+
for (unsigned int k = 0; k < n->numWeights(); k++)
7777
{
7878
n->setWeight(k, (*weights)[w++]);
7979
}
@@ -85,25 +85,25 @@ void NN::getWeights(std::vector<ga_value>* weights) const
8585
{
8686
for (const NNLayer* l : m_Layers)
8787
{
88-
for (unsigned short int j = 0; j < l->numNeurons(); j++)
88+
for (unsigned int j = 0; j < l->numNeurons(); j++)
8989
{
9090
const CPerceptron* n = l->getNeuron(j);
9191

92-
for (unsigned short int k = 0; k < n->numWeights(); k++)
92+
for (unsigned int k = 0; k < n->numWeights(); k++)
9393
{
9494
weights->emplace_back(n->getWeight(k));
9595
}
9696
}
9797
}
9898
}
9999

100-
void NN::trainOutputs(std::vector<ga_value>* wanted_outputs) const
100+
void NN::trainOutputs(const std::vector<ga_value>* wanted_outputs) const
101101
{
102-
unsigned short int w = 0;
102+
unsigned int w = 0;
103103

104104
for (const NNLayer* l : m_Layers)
105105
{
106-
for (unsigned short int j = 0; j < l->numNeurons(); j++)
106+
for (unsigned int j = 0; j < l->numNeurons(); j++)
107107
{
108108
CPerceptron* n = l->getNeuron(j);
109109

@@ -120,7 +120,7 @@ void NN::getOutputs(std::vector<ga_value>* outputs) const
120120

121121
for (const NNLayer* l : m_Layers)
122122
{
123-
for (unsigned short int j = 0; j < l->numNeurons(); j++)
123+
for (unsigned int j = 0; j < l->numNeurons(); j++)
124124
{
125125
const CPerceptron* n = l->getNeuron(j);
126126

@@ -131,7 +131,7 @@ void NN::getOutputs(std::vector<ga_value>* outputs) const
131131

132132
void NN::execute(std::vector <ga_value>* outputs, std::vector <ga_value>* inputs) const
133133
{
134-
unsigned short int i;
134+
unsigned int i;
135135

136136
std::vector<ga_value> newoutputs;
137137

@@ -146,7 +146,7 @@ void NN::execute(std::vector <ga_value>* outputs, std::vector <ga_value>* inputs
146146

147147
newoutputs.clear();
148148

149-
for (unsigned short int j = 0; j < l->numNeurons(); j++)
149+
for (unsigned int j = 0; j < l->numNeurons(); j++)
150150
{
151151
CPerceptron* n = l->getNeuron(j);
152152

@@ -158,8 +158,8 @@ void NN::execute(std::vector <ga_value>* outputs, std::vector <ga_value>* inputs
158158

159159
outputs->clear();
160160

161-
for (unsigned int k = 0; k < newoutputs.size(); k++)
162-
outputs->emplace_back(newoutputs[k]);
161+
for (float& newoutput : newoutputs)
162+
outputs->emplace_back(newoutput);
163163
}
164164
}
165165

@@ -243,7 +243,7 @@ void NN::randomize() const
243243
{
244244
for (const NNLayer* l : m_Layers)
245245
{
246-
for (unsigned short int j = 0; j < l->numNeurons(); j++)
246+
for (unsigned int j = 0; j < l->numNeurons(); j++)
247247
{
248248
l->getNeuron(j)->randomize();
249249
}
@@ -256,7 +256,7 @@ void NN::freeMemory()
256256
{
257257
NNLayer* l = m_Layer;
258258

259-
for (unsigned short int j = 0; j < l->numNeurons(); j++)
259+
for (unsigned int j = 0; j < l->numNeurons(); j++)
260260
{
261261
l->freeMemory();
262262
}

dlls/cbase.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ class CSquadMonster;
122122
class EHANDLE
123123
{
124124
private:
125-
edict_t* m_pent;
126-
int m_serialnumber;
125+
edict_t* m_pent = nullptr;
126+
int m_serialnumber = 0;
127127
public:
128128
edict_t* Get();
129129
edict_t* Set(edict_t* pent);
@@ -250,12 +250,12 @@ class CBaseEntity
250250

251251
virtual CBaseEntity* Respawn() { return nullptr; }
252252

253-
void SUB_UseTargets(CBaseEntity* pActivator, USE_TYPE useType, float value);
253+
virtual void SUB_UseTargets(CBaseEntity* pActivator, USE_TYPE useType, float value);
254254
// Do the bounding boxes of these two intersect?
255255
int Intersects(CBaseEntity* pOther);
256256
void MakeDormant();
257257
int IsDormant();
258-
BOOL IsLockedByMaster() { return false; }
258+
static BOOL IsLockedByMaster() { return false; }
259259

260260
#ifdef _DEBUG
261261
static CBaseEntity* Instance(edict_t* pent)
@@ -279,17 +279,16 @@ class CBaseEntity
279279
static CBaseEntity* Instance(entvars_t* pev) { return Instance(ENT(pev)); }
280280
static CBaseEntity* Instance(int eoffset) { return Instance(ENT(eoffset)); }
281281

282-
CBaseMonster* GetMonsterPointer(entvars_t* pevMonster)
282+
static CBaseMonster* GetMonsterPointer(entvars_t* pevMonster)
283283
{
284-
CBaseEntity* pEntity = Instance(pevMonster);
285-
if (pEntity)
284+
if (CBaseEntity* pEntity = Instance(pevMonster))
286285
return pEntity->MyMonsterPointer();
287286
return nullptr;
288287
}
289-
CBaseMonster* GetMonsterPointer(edict_t* pentMonster)
288+
289+
static CBaseMonster* GetMonsterPointer(edict_t* pentMonster)
290290
{
291-
CBaseEntity* pEntity = Instance(pentMonster);
292-
if (pEntity)
291+
if (CBaseEntity* pEntity = Instance(pentMonster))
293292
return pEntity->MyMonsterPointer();
294293
return nullptr;
295294
}
@@ -462,7 +461,7 @@ class CBaseDelay : public CBaseEntity
462461

463462
static TYPEDESCRIPTION m_SaveData[];
464463
// common member functions
465-
void SUB_UseTargets(CBaseEntity* pActivator, USE_TYPE useType, float value);
464+
void SUB_UseTargets(CBaseEntity* pActivator, USE_TYPE useType, float value) override;
466465
void EXPORT DelayThink();
467466
};
468467

dlls/dll.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,7 @@ void ClientCommand(edict_t* pEntity)
941941
}
942942

943943
// finished with message
944-
std::free(szMessage);
945-
944+
delete[] szMessage;
946945
szMessage = nullptr;
947946
}
948947
}
@@ -1766,7 +1765,7 @@ void BotFunc_ReadProfile(std::FILE* fp, bot_profile_t* bpBotProfile)
17661765
{
17671766
char szBuffer[128];
17681767

1769-
int i;
1768+
unsigned int i;
17701769

17711770
char szTemp[64];
17721771
int j;
@@ -2012,7 +2011,7 @@ void ReadBotUsersConfig()
20122011
if (length == 0) // nothing on line
20132012
continue;
20142013

2015-
int i = 0;
2014+
unsigned int i = 0;
20162015

20172016
while (i < length && buffer[i] != '"')
20182017
i++;

dlls/globals.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ void CBotGlobals::MapInit()
11641164
m_fNextJoinTeam = 0.0f;
11651165
m_iNumBots = 0;
11661166

1167-
m_bTeamPlay = false;
1167+
m_bTeamPlay = true;
11681168

11691169
m_currCapPoint = nullptr;
11701170
m_currFlag = nullptr;
@@ -1224,14 +1224,21 @@ void CBotGlobals::MapInit()
12241224
}
12251225
else if (IsMod(MOD_GEARBOX))
12261226
{
1227-
if (std::strncmp(mapname, "op4ctf_", 3) == 0)
1227+
if (std::strncmp(mapname, "op4ctf_", 7) == 0 || std::strncmp(mapname, "op4cp_", 6) == 0)
12281228
{
12291229
setMapType(NON_TS_TEAMPLAY);
12301230
//TODO: To make sure that Op4DM mode doesn't play as CTF Mode [APG]RoboCop[CL]
12311231
// Op4CTF Support [APG]RoboCop[CL]
12321232
//extern edict_t *pent_info_ctfdetect;
12331233
m_bTeamPlay = true;
12341234
}
1235+
else
1236+
{
1237+
if (CVAR_GET_FLOAT("mp_teamplay") <= 0.0f)
1238+
{
1239+
m_bTeamPlay = false;
1240+
}
1241+
}
12351242
}
12361243

12371244
PRECACHE_MODEL("models/mechgibs.mdl");

0 commit comments

Comments
 (0)