Clicking on an NPC & getting its coordinates then moving object to location

Started by jamesreg, Sun 11/07/2010 14:33:27

Previous topic - Next topic

jamesreg

I have an invisible character following my main character around

I am wanting to do something simular to this I want to to be able to click on a npc character
then have the invisible character become visable and take on the graphic of whatever selected weapon was choosen
and have that character move to the location of the npc that I just clicked on.

im not sure how to get the mouse click coordinates when I click on the npc then use that to tell the character to goto that location.
the npc will be at random locations at random times.

thank you for any help given

barefoot

Hi

well, you could script it so that when you click on a NPC the invisible character appears as the view of NPC that you clicked on then move to NPC position. I assume original NPC will be replaced?

Is this right?

-barefoot-
I May Not Be Perfect but I Have A Big Heart ..

jamesreg

the npc I clicked on will still be there it will look like a weapon is traveling to him
so I basicaly need to know how to get the coordinates hes at when I click on him
then i had planned for the invisible character to turn on and look like the weapon
and then use the coordinates that i just got from clicking on the npc to move my
weapon character to the npc to look like i shot at him

basicly getting the coordinates that the npc is at once clicked on is my main issue

Virgil

Something along the lines of:

Code: ags

//in global script
on_mouse_click()
{
   int x = mouse.x;
   int y = mouse.y;
   //binds the click of the mouse to two ints, x and y
}

//in room script
   if (Character.GetAtScreenXY(x, y,) == c.NPC) //makes sure you clicked on a character
   {
      c.Invisible.ChangeView(int of view for weapon);
      c.Invisible.Walk(x, y);
    }



I'm not sure if you have to set mouse.x and mouse.y to other ints, but I did just to be safe. No guarantees if that will work, though, I haven't scripted in a while.

Khris

Code in relation to clicks on characters should also be in Global.asc.

You can get the coordinates of a character by reading their .x and .y.

SMF spam blocked by CleanTalk