trying to set different baselines with follow_exactly

Started by homelightgames, Fri 24/11/2006 20:17:57

Previous topic - Next topic

homelightgames

Hey All,

I'm wondering if it's possible to change the baseline of a character(s) exactly following a main character. (not the player character, though)

My dilemna is that I want to have the last character to follow always on top (whether there is two or three characters following).  Instead the characters with lowest default baseline are automatically on top, regardless of how I manually set the baselines.

I have tried setting the baselines for the characters (setting the baseline lower for characters the start following later), but it doesn't change.

Does follow_exactly always lock the baseline? (which seems to be the case) Is there a way around this?

Thanks for your help.

visionmind

Ashen

Can you post the code you've used so far?

Setting the baselines in repeatedly_execute should do what you want, in theory. However, it's possible that the 'Eagerness' parameter (which sets whether the Follower character should be in front or behind the Followed, when you use follow_exactly) overrides manually set Baselines.

Could you set the characters to follow each other, instead of the 'Main' one? (E.G. instead of chars B, C and D following char A, B follows A, C follows B, and D follows C.) That way you could use the 'Eagerness' parameter to 'stack' them for you. You would need some way to determine the order they started following - but it sounds like you might have that anyway.
I know what you're thinking ... Don't think that.

homelightgames

#2
Unfortunately I'm not at the computer with the code;

But the biggest problem is that the order determined by the user (meaning never a preset pattern).

Here's the code:

Code: ags
if (GetGraphicalVariable("toppings_order")==1) {
  cMustard.ChangeRoom(cPlayer.Room, cDogbun.x, (cDogbun.y)-9);
  cMustard.LockViewOffset(6, 0, -19);
  cMustard.FollowCharacter(cDogbun, FOLLOW_EXACTLY,0);
  SetGraphicalVariable("toppings_order", 2);
  cMustard.Baseline = 190;
}


This was placed in the Character Interaction editor.

There are more checks for what order the character it is and the baseline is set accordingly.

I'm afraid the 'Eagerness' does manually override the manual the set baseline, I'm just hoping there's a way around it.

The idea of each character following the one before it is a good idea, but since there's no preset order I don't know how to code that.

Thanks.

visionmind

Ashen

Where is that (Character interaction, rep_ex, etc)?

There might be problems with that code: E.g. the line cExample1.changeroom(cmain, follow_exactly, 0); doesn't make sense - it looks like you've confused the ChangeRoom and FollowCharacter commands - but they're probably because it's from memory.

I think that, for it to work, you'd need to constantly update the Baseline relative to cMain and not just set a value and leave it. (At least, if cMain moves, you would.)
Whether you do it with all characters following cMain or D follows C follows B follows cMain, using an array to store the order is probably the simplest way to go. E.g. (untested):

Code: ags

Character *Following[10]; // Or Maximium number in the chain
int FollowCount;

function FollowChain(Character *Follower) {
  // This is the 'D follows C follows B follows A' method
  Following[FollowCount] = Follower; // Add 'Follower' to list at current position
  if (FollowCount == 0) Follower.FollowCharacter(cMain, follow_exactly, 0);
  else Follower.FollowCharacter(Following[FollowCount-1], follow_exactly, 0);
  // Sets the first character to follow cMain, all others to follow the one before them
  FollowCount ++; // Move the list on for the next character
}

This would probably go in the Global Script, and FollowChain might need to be made global (imported in the Header). The other method (all follow cMain) would only need Follower.FollowCharacter(cMain, follow_exactly, 0);, but would also have to check the order in rep_ex and change the Baselines.

Then you should just need to do:
Code: ags

cExample1.LockViewOffset(whatever, 0, -17);
FollowChain(cExample1);
I know what you're thinking ... Don't think that.

homelightgames

Yeah, you were right I got that mixed up:

Here's the current code:

Code: ags

if (GetGraphicalVariable("toppings_order")==1) {
  cMustard.ChangeRoom(cPlayer.Room, cDogbun.x, (cDogbun.y)-9);
  cMustard.LockViewOffset(6, 0, -19);
  cMustard.FollowCharacter(cDogbun, FOLLOW_EXACTLY,0);
  SetGraphicalVariable("toppings_order", 2);
  cMustard.Baseline = 190;
}


This was placed in the Character Interaction editor.

I'm going to try the method you suggested as that would probably work the best.  I'll update the with the results.

UPDATE:  I actually got it working, I just needed to update some other areas of the program.

So I understand in theory how it works, but like before I'm also puzzled how it automatically connected with my characters.  Mainly how the 'Following' variable connected up?  What exactly is happening?

Does it have to do with the first 'Characters *Following[8]'?  (which seems to be a pointer to the characters, but I'm still perplexed how it automatically connected).

Thanks so much for your help Ashen.

Visionmind

Ashen

Not sure what you mean by 'automatically connecting'. You're right that Character *Following[8] is a character pointer - in fact, it's an array of them (Following[0], Following[1], ..., Following[7]).
Which Character they point to is set by this line:
Code: ags

Following[FollowCount] = Follower;


Since FollowCount is increased at the end of the function (FollowCount ++;), the next character is added to the 'next' pointer along (that is, they don't all overwrite each other in Following[0]).
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk