From a06281df307191b97c24bbd7dbcf70f1db7faf35 Mon Sep 17 00:00:00 2001 From: Robin Kisman <99972691+KcRobin9@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:09:07 +0100 Subject: [PATCH] Retrieve Color Count from Vehicle Info --- code/midtown/mmai/aiVehicleOpponent.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/code/midtown/mmai/aiVehicleOpponent.cpp b/code/midtown/mmai/aiVehicleOpponent.cpp index c0acb772..18a2c4bf 100644 --- a/code/midtown/mmai/aiVehicleOpponent.cpp +++ b/code/midtown/mmai/aiVehicleOpponent.cpp @@ -23,13 +23,16 @@ define_dummy_symbol(mmai_aiVehicleOpponent); #include "agi/dlptmpl.h" #include "agi/getdlp.h" #include "agiworld/quality.h" +#include "data7/str.h" +#include "mmcityinfo/vehinfo.h" +#include "mmcityinfo/vehlist.h" #include "aiData.h" #include "aiGoalBackup.h" #include "aiGoalFollowWayPts.h" #include "aiGoalStop.h" -static mem::cmd_param PARAM_opponent_color_count {"colorcount"}; +static mem::cmd_param PARAM_opp_color_count {"colorcount"}; void aiVehicleOpponent::DrawDamage() {} @@ -40,10 +43,10 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name) if (agiRQ.TextureQuality) --agiRQ.TextureQuality; - i32 paint_job = opp_id % PARAM_opponent_color_count.get_or(4); - i32 index = opp_id + 1; + OpponentRaceData* opp = static_cast(race_data->Opponents.Access(opp_id + 1)); - OpponentRaceData* opp = static_cast(race_data->Opponents.Access(index)); + mmVehInfo* veh_info = VehList()->GetVehicleInfo(opp->Model); + i32 paint_job = opp_id % PARAM_opp_color_count.get_or(string(veh_info->Colors).NumSubStrings()); Car.Init(opp->Model, CAR_TYPE_OPPONENT, paint_job); @@ -54,9 +57,7 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name) WayPts = arnew aiGoalFollowWayPts( opp->PathFile, &RailSet, this, &IsBackup, &IsFinished, &IsStopped, xconst(race_name), opp->MaxThrottle); - BackupGoal = arnew aiGoalBackup(&RailSet, &Car, &IsBackup); - StopGoal = arnew aiGoalStop(&Car, &IsStopped); IsSemi = !std::strcmp("vpsemi", opp->Model); @@ -73,5 +74,6 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name) RailSet.BackBumperDist = max.z; RailSet.RSideDist = max.x; } + AudIndexNumber = -1; }