You are here

Geas object

8 posts / 0 new
Last post
Arianna0
Geas object

Is it possible to script a object  that the player would carry to simulate a GEAS, against  casting necromatic spells?

Basically so that anytime they cast a necromatic spell they would suffer  3d6 damage

  • up
    50%
  • down
    50%
kevL's

sounds like a job for spellhook

// 'spellhook_geas'

const string sTAG_GEAS = "it_geas";


void main()
{
    object oCaster = OBJECT_SELF;

    object oGeas = GetItemPossessedBy(oCaster, sTAG_GEAS);
    if (GetIsObjectValid(oGeas))
    {
        //int SPELL_SCHOOL_NECROMANCY = 7;
        // note: If you find a core function that gets the spellschool
        //       it should be used instead of ->

        if (Get2DAString("spells", "School", GetSpellId()) == "N") // spell is Necromantic
        {
            effect eGeas = EffectDamage(d6(3),
                                        DAMAGE_TYPE_MAGICAL,
                                        DAMAGE_POWER_NORMAL,
                                        TRUE);
            DelayCommand(0.1f, ApplyEffectToObject(DURATION_TYPE_INSTANT, eGeas, oCaster));
        }
    }
}

  • up
    50%
  • down
    50%
Arianna0

oooh  thanks  will try this out  ASAP and see if it works

 

  • up
    50%
  • down
    50%
Arianna0

so if I have the script in the mod and the  item tag in the script and the item on the person it should work?

 

  • up
    50%
  • down
    50%
Trinital

Yup, You need the script to be called from the Spell Pre-Hook though. SO everytime a spell is casted it will run this code first.

  • up
    50%
  • down
    50%
kevL's

the spellhook needs to be enabled. This can be done either by setting a string_variable on the Module(s) in the toolset:

X2_S_UD_SPELLSCRIPT = spellhook_script


or like this in the OnModuleLoad event(s):

    SetLocalString(GetModule(), "X2_S_UD_SPELLSCRIPT", "spellhook_script");



Note that only PCs are affected by that. To affect Companions and other NPCs, an int_variable also has to be set TRUE on every Area of the (each) Module:

X2_L_WILD_MAGIC = 1


or in the OnModuleLoad event(s):

    object oArea = GetFirstArea();
    while (GetIsObjectValid(oArea))
    {
        SetLocalInt(oArea, "X2_L_WILD_MAGIC", TRUE);

        oArea = GetNextArea();
    }




But if eg. you want to limit the geas to pc-faction only, you'd have to script that into the spellhook itself.


Spellhooks work like in Nwn1: http://nwn.wikia.com/wiki/Spellhook (except Nwn2 has the added complication of Companions)

  • up
    50%
  • down
    50%
Arianna0

hmmm Tried the above, adding it to the  onmoduleload script  and it caused other peoples ability to craft scrolls to no longer work in the game soooo    have to figure out what I am doing wrong

 

  • up
    50%
  • down
    50%
kevL's

sounds like there is a spellhook script enabled already.

debug:
- revert to get crafting scrolls working again.
- run console script to find the name of the current spellhook (if any)

// 'getspellhook'
// - console script.
void main()
{
    SendMessageToPC(OBJECT_SELF, GetLocalString(GetModule(), "X2_S_UD_SPELLSCRIPT"));
}


- then merge the two scripts.

  • up
    50%
  • down
    50%