Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: RetroJay on Fri 24/02/2012 07:21:10

Title: How do I animate death scene depending on what way Ego is facing? [SOLVED]
Post by: RetroJay on Fri 24/02/2012 07:21:10
Hi all.

I have made a view. within this view I have frames of Ego falling over (to the left) in loop 1 and (to the right) in loop 2.

The script bellow works well, if Ego is already facing left.
However. If Ego is facing right he uses (obviously) the same loop (loop 1), which is wrong and looks crap.


// script for Object 4 (Mushroom2): Interact object

if (John_Examine_Mushroom == true){
 cEgo.Say("I'll take this.");
 Wait(20);
 cEgo.Say("Oh. I don't feel so good.");
 cEgo.Say("I think I may have made a fatal error.");
 Wait(20);
 mouse.Visible = false;
 character[EGO].LockViewAligned(29,1, eAlignLeft);
 character[EGO].Animate(1, 5, eOnce, eBlock, eForwards);
 Display("Well. That was just stupid. You are dead.");
 FadeOut(1);
 RestartGame();
}


How on earth can I get the correct loop to play depending on what way Ego is facing in the game.
I have looked in the manual, I have searched and tinkered about with this for days and can't get it to work the way I would like. :'(

Any help would be greatly appreciated.
Many thanks.

Jay.
Title: Re: How do I animate death scene depending on what way Ego is facing?
Post by: Khris on Fri 24/02/2012 07:59:37
This should do it:
  int align = (cEgo.Loop == 1) * eAlignLeft + (cEgo.Loop == 2) * eAlignRight;
  cEgo.LockViewAligned(29, eEgo.Loop, align);
  cEgo.Animate(cEgo.Loop, 5, eOnce, eBlock, eForwards);


(The first line is short for "int align; if (cEgo.Loop == 1) align = eAlignLeft; if (cEgo.Loop == 2) align = eAlignRight;")
Title: Re: How do I animate death scene depending on what way Ego is facing?
Post by: RetroJay on Fri 24/02/2012 09:27:37
Hi Khris.

Once again I bow down before your greatness. :)

That works like a charm.
I am still slightly bemused by these 'int' thingies.

There is one small error in your code I found.
On the second line you have put 'eEgo' instead of 'cEgo'.

If I just say "Thank you infinite" that should cover now and future problem solving. ;)

Many thanks.
Jay.
Title: Re: How do I animate death scene depending on what way Ego is facing?
Post by: RetroJay on Tue 28/02/2012 01:09:49
Hi all.

The script bellow, nearly, works. Just one stupid thing is bothering me.

The top section works fine.
However. If you have done the thing you need to do.
The first comment happens in the top section and then runs the bottom section.

could someone, please, take a look at this script and tell me why  


// script for Object 6 (Mushroom1): Interact object

if (John_Examine_Mushroom == false){
if (killer_mushroom == 0) {
   cEgo.Say("This could be poisoness.");
}
if (killer_mushroom == 1) {
   cEgo.Say("I don't know if I should touch this.");
}
if (killer_mushroom == 2) {
   cEgo.Say("I like mushrooms. They're tasty.");
}
if (killer_mushroom == 3) {
 cEgo.Say("Oh. Hell. I'll take it. What's the worst that could happen.");
 Wait(20);
 cEgo.Say("Oh. I don't feel so good.");
 Wait(20);
 mouse.Visible = false;
   
 if (player.View == 1){
   int align = (cEgo.Loop == 1) * eAlignRight + (cEgo.Loop == 2) * eAlignLeft;
   cEgo.LockViewAligned(29, cEgo.Loop, align);
   cEgo.Animate(cEgo.Loop, 5, eOnce, eBlock, eForwards);
 }
 
 if (player.View == 12){
   int align = (cEgo.Loop == 1) * eAlignRight + (cEgo.Loop == 2) * eAlignLeft;
   cEgo.LockViewAligned(39, cEgo.Loop, align);
   cEgo.Animate(cEgo.Loop, 5, eOnce, eBlock, eForwards);
 }
 
   Display("Well. That was just stupid. You are dead.");
   FadeOut(1);
   RestartGame();
}
 
if (killer_mushroom < 3) {
 killer_mushroom +=1;
}
}
-----------------------------------------------------------------------------

if (John_Examine_Mushroom == true){
 cEgo.Say("I think that this mushroom is what John wants.");
 
if (cEgo.InventoryQuantity[18] > 0){
  cEgo.Say("I'll take this one.");
  object[3].Visible = false;
  cEgo.LoseInventory(inventory[18]);
  cEgo.AddInventory(inventory[2]);
  Display("Mushroom added to inventory.");
  Wait(20);
  cEgo.Say("That's it I now have the two mushrooms John wants.");
}

else{
  cEgo.Say("This is one I need.");
  object[3].Visible = false;
  cEgo.AddInventory(inventory[18]);
   Display("Mushroom added to inventory.");
  Wait(20);
  cEgo.Say("I need to find one more.");
 }
}
}


What am I missing here?
Many, Many thanks.

Jay.
Title: Re: How do I animate death scene depending on what way Ego is facing?
Post by: Khris on Tue 28/02/2012 01:43:29
The question is, why would AGS suddenly skip over the top part unless you told it to? Of course it's still processing the top part if you're only checking for the game changing condition afterwards.

Put this around the top part:
  if (John_Examine_Mushroom == false){ 

    ...

  }
Title: Re: How do I animate death scene depending on what way Ego is facing?
Post by: RetroJay on Tue 28/02/2012 01:56:19
Hi Khris.

I already tried that.
With that line at the top of the first section the bottom section doesn't get run at all. ???

I am confussed.

EDIT:
Oh. Forget what I just said.

All I needed was to put the extra '}' at the bottom of the first section, as you already showed me.
For some reason I completely ignored the "AROUND" bit in "put this around the top part". ::)
I have updated the script above.

Sorry to have wasted your time, Khris.
I think I can re-Solvicate this now. :)

Thank you ever so much.

Jay.