You are here

on critical hit ?

7 posts / 0 new
Last post
Arianna0
on critical hit ?

Help please . . . lack scripting abilites . .

 

in an effort to make up for the lack of a suitable  grapple or  grab function in NWN2, is it possible to script something  that will  only trigger an ability drain function if the monster makes a  Critical hit ?  or  some sort of percent chance to  grapple  if it hits ?  Which would then have to take into account all the various ways PCs can avoid a grapple.

 

Trying to create the Leechwalker  . . and one of its  best abilities is only applicable  if it can grab its victim

  • up
    50%
  • down
    50%
kevL's

- create special blueprints for the creature's claws, bites, etc. Give them the itemproperty "OnHitCastSpell: Unique Power"

That enables the creature-weapon to use a "tag-based scripted event": OnHitCastSpell. The script needs to be named

i_tag_hc

as in 'i_tag_hc.nss' (tag is the tag you specify in the blueprint) and it will execute every time the claw or whatever hits an opponent. But i don't think there's any way to get whether a critical happens. Instead, it could have a random chance of grappling and doing an ability drain (for example).

These are the objects that such a script has access to:

    oItem     = GetSpellCastItem();      // the item triggering the script
    oTarget   = GetSpellTargetObject();  // the target that got hit
    oCreature = OBJECT_SELF;             // the creature making the attack



once you've got things like that okay, the spellscripts for Bigby's Hands line of spells have good ideas for grapples, iirc, and applying an ability drain is cake at that pt.


here's what i tricked-up before zzzzzzzzzz

// 'i_sword_onhit_hc'

#include "nwn2_inc_spells"  // HasSizeIncreasingSpellEffect()
//#include "x0_i0_spells"   // GetSizeModifier()


const int iGRAPPLE_DC = 10; // the higher this is, the harder the grapple is to avoid.

//
void main()
{
    SendMessageToPC(GetFirstPC(FALSE), "i_sword_onhit_hc");

    object oItem = GetSpellCastItem();
    SendMessageToPC(GetFirstPC(FALSE), ". item= " + GetName(oItem));

    object oTarget = GetSpellTargetObject();
    SendMessageToPC(GetFirstPC(FALSE), ". target= " + GetName(oTarget));

    object oCreature = OBJECT_SELF;
    SendMessageToPC(GetFirstPC(FALSE), ". self= " + GetName(oCreature));



    int iAttackRoll = d20() + iGRAPPLE_DC
                    + GetAbilityModifier(ABILITY_STRENGTH, oCreature)
                    + GetBaseAttackBonus(oCreature)
                    + GetSizeModifier(oCreature)
                    + (HasSizeIncreasingSpellEffect(oCreature) ? 4 : 0);

    int iTargetRoll = d20()
                    + GetAbilityModifier(ABILITY_STRENGTH, oTarget)
                    + GetBaseAttackBonus(oTarget)
                    + GetSizeModifier(oTarget)
                    + (HasSizeIncreasingSpellEffect(oTarget) ? 4 : 0);

    SendMessageToPC(GetFirstPC(FALSE), ". . attack= " + IntToString(iAttackRoll));
    SendMessageToPC(GetFirstPC(FALSE), ". . target= " + IntToString(iTargetRoll));

    if (iAttackRoll >= iTargetRoll)
    {
        effect eDecrease = EffectAbilityDecrease(ABILITY_DEXTERITY, 6);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDecrease, oTarget, RoundsToSeconds(1));

        effect eImpact = EffectVisualEffect(VFX_IMP_BIGBYS_FORCEFUL_HAND);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eImpact, oTarget);
    }
}

  • up
    50%
  • down
    50%
kevL's

make sense?

the effects can be changed: I don't know what a Leechwalker is, but if it's undead (akin to Nightwalker) you might want a level-drain in addition to the dex-decrease. The VFX should prob. be different also ....


plus i'm thinking that the defender should use its dexterity modifier instead of str-mod

the target could even be put in a "freeze" effect ... although if it's going to be that powerful, there should be a save (or some additional % chance given)

  • up
    50%
  • down
    50%
Arianna0

Leechwalker is considered  Vermin  from the  3.5 Monster Manual II

 

they have a thing called 

Blood Drink  - a leechwalker can drink the blood of a grabbed victim with a successful grapple check. this Deals 2d4 points of constitution drain

 

I tried attaching your script to the  Claw for this , changing the tag of the item and the  includes to fit our system.  Also changed the  Strength to Constitution  etc .  But it never seemed to fire when I tested the creature

  • up
    50%
  • down
    50%
kevL's

(long detailed post in progress...)

it's just a tag-based script. Your module needs tag-based scripting Nwn2-style enabled. See your OnModuleLoad script and 'x2_inc_switches' file, roughly [the values specified in the OnModuleLoad script can conceivably be changed in other places]. Such files are set to work by default, but they could have been changed on your server.

eg, 'x2_mod_def_load'

    // * Item Event Scripts: The game's default event scripts allow routing of all item related events
    // * into a single file, based on the tag of that item. If an item's tag is "test", it will fire a
    // * script called "test" when an item based event (equip, unequip, acquire, unacquire, activate,...)
    // * is triggered. Check "x2_it_example.nss" for an example.
    // * This feature is disabled by default.
    SetModuleSwitch(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE); // nwn1-style, required for nwn2 also, iirc.


default value in 'x2_inc_switches' : const string MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS = "X2_SWITCH_ENABLE_TAGBASED_SCRIPTS";


    // Enabling this causes tagbased scripting to use 7 different scripts for item events instead of
    // having them packaged all in one.  
    // The scripts are postfixed with "_aq", "_ua", "_eq", "_ue", "_ac", "_ci", and "_hc"
    SetModuleSwitch(MODULE_SWITCH_ENABLE_SEPERATE_ITEM_SCRIPTS, TRUE); // this is the flag for nwn2-style tag-based scripting


default value in 'x2_inc_switches' : const string MODULE_SWITCH_ENABLE_SEPERATE_ITEM_SCRIPTS = "NWN2_SEPERATE_ITEM_SCRIPTS";

The special suffixes are also defined in 'x2_inc_switches'. Here are also several functions that handle tag-based mechanics; those need to be intact (although i think that mechanics for _hc and _ci are kinda hardcoded.. since they fire as itemproperties instead of module-events, unlike the others ).


    if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS))
    {
        // * If Tagbased scripts are enabled, and you are running a Local Vault Server
        // * you should use the line below to add a layer of security to your server, preventing
        // * people to execute script you don't want them to. If you use the feature below,
        // * all called item scrips will be the prefix + the Tag of the item you want to execute, up to a
        // * maximum of 16 chars, instead of the pure tag of the object.
        // * i.e. without the line below a user activating an item with the tag "test",
        // * will result in the execution of a script called "test". If you uncomment the line below
        // * the script called will be "i_test.nss"
        SetUserDefinedItemEventPrefix("i_"); // generally speaking, leave this defined whether running either a LocalVault or ServerVault.
    }


( note the maximum chars for a scriptname is increased to 32 in nwn2 )


The claw-item's blueprint should be customized with a unique-ish tag (etc.) and have the itemproperty OnHitCastSpell:UniquePower.

Equip the item in a creature-weapon slot(s) of a Leechwalker, and when a successful hit *with that weapon* occurs, the script 'i_<tag_of_claw>_hc' ought to fire.



* monsters randomly choose which creature-weapon to attack with ... (although i'm not terribly impressed w/ Nwn2's pRNG *shrug )



For a stock example, see SoZ, module F_X2, item: Ghast Claw 1d4 ( "claw_ghast" ), equipped on creature: Ghast ( "f_ghast" ) [but don't get it confused with other ghasts that don't have the special claw/bite attacks ]. There are similarly special ghouls in SoZ ....

the script for the special ghastclaw is 'i_claw_ghast_hc'


/admittedly it takes a bit of luck & determination

but I ran the ghast as a test and its claw and bite scripts fired okay here. ( i died at L5 lol )

  • up
    50%
  • down
    50%
Arianna0

We have all the  tag based scripting inplace  

I didn't have the 

"The claw-item's blueprint should be customized with a unique-ish tag (etc.) and have the itemproperty OnHitCastSpell:UniquePower."

in place.  Hoping that was the only  snafu.  Thanks for the help so far.  Really appreciate it!

  • up
    50%
  • down
    50%
kevL's

sounds like a cool monster ability ... let me know how it goes pls

  • up
    50%
  • down
    50%