Skip to content

nw_i0_spells and Basilisks too!

Oh boy. Where to start.
I'm trying to alter the basilisks petrify attack. I need them to stop using their petrify attack and switch to their claws after I'm petrified. This bugs me to no end... :(

Is there an easy fix for this? I poked around nw_i0_spells and didn't find anything relating to being petrified???
Anyone have clue on how to tackle this?

Comments

  • TerrorbleTerrorble Member Posts: 169
    nw_i0_spells just controls what happens when they use the ability. The behavior is controlled in the AI and I don't know how to fix that.


    I have a way to generally make creatures do what I want when certain conditions are met using custom AI overrides. It's a bit clunky but it works like this.

    In nw_c2_default9 either uncomment the line that sets the creature to run END_COMBAT_ROUND_EVENTS or do this:
        if( GetLocalInt(OBJECT_SELF,"ECRE") == 1 )
        {
            SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT);
        }
    



    Make a basilisk copy and add the variable ECRE|Int|1 to it.

    Change the creature's OnUserDefined script handle to x2_def_userdef
    Now, at the end of every combat round, the basilisk will run this next part.

    In x2_def_userdef in the section:
    else if(nUser == EVENT_END_COMBAT_ROUND || GetUserDefinedEventNumber() == 1003) // END OF COMBAT

    put code to check if the basilisk's attack target is petrified. If so, set a custom AI script to run.
    if( GetTag(OBJECT_SELF) == "betterbasilisk" )
    {
    
        object oAttacker = GetAttackTarget();
    
        if( GetIsObjectValid(oAttacker) )
        {
            int bPetrified = FALSE;
            effect e = GetFirstEffect(oAttacker);
    
            while( GetIsEffectValid(e) )
            {
                if( GetEffectType(e) == EFFECT_TYPE_PETRIFY )
                {
                    bPetrified = TRUE;
                    break;
                }
    
            e = GetNextEffect(oAttacker);
            }
        }
    
        if( bPetrified )
        {
            SetLocalString(OBJECT_SELF,"X2_SPECIAL_COMBAT_AI_SCRIPT","basilisk_ai");
        }
        else DeleteLocalString(OBJECT_SELF,"X2_SPECIAL_COMBAT_AI_SCRIPT");
    }
    

    Then make a basilisk_ai script. (using x2_ai_demo as the template)
    #include "nw_i0_generic"
    #include "x2_inc_switches"
    void main()
    {
        // The following two lines should not be touched
        object oIntruder = GetCreatureOverrideAIScriptTarget();
        ClearCreatureOverrideAIScriptTarget();
    
    
        // ********************* Start of custom AI script ****************************
    
    
       if( GetIsObjectValid(oIntruder) ) ActionAttack(oIntruder);
      else DeleteLocalString(OBJECT_SELF,"X2_SPECIAL_COMBAT_AI_SCRIPT");
    
    
        // ********************* End of custom AI script ****************************
    
        // This line *** has to be called here *** or the default AI will take over from
        // this point and really bad things are going to happen
        SetCreatureOverrideAIScriptFinished();
    }
    

    I haven't tested this (so I'm sure there will be a problem :wink: ). To summarize, the creature runs normal AI. At the end of its combat round, it checks if the target it is attacking is petrified. If it is, then we set the custom AI script which just tells it to attack. If it isn't petrified, then it deletes the custom AI so that it goes back to standard AI stuff. There are limitations, of course. The custom AI doesn't try to find a new target if the other one died or disappeared, but it should return to regular AI to allow that. It doesn't respond well to another enemy doing stuff to it while it's attacking the petrified target or make use of other abilities should it have them. Anyway, I'm sure there's a better way, but maybe this is helpful.

  • ZephiriusZephirius Member Posts: 411
    Hey, thanks for the response. I'm gonna try this! I don't care how clunky it is.
Sign In or Register to comment.