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:
- 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.
- 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.

- 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.
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 :)


