Select actor on key down

Non-platform specific questions.

Select actor on key down

Postby nate020605 » Thu May 03, 2007 11:47 pm

i would liek to find out how i can SELECT an ACTOR on key down "q" and then deselect the actor once a different key is pressed "a", i have six gun turrets all with the same functions and i need to have a key asigned to select them, and does anybody have a link to a good post that would describe how to rotate them, each only needs to 180 degrees does anybody know how i would go about doing that, i've read some of the other posts and had a hard time following them. thanks for your help in advance i appreciate it.
nate020605
 
Posts: 4
Joined: Mon Apr 30, 2007 1:05 pm
Location: The Ocean
Score: 0 Give a positive score

Postby Sgt. Sparky » Fri May 04, 2007 12:05 am

to make your actor rotate only 180 degrees,
use this on the rotation event after you make an actor variable called MOVE:
Code: Select all
if(MOVE == 1) {
if(direction(x, y, player.x, player.y) < 360 && direction(x, y, player.x, player.y > 180)animpos = direction(x, y, player.x, player.y);\
}

for selecting an actor,
make a variable called count,(integer)
and make a variable called i.
also make a variable(string) called NAME1 and one called NAME2.
on the key down event of q (repeat disabled),
Code: Select all
count = ActorCount("turret");
sprintf(NAME1, "turret.%d", i);
getclone(NAME)->MOVE = 1;
while(i <= count) {
sprintf(NAME2, "turret.%d", i);
if(strcmp(NAME2, NAME) == 1)getclone(NAME2)->MOVE = 0;
i++;
}
if(i > count) i = 0;

this allows you to make more than one clone of the turret instead of making a bunch of different actors(not clones) . :)
:D
I hope that helps,
if you need more help let me know. :)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby nate020605 » Fri May 04, 2007 5:18 pm

i appreciate the help i'll try it out tonight, do you or anyone else know of any scripting specific tutorials besides the one packaged with GE, ones that perhaps go more in depth and explain more?
nate020605
 
Posts: 4
Joined: Mon Apr 30, 2007 1:05 pm
Location: The Ocean
Score: 0 Give a positive score

Postby Sgt. Sparky » Fri May 04, 2007 10:57 pm

I do not know of any... :(

but if you need help,
I and many others are willing to help. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby nate020605 » Mon May 07, 2007 9:24 pm

im not sure how much work it might be but could anyone break down the script into laymans terms and basically explain what each part is doing, so i can get abetter understanding of whats happeneing and hopefully wont have to post a whole lot more times :D . still pretty confused as to why it works the way it does.
Also attached is a screenshot of my game wich will hopefully give everyone abetter understanding of what im trying to accomplish.

1."q" key down to select turret1 (pressing any other key deselects it)

2."z" key down to select turret2 (pressing any other key deselects it)

3. Mouse click left on water -> fire missle from turret1
missle parent is turret1. (mouse cursor is the direction i want the missle to go in)

4.mouse click "right" on water -> fire missle from turret2
missle parent is turret1. (mouse cursor is the direction i want the missle to go in)

sorry if it was rendundant just wanted to get my point acrros clearly. thanks for the help everyone
Attachments
General Quarters Screenshot.gif
nate020605
 
Posts: 4
Joined: Mon Apr 30, 2007 1:05 pm
Location: The Ocean
Score: 0 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 12:48 am

make a variable called select,
when you press q,
Code: Select all
select = 1;//setting the select variable to 1

when you press z,
Code: Select all
select = 2;//setting the select variable to 2

and on the key down event of any key,
Code: Select all
char*key=GetKeyState();
if(key[KEY_q] == 0 &&  key[KEY_z] == 0)select = 0;
//it asks if either q or z is not pressed it will set the select variable to 0,
//in which case you will not use a turret.

and when you fire turret one,
Code: Select all
if(select == 1)
{
    your actions here;
}

when you fire turret 2,
Code: Select all
if(select == 2)
{
    your actions here;
}

:D
if you still need help let me know. :)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby nate020605 » Tue May 08, 2007 1:11 am

extremly helpful Sparky thanks for the quick replies as well, i see your name on alot of the posts. I along with everyone else apprciates your knowledge of C script. thanks again
nate020605
 
Posts: 4
Joined: Mon Apr 30, 2007 1:05 pm
Location: The Ocean
Score: 0 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 1:12 am

you're welcome. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest