Author Topic: click on ego to shoot??  (Read 4082 times)

0 Members and 1 Guest are viewing this topic.

Offline Sami Tervo

click on ego to shoot??
« on: March 05, 2002, 04:30:28 AM »
ive read many tutorials and different topics which contain some information of agimouse, but i havent found answer to my question.

in my project there would be point and click to shoot- system in combats. i was wondering, is there any command/syntax-for determining ,has player clicked on e.g. object 4? or do i have to do it by the hard way like getting object 4's x&y with get posn-stuff and then but code that checks is the click within some area (based on object 4's x&y-coordinates)
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »


Apocalyptic Quest [ http://apocalypticquest.cjb.net ] No Mutants Allowed [ http://www.nma-fallout.com ] Batmud [ http://www.bat.org ]

Offline Chris Cromer

Re: click on ego to shoot??
« Reply #1 on: March 05, 2002, 04:57:33 AM »
Sorry but there is not a command for seeing if the user click on an object, you will have to get the coordinates to try to see if the user clicked on it or not.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Sami Tervo

Re: click on ego to shoot??
« Reply #2 on: March 06, 2002, 12:19:17 AM »
:P,well i managed to get it work quite easily, but multiple enemies might cause som probs due to blending of clicking areas.

but i ran into bigger problem; i wanna regulate how much can object move within 'turn',because combat would be turn-based (just like in fallouts).

i have faint vision of creating somekind get(posn)-system again, but thats all what i got. i thought if someone of you could create somekind of plan, or even better, quote code how to do that.

« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
Apocalyptic Quest [ http://apocalypticquest.cjb.net ] No Mutants Allowed [ http://www.nma-fallout.com ] Batmud [ http://www.bat.org ]

Offline Chris Cromer

Re: click on ego to shoot??
« Reply #3 on: March 06, 2002, 12:32:06 AM »
Quote
well i managed to get it work quite easily, but multiple enemies might cause som probs due to blending of clicking areas.
There is a simple way around this. Check to see the enemy's Y coordinates and X coordinates. If the X coordinates are around the same numbers then have it compare the Y coordinates to see which one is closer to the screen. Then only let it shoot the one that is up closer.
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Andrew_Baker

Re: click on ego to shoot??
« Reply #4 on: March 07, 2002, 01:52:19 PM »
Wouldn't you have to justify the view's x,y (the left bottom corner of the view by default?) with an   if obj.in.box(view_x, view_y+view_height,view_x+view_width, view_y) { ...

Is this correct, or am I making a mistake"?
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
I hope you realize that one day I will devour the Earth.

Offline Andrew_Baker

Re: click on ego to shoot??
« Reply #5 on: March 07, 2002, 02:37:46 PM »
I had an idea about turn-based combat....

First, set a limit to the number of fighters you can have.  This is due to limitations in the number of objects, etc. but moreover because of the lack of dynamic allocation.  Anyway, let's assume 2 characters for the sake of argument.

First, determine initiative.  This is the order the characters will move.  However you did this makes no difference as long as the result is expressed in an integer variable within the set of {0... max characters}.

Second, you can then initialize the characters.  I believe that would look something like:

if(cur_turn == char_init) { //for AI
        Labelnot_done:
        distance(ego, bad_guy, vD);
        if (vD<==range_of_weapon      &&                            movement>== movement_needed_to_attack) { //Attack
       //movement cost
       }
       if (vD>range_of_weapon ||
           movement<movement_needed_to_attack) {
           //Move towards ego
           //Movement cost
       }
       if (movement == 0) {
          cur_turn == cur_turn+1;
          }
       else {goto(Labelnot_done);}
    }

if (cur_turn == ego_init) { //for Player
        Labelego_not_done:
        distance(ego, bad_guy, vD);
        distance(ego, mouse_cursor, vD2);
        if (movement>0) {
            if (vD2<==movement && Left_Clickon_Mouse) {
                //Move player
                //Movement cost
            }
            if (vD<==range_of_weapon &&
                movement>==movement_needed_to_attack &&
                Right_Clickon_Mouse) {
                //Attack
                //Movement Cost
             }
       goto(Labelego_not_done);
       }
       else {cur_turn = cur_turn +1;}
      }

One of these will be needed for each character, I think.  I don't know, but I thought maybe this might help.  By the way, AGI Studio turns "for" blue as if it was a reserved keyword, but I've never found any mention in the help documentation or FAQs about a for command.  This would allow for an even easier turn-based game.   Anyway, I hope it helps some.
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
I hope you realize that one day I will devour the Earth.

Offline Sami Tervo

Re: click on ego to shoot??
« Reply #6 on: March 08, 2002, 01:11:30 AM »
:D thanks !! this will help me alot, now when hardest part is behind i can focus in the game itself again.
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
Apocalyptic Quest [ http://apocalypticquest.cjb.net ] No Mutants Allowed [ http://www.nma-fallout.com ] Batmud [ http://www.bat.org ]

Offline Chris Cromer

Re: click on ego to shoot??
« Reply #7 on: March 08, 2002, 01:23:11 AM »
What I am talking about is approximation not exact form of telling if they are in front. obj.in.box would be really hard to use because you would have to set up a box everywhere on the screen, which is not really fun or easy to do. Plus it would be harder to do it that way in the first place. You have to realise that he said multiple enemies would be on the screen so checking there x position first to see if they are close then if they are check to see if the y positions are close too and if they are only let the interpreter shoot the bad guy with the higher y position.
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Andrew_Baker

Re: click on ego to shoot??
« Reply #8 on: March 08, 2002, 04:10:11 PM »
You're right about obj.in.box.  I found out the hard way that one cannot use variables as arguments (so it's only for static triggers), while writing my pushing objects code.
« Last Edit: December 31, 1969, 07:00:00 PM by 1018072800 »
I hope you realize that one day I will devour the Earth.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.044 seconds with 22 queries.