Welcome to the second update for Otherworld. This update focuses on some fo the scripting for the mod.
Zombies, we all love them, or at least I do. Zombies will be one of the main enemies in Otherworld. Each will be different, some will be fast, some will be strong, but all will have a chance of coming back alive after being killed.
How is this done?
The Fallout 3 engine has a specific function for dealing with this, it is "ResurrectActor". We want each zombie to have a chance of being resurrected so we will attach a script to each one. This script is broken down into 2 sections, a OnDeath block and a GameMode block, each handles a different part of the process.
The OnDeath block doesn't become active until the actor (the zombie that the script is attached to) dies. In this block the script creates a test to see if the zombie is worthy enough to come back, as we don't want every zombie resurrecting all the time, that would make the game impossible. This is done by picking a random number between 1 and 100 and checking if it's over a certain number, if it is then the zombie is 1 step closer to resurrection! however for the purpose of testing this number was set to 0 in the final 2 videos. The OnDeath block also activates the GameMode block.
Once the GameMode block has become active it sets timer, as we don't want zombies to get up straight away, some are older than others and take more time to get up!. Once again a random number is picked and this becomes the number of seconds before the next part of the script is played through. This has been left out as we dont want to have to wait for X amount of time to see results.
Once this timer has counted down the script revives the actor with "ResurrectActor".
Lets check to see if this works:
Well the zombies re-appear, but not how we want them to. We want them to get up off the floor and keep fighting.
How do we do this? it could be done by scripting certain animations to play as soon as the zombie is resurrected, but it would be much simpler to look at the parameter flag with the "ResurrectActor" function.
Parameters allow you to define extra information to a function, Some functions require a parameter but some dont (such as ResurrectActor, it will work with "ResurrectActor", or "ResurrectActor [parameter]") ResurrectActor's single parameter has 2 options, a 0 (default) or a 1. A 0 will cause the actor to 'reset' and appear standing up. A 1 will cause the actor to get up off the floor, as if it was knocked down, this is what we want, so lets change the code quickly and watch another video:
Yes! it does what we want, they get up off the floor and continue to attack...wait, that zombie doesn't have any legs! and I thought zombies couldn't survive without their heads (these zombies obviously can!)
This is because our script isn't checking for missing limbs. We want our script to do so, we use the function "IsLimbGone". This function checks if a specific limb has been removed from the body, and because of this it requires a parameter (the parameter's codes are shown below)
NONE = -1
TORSO = 0
HEAD_1 = 1
HEAD_2 = 2
LEFT_ARM_1 = 3
LEFT_ARM_2 = 4
RIGHT_ARM_1 = 5
RIGHT_ARM_2 = 6
LEFT_LEG_1 = 7
LEFT_LEG_2 = 8
LEFT_LEG_3 = 9
RIGHT_LEG_1 = 10
RIGHT_LEG_2 = 11
RIGHT_LEG_3 = 12
BRAIN = 13
for example, if we want to check if a zombies brain is missing we would write "IsLimbGone 13" and if the brainw as missing it would return a 1, if it was still attached it would return a 0. this means that we can now check for missing limbs, and if any are missing we can tell the script not to resurrect the zombie.
It may seen easy to check if no limbs are missing (-1 parameter code) however this seems bugged, and did not work as expected (No video because the end result is the same as the video above) so all thats left is to check for each limb seperatly.
A few more lines of code and its time for the last video:
As you can see the zombies now only get up if they are fully intact, and that it is possible to remove a limb while they are dead and they will not get up.
The script can also be easily changed to allow for certain limbs not to be checked, so a zombie could get back up if it was missing its arm for example.
Until next time,
p.s. I would like to thank Cipscis for his help with this script, as I am new to this scripting language. He can be found at the Bethesda Forums.