Re: MapFix Plugin [message #492337 is a reply to message #492314] |
Sun, 30 April 2017 12:47 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma:
|
General (3 Stars) |
|
|
jonwil wrote on Fri, 28 April 2017 06:41 | If you want to find the exact position/facing of, say, the Nod Refinery MCT (that is, the physics object that counts as the MCT and will take the extra MCT damage when hit), do this:
#include "buildingaggregateclass.h"
#include "buildinggameobj.h"
#include "matrix3d.h"
//somewhere in your code
BuildingGameObj *obj = Find_Refinery(0);
BuildingAggregateClass *ba = obj->Find_MCT();
Matrix3D tm = ba->Get_Transform();
Vector3 position = tm.Get_Translation();
float rotation = RAD2DEG(tm.Get_Z_Rotation());
Change the first line of code as appropriate to find the MCT for different buildings.
The position/rotation values you just obtained can be passed to Commands->Set_Position and Commands->Set_Facing as appropriate.
The values you get here should match exactly to what you would see if you opened up the .lvl file in LevelEdit and double clicked on the MCT object.
|
Toggle Spoiler
void MapFix::Mct_Fix()
{
MCTOBJ = 0;
GameObject *obj = Find_Refinery(0);
BuildingAggregateClass *REFMCT = obj->As_BuildingGameObj()->Find_MCT();
Matrix3D tm = REFMCT->Get_Transform();
Vector3 position = tm.Get_Translation();
float rotation = RAD2DEG(tm.Get_Z_Rotation());
if (REFMCT) {
Debug(3, 2, "Create mnref_ag_3_n\n");
Vector3 Defualt(0.0f, 0.0f, 0.0f);
Vector3 Position;
bool ReadINI = DASettingsManager::Get_Bool(The_Game()->Get_Map_Name(), "MCT_ReadINI", false);
DASettingsManager::Get_Vector3(Position, The_Game()->Get_Map_Name(), "MCT_Position", Defualt);
float Facing = DASettingsManager::Get_Float(The_Game()->Get_Map_Name(), "MCT_Facing", 90.0f);
Vector3 MCTPos = position;
//Read from INI instead of getting position from MCT
if (ReadINI) {
MCTPos = Position;
}
else
Facing = rotation;
Console_Output("Position %f %f %f Rotation %f Facing %f\n", position.X, position.Y, position.Z, rotation, Facing);
PhysicalGameObj *c = Create_Object("Invisible_Object", MCTPos);
Commands->Set_Facing(c, Facing);
Commands->Set_Model(c, "mctfix");
Commands->Set_Is_Visible(c, true);
MCTOBJ = c;
MCTPOS = MCTPos;
obj->Add_Observer(new MCTObserverClass(c));
}
}
The Position I get from Find_MCT on canyon.
I cant get the facing it is always 0.
Position -74.823540 -128.861725 1.024454 Rotation 0.000000 Facing 0.000000
Do you know if this is something that could be fixed by editing the mctfix w3dfiles. The mct is centered 0.0.0 in the gmax file.
The correct position for canyon
MCT_Position_X=-74.803001
MCT_Position_Y=-128.895004
MCT_Position_Z=1.486000
MCT_Facing=90.000000
Correcting the facing and position in game.
[Updated on: Sun, 30 April 2017 12:51] Report message to a moderator
|
|
|