Initial commit: bt411 -- standalone Windows BattleTech (Tesla 4.10 port)
Clean, self-contained extraction of the BattleTech-specific work from the
reverse-engineering workspace -- engine + game + content + build, with nothing
from Red Planet or the raw archive dumps. Builds green (Win32) and runs the
single-player drive->animate->target->fire->damage->destroy loop out of the box.
Layout:
engine/ MUNGA + MUNGA_L4 shared 2007 engine, carrying our BT render/loader
work (bgfload/L4D3D/L4VIDEO: BSL bit-slice decode, LOD/ground/shadow
models) + image codec; the minimal rp/ headers the audio HAL needs
game/ reconstructed BT logic + surviving-original BT source + fwd shims
+ WinMain launcher
content/ full runtime tree (BTL4.RES, VIDEO/, GAUGE/, AUDIO/, eggs, BTDPL.INI)
docs/ format specs + reconstruction ledgers
reference/ raw Ghidra pseudocode (recon source-of-truth) + decomp exporter
tools/ MP console emulator + map/resource scanners
One top-level CMake builds munga_engine lib + bt410_l4 game lib + btl4.exe.
All paths relativized (186 fwd shims + ~437 CMake abs paths -> repo-relative);
DXSDK is the one external, overridable via -DDXSDK. Verified: builds to a
byte-identical 2.27MB exe and runs combat (TARGET DESTROYED, 0 crashes) against
the bundled content.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,235 @@
|
||||
#include "munga.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "scnrole.h"
|
||||
#include "app.h"
|
||||
#include "notation.h"
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
ScenarioRole::ScenarioRole(const CString &role_name)
|
||||
{
|
||||
damageReceivedModifier = 0.0f;
|
||||
damageInflictedModifier = 0.0f;
|
||||
damageBias = 0.0f;
|
||||
friendlyFirePenalty = 0.0f;
|
||||
killBonus = 0.0f;
|
||||
roleName = role_name;
|
||||
returnFromDeath = 0;
|
||||
}
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
ScenarioRole::ScenarioRole(const CString &role_name, const CString &model_file)
|
||||
{
|
||||
Check_Pointer(&role_name);
|
||||
Check_Pointer(&model_file);
|
||||
|
||||
roleName = role_name;
|
||||
//
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Truncate the Role:: from roleName
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
ResourceFile
|
||||
*res = application->GetResourceFile();
|
||||
ResourceDescription
|
||||
*player_res_des;
|
||||
|
||||
player_res_des = res->FindResourceDescription(
|
||||
model_file,
|
||||
ResourceDescription::GameModelResourceType
|
||||
);
|
||||
|
||||
if (player_res_des)
|
||||
{
|
||||
player_res_des->Lock();
|
||||
ModelResource
|
||||
*player_data = (ModelResource *)player_res_des->
|
||||
resourceAddress;
|
||||
|
||||
killBonus = player_data->killBonus;
|
||||
returnFromDeath = player_data->returnFromDeath;
|
||||
damageReceivedModifier = player_data->damageReceivedModifier;
|
||||
damageInflictedModifier = player_data->damageInflictedModifier;
|
||||
damageBias = player_data->damageBias;
|
||||
friendlyFirePenalty = player_data->friendlyFirePenalty;
|
||||
player_res_des->Unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
Tell(role_name);
|
||||
Warn(" does not exists in resource! ");
|
||||
damageReceivedModifier = 0.0f;
|
||||
damageInflictedModifier = 0.0f;
|
||||
damageBias = 0.0f;
|
||||
friendlyFirePenalty = 0.0f;
|
||||
killBonus = 0.0f;
|
||||
returnFromDeath = 0;
|
||||
}
|
||||
}
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
Scalar
|
||||
ScenarioRole::CalcDamageReceivedScore(const Scalar &damage_received)
|
||||
{
|
||||
Check(this);
|
||||
// ]
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Calculate modified score for the player receiving damage
|
||||
// damageReceived * damageReceivedModifier
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
Check(this);
|
||||
|
||||
Check_Fpu();
|
||||
return -(damage_received * GetDamageReceivedModifier());
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
ScenarioRole::~ScenarioRole()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
ResourceDescription::ResourceID
|
||||
ScenarioRole::CreateModelResource(
|
||||
#if DEBUG_LEVEL>0
|
||||
ResourceFile *resource_file,
|
||||
const char* model_name,
|
||||
NotationFile * model_file,
|
||||
const ResourceDirectories *directories,
|
||||
ModelResource *model
|
||||
#else
|
||||
ResourceFile *resource_file,
|
||||
const char* model_name,
|
||||
NotationFile * model_file,
|
||||
const ResourceDirectories *,
|
||||
ModelResource *model
|
||||
#endif
|
||||
)
|
||||
{
|
||||
Check(resource_file);
|
||||
Check_Pointer(model_name);
|
||||
Check_Pointer(directories);
|
||||
|
||||
//
|
||||
// If we were not provided a buffer to write the model data into, we must
|
||||
// create it ourselves. Then make sure that the model stuff is read in
|
||||
//
|
||||
ModelResource *local_model = model;
|
||||
if (!local_model)
|
||||
{
|
||||
local_model = new ModelResource;
|
||||
Register_Pointer(local_model);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Read in the data from notation file
|
||||
//----------------------------------------
|
||||
//
|
||||
// Get PointValue assigned to this ScoreZone
|
||||
//
|
||||
|
||||
if(
|
||||
!model_file->GetEntry(
|
||||
"gamedata",
|
||||
"KillBonus",
|
||||
&local_model->killBonus
|
||||
)
|
||||
)
|
||||
{
|
||||
std::cerr << model_name << "Missing KillBonus" << std::endl;
|
||||
Dump_And_Die:
|
||||
if (!model)
|
||||
{
|
||||
Unregister_Pointer(local_model);
|
||||
delete local_model;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(
|
||||
!model_file->GetEntry(
|
||||
"gamedata",
|
||||
"DamageReceivedModifier",
|
||||
&local_model->damageReceivedModifier
|
||||
)
|
||||
)
|
||||
{
|
||||
std::cerr << model_name << "Missing DamageReceivedModifier" << std::endl;
|
||||
goto Dump_And_Die;
|
||||
}
|
||||
|
||||
if(
|
||||
!model_file->GetEntry(
|
||||
"gamedata",
|
||||
"DamageInflictedModifier",
|
||||
&local_model->damageInflictedModifier
|
||||
)
|
||||
)
|
||||
{
|
||||
std::cerr << model_name << "Missing DamageInflictedModifier" << std::endl;
|
||||
goto Dump_And_Die;
|
||||
}
|
||||
if(
|
||||
!model_file->GetEntry(
|
||||
"gamedata",
|
||||
"ReturnFromDeath",
|
||||
&local_model->returnFromDeath
|
||||
)
|
||||
)
|
||||
{
|
||||
std::cerr << model_name << "Missing ReturnFromDeath" << std::endl;
|
||||
goto Dump_And_Die;
|
||||
}
|
||||
if(
|
||||
!model_file->GetEntry(
|
||||
"gamedata",
|
||||
"DamageBias",
|
||||
&local_model->damageBias
|
||||
)
|
||||
)
|
||||
{
|
||||
std::cerr << model_name << "Missing DamageBias" << std::endl;
|
||||
goto Dump_And_Die;
|
||||
}
|
||||
|
||||
if(
|
||||
!model_file->GetEntry(
|
||||
"gamedata",
|
||||
"FriendlyFirePenalty",
|
||||
&local_model->friendlyFirePenalty
|
||||
)
|
||||
)
|
||||
{
|
||||
std::cerr << model_name << "Missing FriendlyFirePenalty" << std::endl;
|
||||
goto Dump_And_Die;
|
||||
}
|
||||
|
||||
|
||||
if (!model)
|
||||
{
|
||||
ResourceDescription *new_res =
|
||||
resource_file->AddResource(
|
||||
model_name,
|
||||
ResourceDescription::GameModelResourceType,
|
||||
1,
|
||||
ResourceDescription::Preload,
|
||||
local_model,
|
||||
sizeof(*local_model)
|
||||
);
|
||||
Unregister_Pointer(local_model);
|
||||
delete local_model;
|
||||
Check_Fpu();
|
||||
Check(new_res);
|
||||
return new_res->resourceID;
|
||||
}
|
||||
else
|
||||
{
|
||||
Check_Fpu();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user