Character problems...

Started by Tuomas, Wed 06/04/2005 19:17:07

Previous topic - Next topic

Tuomas

I've finally come to the stage, where I'm a "Can't do that without using script-newbie", and I cant get my character act the way I want to. He should do this sleeping movement for a while, until my character falls into the room. Tha Problem is, I don't know where to start, and I don't get the "help".  If anyone could give me some hand-to-hand advice? ???

strazer

How about this:

Code: ags

  // Player enters room (before fadein)

  SetCharacterView(CHARACTERNAME, SLEEPINGVIEW); // set sleeping char to sleeping animation view
  AnimateCharacter(CHARACTERNAME, 0, 0, 1); // animate him contiously using loop 0 of this view

  character[GetPlayerCharacter()].x = 150;
  character[GetPlayerCharacter()].y = 0; // position player at the very top
  SetCharacterView(GetPlayerCharacter(), FALLINGVIEW); // set his view to the falling animation view
  AnimateCharacter(GetPlayerCharacter(), 0, 0, 1); // animate him continously using loop 0 of this view


Code: ags

  // Player enters room (after fadein)

  MoveCharacterBlocking(GetPlayerCharacter(), 150, 100, 1); // move player to middle of room (falling down)
  // at this point the player has landed
  PlaySound(1); // *thud*
  ReleaseCharacterView(GetPlayerCharacter(), NORMALVIEW); // stop animating player
  ReleaseCharacterView(CHARACTERNAME, NORMALVIEW); // stop animating sleeping char (awake)
  // or animate him first waking up using another loop and a blocking AnimateCharacterEx

  Wait(40); // wait 1 second
  DisplaySpeech(CHARACTERNAME, "What's going on?");
  //...

Tuomas

Seems usable, have to try it, but...ehm... where should I start writing to? I mean, I can't find the script editing thing... if you know what I mean..... :P (Thanks by the way)

Ashen

In the room you want this to happen in, go to the 'Settings' window. Click the 'Interactions' button (looks like a red 'i'), or press Ctrl-I. This gives you a list of options, the ones you want for strazer's code are Player enters room (before fadein) and Player enters room (after fadein).
Click one of them, add a 'Run script' command, and press the 'Edit script' button.

Once you've created the 'Run script' commands, you can edit them either by the 'Interaction' list, or by opening the Room Script (the '{}' button, or Ctrl-E).
I know what you're thinking ... Don't think that.

Tuomas

Oh Yeah, the...a..."edit script" in the room editor... Yep, I got it... so... is it then... when I want my Char. to do something, I define it trough the room-script-editor-thing?

Candle

Best if you read the help file Me thinks . hit F1 with game editor open .

Tuomas

You'd think so... eh? Got nothing out of it. Yes, I know how to do it, but does it ever say where to do it at? Well, at least I couldn't find it...

Ashen

There isn't really one 'right' place to put the scripting - it depends on how & when you want it to be triggered.

If you want it to happen as soon as you enter the room, it's Player enters room (after fadein) you want, as described above. If you want it to happen after a certain time has passed, use a timer, then check if it's expired in Repeatedly execute (using SetTimer() and IsTimerExpired()). If you want it to happen when the player clicks on an object, go to the 'Objects' window, pick the object you want, and put the script in it's interaction editor. Same for hotspots, regions, or characters. (All of which should be mentioned in the Tutorial in the manual, if not in the manual itself.)

After you've started the script this way, then you can edit it directly in the Room script, since the functions (look at hotspot0, Player enters room (after fadein), talk to object4, etc) will have been created. Character interactions (Talk to EGO, Look at MAN, etc) are in the Global Script, not the Room script, and can be accessed from the 'Characters' window.
I know what you're thinking ... Don't think that.

TerranRich

Status: Trying to come up with some ideas...

Tuomas

Yeah, okay I think I got it! Thanking you :) The code up there worked all right, and I'm currently trying to make the guy fall faster, having increased and degreased all places I find the word "speed" or "delay"... perhaps I'll get it soon, perhaps not 8)

strazer

You could increase the player's walking speed, but it's probably more practical to do a while-loop instead of the MoveCharacterBlocking command:

Code: ags

  while (character[GetPlayerCharacter()].y < 150) {
    character[GetPlayerCharacter()].y -= 1; // increase this number to speed it up
    Wait(1);
  }

SMF spam blocked by CleanTalk