YolkfolkThe Dizzy Fansite 1 logged in0 playing
Community discussion

Respawning on Dry Land

Started by EgoTrip on 10 September 2014 • 8,069 views

14 posts
#55400
I have water enabled and the game uses both the flippers and aqualung. But, early in the game its possible to fall in the water and drown, I want this. What I do not want however is Dizzy respawning in the water, which is what happens. I want him to respawn on dry land, otherwise it kind of means game over and that isn't very good.

I do want him to respawn in water if carrying the aqualung though.

How would I fix this?
👍 0
#81579
Jamie devised a neat little trick for respawning Dizzy back on dry land when he drowned in water. See post 251 on page 26 of the DizzyAge General Coding Queries thread for details of the coding.

I think the 'waterplay' section of the HandlerGameUpdate will still respawn Dizzy under water if he's wearing the scuba outfit, but if not, then you can just add an 'if' qualification to exclude respawning on dry land if he's wearing the scuba ...or play around with separate death numbers on each bit of water and set where Dizzy respawns with separate respawn functions.
👍 0
#81580
Thanks for the reply, but I don't think that will work. I have multiple water areas, and you can enter them all from either side (or from falling down from the sky).

Hopefully I will figure out something as its not ideal as it is now. Preferably without going the Treasure Island Dizzy one-life route.
👍 0
#81581
I've had a look at my 'almost spellbound dizzy' and the coding works fine. If Dizzy drowns (or dies) in any of the water areas without the scuba he respawns at the last 'safe' place before he entered the water - this could be either at the edge of the water or the top of a cliff etc where he jumps into the water. Likewise, if he falls into the water from a cloud and dies then he respawns at the place where he started jumping onto the clouds. If he's wearing the scuba when he dies in water then he respawns in the water where he died.

I thought this was what you were trying to achieve and this simple bit of code saves an awful lot of faffing around trying to take every bit of water into consideration.
👍 0
#81582
Oh OK I thought it did something else by looking at the code. I'll give it a try. Thanks.
👍 0
#81583
I've done everything in that topic and it just wont work.
👍 0
#81585

Possibly it's the respawn part thats throwing the game off. I believe the default for water death is '5', so look in the Player.gs file for func PlayerRespawn(). The two PlayerSet lines use XSAFE & YSAFE. Copy the whole function and paste it under the respawn function. Name it func PlayerRespawn_5() and switch the PlayerSet lines.

func PlayerRespawn_5() //water death
{
//respawn
SamplePlay(FX_RESPAWN);
PlayerSet(P_DEATH, 0);
PlayerSet(P_LIFE, 100);
PlayerSet (P_X, GameGet(G_WATER X) );
PlayerSet (P_Y, GameGet(G_WATERY));
PlayerEnterIdle();
MusicFade(0,3);
MusicRestore();
}

If you've been adding your own respawn functions that respawn Dizzy to specific co-ordinates, make sure you don't have another PlayerRespawn_5() function. If so, change the number in the 'death' property of the object and the number in the respawn function.

Hope this works.

👍 0
#81586
[quote data-userid="279" data-postid="81585"]

Possibly it's the respawn part thats throwing the game off. I believe the default for water death is '5', so look in the Player.gs file for func PlayerRespawn(). The two PlayerSet lines use XSAFE & YSAFE. Copy the whole function and paste it under the respawn function. Name it func PlayerRespawn_5() and switch the PlayerSet lines.

func PlayerRespawn_5() //water death
{
//respawn
SamplePlay(FX_RESPAWN);
PlayerSet(P_DEATH, 0);
PlayerSet(P_LIFE, 100);
PlayerSet (P_X, GameGet(G_WATER X) );
PlayerSet (P_Y, GameGet(G_WATERY));
PlayerEnterIdle();
MusicFade(0,3);
MusicRestore();
}

If you've been adding your own respawn functions that respawn Dizzy to specific co-ordinates, make sure you don't have another PlayerRespawn_5() function. If so, change the number in the 'death' property of the object and the number in the respawn function.

Hope this works.

[/quote]

Nah its not working, I don't know what I'm doing wrong and to be perfectly honest, at this point I'm about to give up and scrap the game.

👍 0
#81592
Don't give up! It can be super frustrating but where there's a will there's a way... Actually I need to do this myself as I'm close to finishing my first game and I've been putting it off because it does look scary. If I can work it out before you, I'll post whatever I can think of that you might be missing :tup:
👍 0
#81593

OK, having made my own little game I've got it to work with a small change in the respawn function in Player.GS.
Add the two global defines in GameDef.GS and the extra coding in the HandlerPlayerUpdate (between cloud and water) as in Jamie's post. Then replace func PlayerRespawn() in the Player.GS file with the following:

func PlayerRespawn()
{
SamplePlay(FX_RESPAWN);
PlayerSet(P_DEATH, 0);
PlayerSet(P_LIFE, 100);
if (InventoryHasItem(100)) // id of the scuba/aqualung
{
PlayerSet(P_X, PlayerGet(P_XSAFE));
PlayerSet(P_Y, PlayerGet(P_YSAFE)):
}
else
{
PlayerSet(P_X, GameGet(G_WATER X) );
PlayerSet(P_Y, GameGet(G_WATERY));
}
PlayerEnterIdle();
MusicFade(0,3);
MusicRestore();
}

My game had a pond with a ledge on either side and a fish in the middle. Without the scuba when Dizzy either drowns or is eaten by the fish he respawns at the edge of the ledge he entered the water. When wearing the scuba and eaten by the fish he respawns just next to the fish that ate him.

I'll keep my fingers crossed that this works for both of you.

👍 0
#81594
[quote data-userid="279" data-postid="81593"]

I’ll keep my fingers crossed that this works for both of you.

[/quote]

YES! It works thanks!

There is an error in your above code tho, theres a colon instead of a semi-colon on the 9th line.
👍 0
#81596
Nice one Grandad! You saved me again :teethy:
👍 0
#81598
Glad I could help ...looking forward to two new games to play!
PS - blame my stubby fingers and these damned new 'flat' keyboards for the typing error :no:
👍 0
#81746
I'm rather late to the game here, but TBH I really don't check this site very much anymore.

Looking at my way of re-spawning out of water, yes you're correct that it will re-spawn at the last point before you enter water, even if that's just above the water having fallen from a platform. However, when I first wrote it (goodness-knows how long ago) I only really needed it for the edges of lakes etc.

It will be possible to automatically re-spawn at the last point where Dizzy was walking (out of water). It's been years now since I did any DizzyAGE coding, but I think you'd basically combine my original coding with something in Movement.GS which checks if he's walking when G_WATERX etc is set (and doesn't set it if he isn't walking).

Therefore, falling from a platform would be classed as 'fall' movement, so it wouldn't set it then, and the last place it would have been set would be when he was walking on the platform before he fell into the water.

I will acknowledge though, that of all the coding in DizzyAGE, the movement coding is by far the most complex, and I only really mastered it in the latter years, around about the time I was coding Pirate Ship Dizzy or Rock Dash Dizzy, which both use heavily-modified movement code.

Interesting fact: The coding for Pirate Ship Dizzy is so automated and pared-down that the file size for the game is actually smaller than the file size of the standard template that you start off with. :wink:
👍 0