Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add information about upgrade part handling calculation #33

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions swep1rcr.exe/handling.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
typedef struct {
float AntiSkid; // 0
float TurnResponse; // 4
float MaxTurnRate; // 8
float Acceleration; // 12
float MaxSpeed; // 16
float AirbrakeInv; // 20
float DecelInv; // 24
float BoostThrust; // 28
float HeatRate; // 32
float CoolRate; // 36
float HoverHeight; // 40
float RepairRate; // 44
float BumpMass; // 48
float DmgImmunity; // 52
} PACKED PodracerHandlingData;

// This is the format used for storing information in the binary.
// At load time, IsectRadius is shifted back by 4 additional bytes.
// So it is seperated here so we can re-use PodracerHandlingData.
typedef struct {
PodracerHandlingData
float IsectRadius; // 56
} PACKED PodracerHandlingTableData;
162 changes: 162 additions & 0 deletions swep1rcr.exe/upgrades.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/* Information related to podracer upgrades */

// Research based on patched US version

#include "handling.h"

typedef struct {
uint8_t index; // absolute index to identify part?
uint8_t level; // level / quality?
uint8_t unk1; // ?
uint8_t category; // what kind of part it is?
int32_t price;
int32_t model; // model index
char* title;
} PartData;

PartData data_4C1CB8[7 * 6]; // 7 categories x 6 levels



//----- (004493F0) --------------------------------------------------------
// Calculates the handling data for a podracer after an upgrade
// a1 = Handling data to be modified
// a2 = Upgrade category
// a3 = Upgrade level
// a4 = Upgrade health?! [0.0, 1.0]
void __cdecl sub_4493F0(PodracerHandlingData* a1, int32_t a2, int32_t a3, float a4) {

switch (a2) {

case 0:
if (a3 == 1) {
a1->AntiSkid = clamp(a4 * 0.05f + a1->AntiSkid, 0.01f, 1.0f);
}
if (a3 == 2) {
a1->AntiSkid = clamp(a4 * 0.10f + a1->AntiSkid, 0.01f, 1.0f);
}
if (a3 == 3) {
a1->AntiSkid = clamp(a4 * 0.15f + a1->AntiSkid, 0.01f, 1.0f);
}
if (a3 == 4) {
a1->AntiSkid = clamp(a4 * 0.20f + a1->AntiSkid, 0.01f, 1.0f);
}
if (a3 == 5) {
a1->AntiSkid = clamp(a4 * 0.25f + a1->AntiSkid, 0.01f, 1.0f);
}
break;

case 1:
if (a3 == 1) {
a1->TurnResponse = clamp(a4 * 116.0f + a1->TurnResponse, 50.0f, 1000.0f);
}
if (a3 == 2) {
a1->TurnResponse = clamp(a4 * 232.0f + a1->TurnResponse, 50.0f, 1000.0f);
}
if (a3 == 3) {
a1->TurnResponse = clamp(a4 * 348.0f + a1->TurnResponse, 50.0f, 1000.0f);
}
if (a3 == 4) {
a1->TurnResponse = clamp(a4 * 464.0f + a1->TurnResponse, 50.0f, 1000.0f);
}
if (a3 == 5) {
a1->TurnResponse = clamp(a4 * 578.0f + a1->TurnResponse, 50.0f, 1000.0f);
}
break;

case 2:
if (a3 == 1) {
a1->Acceleration = clamp(((1.0f - a4) * 0.14f - -0.86f) * a1->Acceleration, 0.1f, 5.0f);
}
if (a3 == 2) {
a1->Acceleration = clamp(((1.0f - a4) * 0.28f - -0.72f) * a1->Acceleration, 0.1f, 5.0f);
}
if (a3 == 3) {
a1->Acceleration = clamp(((1.0f - a4) * 0.42f - -0.58f) * a1->Acceleration, 0.1f, 5.0f);
}
if (a3 == 4) {
a1->Acceleration = clamp(((1.0f - a4) * 0.56f - -0.44f) * a1->Acceleration, 0.1f, 5.0f);
}
if (a3 == 5) {
a1->Acceleration = clamp(((1.0f - a4) * 0.70f - -0.30f) * a1->Acceleration, 0.1f, 5.0f);
}
break;

case 3:
if (a3 == 1) {
a1->MaxSpeed = clamp(a4 * 40.0f + a1->MaxSpeed, 450.0f, 650.0f);
}
if (a3 == 2) {
a1->MaxSpeed = clamp(a4 * 80.0f + a1->MaxSpeed, 450.0f, 650.0f);
}
if (a3 == 3) {
a1->MaxSpeed = clamp(a4 * 120.0f + a1->MaxSpeed, 450.0f, 650.0f);
}
if (a3 == 4) {
a1->MaxSpeed = clamp(a4 * 160.0f + a1->MaxSpeed, 450.0f, 650.0f);
}
if (a3 == 5) {
a1->MaxSpeed = clamp(a4 * 200.0f + a1->MaxSpeed, 450.0f, 650.0f);
}
break;

case 4:
if (a3 == 1) {
a1->AirbrakeInv = clamp(((1.0f - a4) * 0.08f - -0.92f) * a1->AirbrakeInv, 1.0f, 1000.0f);
}
if (a3 == 2) {
a1->AirbrakeInv = clamp(((1.0f - a4) * 0.17f - -0.83f) * a1->AirbrakeInv, 1.0f, 1000.0f);
}
if (a3 == 3) {
a1->AirbrakeInv = clamp(((1.0f - a4) * 0.26f - -0.74f) * a1->AirbrakeInv, 1.0f, 1000.0f);
}
if (a3 == 4) {
a1->AirbrakeInv = clamp(((1.0f - a4) * 0.35f - -0.65f) * a1->AirbrakeInv, 1.0f, 1000.0f);
}
if (a3 == 5) {
a1->AirbrakeInv = clamp(((1.0f - a4) * 0.44f - -0.56f) * a1->AirbrakeInv, 1.0f, 1000.0f);
}
break;

case 5:
if (a3 == 1) {
a1->CoolRate = clamp(a4 * 1.6f + a1->CoolRate, 1.0f, 20.0f);
}
if (a3 == 2) {
a1->CoolRate = clamp(a4 * 3.2f + a1->CoolRate, 1.0f, 20.0f);
}
if (a3 == 3) {
a1->CoolRate = clamp(a4 * 4.8f + a1->CoolRate, 1.0f, 20.0f);
}
if (a3 == 4) {
a1->CoolRate = clamp(a4 * 6.4f + a1->CoolRate, 1.0f, 20.0f);
}
if (a3 == 5) {
a1->CoolRate = clamp(a4 * 8.0f + a1->CoolRate, 1.0f, 20.0f);
}
break;

case 6:
if (a3 == 1) {
a1->RepairRate = clamp(a4 * 0.10f + a1->RepairRate, 0.0f, 1.0f);
}
if (a3 == 2) {
a1->RepairRate = clamp(a4 * 0.20f + a1->RepairRate, 0.0f, 1.0f);
}
if (a3 == 3) {
a1->RepairRate = clamp(a4 * 0.30f + a1->RepairRate, 0.0f, 1.0f);
}
if (a3 == 4) {
a1->RepairRate = clamp(a4 * 0.40f + a1->RepairRate, 0.0f, 1.0f);
}
if (a3 == 5) {
a1->RepairRate = clamp(a4 * 0.45f + a1->RepairRate, 0.0f, 1.0f);
}
break;

default:
break;
}
return;
}