Skip to content

Commit 4d691eb

Browse files
author
Motive
committed
- Added support for @rotate yaw pitch roll, which will rotate an object on the 3 axis. Unfortunately, the up vector is not used by the actor API at this time.
1 parent 1c081ee commit 4d691eb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Diff for: Commands/Commands.galaxy

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void libcrtx_commands_init()
100100
libcrtx_command_create("@weaponspeed", "libcrtx_command_weaponspeed");
101101
libcrtx_command_create("@weaponspeedall", "libcrtx_command_weaponspeedall");
102102
libcrtx_command_create("@animspeed", "libcrtx_command_animspeed");
103+
libcrtx_command_create("@rotate", "libcrtx_command_rotate");
103104

104105

105106
// admin commands

Diff for: Commands/UnitCommands.galaxy

+23
Original file line numberDiff line numberDiff line change
@@ -2166,3 +2166,26 @@ bool libcrtx_command_animspeed(bool testConds, bool runActions)
21662166
return true;
21672167
}
21682168

2169+
bool libcrtx_command_rotate(bool testConds, bool runActions)
2170+
{
2171+
unitgroup g = libcrtx_chat_get_context(EventPlayer());
2172+
fixed yaw = StringToFixed(libcrtx_param_index(2));
2173+
fixed pitch = StringToFixed(libcrtx_param_index(3));
2174+
fixed roll = StringToFixed(libcrtx_param_index(4));
2175+
2176+
fixed forwardX = Sin(yaw);
2177+
fixed forwardY = -Sin(pitch) * Cos(yaw);
2178+
fixed forwardZ = Cos(pitch) * Cos(yaw);
2179+
2180+
fixed upX = -Cos(yaw) * Sin(roll);
2181+
fixed upY = -Sin(pitch) * Sin(yaw) * Sin(roll) + Cos(pitch) * Cos(roll);
2182+
fixed upZ = Cos(pitch) * Sin(yaw) * Sin(roll) + Sin(pitch) * Cos(roll);
2183+
2184+
UnitGroupLoopBegin(g);
2185+
while(!UnitGroupLoopDone()) {
2186+
ActorSend( libNtve_gf_MainActorofUnit(UnitGroupLoopCurrent()), libNtve_gf_SetRotation(forwardX, forwardY, forwardZ, upX, upY, upZ) );
2187+
UnitGroupLoopStep();
2188+
}
2189+
UnitGroupLoopEnd();
2190+
return true;
2191+
}

0 commit comments

Comments
 (0)