[SOLVED] If Character is facing a direction...

Started by deadsuperhero, Sat 20/02/2010 20:24:16

Previous topic - Next topic

deadsuperhero

I've tried doing a search on this through the forums, but nothing has come up that I quite have in mind, so here goes:

I want to code in a segment where you [EGO] have to steal a cheese grater from the kitchen, and your mom [MOM] doesn't want you to take it. [MOM] currently runs on a series of looping scripts to make it look as if she is working in the kitchen. She walks to the fridge, opens it, cuts some carrots, heats something up in the microwave, etc.

However, I have no idea as to how to code this: She doesn't want you to take the cheese grater, so you can only take it while her back is turned. If she is facing the player character [EGO], I want to have the player reach for it, the mother to scold him, and the player character to shrug and walk away.


So, I guess my question is: What function do I need to determine if the Mom character is facing the player character while you try and take the cheese grater?
The fediverse needs great indie game developers! Find me there!

GarageGothic

In the interaction script for the cheese grater, check the mother's loop. Something like this.

Code: ags
if (cMother.Loop == 2) cMother.Say("Don't you dare pick up the cheese grater");
else {
  player.Say("Yoink!");
  player.AddInventory(iCheesegrater);
  }

deadsuperhero

That worked beautifully! Since I'm using an older version of AGS (for the sake of Mac and Linux compatibility) my final script came out like this, in the object interaction script:

Quote
MoveCharacterBlocking(EGO, 197, 115, 1);
if ((character[EGO].x==197)&&(character[EMO].y==115)) { 
if (character[MOM].loop == 2) {
DisplaySpeech(MOM, "Don't you dare pick up that cheese grater!");
}
else {
  DisplaySpeech(EGO, "Yoink!");
   AddInventory(6);
   ObjectOff(1);
   GiveScore(1);
  }
}

I definitely appreciate the help!
The fediverse needs great indie game developers! Find me there!

SMF spam blocked by CleanTalk