Turn character (SOLVED) (and about the reason for some things in AGS)

Started by Hans, Fri 05/01/2007 21:58:12

Previous topic - Next topic

Hans

Again I am going to ask a probably stupid question. But I just can't find the anwser. I can make characters face a location, but how do I make them look down.
(I wanted to make it look like he's talking to you.)
How do I do this?

Akatosh

#1
cEgo.FaceLocation(player.x,player.y+1,eBlock);

This will make him face a point one pixel below his feet.

strazer


Hans

#3
Quote from: Akatosh on Sat 06/01/2007 11:37:18
cEgo.FaceLocation(player.x,player.y-1,eBlock);

This will make him face a point one pixel below his feet.

Thank you very much. I just couldn't find it.

Quote from: strazer on Sat 06/01/2007 11:43:34
Surely you mean +1 ?


I wouldn't know, but I will try.
Thanks a lot.

Ashen

#4
Don't double post.

Because AGS coordinates start from the top of the screen, it would indeed be '+1' to make the character look at the player. -1 would make them look up the screen (with their back to the player). You might have to use a larger number than 1, though - if it doesn't work try +10 and see if that's any better.
I know what you're thinking ... Don't think that.

Akatosh

Whoops sorry  :-[
I tend to mess those two up...

Hans

 ??? I probably don't know where to place the code, because it doesn't seem to work.  ??? Don't I have to place it by "Interactions" and than "Run script" ?

Ashen

Yes, it goes in a 'Run Script' interaction. However, where exactly you'd put it, depends on when you want it to happen (Character interaction, Object interaction, etc).

Where have you got it at the moment, and when should it run?
I know what you're thinking ... Don't think that.

Akatosh

If that's what you're aiming at... for example, a valid script would be the following:
Code: ags

  // script for Inventory item 1 (Cigar): Look at inventory item
player.Say("It's an unlit cigar.");
player.Say("Which is good, because inhaling its fumes would be bad for my health.");
player.FaceLocation(player.x,player.y+10); //character turns to face the player
player.Say("I hope you got the hint!");

Hans

#9
I want to make my character look at you when you use "look at" on him.
He has to tun and say something. My characters scriptname is cEgo and I placed the exact code in "Run script" when you look at him. But nothing happens in the game.  :(
Where is the code supposed to stand?  ???

Akatosh

Did you really place it in the right point? Here's a help screen I originally made for another problem, but the same principle is true: http://i8.photobucket.com/albums/a23/FAMILIAR_QUEST/helpforsnail.png

Just choose "Look at" instead of "Talk to". Also, check whether cEgo is "clickable" (checkbox right above the interaction button).

Ashen

#11
Akatosh's code should be fine. Are you using the right Character references in the code? (E.g. using (player.x,player.y+10) might not work right if cEgo isn't the player character.) If you're not using the default Roger graphics, have you got the Loops set up right?
Show us the actual code you're using, and where abouts it is - there might be something that fresh eyes can spot.
I know what you're thinking ... Don't think that.

Hans

#12
It's like this:

- The character Roger
- "Interaction..."
- Under "Look at character":
     - "Run Script":
                   // script for Character 0 (Roger): Look at character
                  cEgo.FaceLocation(player.x,player.y+10,eBlock);
     - "Game - Run dialog"

The problem now is that the character turns AFTER saying his tekst.

What wrong?

Ashen

I think it's because you're mixing Interation Editor commands ('Game - Run Dialog') and scripting - IIRR 'Run Script' interactions are always run AFTER any other Interaction Editor commands. Try starting the dialog from the Script, instead (Dialog.Start or equivalent command).
I know what you're thinking ... Don't think that.

Ishmael

The execution queue only applies within one script, I think. so adding Wait(1); right after the FaceLocation command should fix it.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Hans

#15
Wait(1); doesn't do it. The character still turns after the dialog.

EDIT:
YES!!! That's it!!! It should be something in the script!
This does it:

  // script for Character 0 (Worm): Look at character
cEgo.FaceLocation(player.x,player.y+10,eBlock);
dTopic.Start();

Why isn't it just made to do it in the order I put it in?
Id really like to know the positive side of this.

Ishmael

Oh, I misunderstood Ashen's post. Sorry, my bad.

Dialogs are always ran last in the script they are part of, but the interaction editor is a different deal.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Ashen

Yea, just to clarify that:
'Run script' interactions are run after any other Interaction Editor commands ('Game - Run Dialog' in this case). However within a script, Dialog.Start() will be queued until after all other code has been run. (I can see the point of this with, for example, Character.ChangeRoom - but I'm not sure why it happens with Dialogs, or why 'Run script' interactions aren't just run in order.)
I know what you're thinking ... Don't think that.

Hans

Maybe there is no good reason and maybe it would be best to advise Chris about this. What do you think? :D

Ishmael

Dialog.Start runs last so the script block can finish before the engine starts parsing the dialog out, so it doesn't have to retain the old code suspended in the background when for example running dialog_requests, I believe.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk