mirror of
https://github.com/XLabsProject/iw3x-port.git
synced 2023-08-02 15:02:11 +02:00
Add care package to ents
This commit is contained in:
parent
07d475a6fe
commit
baa5578482
@ -14,6 +14,8 @@ namespace Components
|
||||
std::string entString(ents->entityString, ents->numEntityChars - 1);
|
||||
|
||||
Utils::Entities mapEnts(entString);
|
||||
|
||||
mapEnts.addCarePackages();
|
||||
mapEnts.deleteOldSchoolPickups();
|
||||
|
||||
if (mapEnts.convertTurrets())
|
||||
|
@ -502,6 +502,7 @@ namespace Components
|
||||
const auto brushNodeIndex = clipMap->leafbrushNodesCount;
|
||||
const auto brushEdgeIndex = clipMap->numBrushEdges;
|
||||
const auto materialIndex = clipMap->numMaterials;
|
||||
const auto cModelIndex = clipMap->numSubModels;
|
||||
|
||||
// Materials
|
||||
constexpr auto matSize = sizeof(Game::IW3::dmaterial_t);
|
||||
@ -579,12 +580,12 @@ namespace Components
|
||||
bounds.max(model.leaf.maxs);
|
||||
|
||||
model.leaf.leafBrushNode = brushNodeIndex;
|
||||
reallocatedCModels[cModelIndex + i] = model;
|
||||
}
|
||||
|
||||
clipMap->numSubModels++;
|
||||
clipMap->numSubModels += 2;
|
||||
clipMap->cmodels = reallocatedCModels;
|
||||
|
||||
|
||||
// Brushes
|
||||
constexpr auto brushSize = sizeof(Game::IW3::cbrush_t);
|
||||
|
||||
@ -636,7 +637,6 @@ namespace Components
|
||||
if (clipMap->brushEdges[i] == *reallocatedBrushes[j].baseAdjacentSide)
|
||||
{
|
||||
reallocatedBrushes[j].baseAdjacentSide = &clipMap->brushEdges[i];
|
||||
validated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ namespace Game
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
out[i] = midPoint[i] - halfSize[i] * 2;
|
||||
out[i] = midPoint[i] - halfSize[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ namespace Game
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
out[i] = midPoint[i] + halfSize[i] * 2;
|
||||
out[i] = midPoint[i] + halfSize[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,10 @@ namespace Utils
|
||||
{
|
||||
std::string model = entity["model"];
|
||||
|
||||
if (!model.empty() && model[0] != '*' && model[0] != '?') // Skip brushmodels
|
||||
if (!model.empty()
|
||||
&& model[0] != '*' && model[0] != '?' // Skip brushmodels
|
||||
&& !model.starts_with("com_plasticcase_") // Skip care package (part of team zones)
|
||||
)
|
||||
{
|
||||
if (std::find(models->begin(), models->end(), model) == models->end())
|
||||
{
|
||||
@ -99,6 +102,73 @@ namespace Utils
|
||||
return hasVehicles;
|
||||
}
|
||||
|
||||
void Entities::addCarePackages()
|
||||
{
|
||||
auto subModelCount = 0;
|
||||
|
||||
// We don't have a clipmap reference, so
|
||||
Game::DB_EnumXAssetEntries(Game::XAssetType::ASSET_TYPE_CLIPMAP_PVS, [&subModelCount](Game::IW3::XAssetEntry* entry) {
|
||||
if (entry && entry->asset.header.clipMap && subModelCount == 0)
|
||||
{
|
||||
// A clipmap is loaded, we may add the care packages
|
||||
auto clipMap = entry->asset.header.clipMap;
|
||||
|
||||
subModelCount = clipMap->numSubModels;
|
||||
}
|
||||
}, false);
|
||||
|
||||
|
||||
if (subModelCount > 0)
|
||||
{
|
||||
// The last two static models will always be the care packages if we added them ourselves
|
||||
auto countWithoutPackages = subModelCount - 2;
|
||||
|
||||
// All values here taken from mp_rust
|
||||
std::unordered_map<std::string, std::string> airdropPalletBrushModel =
|
||||
{
|
||||
{ "script_gameobjectname", "airdrop_pallet"},
|
||||
{ "targetname", "iw3x_entity_carepackage"},
|
||||
{ "classname", "script_brushmodel"},
|
||||
{ "origin", "-5072 6560 858"},
|
||||
{ "model", "*" + std::to_string(countWithoutPackages) }
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, std::string> airdropPalletScriptModel =
|
||||
{
|
||||
{ "ltOrigin", "-5072 6560.19 872.889"},
|
||||
{ "target", "iw3x_entity_carepackage"},
|
||||
{ "targetname", "airdrop_crate"},
|
||||
{ "origin", "-5072 6560 858"},
|
||||
{ "classname", "script_model"},
|
||||
{ "model", "com_plasticcase_green_big_us_dirt"}
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, std::string> carePackageBrushModel =
|
||||
{
|
||||
{"script_gameobjectname", "airdrop_pallet"},
|
||||
{ "targetname", "iw3x_entity_airdroppallet"},
|
||||
{ "classname", "script_brushmodel"},
|
||||
{ "origin", "250 325 -299"},
|
||||
{ "model", "*" + std::to_string(countWithoutPackages+1) }
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, std::string> carePackageScriptModel =
|
||||
{
|
||||
{ "ltOrigin", "249.7 324.886 -299.611"},
|
||||
{ "target", "iw3x_entity_carepackage"},
|
||||
{ "targetname", "care_package"},
|
||||
{ "origin", "249.7 324.7 -314.5"},
|
||||
{ "classname", "script_model"},
|
||||
{ "model", "com_plasticcase_green_big_us_dirt"}
|
||||
};
|
||||
|
||||
entities.push_back(airdropPalletBrushModel);
|
||||
entities.push_back(airdropPalletScriptModel);
|
||||
entities.push_back(carePackageBrushModel);
|
||||
entities.push_back(carePackageScriptModel);
|
||||
}
|
||||
}
|
||||
|
||||
void Entities::deleteTriggers()
|
||||
{
|
||||
for (auto i = this->entities.begin(); i != this->entities.end();)
|
||||
|
@ -17,6 +17,7 @@ namespace Utils
|
||||
void deleteOldSchoolPickups();
|
||||
bool convertTurrets();
|
||||
bool convertVehicles();
|
||||
void addCarePackages();
|
||||
|
||||
private:
|
||||
enum
|
||||
|
Loading…
Reference in New Issue
Block a user