Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, AndrewAMD), 14,749 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
lassoing RTS units #86992
08/22/06 02:04
08/22/06 02:04
Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
anonymous_alcoho Offline OP
Senior Developer
anonymous_alcoho  Offline OP
Senior Developer

Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
Okay, most of you have played an RTS before. You click and drag and you form a little box on the screen to select a unit or a group of units. It's called lassoing units. Now I have figured out how to lasso units by dragging the mouse fine, it took about a day because it was somewhat complicated, but now it works perfectly, I can select units by dragging the mouse to lasso them. But there is one small detail remaining

I can't seem to figure out how I would go about drawing the box on the screen. I know this would prolly be easier if I'd upgrade to A6 and used draw_line or whatever that function is, but I don't know if I have the money. What I have done is create an onscreen entity that, when I drag, its scale_x and scale_y is modified. The problem with this is, 1, when I drag, the thickness of the lines distort, much like scaling a hollow cube in WED, and 2, I can't seem to get it so that one corner starts at the initial mouse click (mouseCoord1) and the diagnal corner at the final mouse release (mouseCoord2). The following code is my attempt at creating this box.

Code:


entity lassoBox
{
type = <lasso.bmp>;
layer = 2;
view = camera;
x = 100;
y = 0;
z = 0;
flags = visible;
}

function deselect() //deselects units and lassoes units
{
var recorded;
if(!key_ctrl) //if ctrl is not pressed
{
unselect = 1; //set unselect flag to unselect everything
wait(1); //wait a frame
unselect = 0; //re-enable selection
}
while(mouse_left) //while mouseLeft is pressed
{
if(recorded != 1) //if first position if mouse is not recorded
{
mouse_trace();
vec_set(mouseCoord1,target);
recorded = 1;
}
mouse_trace();
vec_set(mouseCoord2,target);
mouseCoord3.x = mouseCoord1.x; //find the next corner (don't need the fourth)
mouseCoord3.y = mouseCoord2.y;
mouseCoord3.z = 0;
lassoBox.scale_x = -vec_dist(mouseCoord2,mouseCoord3) / 100;
lassoBox.scale_y = -vec_dist(mouseCoord1,mouseCoord3) / 100;
wait(1);
}
mouse_trace();
vec_set(mouseCoord2,target);
lasso = 1;
wait(1);
lasso = 0;
recorded = 0;
return; //exit function
}




The entity, by the way is a 30x30 bitmap of a white square.


"Oh no, it's true! I'm a love magnet!" Calvin from Calvin and Hobbes My name's Anonymous_Alcoholic.
Re: lassoing RTS units [Re: anonymous_alcoho] #86993
08/22/06 05:41
08/22/06 05:41
Joined: Aug 2003
Posts: 716
Canada, Toronto
thegamedesigner Offline
User
thegamedesigner  Offline
User

Joined: Aug 2003
Posts: 716
Canada, Toronto
This function draws a 3d line in the world, not on the screen, so you might be able to use it.


////////////////

function greenline_effect()
{
my.lifespan = 0.1;
my.streak = on;
my.red = 0;
my.green = 255;
my.blue = 0;
my.size = 4;
my.function = NULL;
}

function blueline_effect()
{
my.lifespan = 0.1;
my.streak = on;
my.red = 0;
my.green = 0;
my.blue = 255;
my.size = 4;
my.function = NULL;
}

function redline_effect()
{
my.lifespan = 4;
my.streak = on;
my.red = 255;
my.green = 0;
my.blue = 0;
my.size = 4;
my.function = NULL;
}

function yellowline_effect()
{
my.lifespan = 0.1;
my.streak = on;
my.red = 255;
my.green = 255;
my.blue = 0;
my.size = 4;
my.function = NULL;
}

function blackline_effect()
{
my.lifespan = 14;
my.streak = on;
my.red = 9;
my.green = 9;
my.blue = 9;
my.size = 4;
my.function = NULL;
}

function whiteline_effect()
{
my.lifespan = 0.1;
my.streak = on;
my.red = 255;
my.green = 255;
my.blue = 255;
my.size = 4;
my.function = NULL;
}

function orangeline_effect()
{
my.lifespan = 14;
my.streak = on;
my.red = 255;
my.green = 125;
my.blue = 0;
my.size = 4;
my.function = NULL;
}

function drawline_fun(&start,&end,color)//g1,b2,r3,y4,b5,w6,7o
{
vec_diff(temp,end,start);
if(color == 1){effect_local(greenline_effect,1,start,temp);}
if(color == 2){effect_local(blueline_effect,1,start,temp);}
if(color == 3){effect_local(redline_effect,1,start,temp);}
if(color == 4){effect_local(yellowline_effect,1,start,temp);}
if(color == 5){effect_local(blackline_effect,1,start,temp);}
if(color == 6){effect_local(whiteline_effect,1,start,temp);}
if(color == 7){effect_local(orangeline_effect,1,start,temp);}
}


Note: The effects for the different colors have different stats. I.E. I use the orange line for something that is only called once, so the line stays long enough to see. Based on how far from the screen, you might want to change the size (thickness) of the lines.

Also, I am not sure this will work with A5, but assuming you have particles, it should be work-able.

Send me an email about your rts project, I love to talk about rts projects with gamestudio. I have worked on making one for years. My current project is more of an rtt, like the total war stuff, but I played "Rise of Legends" and my rts gander is up so to speak. So very good.

thegamedesigner.

Last edited by thegamedesigner; 08/22/06 05:43.

My games - www.spyeart.com
Re: lassoing RTS units [Re: anonymous_alcoho] #86994
08/22/06 17:39
08/22/06 17:39
Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
anonymous_alcoho Offline OP
Senior Developer
anonymous_alcoho  Offline OP
Senior Developer

Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
brilliant idea, problem is, I only have extra, so I can't have streak and the highest edition I'm willing to go to is commercial. If I could get it to look right, it would be fine though.

And if you want information about my game, I've been running a blog to journal the developement at codebreakpoint.blogspot.com (you may need to go to the archives to find the initial post that explains the game) and I have information about it at my site

Last edited by anonymous_alcoho; 08/22/06 17:44.
Re: lassoing RTS units [Re: anonymous_alcoho] #86995
08/22/06 21:22
08/22/06 21:22
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Search for C&C tutorial by Realspawn (may be in the acknex resources).

Re: lassoing RTS units [Re: Lion_Ts] #86996
08/22/06 21:34
08/22/06 21:34
Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
anonymous_alcoho Offline OP
Senior Developer
anonymous_alcoho  Offline OP
Senior Developer

Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
Uses pixel_to_bmap. Thats it then. I'm upgrading ASAP.

*EDIT* Just bought it.

Last edited by anonymous_alcoho; 08/22/06 23:25.

"Oh no, it's true! I'm a love magnet!" Calvin from Calvin and Hobbes My name's Anonymous_Alcoholic.

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1