Saturday, May 02, 2009

A Deadly Bug

Some time ago... possibly last year, I explained the death system I wanted in chapter 1 to Lance Botelle, and he was kind enough to supply me with some scripts that would hopefully have it working. Technically, he did have it working, but... allow me to explain...

What this first module required was as follows:

  1. Up to a certain point (visiting a lighthouse), death would mean game over, with no respawn option. I felt that I could tie in some of the developing story into the respawn system to help make the story more immersive and death feel more real early on in the game.

  2. Once the lighthouse is reached, it becomes apparent that it's possible to return from death there for a limited amount of time owing to the lighthouse co-existing in Limbo (the plane that the dead travel upon - see accompanying pic). It does mean however that the player has to retrace his steps to where he died, but at least it's less frustrating than not being able to come back at all. So, after the lighthouse has been discovered, death should result in the player teleporting to Limbo, but able to return to the land of the living via the lighthouse.

  3. Later in the module, it becomes apparent that the lighthouse method can no longer be used because of how the story has developed, but another method becomes available in the form of soul crystals. As long as a player has some, he should be able to respawn on the spot.
Early testing of the system Lance had scripted for me looked positive. In case 1, the GUI panel appeared with no respawn option - great! In case 2, the player went to Limbo - woohoo!

Unfortunately I hadn't got around to testing case 3 until a couple of nights ago. While technically it did what I had asked for, respawned the player and removed a soul crystal, it did it in the same manner as case 2, in that no GUI panel came up. It just happened automatically. Now in case 2 I liked the fact that it did it like that. The first thing a player experiences when venturing to Limbo is disorientation. He asks where he is and has to be told he is dead. The fact that no GUI panel appears with the respawn option helps add to the feeling of "what just happened" when arriving in Limbo - perfect.

In contrast, case 3 didn't feel right at all. I wanted to have the GUI panel appear to give a sense of having died as opposed to looking like you'd just got up again after falling over, so I did a terrible thing... I got brave and started to tinker with it myself.

I discovered that the routine Lance had made rested exclusively within the "ondeath" script, so logically concluded I needed to transfer case 3 to the "onrespawn" script. That's when it all started to go horribly wrong. At first it wouldn't work at all, so I started tampering with it some more, and along the way all the logic got screwed up. Eventually I figured out that because I'd changed the script where the routine rested, my variable names were doomed from the start. Calling a target referred to as "odead" in a respawn script should have gave the game away early on really - doh!


So, I'd wasted a whole night screwing it all up, but the good news is that I managed to fix it after a couple of laborious hours tonight consulting the Lexicon. I'm glad I did though, because I discovered how to place text in the GUI panel (This is the article that helped me.). This has meant I've been able to improve on the immersion even more by using text relevant to the story instead of the standard random game hints that can appear. What this means is that by further editing of the "ondeath" script I now have messages appear in the GUI panel such as "You are currently unable to return to the land of the living." for case 1, and for case 3, either a message explaining that a Soul Crystal will be used for respawning, or that the player has no soul crystals remaining (with the respawn button vacant).

Please excuse me while I let out a small scream of elation ;)

WOOHOOO!


It's always great if you can solve something yourself :)

3 comments:

Lance Botelle (Bard of Althéa) said...

You only needed to ask and I could have sorted it out for you. ;)

However, I'm glad you managed to figure it out yourself. It's always a good feeling when you get what you want.

Most of the time, scripting is fairly straight forward. However, knowing what the builder wants exactly is sometimes the part that needs closer attention.

Don't forget, if you ever need greater explanation of what is done or need to tweak something to do something slightly different from first testing, just let me know. :)

Lance

Lance Botelle (Bard of Althéa) said...

By the way, it does not matter what you call your variable in any script. i.e. You can call an object oDead in any script. :) It just makes it easier to understand what the variable refers to.

Lance.

Quillmaster said...

I know Lance, but my confidence has been growing so I wanted to see if I could do it, and besides, I'm bound to encounter some other obstacle soon ;) As for the variable thing, I know you can call them what you want, but the point was I hadn't defined who oDead was because the script was only defining oRespawner. Of course changing oDead to oRespawner had the battle half won, but by that point I had changed much in an attempt to get it working thinking the flaw was elsewhere. Took quite a while to juggle it all back together by logically reading the code, so I was dead chuffed that I'd finally managed to fix it, and learnt something too! :)

Thanks again btw. I would never have got this far if you hadn't have helped me in the first place. :)