Pages: [1]
  Print  
Author Topic: Unit Formations In RTS  (Read 1478 times)
Offline (Unknown gender) MrGriggs
Posted on: January 18, 2011, 10:10:34 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
Not sure if this will work, as I wrote it in notepad and can't test currently, but I've come up with the idea of doing something such as

assign is the variable which determines what number unit is the current one of the list that's selected

Code: [Select]
if main.selected-1>1{
for(i=0;i<assign;i+=1) {
    if direction-main.initialdirection <100{
        targt_x=mouse_x+lengthdir_x(((i-(main.selected-1-i)) mod 5)* 64,main.initialdirection+90)
        targt_y=mouse_y+lengthdir_y(((i-(main.selected-1-i)) mod 5)* 64,main.initialdirection+90)}
        else{       
        targt_x=mouse_x+lengthdir_x(((i-(main.selected-1-i)) mod 5)* 64,main.initialdirection-90)
        targt_y=mouse_y+lengthdir_y(((i-(main.selected-1-i)) mod 5)* 64,main.initialdirection-90)}

}
}
« Last Edit: January 21, 2011, 11:38:04 AM by MrGriggs » Logged
Offline (Male) RetroX
Reply #1 Posted on: January 18, 2011, 10:13:26 AM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
Please use [code] tags; they make code much easier to read.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) MrGriggs
Reply #2 Posted on: January 18, 2011, 10:15:09 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
Really sorry, I usually do, just in this instance I forgot :(.
Logged
Offline (Female) IsmAvatar
Reply #3 Posted on: January 18, 2011, 12:06:19 PM

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 891

View Profile Email
The idea, if I read this correctly, is that units maintain their orientation and distance from a central unit who goes towards the desired point, while everyone ends up at their respective distance and orientation from the central unit. This is essentially what Age of Empires II does with villagers.

So it's nothing new, and it can work, it's just somewhat ugly if the units aren't aligned already, or if they don't all fit in their target locations.
Logged
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: January 18, 2011, 01:10:40 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2952

View Profile Email
You mean, like an object index? :P
Anyway, the assign is where you'd want to use a switch(), not a for(). :P
And yes, I'm getting to it.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) MrGriggs
Reply #5 Posted on: January 19, 2011, 04:41:48 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
I got the code to function as intended, I will post it up later on today so people can use it if they so desire, if I have time I'll properly comment all variable factors as well.
Logged
Offline (Unknown gender) MrGriggs
Reply #6 Posted on: January 21, 2011, 06:28:39 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
I got the code to function as intended, I will post it up later on today so people can use it if they so desire, if I have time I'll properly comment all variable factors as well.

Why would I use a switch, that would only allow me to have a limited number of pre-defined units :S.

With a for loop I can loop until the max selected through all the selected and apply the neccessary value.
Logged
Offline (Unknown gender) MrGriggs
Reply #7 Posted on: January 21, 2011, 06:34:46 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
Quote
The idea, if I read this correctly, is that units maintain their orientation and distance from a central unit who goes towards the desired point, while everyone ends up at their respective distance and orientation from the central unit. This is essentially what Age of Empires II does with villagers.

So it's nothing new, and it can work, it's just somewhat ugly if the units aren't aligned already, or if they don't all fit in their target locations.

That's the idea, yeah :)
Logged
Post made January 21, 2011, 10:42:48 AM was deleted at the author's request.
Offline (Unknown gender) MrGriggs
Reply #9 Posted on: January 21, 2011, 11:58:42 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
I actually hate that kind of alignment in AoE2 with the villagers, but do as you please. Why not just add different options? For example, Warcraft 3 allows you to move everyone to the goal with their respective moving speed, or keep them aligned in a formation.

I will be adding different options for players, that will be implemented with particular easy to use mouse gestures.
Logged
Pages: [1]
  Print