Choose Your Language

Monday 24 December 2007

Die! Die! Die! And Stay Dead!

Before I begin to start transferring some information from the forums, I thought I would let you know what I have been up to in the time I have had over the last few weeks: Trying to script the companions in such a way that they would STAY DEAD!

As you know, the default for the official campaign is that companions do not actually die when they fall to the ground during combat at zero hitpoints. Instead, after a battle, if any of your characters are still alive, they get up and can simply be healed to be up and ready to go again. This is not how I want the Althéa Campaign to play, and I have been reworking the scripts to ensure that any PC who drops below 1 HP, dies.

This may sound simple on the surface of things, but the problem was complicated by the introduction of the new Life Essence system. Not only that, but I wanted to ensure the game remained playable and yet give the player a recognition that dying would still cost something within the game.

During my testing, however, it soon became evident that the OnDeath script on a companion (that was being possessed/controlled by a player at the time) was not executing the same way as if the companion was not being possessed/controlled by the player at the time of its death. This led to the companion repeatedly coming back to life after a battle even though my script was saying something different.

In the end, after much searching and help from Man_From_Geldar on the Bioware forums (who sent me a copy of his mod to test), I was able to ascertain that the OnDeath script has special requirements that were necessary under certain conditions. Furthermore, as I looked through the OnDeath script, it became obvious when I read these lines:
// Check for additional death script. (For adding extra actions and events.)
string sDeathScript = GetLocalString(oCompanion, "DeathScript");
if (sDeathScript != ""){ExecuteScript(sDeathScript, oCompanion);}
I had read them a few times as I was writing the script, but I did not pay them much heed at the time. It was only when I discovered that certain lines of my code were being ignored that I decided to write a separate script and attach it to the companion to fire when these lines were met instead. As soon as I did that, everything started to fall into place.
So, for anybody else struggling with companion OnDeath scripts (while being possessed by the player), you now have my experiences to learn from. :)

No comments: