Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Nine Toes on Sun 10/02/2008 09:00:37

Title: AT meter script (SOLVED - Cripe, I'm an idiot!)
Post by: Nine Toes on Sun 10/02/2008 09:00:37
I don't know how to ask for help with this, because it seems fairly complicated to me, but I'm having some problems with animations not animating, and key presses not responding.

I made this Active Time meter for an RPG that I'm working on.

  function active_timer_first() {
    if (human[party.first].deceased == true) {
      // DO NOTHING!!!!
    }
    else if (party.AT_first <= 99){
      party.AT_first_count = party.AT_first_count + human[party.first].speed;
      if (party.AT_first_count >= 100) {
        party.AT_first ++;
        party.AT_first_count = 0;
      }
      btn_AT_first.NormalGraphic = (500 - party.AT_first);
    }
    else if (party.AT_first == 100) {
      party.active = party.first;
    }
  }


I figured the only logical place to run this code would be in repeatedly_execute:

    else if (party.active == -1) {
        active_timer_first ();
    }


During battle mode, I always have to hit alt+x to exit the game, because ctrl+q doesn't work.  I used the debug feature, and the key press is registering (ascii code 17, I believe), but it doesn't bring up the exit gui.

As far as animations go, when the meter hits 100, a pointer is supposed to appear above the character's head.  The pointer won't animate no matter what I try.  Here's the code for that too, just in case:

  function setup_active () {
    object[0].SetPosition ((character[party.active].x - 4), (character[party.active].y - 34));
    object[0].SetView (2, 1, 0);
    object[0].Animate (1, 0, eRepeat, eNoBlock, eForwards);
    object[0].Visible = true;
    PlaySound (0);
  }

(The only reason why this bugs me is because if that pointer's not animating, I fear that nothing else will animate in battle mode either).

And that code is also in repeatedly execute, right above the one I just showed you:

  else if (battle_mode_on == true) {
    if (party.active != -1) {
      setup_active ();
    }
    else if (party.active == -1) {
        active_timer_first ();
      }
    ...


I know it's all a big, horrible sloppy mess, but if anyone could offer any sort of advice, it would really help.
Title: Re: AT meter script - animations and key presses don't work
Post by: Khris on Sun 10/02/2008 14:44:40
Going from the symptoms you're describing, it looks like the game was stuck in a while loop.
It's hard to tell though without looking at the rest of the code.

Btw, just curious, did you import 100 sprites to display the AT? :=
Title: Re: AT meter script - animations and key presses don't work
Post by: Nine Toes on Sun 10/02/2008 17:11:50
Heh, yeah I did.  My first edition of the code was pretty hefty, over 100 "if" statements. :P  Luckily I figured out a way to slim it down.

Which other parts of the code would you like to see?  Here's the whole of the repeatedly_execute section:

function repeatedly_execute() {
// put anything you want to happen every game cycle here
  if (battle_mode_on == false) {
    available_interactions (mouse.x, mouse.y);
    enemy_AI (1);
    enemy_AI (2);
    enemy_AI (6);
  }
  else if (battle_mode_on == true) {
    if ((party.active != -1) && (active_hang == false)) {
      setup_active ();
      active_hang = true;
    }
    else if (party.active == -1) {
        active_timer_first ();
      if (party.second != -1) {
        active_timer_second ();
      }
      if (party.third != -1) {
        active_timer_third ();
      }
      if (party.fourth != -1) {
        active_timer_fourth ();
      }
    }
  }
}


EDIT:
Mon Dieu!  Please don't lynch me, but it turns out the GUI that the meter is on was set to "popup modal", and not "normal".  Sorry for wasting your time.