You are here

Mages buff hostile creatures?

11 posts / 0 new
Last post
jestemwlodzimierz
jestemwlodzimierz's picture
Mages buff hostile creatures?

I noticed that mages in my module (with standard event handlers) tend to cast buffs and protection spells (e.g. "Mage Armor") on creatures that are hostile towards them (that includes a standard "hostile" faction mages casting buff on PC). The AI scripts are too complicated for me to handle... Anyone know any simple fix?

  • up
    50%
  • down
    50%
kevL's

do you have Tony's 2.2 AI hooked in at all, or is everything stock?


tbh, if it's all stock (or even Tony's) i'd think it woulda been noticed before

  • up
    100%
  • down
    0%
jestemwlodzimierz
jestemwlodzimierz's picture

No Tony.

  • up
    50%
  • down
    50%
kevL's

i'd have to debug it ... got a save? (and a module with the walkmesh)

  • up
    50%
  • down
    50%
jestemwlodzimierz
jestemwlodzimierz's picture

A save of the game progress or just module file saved?

Also: SetModuleOverrideSpellScriptFinished(); doesn't stop any spells from happening for me. I figured I could make a workaround with the PreSpellHook so that if it identifies a buff being cast at an enemy, stops it and then casts an instantenous offensive spell instead.

But right now I can't even get a script like this to work:

void main()
{
SendMessageToPC(GetFirstPC(), "Running script...");
SetModuleOverrideSpellScriptFinished();
}
 
I get the message but no spells are stopped :-/
  • up
    50%
  • down
    50%
kevL's

to get the spellhook to work for non-player-controlled characters (uncontrolled companions, NPCs, etc.) an int_variable needs to be set on the area-object (each & every Area) that the spell is being/will be cast in:

X2_L_WILD_MAGIC=1
 

  • I get the message but no spells are stopped :-/

It sounds like you've got the spellhook set up okay ... try flagging your area w/ X2_L_WILD_MAGIC (or just cast with a controlled character to see if the spell is stopped).

Here's the relevant code in X2PreSpellCastCode() 'x2_inc_spellhook'

    //---------------------------------------------------------------------------
    // This stuff is only interesting for player characters. We assume that use
    // magic device always works and NPCs don't use the crafting feats or
    // sequencers anyway. Thus, any NON PC spellcaster always exits this script
    // with TRUE (unless they are DM possessed or in the Wild Magic Area in
    // Chapter 2 of Hordes of the Underdark.
    //---------------------------------------------------------------------------
    if (!GetIsPC(oSelf)
        && !GetIsDMPossessed(oSelf)
        && !GetLocalInt(GetArea(oSelf), "X2_L_WILD_MAGIC"))
    {
        return TRUE;
    }


( as you see by the notes it's a remnant from NwN1 )



i'd need the original module (for the walkmesh since it doesn't go into a save), *plus* a save made shortly before the bug manifests itself. And instructions on how to trigger the bug

  • up
    50%
  • down
    50%
jestemwlodzimierz
jestemwlodzimierz's picture

I like you. We should grab a cofee some time.

  • up
    50%
  • down
    50%
jestemwlodzimierz
jestemwlodzimierz's picture

Here's the deal: I can't provide any decent saves... but here's what I got from testing: the AI goes bonkers when there's more than one hostile faction in sight.

I have an arena segment in the module which is a 8-people free-for-all battle. Originally I had a single faction that was hostile to everyone including it's own members, but that resulted in dudes killing their own summons. So now I got 7 different factions - all hostile to each other and to the PC (but friendly within single factions).

I'll try doing some more testing to figure that out, but for now - thanks to you - my work around makes it pretty much fixed. :P

  • up
    50%
  • down
    50%
kevL's

ok cool :)

btw, if you need a function that checks if a spell is a buff-spell, dl the MetaPrepa and look in 'mrop_spellhook' for

// Checks if spell is a buff spell.
int isBuff(int iSpellId);



It should, hopefully, check for every buff (stock + kPrC Pack).

  • up
    50%
  • down
    50%
kamal

I'd think a copy of the faction file would be enough. All the factions presumably are set to 0 towards everything else, and 100 towards their own faction.

  • up
    50%
  • down
    50%
kevL's
  • I'd think a copy of the faction file would be enough. All the factions presumably are set to 0 towards everything else, and 100 towards their own faction.

that should work well enough (else someone would've notice before). The question, to me, is why isn't/didn't it work in a particular module

  • up
    50%
  • down
    50%