Always the character face the hotspots

Started by Docoptik, Thu 07/07/2005 00:45:07

Previous topic - Next topic

Docoptik

Hi. I want the player when look,interact in any hotspot to turn his face on that.
for example:when the player comes from up to down (He is like as he sees me),and the hotspot is at the left of the screen,he won't turn over and the script will start.
I already checked the box from the "General settings" Character turns to face direction.
Don't say to put at the interaction of every hotspot, the command face location the right x,y.It's very boring!!!!
Thanks for your help.

Ashen

Boring yes, but perhaps the most reliable way.
How exactly would you want it to work? Would the character turn when the mouse moves over the hotspot, or when the player clicks on the hotspot?

For 'mouse over hotspot', something like:
Code: ags

//in 'repeatedly_execute'
if (GetHotspotAt(mouse.x, mouse.y) != 0) FaceLocation (GetPlayerCharacter(), mouse.x, mouse.y);


For 'click on hotspot':
Code: ags

// in 'on_mouse_click'
else if (button == LEFT) { // This bit should already be there
  if (GetHotspotAt(mouse.x, mouse.y) != 0) FaceLocation (GetPlayerCharacter(), mouse.x, mouse.y);
  Wait(1);
  ProcessClick(mouse.x, mouse.y, GetCursorMode());
}


One of them should work, anyway. If not, or if I've misunderstood what you're asking, could you be a bit more specific about what you want.
I know what you're thinking ... Don't think that.

Docoptik

Ashen thanks for the code but it doesn't work. :-[
I have AGS vers. 2.7 and the command GetHotspotAT doesn't know it.

Ok.I tried to be more specific with a example:

Let's say that i have a hotspot at the left of the screen and i set the
Walk-to point at (96,203).
I click in Interaction and at the Look at hotspot i put the player says "Nice picture!!".

If he is on (140,203),when i click the look icon he'll walk at (96,203)=walk-to point and he face looks towards the hotspot(because he came from right to left).
BUT when he is on (96,160),he will come from UP to DOWN and he'll say
"Nice picture!!" with he face looks ME!! because he came from UP to DOWN.

See the problem???
HELP!!

hedgefield

#3
I think you have to manually set the characterview in every interaction script you make for a hotspot (look, use etc). This way he will always turn towards the hotspot when he reaches the walk-to point, no matter which direction he came from.



*Didn't see the part about the x-y value method, sorry. But you don't have to set the values, you only have to specify which way the character should be facing when he is on the walk-to point. E.g. you main walkcycle is view 1, and you want him to face right, then you say SetCharacterViewEx (EGO, 1, 2, ALIGN_CENTRE); Copy n paste for each interaction, changing the second number for the direction and it should work fine.

Docoptik

I already know that!!! 8)
At my first message i said another solution except that.
It is very boring and tired. :-\

Gilbert

If you're using V2.7, GetHotspotAt() had undergone a name change into Hotspot.GetAtScreenXY().

Ashen

#6
Yes, sorry. It was late and I couldn't think of the 2.7 code off the top of my head. Try:
Code: ags

// in 'on_mouse_click'
else if (button == eMouseLeft) { // This bit should already be there
  if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) != hotspot[0]) player.FaceLocation(mouse.x, mouse.y, eBlock);
  ProcessClick(mouse.x, mouse.y, mouse.Mode);
}


(Look the commands up in the manual for the proper usage, if it still doesn't work.)
I know what you're thinking ... Don't think that.

coach z

Had same problem so searched and found this thread.  Ashen, is there a way you can face the hotspot first then go on with whatever the player does upon the click of the hotspot?  Thanks anyone who can answer.

Khris

Ashen has been AWOL for a few years now :(

This should work:

Code: ags
// in 'on_mouse_click'
  else if (button == eMouseLeft) { // This bit should already be there
    if (GetLocationType(mouse.x, mouse.y) != eLocationNothing) player.FaceLocation(mouse.x, mouse.y, eBlock);
    ProcessClick(mouse.x, mouse.y, mouse.Mode);
  }


This will make the character face the mouse position if the mouse is over a Hotspot, Object or Character.

coach z

Thanks Khris.  I thin I figured out the problem.  The player is saying what I have scripted him to say when he looks at an object (ex: "Nice door.") then turning to face it.  It must just be because he player is saying something and the text is not displayed instead?

Khris

Could you post the code you're using?

coach z

 else if (button == eMouseLeft) { // This bit should already be there
    if (GetLocationType(mouse.x, mouse.y) != eLocationNothing) player.FaceLocation(mouse.x, mouse.y, eBlock);
    ProcessClick(mouse.x, mouse.y, mouse.Mode);

So when I click on a hotspot the function takes place depending on if its look, interact, talk to and then the player faces it.

Khris

I meant could you post the door's interaction code?

coach z

function door_Interact()
{
player.Walk(280, 158, eBlock);
player.Say("It leads to Tesla's lab and testing facility.");
player.Say("Against my better judgment,  I'll enter, but I did not stock up on a 14 pack of replacement razor heads this weekend,  just so I can die today.");
player.ChangeRoom(3, 22, 136);
}

Monsieur OUXX

 

coach z


monkey0506

Do you have, per chance, more than one on_mouse_click function?

coach z


SMF spam blocked by CleanTalk