There's no ifs with TRUE in this script for me, though. Here's how it looks like:
void HenchSummonFamiliar(object oTarget)
{
if (GetFamiliarName(OBJECT_SELF) != "")
{
ActionUseFeat(FEAT_SUMMON_FAMILIAR, OBJECT_SELF);
return;
}
SetLocalInt(OBJECT_SELF, sHenchSummonedFamiliar, TRUE);
DecrementRemainingFeatUses(OBJECT_SELF, FEAT_SUMMON_FAMILIAR);
int bSoUInstalled = Get2DAString("hen_familiar", "BASERESREF", == "X0_FM_FDRG";
int bHoTUInstalled = Get2DAString("hen_familiar", "BASERESREF", 10) == "X2_FM_EYE0";
int nGoodEvil = GetAlignmentGoodEvil(OBJECT_SELF);
if (nGoodEvil == ALIGNMENT_NEUTRAL && GetRacialType(OBJECT_SELF) == RACIAL_TYPE_UNDEAD)
{
// convert neutral undead to evil for familiar
nGoodEvil = ALIGNMENT_EVIL;
}
string sTemplate;
if (nGoodEvil == ALIGNMENT_EVIL)
{
switch (d4())
{
case 1:
sTemplate = "NW_FM_ICE";
break;
case 2:
sTemplate = "NW_FM_FIRE";
break;
default:
sTemplate = "NW_FM_IMP";
break;
}
if (bHoTUInstalled && d3() == 1)
{
sTemplate = "X2_FM_EYE0";
}
}
else if (nGoodEvil == ALIGNMENT_GOOD)
{
switch (d6())
{
case 1:
sTemplate = "NW_FM_BAT";
break;
case 2:
sTemplate = "NW_FM_RAVE";
break;
case 3:
case 4:
sTemplate = "NW_FM_CRAG";
break;
default:
sTemplate = "NW_FM_PIXI";
break;
}
if (d3() == 1 && bSoUInstalled)
{
if (d2() == 1)
{
sTemplate = "X0_FM_FDRG";
}
else
{
sTemplate = "X0_FM_PDRG0";
}
}
}
else // ALIGNMENT_NEUTRAL
{
switch (d6())
{
case 1:
sTemplate = "NW_FM_BAT";
break;
case 2:
sTemplate = "NW_FM_RAVE";
break;
case 3:
sTemplate = "NW_FM_ICE";
break;
case 4:
sTemplate = "NW_FM_FIRE";
break;
default:
sTemplate = "NW_FM_CRAG";
break;
}
}
object oFam = HenchDoFakeSummons(sTemplate, GetLevelByClass(CLASS_TYPE_WIZARD) +
GetLevelByClass(CLASS_TYPE_SORCERER), oTarget, bHoTUInstalled);
SetLocalObject(OBJECT_SELF, sHenchSummonedFamiliar, oFam);
}
I also tried adding something like this on the beginning:
if (GetLocalInt(OBJECT_SELF, "Summons") == FALSE)
{
DecrementRemainingFeatUses(OBJECT_SELF, FEAT_SUMMON_FAMILIAR);
return;
}
And it did almost work, but if the Spell Resistance of my PC was too high for the creature to be able to attack him with a spell successfully, the creature just stood there after buffing itself. Without this part of code, the creature would (apart from summoning a familiar) attack my character in melee after buffing itself. With this workaround, it just stood there, which is not exactly desirable behavior.