Mirror matches walking views but not talking views

Started by TerranRich, Fri 27/08/2004 08:16:23

Previous topic - Next topic

TerranRich

First time I've posted here in a loooong time, but I'm workinig on AGS MiniDemo #1 regardng mirrors. My character (CJ :P) and his mirror image work fine. The walking views match perfectly, but when he's talking, the walking view plays instead. Here's my code from the global script:

Code: ags
int mirrorbase=135;	// Y-value of the mirror baseline -- the line between the feet of CJ and the feet of CJMIRROR
int cj_dist;		// CJ's feet's distance from the mirror baseline
int mr_dist;		// CJMIRROR's feet's distance from the mirror baseline
int perspective=1;	// Hard to explain. If 1, the mirror's feet are same distance from mirror baseline as CJ's. The higher, the closer mirror image is to mirror baseline than CJ.

   . . .

#sectionstart repeatedly_execute_always  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute_always() {
  //Plays every game cycle, of course. Code within here is to match CJMIRROR's X, Y, loop, and frame to CJ's constantly.
  
  character[CJMIRROR].x = character[CJ].x;	// Match the X-coordinates, as always
  cj_dist = character[CJ].y - mirrorbase;	// Find CJ's distance from mirror baseline
  mr_dist = cj_dist / perspective;	// If perspective is 1, of course CJMIRROR will be same distance from mirror as CJ. The higher, the closer mirror image is to mirror bsaeline than CJ
  character[CJMIRROR].y = mirrorbase - mr_dist;		// CJMIRROR's Y-coordinate is set with respect to mirror baseline
  character[CJMIRROR].loop = character[CJ].loop;
  character[CJMIRROR].frame = character[CJ].frame;	// Now, match the two characters' loops and frames
}


What could I be doing wrong? CJ has walking view #1, talking view #2, and CJMIRROR has #3 and #4, respectively. The talking views has less frames than the walking views. Since I swapped up and down loops for the mirror's walking and talking views, the talking up loop for CJ has one less frame than the talking up loop for CJMIRROR (which is the talking down loop for CJ). Could that have something to do with it?
Status: Trying to come up with some ideas...

Gilbert

Because repeatedly_execute_always() won't be executed while in a dialog I think.
I think there's no easy way around it except for some hard coded scripting at the moment.

TerranRich

Crap...what kind of hard coded scripting? Even if R_E_A doesn't execute during dialog, the frames do still change. What's up with that? I think there's something else causing it. Thanks, though!

Heh, maybe CJ should add the capability for a "repeatedly_execute_always_even_during_dialogs_and_everything" function. ;)
Status: Trying to come up with some ideas...

Edwin Xie

Happens to me when the talking view is the same as the walking view, or atleast set that way.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

strazer

#4
Don't you have to set the appropriate view for the mirror character as well?
I do it like this:

if (player.view == HEROWALKING-1)
   character[MIRROR].view = MIRRORWALKING-1;
else if (player.view == player.talkview)
   character[MIRROR].view = character[MIRROR].talkview;
// else if (player.view == HEROBLINKING-1)
//   character[MIRROR].view = MIRRORBLINKING-1;

EDIT:
Of course, since you have mirror's views as 3 and 4, you could just do
  character[MIRROR].view = player.view + 2;
but this could lead to problems for users that have their views set up differently.
So I suggest using something similar to the code above.

Edwin Xie

Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

TerranRich

#6
Edwinxie: Um...that's what I used as my basis, except I used the second bit, with the true mirror images (up=down and vice versa).

Holy crap, strazer, you know...you're right! Let me try that. How could I have missed that? Just one thing, what are HEROWALKING and MIRRORWALKING? What do they equal?

EDIT:

Here is what I have now in my rep_exec_always function:

Code: ags
function repeatedly_execute_always() {
  //Plays every game cycle, of course. Code within here is to match CJMIRROR's X, Y, loop, and frame to CJ's constantly.
  
  character[CJMIRROR].x = character[CJ].x;	// Match the X-coordinates, as always
  cj_dist = character[CJ].y - mirrorbase;	// Find CJ's distance from mirror baseline
  mr_dist = cj_dist / perspective;	// If perspective is 1, of course CJMIRROR will be same distance from mirror as CJ. The higher, the closer mirror image is to mirror bsaeline than CJ
  character[CJMIRROR].y = mirrorbase - mr_dist;		// CJMIRROR's Y-coordinate is set with respect to mirror baseline
  if (player.view == player.talkview) {		// If player is talking...
    character[CJMIRROR].view = character[CJMIRROR].talkview;	// Set the mirror to his talking view as well
  } else {	// Otherwise...
    character[CJMIRROR].view = 3;	// Set mirror to walking view
  }
  character[CJMIRROR].loop = character[CJ].loop;
  character[CJMIRROR].frame = character[CJ].frame;	// Now, match the two characters' loops and frames
}


NOW, the talkng views match, but while walking, the mirror image seems to just glide along, standing straight. What now?
Status: Trying to come up with some ideas...

strazer

QuoteHoly crap, strazer, you know...you're right! Let me try that. How could I have missed that? Just one thing, what are HEROWALKING and MIRRORWALKING? What do they equal?

HEROWALKING and MIRRORWALKING are the names of their walking views. Change it according to your views.

The problem with your code is, character[CJMIRROR].view is the view number (3) minus 1, so it should be
character[CJMIRROR].view = 2; // view 3

TerranRich

[slaps himself on forehead]

Sometimes I can forget the simplest things so easily. Thank you very much, strazer. :)
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk