Dragon knight 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:

Dragon knight script

Post by Winterhawk99 »

I always had a problem with Dragon knight in that you could only call an evil dragon. Fortunately, my lead scripter corrected this on my old world pretty quickly. Mermut made a script so that dragon knight became alignment based so people with alignments would call a dragon knight that aligned with their way of seeing the world.

Here is the script and a link to download an .erf for the dragon models. As with all erfs. I would highly recommend you download it into a test module. These models may require a version of cep being that there are crystal and a brown dragon model used.

Here is the script.

Code: Select all

//::///////////////////////////////////////////////
//:: Dragon Knight
//:: X2_S2_DragKnght
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
     Summons an adult red dragon for you to
     command.
*/
//:://////////////////////////////////////////////
//:: Created By: Andrew Nobbs
//:: Created On: Feb 07, 2003
//:: Modified By: Mermut
//:: Modified On: November 20, 2007
//:: Modification: Made which dragon is summones alignment specific
//:://////////////////////////////////////////////
#include "x2_inc_toollib"

#include "x2_inc_spellhook"
void main()
{
    /* 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())
    { // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

    //Declare major variables
    object oCaster = OBJECT_SELF;
    location lTarget = GetSpellTargetLocation();
    int iCasterLevel = GetCasterLevel(oCaster);
    int nDuration = 2*iCasterLevel;
    if (GetIsObjectValid(GetSpellCastItem()))
        nDuration = 10;

    // determine which dragon to summon dragons include red, green,brown,copper,crystal,amythest,electrum,gold and sapphire
    string sDragon;
    int iGEAlign = GetAlignmentGoodEvil(oCaster);
    int iLCAlign = GetAlignmentLawChaos(oCaster);

    switch (iGEAlign)
    {
        case ALIGNMENT_GOOD: //GOOD aligned creatures summon a celestial:
            if (iLCAlign == ALIGNMENT_CHAOTIC)
            {
                sDragon = "dragknight_cg";
            }
            else if (iLCAlign == ALIGNMENT_LAWFUL)
            {
                sDragon = "dragknight_lg";
            }
            else // (iLCAlign == ALIGNMENT_NEUTRAL)
            {
                sDragon = "dragknight_ng";
            }
        break;
        case ALIGNMENT_EVIL:
            if (iLCAlign == ALIGNMENT_CHAOTIC)
            {
                sDragon = "dragknight_ce";
            }
            else if (iLCAlign == ALIGNMENT_LAWFUL)
            {
                sDragon = "dragknight_le";
            }
            else // (iLCAlign == ALIGNMENT_NEUTRAL)
            {
                sDragon = "dragknight_ne";
            }
        break;
        case ALIGNMENT_NEUTRAL:
            if (iLCAlign == ALIGNMENT_CHAOTIC)
            {
                sDragon = "dragknight_cn";
            }
            else if (iLCAlign == ALIGNMENT_LAWFUL)
            {
                sDragon = "dragknight_ln";
            }
            else // (iLCAlign == ALIGNMENT_NEUTRAL)
            {
                sDragon = "dragknight_tn";
            }
        break;
    }

    effect eSummon;
    effect eVis = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION);
    eSummon = EffectSummonCreature(sDragon, VFX_FNF_SUMMONDRAGON, 0.0, TRUE);

    // * make it so dragon cannot be dispelled
    eSummon = ExtraordinaryEffect(eSummon);

    //Apply the summon visual and summon the dragon.
    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, lTarget, RoundsToSeconds(nDuration));
    DelayCommand(1.0, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, lTarget));
}
and here is the links: https://1drv.ms/u/s!AEALWuBD7wYDgeE5

https://onedrive.live.com/?cid=0306EF43 ... 56&o=OneUp

one of those two links should work.
CTP team member
http://www.harvestmoonconsortium.com
Chief cook and bottle washer for Harvest Moon

Post Reply