Skip to content

Commit ec4038b

Browse files
authored
Customize max opponent colors when using -maxoppcolors (closes #102)
2 parents ee694ff + 54af95b commit ec4038b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

code/midtown/mmai/aiVehicleOpponent.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ define_dummy_symbol(mmai_aiVehicleOpponent);
2323
#include "agi/dlptmpl.h"
2424
#include "agi/getdlp.h"
2525
#include "agiworld/quality.h"
26+
#include "data7/str.h"
27+
#include "mmcityinfo/vehlist.h"
2628

2729
#include "aiData.h"
2830
#include "aiGoalBackup.h"
2931
#include "aiGoalFollowWayPts.h"
3032
#include "aiGoalStop.h"
3133

34+
static mem::cmd_param PARAM_maxoppcolors {"maxoppcolors"};
35+
3236
void aiVehicleOpponent::DrawDamage()
3337
{}
3438

@@ -38,10 +42,10 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)
3842
if (agiRQ.TextureQuality)
3943
--agiRQ.TextureQuality;
4044

41-
i32 paint_job = opp_id & 3;
42-
i32 index = opp_id + 1;
45+
OpponentRaceData* opp = static_cast<OpponentRaceData*>(race_data->Opponents.Access(opp_id + 1));
4346

44-
OpponentRaceData* opp = static_cast<OpponentRaceData*>(race_data->Opponents.Access(index));
47+
mmVehInfo* veh_info = VehList()->GetVehicleInfo(opp->Model);
48+
i32 paint_job = opp_id % PARAM_maxoppcolors.get_or(string(veh_info->Colors).NumSubStrings());
4549

4650
Car.Init(opp->Model, CAR_TYPE_OPPONENT, paint_job);
4751

@@ -52,9 +56,7 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)
5256

5357
WayPts = arnew aiGoalFollowWayPts(
5458
opp->PathFile, &RailSet, this, &IsBackup, &IsFinished, &IsStopped, xconst(race_name), opp->MaxThrottle);
55-
5659
BackupGoal = arnew aiGoalBackup(&RailSet, &Car, &IsBackup);
57-
5860
StopGoal = arnew aiGoalStop(&Car, &IsStopped);
5961

6062
IsSemi = !std::strcmp("vpsemi", opp->Model);
@@ -71,5 +73,6 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)
7173
RailSet.BackBumperDist = max.z;
7274
RailSet.RSideDist = max.x;
7375
}
76+
7477
AudIndexNumber = -1;
7578
}

docs/setup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ For a tutorial on how to use command line arguments, click [here](https://www.bl
4040
| allrace | false | Unlocks All Races |
4141
| maxcops | 3 | Max cops chasing you at once |
4242
| nodamage | false | Disables Damage |
43+
| maxoppcolors | auto | Cycles through the opponent car colors based on the number of paintjobs available |
4344

4445
## Basic
4546

0 commit comments

Comments
 (0)