Alignment based Gate Script
This scripting forum is to discuss scripting and for those needing help scripting to get help from others.

Moderators: Mermut, rdjparadis

Post Reply
User avatar
Winterhawk99
Posts: 1627
Joined: Thu Oct 08, 2009 12:00 am
ctp: Yes
nwnihof: Yes
Location: Pa.
Contact:

Alignment based Gate Script

Post by Winterhawk99 »

As with the epic spell dragon knight I always had a problem with the gate spell for the same reason. Mermut created a new script so the spell summons a creature nearest to your alignment. She also went a little farther with this spell in the if you are 25th level or above you will summon a stronger creature than below 25th. You will definitely need CEP for the creatures in the .erf or recreate them in the toolset if you do not. Here is the script:

Code: Select all

//::///////////////////////////////////////////////
//:: Gate
//:: Name nw_s0_gate
//:://////////////////////////////////////////////
/*
    The Caster summons an extra-planar entity to fight by his side
    The creature summoned depends on the caster's alignment.
    Evil casters are advised to protect themselves from the denizens
    of the lower planes before casting this spell
    As casters gain expertise, they can summon more powerful denizens
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: April 12, 2001
//:: Modified By: Mermut
//:: Modified On: September 3, 2007
//:: Modification: Made the outsider summoned be alignment based
//::                Also added a bonus so PCs with more then 25 levels
//::                in the -specific- class that cast the spell get a
//::                'bigger' outsider
//:://////////////////////////////////////////////Summons include Astral Deva,Avoral,Balor,Bralani,Death Slaad Lord,Gelugon,Ghaele,Grey Slaad Lord,Kolyarut, Leonal, Marut, Nycadaemon, Pit Fiend, //Planetar, Ultrodaemon
#include "x2_i0_spells"
#include "x2_inc_spellhook"

void main()
{
    object oCaster = OBJECT_SELF;
    int iCasterLevel = GetCasterLevel(oCaster);
    object oTarget = GetFirstPC();
    location lTarget = GetSpellTargetLocation();
    int iMetamagic = GetMetaMagicFeat();
    float fDuration = TurnsToSeconds(iCasterLevel);

    //--------------------------------------------------------------------------
    // Spellcast Hook Code
    // Added 2003-06-20 by Georg
    // If you want to make changes to all spells, check x2_inc_spellhook.nss to
    // find out more
    //--------------------------------------------------------------------------
    if (!X2PreSpellCastCode())
    {
        return;
    }
    // End of Spell Cast Hook

    //--------------------------------------------------------------------------
    // Declare Spell Specific Variables & impose limiting
    //--------------------------------------------------------------------------
    string sSummon;
    int iGEAlign = GetAlignmentGoodEvil(oCaster);
    int iLCAlign = GetAlignmentLawChaos(oCaster);
    int iVis;
    object oItem = GetSpellCastItem();  // check if cast from an item

    // Items and TN casters get a random summon
    if (GetIsObjectValid(oItem))
    {
        iGEAlign = ALIGNMENT_NEUTRAL;
        iGEAlign = ALIGNMENT_NEUTRAL;
    }
    while (iGEAlign == ALIGNMENT_NEUTRAL && iLCAlign == ALIGNMENT_NEUTRAL)
    {
        iGEAlign = Random(3) + 1;
        if (iGEAlign > 1)
            iGEAlign = iGEAlign + 2;
        iLCAlign = Random(3) + 1;
    }

    // Determine the vfx and summon resref
    switch (iGEAlign)
    {
        case ALIGNMENT_GOOD: //GOOD aligned creatures summon a celestial:
            iVis = VFX_FNF_SUMMON_CELESTIAL;
            if (iLCAlign == ALIGNMENT_CHAOTIC)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_cg_high";
                else
                    sSummon = "gate_cg_low";
            }
            else if (iLCAlign == ALIGNMENT_LAWFUL)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_lg_high";
                else
                    sSummon = "gate_lg_low";
            }
            else // (iLCAlign == ALIGNMENT_NEUTRAL)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_ng_high";
                else
                    sSummon = "gate_ng_low";
            }
        break;
        case ALIGNMENT_EVIL:
            iVis = VFX_FNF_SUMMON_GATE;
            if (iLCAlign == ALIGNMENT_CHAOTIC)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_ce_high";
                else
                    sSummon = "gate_ce_low";
            }
            else if (iLCAlign == ALIGNMENT_LAWFUL)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_le_high";
                else
                    sSummon = "gate_le_low";
            }
            else // (iLCAlign == ALIGNMENT_NEUTRAL)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_ne_high";
                else
                    sSummon = "gate_ne_low";
            }
            // if not protected from evil, summon hostile version
            if(!(GetHasSpellEffect(SPELL_PROTECTION_FROM_EVIL, oCaster) ||
               GetHasSpellEffect(SPELL_MAGIC_CIRCLE_AGAINST_EVIL, oCaster) ||
               GetHasSpellEffect(SPELL_HOLY_AURA, oCaster)) && GetIsPC(oCaster))
                sSummon = sSummon + "_h";
        break;
        case ALIGNMENT_NEUTRAL:
            iVis = VFX_FNF_SUMMON_MONSTER_3;
            if (iLCAlign == ALIGNMENT_CHAOTIC)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_cn_high";
                else
                    sSummon = "gate_cn_low";
            }
            else // (iLCAlign == ALIGNMENT_LAWFUL)
            {
                if (iCasterLevel > 25)
                    sSummon = "gate_ln_high";
                else
                    sSummon = "gate_ln_low";
            }
        break;
    }

    //--------------------------------------------------------------------------
    // Resolve Metamagic, if possible
    //--------------------------------------------------------------------------
    if (iMetamagic == METAMAGIC_EXTEND)
        fDuration *= 2;

    //--------------------------------------------------------------------------
    // Effects
    //--------------------------------------------------------------------------
    effect eSummon;
    effect eVis = EffectVisualEffect(iVis);

    //--------------------------------------------------------------------------
    //Apply effects
    //--------------------------------------------------------------------------
    if (GetStringRight(sSummon, 2) == "_h") // if it's a hostile summon
    {
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, lTarget);
        object oFiend = CreateObject(OBJECT_TYPE_CREATURE, sSummon, lTarget);
        AssignCommand(oFiend, ActionAttack(oCaster));
    }
    else
    {
        effect eSummon = EffectSummonCreature(sSummon, iVis, 3.0);
        DelayCommand(3.0, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, lTarget, fDuration));
    }
}
Here is the first address for the .erf: https://onedrive.live.com/?cid=0306EF43 ... 56&o=OneUp

And here is the second addy: https://1drv.ms/u/s!AkALWuBD7wYDgeE6fRxz2uINBcEKOw
CTP team member
http://www.harvestmoonconsortium.com
Chief cook and bottle washer for Harvest Moon

Post Reply