resetting a puzzle

Need help with using DizzyAGE then look here
Grandad
Hard Boiled Egg
Posts: 1494
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

resetting a puzzle

Post by Grandad » Fri Oct 23, 2009 11:37 am

This is more curiosity rather than actual help required. Let's say you have a scenario where Dizzy gets squashed to death by a falling block if he tries to use the wrong item on an object and when he is re-spawned the puzzle is reset for him to try a different item.

I've played around with this trying enabling the 'block' as a one way train when the wrong item is used, but re-spawning leaves the block down. Tried again with a looped train, but re-spawning just keeps the block going up and down. Looked at 'repeat please' in the GS9 book, but that doesn't seem to be relevant.

Unless there is some specific coding to reset, which I haven't discovered is the solution not to use dynamic brushes but to switch the whole response to a cut-scene ending in death, such as using the right item keeps him alive and having an 'else' command to initiate the cut-scene?

Grandad

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Fri Oct 23, 2009 12:24 pm

I know the type of thing you mean. Basically you need to write the 'reset' code yourself, then call it using a RespawnPlayer_X() function, where X is the death property of the thing that killed him.

this is a sightly modified version of the 'respawn player' code for the lightning bolt in MSD (which needs moving back to its' start position if dizzy dies):

Code: Select all

func PlayerRespawn_1()
{
	Reset_Bolt();
	SamplePlay(FX_RESPAWN);
	PlayerSet(P_DEATH, 0);
	PlayerSet(P_LIFE,1);

	PlayerSet(P_X, 1764);
	PlayerSet(P_Y, 182);
	PlayerEnterIdle();
	MusicFade(0,3);
	MusicRestore();
}
func Reset_Bolt()
{
	bolt = ObjFind(2120);
	ObjSet(bolt,O_STATUS,0);
	ObjSet(bolt,O_X,1862);
	ObjSet(bolt,O_Y,136);
	ObjSet(bolt,O_DRAW,0);
	ObjPresent(bolt);
}
(the reason i didn't incorporate Reset_Bolt() into the respawn function is that i also call it from elsewhere)
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

macon
Hard Boiled Egg
Posts: 174
Joined: Mon Apr 30, 2007 1:08 pm
Location: Grimsby, England

Post by macon » Fri Oct 23, 2009 12:37 pm

When I had to do something like this I called my reset function from PlayerDeathMessage(death) in game.gs. I call it on the line before returning the death message.

Grandad
Hard Boiled Egg
Posts: 1494
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Post by Grandad » Sat Oct 24, 2009 9:56 am

Ah, should have realised it was creating your own function and calling it when required from the 'main' files. I'll have a closer look at the structure in MSD (and the Zak/Troll cave in IID) as I've found that checking out how someone has done something in a specific game often helps to understand the 'flow'. Also I didn't realise that you could call a function from within the PlayerDeathMessage.

This should help in something that has been bugging me in my game as I've got a situation where a soldier is shooting bullets when you enter the room and if you don't jump to a platform in time, you die. Unfortunately the respawn takes place just before the co-ordinates at which they got killed, so I'll have a closer look at the 'safe' respawn to see if I can respawn them back to the edge of the previous room.

Thanks

Grandad

macon
Hard Boiled Egg
Posts: 174
Joined: Mon Apr 30, 2007 1:08 pm
Location: Grimsby, England

Post by macon » Sat Oct 24, 2009 11:18 am

Grandad wrote:This should help in something that has been bugging me in my game as I've got a situation where a soldier is shooting bullets when you enter the room and if you don't jump to a platform in time, you die. Unfortunately the respawn takes place just before the co-ordinates at which they got killed, so I'll have a closer look at the 'safe' respawn to see if I can respawn them back to the edge of the previous room.
Grandad
Similar sort of thing to what I did in Excalibur Dizzy with the Yeti throwing snowballs at you. Though I can't remember what I did now. Looking at the code for that room might give you a clue on using a safe respawn.

Grandad
Hard Boiled Egg
Posts: 1494
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Post by Grandad » Sat Oct 24, 2009 12:50 pm

Andy, Thanks. I've had a look at Excalibur Dizzy but the snowman code looks incredibly complicated for my basic understanding as you also seem to have set death responses in the 'user defines' of the brush property ...but I had been trying to find your insect tiles to use, but thought they were in another game that couldn't be unpacked, and ended up creating my own, which were, to be frank ..rubbish. So I'm going to swap them for the one's you've created and obviously credit you.

Jamie, I can sort of understand your resetting. I'm assuming that you are using the 'custom death' response in the PlayerLoseLife function in the Player.GS file and that as death by lightning is the first response, assume that PlayerRespawn_1 refers to that one to put Dizzy back by the entrance. Is it called automatically from the 'death by lightning' which is why you've put the respawn_1 in the game file or am I missing a pointer somewhere else?

Grandad

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Sat Oct 24, 2009 1:01 pm

Grandad wrote:Jamie, I can sort of understand your resetting. I'm assuming that you are using the 'custom death' response in the PlayerLoseLife function in the Player.GS file and that as death by lightning is the first response, assume that PlayerRespawn_1 refers to that one to put Dizzy back by the entrance. Is it called automatically from the 'death by lightning' which is why you've put the respawn_1 in the game file or am I missing a pointer somewhere else?

Grandad
sorry, all you need to do to get that code to work is to set the 'death' property to '1' for whatever it is that you want to kill dizzy.

if for example you want a moving block to kill him, you'd need to set the 'class' property of the block to 'kill', and the 'collide' property to 'call handler'. This would kill dizzy when he touched it. However if you set the 'death' property to '1', the game would look for function PlayerRespawn_1() before respawning him. If it finds function PlayerRespawn_1() then it will use that code, otherwise it will use the standard PlayerRespawn() function in player.gs

i hope that clears things up a bit :)
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

macon
Hard Boiled Egg
Posts: 174
Joined: Mon Apr 30, 2007 1:08 pm
Location: Grimsby, England

Post by macon » Sat Oct 24, 2009 1:14 pm

Grandad wrote:So I'm going to swap them for the one's you've created and obviously credit you.
Feel free to use them. But I didn't actually create them. I obtained them from Fantastic Dizzy and a Commodore Amiga game called Benefactor.

Grandad
Hard Boiled Egg
Posts: 1494
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Post by Grandad » Sat Oct 24, 2009 2:01 pm

I can't believe it's that simple. Now to recheck death by moving objects and implement it where it's better to move the player completely out of harm's way ...except where the 'object' is moving on a circular path and gives the player a little time to make their own decision on where to run to. At this rate I should have my game finished in about a month.

Thanks

Grandad

Grandad
Hard Boiled Egg
Posts: 1494
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Post by Grandad » Tue Oct 27, 2009 10:53 am

The respawning positioning works fine, but I still can't get the status of the falling block to reset to fall again when a different item is used. The 'brush' to set it in motion works fine (I tried adding a message and after the first death, the message is repeated when the 'brush' is actioned again ..., but the falling block just stays up in the ceiling) and after the first death, using the correct item works fine too.

I've tried it using the exact coding you supplied Jamie for resetting the bolt and retried it by adding it into the respawn function. I've also tried adding a new waypoint with no target so that the falling block returns to the ceiling after dropping. There is no other object in the room that uses AI.

Essentially the coding is:

Code: Select all

func ActionObject_995(idx) //action block to retrieve item
{
	if (ObjGet(ObjFind(995), O_STATUS) == 0)
	{
	Message1 (7,5, "\"message\"");
	Message1 (6,4, "\"message\"");
	MessagePop();
	ObjSet(ObjFind(995), O_STATUS, 1);
	return;
	}
	if (ObjGet(ObjFind(995), O_STATUS) == 1)
	{
		idx = OpenDialogInventory();
		if (idx!=-1)
		{
		UseObject(idx);
		}
	}
}

func UseObject_995(idx)
{
	if (idx!=ObjFind(5010))
	{
	        ObjSet(ObjFind(993), O_STATUS, 1); //falling block
	        return;
	}

	else
	{
	          Message0 (6,4, "message");
	          MessagePop();
	          ReplaceInventoryItem(5010, 900);
	          ObjSet(ObjFind(995), O_DISABLE, 1); //disable action block
	}
}

func UpdateRoom_23_11()
{
idx = ObjFind(993); //falling block with target
AIUpdateTrain(idx);
ObjPresent(idx);
}

func PlayerRespawn_3()
{
ObjSet(ObjFind(993), O_STATUS, 0);  //reset falling block
ObjSet(ObjFind(993), O_X, 5656);
ObjSet(ObjFind(993), O_Y, 1496);

SamplePlay(FX_RESPAWN);
PlayerSet (P_DEATH, 0);
PlayerSet(P_LIFE, 1);
PlayerSet(P_X, 5584);
PlayerSet(P_Y, 1600);
PlayerEnterIdle();
MusicFade (0,3);
MusicRestore();
}
The logic seems OK in that what you are doing when respawning the player is to reset the status of the falling block back to 0, and put it back in its original map position so that when the wrong item is used again on the action block, the status is set to 1 so that the update room AI function kicks in again. But I'm no Mr Spock, so help would be appreciated.

Thanks

Grandad

Post Reply