SOLVED: Returning to a specific room problem...help needed

Started by Slasher, Sun 09/03/2014 05:35:46

Previous topic - Next topic

Slasher

Hi,

I have come across a situation that I am trying to overcome.

It involves going from location to location and returning to previous location (and x y - scripted).

Whilst the below code works fine there is a hurdle to overcome if you then go from 19 to 20 or 20 to 19 (after locating from a sewer room - there will are 5 +). PreviousRoom is not valid, nor is HasPlayerBeenInRoom.

So obviously I need a way to check Room you are in (19 or 20) and to always go back to the sewer room you were in last time if you then click the Sewer Location button.

Code: ags

function Button75_OnClick(GUIControl *control, MouseButton button)
{
 if(cCharles.PreviousRoom==21 && Button75.NormalGraphic==1861 && (cCharles.Room==19 || cCharles.Room==20)){
 cCharles.Say("I think I'll go back to the old sewers.");
 cCharles.ChangeRoom(21);
 }  
 else if(cCharles.PreviousRoom==22 && Button75.NormalGraphic==1861 && (cCharles.Room==19 || cCharles.Room==20)){
 cCharles.Say("I think I'll go back to the old sewers.");
 cCharles.ChangeRoom(22);
 }  
 else if(cCharles.PreviousRoom==23 && Button75.NormalGraphic==1861 && (cCharles.Room==19 || cCharles.Room==20)){
 cCharles.Say("I think I'll go back to the old sewers.");
 cCharles.ChangeRoom(23);
 }


Hope this is understandable and that you can help.

Thanks




Gurok

There are lots of ways to achieve this. I think you just need to store the room number somewhere. Storing the room before fade in might be the simplest. Assuming it's in your global script:

Code: ags

int lastSewerRoom;

function on_event(EventType event, int data)
{
	if(event == eEventEnterRoomBeforeFadein && cCharles.Room > 20 && cCharles.Room < 24)
		lastSewerRoom = cCharles.Room;

	return;
}

function Button75_OnClick(GUIControl *control, MouseButton button)
{
	if(lastSewerRoom > 20 && lastSewerRoom < 24 && Button75.NormalGraphic == 1861 && (cCharles.Room == 19 || cCharles.Room == 20))
	{
		cCharles.Say("I think I'll go back to the old sewers.");
		cCharles.ChangeRoom(lastSewerRoom);
	}

	return;
}


An alternative would be to store the sewer room as you step on the region that takes you to room 19 or 20. Slightly more efficient, but I think the method above is easier to maintain.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Slasher


Slasher

Hi Gurok.

implemented, adjusted and works a treat..

Oh, and it is Buttons that take you to locations.

cheers ;)



SMF spam blocked by CleanTalk