//0E24=4,store_vehicle %1d% rotation_to %2d% %3d% %4d%
eOpcodeResult WINAPI StoreVehicleRotation(CScript* script)
{
script->Collect(1);
unsigned int VehicleStruct = _GetVehicleStructByHandle(Params[0].nVar);
float VehicleRotMatrix[9];
VehicleRotMatrix[0] = *(float *)(VehicleStruct + 0x04);
VehicleRotMatrix[1] = *(float *)(VehicleStruct + 0x04 + 0x04);
VehicleRotMatrix[2] = *(float *)(VehicleStruct + 0x04 + 0x08);
VehicleRotMatrix[3] = *(float *)(VehicleStruct + 0x04 + 0x10);
VehicleRotMatrix[4] = *(float *)(VehicleStruct + 0x04 + 0x14);
VehicleRotMatrix[5] = *(float *)(VehicleStruct + 0x04 + 0x18);
VehicleRotMatrix[6] = *(float *)(VehicleStruct + 0x04 + 0x20);
VehicleRotMatrix[7] = *(float *)(VehicleStruct + 0x04 + 0x24);
VehicleRotMatrix[8] = *(float *)(VehicleStruct + 0x04 + 0x28);
float VehicleAngleXaYaZa[3];
RotationMatrixToEulerianAngle((float *)VehicleRotMatrix, (float *)VehicleAngleXaYaZa);
EulerianAngleNormalize360((float *)VehicleAngleXaYaZa);
Params[0].fVar = VehicleAngleXaYaZa[0];
Params[1].fVar = VehicleAngleXaYaZa[1];
Params[2].fVar = VehicleAngleXaYaZa[2];
script->Store(3);
return OR_CONTINUE;
}
//0E25=4,set_vehicle %1d% rotation %2d% %3d% %4d%
eOpcodeResult WINAPI SetVehicleRotation(CScript* script)
{
script->Collect(4);
unsigned int VehicleStruct = _GetVehicleStructByHandle(Params[0].nVar);
float VehicleAngleXaYaZa[3];
VehicleAngleXaYaZa[0] = Params[1].fVar;
VehicleAngleXaYaZa[1] = Params[2].fVar;
VehicleAngleXaYaZa[2] = Params[3].fVar;
float VehicleRotMatrix[9];
EulerianAngleToRotationMatrix((float *)VehicleAngleXaYaZa, (float *)VehicleRotMatrix);
*(float *)(VehicleStruct + 0x04) = VehicleRotMatrix[0];
*(float *)(VehicleStruct + 0x04 + 0x04) = VehicleRotMatrix[1];
*(float *)(VehicleStruct + 0x04 + 0x08) = VehicleRotMatrix[2];
*(float *)(VehicleStruct + 0x04 + 0x10) = VehicleRotMatrix[3];
*(float *)(VehicleStruct + 0x04 + 0x14) = VehicleRotMatrix[4];
*(float *)(VehicleStruct + 0x04 + 0x18) = VehicleRotMatrix[5];
*(float *)(VehicleStruct + 0x04 + 0x20) = VehicleRotMatrix[6];
*(float *)(VehicleStruct + 0x04 + 0x24) = VehicleRotMatrix[7];
*(float *)(VehicleStruct + 0x04 + 0x28) = VehicleRotMatrix[8];
return OR_CONTINUE;
}