Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - strazer

#1422
Advanced Technical Forum / Re: Looping Rooms
Sun 10/04/2005 20:51:29
I did it like this:

Code: ags

// room script file

#define BUFFERAREA_LENGTH 240 // relative width of room background buffer area (480 pixels)

function PauseMoving (int charid) {
// Stops the supplied character but keeps its last frame
// For seamlessly changing walking speed, for example

  char prevview = character[charid].view+1;
  char prevloop = character[charid].loop;
  char prevframe = character[charid].frame;
  int wasmoving = character[charid].walking;
  StopMoving(charid);
  if (wasmoving) SetCharacterFrame(charid, prevview, prevloop, prevframe);
    // since we're using his current view, the lock will be released automatically once the character is moved again
}


function WaitHidden(int gameloops) {
  int prevmode = GetCursorMode; // store the current cursor mode
  SetCursorMode(MODE_WAIT); // change to wait cursor mode
  SetMouseCursor(prevmode); // change appearance to look like previous cursor mode
  Wait(gameloops);
  SetDefaultCursor(); // revert wait cursor to the default sprite
  SetCursormode(prevmode); // revert to previous cursor mode
}


function on_mouse_click(MouseButton button) {

  if (IsGamePaused()) return; // if game is paused, quit function

  if (button == LEFT) { // if left mouse click
    if (GetCursorMode() == MODE_WALK) { // if mouse is in walk mode
      if (GetViewportX() + mouse.x >= game.room_width - (system.viewport_width / 2)) { // if clicked on right end of room
        PauseMoving(GetPlayerCharacter()); // see above
        character[GetPlayerCharacter()].x = character[GetPlayerCharacter()].x - (game.room_width - BUFFERAREA_LENGTH); // put character at left end of room
        WaitHidden(1); // see above; let screen update before running global on_mouse_click
      }
      else if (GetViewportX() + mouse.x <= (system.viewport_width / 2)) { // if clicked on left end of room
        PauseMoving(GetPlayerCharacter()); // see above
        character[GetPlayerCharacter()].x = character[GetPlayerCharacter()].x + (game.room_width - BUFFERAREA_LENGTH); // put character at right end of room
        WaitHidden(1); // see above; let screen update before running global on_mouse_click
      }
    }
  }

  // global on_mouse_click will be called afterwards -> character starts walking

}
#1423
Yeah, sorry, I didn't have AGS or the manual handy. The property is called "PreviousRoom" in AGS v2.7.

And I used GetPlayerCharacter() because not in all games the player character is named EGO.

Anyway, glad I could help.
#1424
Are you sure the error is in room 2?
Does it happen if you enter room0 first?
Does it happen if you change to other rooms than room0?
Does it happen if you change to room0 from other rooms than room2?
#1425
I just read your comment.
Since you're making a first-person perspective game, you could just position a dummy character at the very bottom-left, outside the screen.
This way, his speech will be displayed in the lower-left corner of the screen.
#1426
Quote from: hello123 on Sat 09/04/2005 04:24:47I can't seem to use DisplaySpeechAt when programming dialogs

That's true.
You could script your own dialog system, but I don't know of any easy, practical solution.
A request for a similar feature was made already, so be sure to add a comment and show your support.
#1427
Quote from: hello123 (via pm)sorry to bug you, strazer, but DisplaySpeechAt does not seem to be in the manual.  I can only find DisplaySpeech

It's in my v2.62 manual, directly after the entry for DisplaySpeech. Which version of AGS are you using? In AGS v2.7, it's called Character.SayAt
#1428
DisplaySpeechAt (see manual)
#1429
Regarding keyboard input in games, I've found this bug entry in WineHQ's bug tracker: http://bugs.winehq.org/show_bug.cgi?id=2811
Somewhere else I read it could be related to the Allegro library which AGS uses.
#1430
Quote
Is there a way to get the integer value of the GUI object at a point, i.e., mouse.x, mouse.y?

Code: ags

GUIControl *thecontrol = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (thecontrol != null) integervalue = thecontrol.ID;
#1431
QuoteIt was on the "to-do" list before, & I know the Object-Based scripting, obviously, took priority.

Hm, which entry is it?
http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=394
http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=444
#1432
Just put a label on the GUI and set its text to "@SCORE@".
See manual: Other Features -> Editing the GUIs -> Interface text
#1433
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);
  }
#1434
Thank you. My pleasure, honestly. :)
#1435
As it were I wrote this just last week. I thought it would be a neat thing to be able to do.
I'll probably use it in my game, which at the moment is nothing more than a tech demo. I love scripting so much I don't get much else done. ;)
#1436
But keep a backup of your current non-working files so CJ can investigate the problem!
#1437
First, try zipping the files and look at the file size.
If it isn't too big (< 1MB I would guess) you can e-mail it, but if it is larger, upload it somewhere and pm him the link.
#1438
Quote from: Pumaman on Thu 07/04/2005 19:52:25
QuoteThank you very much for the character tint function. This relieves me of much cheating with the AmbientTint command. Does this mean that region tints will also get luminance settings in the near future?

The lack of luminance in the region tints is a bit of an oversight -- it happened because region tints were the first type to be implemented, and weren't done as thoroughly as the ambient and object tints which came later. This would be a worthwhile addition to a future version, I agree.

Tracker'd: http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=520

Edit:

Is there a chance you could slip in a GetGameParameter option to return the actual number of inventory items used in the game?

Edit 2:

I noticed this in earlier versions too, maybe even v2.62, can't remember:
Using the "Black box out" transition, if I enter a certain room in my game, the room's background displays for a split second before going black and fading in.
Strangely, it does only seem to affect this particular room and I haven't been able to find out why. Besides a big object and a large walkbehind, there's nothing special in there.

Edit 3:

Okay, that last one seems to be related to the slightly slower frame rate in my Windows emulator, making the whole transition look kind of wrong.
I've taken a video in Windows, analysed it and everything is fine.
#1440
It's possible, using some scripting:

(Code converted from my AGS v2.7 script module, so it may still contain some syntax errors.)

Code: ags

// main global script

struct struct_AnimatedInventoryItem {
  int normalgraphic;
  int view;
  int loop;
  int animationdelay;
  int repeat;
  int currentframe;
  int currentdelay;
};

#define AGS_MAX_INV_ITEMS 300

struct_AnimatedInventoryItem AnimatedInventoryItem[AGS_MAX_INV_ITEMS];


function AnimateInventoryItem(int invitemid, int view, int loop, int delay, int repeat) {

  if (AnimatedInventoryItem[invitemid-1].view == 0) // if inv item does NOT have a view set (isn't animating)
    AnimatedInventoryItem[invitemid-1].normalgraphic = theinvitem.Graphic; // store inv item's current (normal) graphic

  // store supplied settings for animation routines (see repeatedly_execute):
  AnimatedInventoryItem[invitemid-1].view = view;
  AnimatedInventoryItem[invitemid-1].loop = loop;
  AnimatedInventoryItem[invitemid-1].animationdelay = delay;
  AnimatedInventoryItem[invitemid-1].repeat = repeat;

  // reset current status so animation starts from beginning when this function is called on already animating inventory items:
  AnimatedInventoryItem[invitemid-1].currentframe = 0;
  AnimatedInventoryItem[invitemid-1].currentdelay = 0;

}


function StopAnimatingInventoryItem(int invitemid, int keepcurrentframe) {

  if (AnimatedInventoryItem[invitemid-1].view) { // if inv item has a view set (is animating)
    AnimatedInventoryItem[invitemid-1].view = 0; // reset the view so inv item will not be animated anymore
    if (keepcurrentframe == 0) SetInvItemPic(invitemid, AnimatedInventoryItem[invitemid-1].normalgraphic; // if current frame should not be kept, change inv item graphic back to normal
  }

}


function repeatedly_execute() {

  int invitemid = 0; // start with first inventory item (array index starts at 0)
  while (invitemid < AGS_MAX_INV_ITEMS) { // loop for each inventory item
    if (AnimatedInventoryItem[invitemid].view) { // if inv item has a view set (is animating)
      if (AnimatedInventoryItem[invitemid].currentdelay) AnimatedInventoryItem[invitemid].currentdelay--; // if delay until next frame has NOT yet elapsed, decrease it
      else { // if delay until next frame has elapsed
        SetInvItemPic(invitemid+1, GetGameParameter(GP_FRAMEIMAGE, AnimatedInventoryItem[invitemid].view, AnimatedInventoryItem[invitemid].loop, AnimatedInventoryItem[invitemid].currentframe);
          // change inv item's graphic to new frame
  AnimatedInventoryItem[invitemid].currentdelay = AnimatedInventoryItem[invitemid].animationdelay + GetGameParameter(GP_FRAMESPEED, AnimatedInventoryItem[invitemid].view, AnimatedInventoryItem[invitemid].loop, AnimatedInventoryItem[invitemid].currentframe);
          // set delay until next frame to animation delay + new frame's delay
        AnimatedInventoryItem[invitemid].currentframe++; // set following frame to display next
        if (AnimatedInventoryItem[invitemid].currentframe >= GetGameParameter(GP_NUMFRAMES, AnimatedInventoryItem[invitemid].view, AnimatedInventoryItem[invitemid].loop, 0)) { // if no more frames in view loop
          if (AnimatedInventoryItem[invitemid].repeat == 0) StopAnimatingInventoryItem(inventory[invitemid+1], 0); // if animation was set to play once, stop animation (reverting to normal graphic)
          else if (AnimatedInventoryItem[invitemid].repeat == 1) AnimatedInventoryItem[invitemid].currentframe = 0; // if animation was set to repeat, set first frame to display next
          else if (AnimatedInventoryItem[invitemid].repeat == 2) StopAnimatingInventoryItem(inventory[invitemid+1], 1); // if animation was set to play once and to keep last frame, stop animation keeping current frame
        }
      }
    }
    invitemid++; // loop to next inventory item
  }

}


Code: ags

// main script header

import function AnimateInventoryItem(int invitemid, int view, int loop, int delay, int repeat);

import function StopAnimatingInventoryItem(int invitemid, int keepcurrentframe);


Edit:

It may not work if your inventory GUI is set to "Popup modal" so you might need to set it to "Normal" and turn it off in game_start first.
SMF spam blocked by CleanTalk