1. Random Hitpoints for Creatures
2. What it does: Rolls up Random hitpoint totals for your creatures, then
applies them.
3. Notes: This should be used OnEnter the area/module (it can be adapted to
other places). There are of course some issues with this script -- Since
Bioware did not include anyway to actually Set the Max hitpoints for a
creature (doh!), I had to use Damage effects for creatures that have less
than default hitpoints (so they can 'heal' above their new 'Max'
unfortunately), and temporary hitpoints (applied permanently though) for #s
above default. If someone knows a better way, please fix this up and repost.
I just commented out a few debug lines, feel free to uncomment the
PrintString lines to see a little more of what is happening (in the log
file).
I also ignored PCs entering, and "Playable" races, because these are the
most likely to be NPCs (though a better way might be to check for any
'classes' instead)
Also while doing this, I noticed that the DM Client doesn't show current
hitpoints above Max, so even though the Chooser might say 4/4 Hps for an
Orc, that Orc might actually have 5 or 8 hitpoints.
NWScript:
void main()
{
object oCreature = GetEnteringObject();
if( GetIsPC(oCreature) ) return;
int nHD = GetHitDice(oCreature);
int nRacialType = GetRacialType(oCreature);
int nConstMod = GetAbilityModifier(ABILITY_CONSTITUTION, oCreature);
if( nConstMod < 0 ) nConstMod = 0;
int nMax = GetMaxHitPoints(oCreature);
int nNewHP;
int nDie;
if( (nRacialType == RACIAL_TYPE_DWARF) || (nRacialType == RACIAL_TYPE_ELF) ||
(nRacialType == RACIAL_TYPE_GNOME) || (nRacialType == RACIAL_TYPE_HALFELF) ||
(nRacialType == RACIAL_TYPE_HALFLING) || (nRacialType == RACIAL_TYPE_HALFORC) ||
(nRacialType == RACIAL_TYPE_HUMAN) || (nRacialType == RACIAL_TYPE_INVALID))
{
return;
}
else if( (nRacialType == RACIAL_TYPE_ABERRATION) || (nRacialType == RACIAL_TYPE_ANIMAL) ||
(nRacialType == RACIAL_TYPE_ELEMENTAL) || (nRacialType == RACIAL_TYPE_GIANT) ||
(nRacialType == RACIAL_TYPE_HUMANOID_GOBLINOID) || (nRacialType == RACIAL_TYPE_HUMANOID_MONSTROUS) ||
(nRacialType == RACIAL_TYPE_HUMANOID_ORC) || (nRacialType == RACIAL_TYPE_HUMANOID_REPTILIAN) ||
(nRacialType == RACIAL_TYPE_OUTSIDER) || (nRacialType == RACIAL_TYPE_SHAPECHANGER) ||
(nRacialType == RACIAL_TYPE_VERMIN))
{
nDie = 8;
}
else if( (nRacialType == RACIAL_TYPE_BEAST) || (nRacialType == RACIAL_TYPE_CONSTRUCT) ||
(nRacialType == RACIAL_TYPE_MAGICAL_BEAST))
{
nDie = 10;
}
else if( (nRacialType == RACIAL_TYPE_DRAGON) || (nRacialType == RACIAL_TYPE_UNDEAD))
{
nDie = 12;
}
else
{
nDie = 6;
}
if( nDie == 8 )
{
nNewHP = d8(nHD) + (nConstMod * nHD);
}
else if (nDie == 10)
{
nNewHP = d10(nHD) + (nConstMod * nHD);
}
else if (nDie == 12)
{
nNewHP = d12(nHD) + (nConstMod * nHD);
}
else
{
nNewHP = d6(nHD) + (nConstMod * nHD);
}
if(nNewHP > nMax)
{
int nChange = nNewHP - nMax;
effect eTempHP = EffectTemporaryHitpoints(nChange);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eTempHP, oCreature, 0.0);
}
else if(nNewHP < nMax)
{
int nChange = nMax - nNewHP;
effect eDmg = EffectDamage(nChange);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDmg, oCreature);
}
else
{
nNewHP = nMax;
}
}
_________________
Braeunk vhos trolkh!
|