Formation movement example
by Stephen Zepp · in RTS Starter Kit · 11/11/2004 (6:39 pm) · 27 replies
This small set of script mods allows you to set a formation that your selected group of units will march into when you set a move destination.
Currently, the formation itself is not capable of being "oriented", meaning that they all line up to the right/down of the destination point. My next goal (which I will probably need some assistance on for the target formation decal) is to have the player able to right click and hold on the destination point, which displays a grid of destination points (one for each unit). While the mouse is held, the player can rotate the formation in the X-Y plane to change the orientation of the formation when they reach the destination. The move will commence when the mouse is released.
Anyway, here's the code:
in file /client/scripts/inputHandler.cs:
Replace the entire function "function GuiRTSTSCtrl::onRightMouseDownTerrain(%this, %x, %y, %z)" with
(con't next message)
Currently, the formation itself is not capable of being "oriented", meaning that they all line up to the right/down of the destination point. My next goal (which I will probably need some assistance on for the target formation decal) is to have the player able to right click and hold on the destination point, which displays a grid of destination points (one for each unit). While the mouse is held, the player can rotate the formation in the X-Y plane to change the orientation of the formation when they reach the destination. The move will commence when the mouse is released.
Anyway, here's the code:
in file
Replace the entire function "function GuiRTSTSCtrl::onRightMouseDownTerrain(%this, %x, %y, %z)" with
function GuiRTSTSCtrl::onRightMouseDownTerrain(%this, %x, %y, %z)
{
if(%this.selectionIncludesTeam)
// first shot at formations. hard code a formation for now, make it a selectable
// choice (global var) later
commandToServer('IssueMove', $Player::CurSquadFormation, %x, %y, %z);
}(con't next message)
#22
I've been wondering that but couldn't figure out what it was
05/08/2008 (8:39 am)
Thanks, what exactly is the %iI've been wondering that but couldn't figure out what it was
#23
we've also been this index to calculate the offset.
05/08/2008 (10:19 am)
%i is a number representing a position in the selection. its used to find the unit whose offset from the centre of the formation we are setting through %obj = %client.selection.getObject(%i);we've also been this index to calculate the offset.
#24
05/08/2008 (10:45 am)
Ah I see,, thanks. Now I've gotta focus on tackling a "follow the leader" type movement, it's called a file in the Army, where everyone just follows the point man in a line. In the game it would move like a snake following the head. I'm not even sure where to begin on that one
#25
05/08/2008 (10:48 am)
That probably wouldnt be here. here you simply set the destination to a certain point in three space.. what you would need probably requires something like setting the aimObject and having the engine handle that... you'd need to apply some core changes for this though...
#26
I just need to focus on the "wedge" formation then now:
It's complex, but this wedge formation is probably the most important formation that I need to figure out how to do.
It's a little simulator I'm making for the Army ROTC, and this is the most common formation we move in. I'm a cadet with them
05/08/2008 (11:29 am)
Hmm, looks like I'll skip that one then :)I just need to focus on the "wedge" formation then now:
It's complex, but this wedge formation is probably the most important formation that I need to figure out how to do.It's a little simulator I'm making for the Army ROTC, and this is the most common formation we move in. I'm a cadet with them
#27
first unit its at X offset
Y += 5
second is {X-5,Y} and third at {X+5,Y}
Y += 5
fourth is {X-10,Y} and fifth at {X+10,Y}
Y += 5
sixth is at {X,Y}
Y += 5
seventh is at {X,Y}
Y += 5
eigth is at {X-5,Y} and ninth at {X+5,Y}
Y += 5
tenth is {X-10,Y} and eleventh at {X+10,Y}
that assumes there are ~11 units.
02/07/2010 (11:00 pm)
That shouldn't be too difficult to create ...first unit its at X offset
Y += 5
second is {X-5,Y} and third at {X+5,Y}
Y += 5
fourth is {X-10,Y} and fifth at {X+10,Y}
Y += 5
sixth is at {X,Y}
Y += 5
seventh is at {X,Y}
Y += 5
eigth is at {X-5,Y} and ninth at {X+5,Y}
Y += 5
tenth is {X-10,Y} and eleventh at {X+10,Y}
that assumes there are ~11 units.
Torque Owner Tijs