You are here

Blindfold?

6 posts / 0 new
Last post
Arianna0
Blindfold?

Trying to create a useable blindfold  but the script is not quite working right  Right now it:

applies the vfx and renders the PC  blind

any NPC in the room at the time of application is seen semi grayed out

if its a caster they can target AOE spells or spells on themself

Any spells or physical attacks that directly target the NPC  do not work Spells show as 0 uses,  initiatives are rolled for physical attacks,  but no attacks happen

If a NPC is spawned in after applying the blind fold they are totally unseen not even a shade to know they are there until they get hit and even then they cannot get any inkling of where the  enemy is.

the blindfold cannot be removed- neither the vfx or the blindness effect will go away

Any way to make this workable?  This is what I have for a script so far,  I have the item with the Cast Spell: Unique Power( self only) on it as a item property

Script is named  i_abr_blindfold1_ac       item is tagged  abr_blindfold1

//
// This script will apply blindness to the item's user. Additionally, it will
// create a blindfold VFX and apply it to the user.
//


#include "acr_effects_i"
#include "acr_vfx_i"

// Local variable kept on the PC to keep track of their blindfold status.
const string VAR_BLINDFOLDED = "TMP_BLINDFOLDED";

// Checks an effect to see if it is the blindness effect we make.
int GetIsDesiredBlindnessEffect( effect e ) {
    if ( !GetIsEffectValid( e ) ) return FALSE;
    if ( GetEffectCreator( e ) != OBJECT_SELF ) return FALSE;
    if ( GetEffectType( e ) != EFFECT_TYPE_BLINDNESS ) return FALSE;
    if ( GetEffectSubType( e ) != SUBTYPE_SUPERNATURAL ) return FALSE;
    return TRUE;
}

// Fetches the effect file to use for the blindfold.
string GetSpecialEffectFileForBlindfold( object oTarget ) {
    string sEffectFile;
    //string VFXbyRace(string basename, object oPC)
    
    int nRacialType = GetRacialType( oTarget );
    switch ( nRacialType ) {
        case RACIAL_TYPE_DWARF:
            sEffectFile = "acme_fx_blackdomino_dd";
            break;
        case RACIAL_TYPE_GNOME:
            sEffectFile = "acme_fx_blackdomino_gg";
            break;
        case RACIAL_TYPE_GRAYORC:
        case RACIAL_TYPE_HALFORC:
            sEffectFile = "acme_fx_blackdomino_oo";
            break;    
        case RACIAL_TYPE_ELF:
            sEffectFile = "acme_fx_blackdomino_dd";
            break;
        default:
            sEffectFile = "acme_fx_blackdomino_hh";
            break;
    }
    
    return sEffectFile;
}

void main() {
    // Get our target.
    object oPC = GetItemActivator();
    
    

    if ( GetLocalInt( oPC, VAR_BLINDFOLDED ) == TRUE ) {
        // PC is blindfolded. Remove effect.
        effect eBlindness = SupernaturalEffect(EffectBlindness());
        
        effect e = GetFirstEffect( oPC);
        while( GetIsEffectValid( e ) ) {
            // Delete blindness/blindfold effects.
            if ( GetIsDesiredBlindnessEffect( e ) ) {
                RemoveEffect( oPC, e );
            }
            
        e = GetNextEffect( oPC );
        
        }
        SendMessageToAllDMs( GetName( oPC ) + " has taken off their blindfold." );

        DeleteLocalInt( oPC, VAR_BLINDFOLDED );
        
    } else if  ( GetLocalInt( oPC, VAR_BLINDFOLDED ) != TRUE ){
        // Add blindness effect.
        effect eBlindness = SupernaturalEffect( EffectBlindness() );
        
         //Declare major varibles
    object oTarget = GetSpellTargetObject();
    int nMetaMagic = GetMetaMagicFeat();
    int nDuration = GetCasterLevel(OBJECT_SELF);
    effect eBlind =  EffectBlindness();
    effect eDeaf = EffectDeaf();
    effect eAC = EffectACDecrease( 2 );
    effect eMoveDec = EffectMovementSpeedDecrease(50);
    effect eSpot = EffectSkillDecrease(SKILL_SPOT , 50);
    effect eSearch = EffectSkillDecrease(SKILL_SEARCH , 4);
    effect eDex;
    effect eVis = EffectVisualEffect(VFX_DUR_SPELL_BLIND_DEAF);
    int nDex = GetAbilityScore( oTarget, ABILITY_DEXTERITY );
    if (nDex > 10)
        {
        int nDecr = (nDex-10);
        eDex = EffectAbilityDecrease( ABILITY_DEXTERITY, nDecr);
        }
    effect eLink = EffectLinkEffects(eBlind, eDeaf);
    eLink = EffectLinkEffects(eLink, eSpot);
    eLink = EffectLinkEffects(eLink, eSearch);
    eLink = EffectLinkEffects(eLink, eAC );
    eLink = EffectLinkEffects(eLink, eMoveDec );
    eLink = EffectLinkEffects(eLink, eDex );
    eLink = EffectLinkEffects(eLink, eVis);
    eLink = SupernaturalEffect(eLink);
        effect eBlindfold = EffectNWN2SpecialEffectFile( GetSpecialEffectFileForBlindfold( oPC ) );
        effect eCombined = EffectLinkEffects( eBlindfold, eBlindness );
        ApplyEffectToObject( DURATION_TYPE_PERMANENT, eCombined, oPC );
        SendMessageToAllDMs( GetName( oPC ) + " has put on a blindfold." );
        SetLocalInt( oPC, VAR_BLINDFOLDED, TRUE );
        
    }
}    

 

  • up
    50%
  • down
    50%
kevL's

there were some issues w/ oPC vs oTarget usages, etc [since this is self-only, only oPC is needed]

Most importantly, i think, is that the creator was being checked against OBJECT_SELF (the module-object). below, I've assigned the application to the PC and therefore checked creator against the PC also.


some of the issues with regard to who can see what (ghosting) is gonna be hardcoded.


// 'blindfold'
/*
    OnItemActivated script.

    This script will apply heavy blindness effects to the PC (item-activator).
    Additionally, it will create a blindfold-VFX and apply it.
*/


//#include "acr_effects_i"
//#include "acr_vfx_i"


// Local variable kept on the PC to keep track of their blindfold status.
const string VAR_BLINDFOLDED = "TMP_BLINDFOLDED";


// Checks an effect to see if it is this blindness.
int GetIsDesiredBlindnessEffect(effect eScan, object oPC);

// Fetches an effect-file to use for the blindfold-VFX.
string GetSpecialEffectFileForBlindfold(object oPC);


//
void main()
{
    object oPC = GetItemActivator();


    if (GetLocalInt(oPC, VAR_BLINDFOLDED))
    {
        DeleteLocalInt(oPC, VAR_BLINDFOLDED);

        effect eScan = GetFirstEffect(oPC);
        while (GetIsEffectValid(eScan))
        {
            if (GetIsDesiredBlindnessEffect(eScan, oPC))
            {
                RemoveEffect(oPC, eScan);
                eScan = GetFirstEffect(oPC);
            }
            else
                eScan = GetNextEffect(oPC);
        }

        SendMessageToAllDMs(GetName(oPC) + " has taken off their blindfold.");
    }
    else
    {
        SetLocalInt(oPC, VAR_BLINDFOLDED, TRUE);

        effect eBlind     = EffectBlindness();
        effect eDeaf      = EffectDeaf();
        effect eAC        = EffectACDecrease(2);
        effect eMoveDec   = EffectMovementSpeedDecrease(50);
        effect eSpot      = EffectSkillDecrease(SKILL_SPOT, 50);
        effect eSearch    = EffectSkillDecrease(SKILL_SEARCH, 4);
        effect eBlindfold = EffectNWN2SpecialEffectFile(GetSpecialEffectFileForBlindfold(oPC));

        effect eVis = EffectVisualEffect(VFX_DUR_SPELL_BLIND_DEAF);

        eVis = EffectLinkEffects(eVis, eBlind);
        eVis = EffectLinkEffects(eVis, eDeaf);
        eVis = EffectLinkEffects(eVis, eAC);
        eVis = EffectLinkEffects(eVis, eMoveDec);
        eVis = EffectLinkEffects(eVis, eSpot);
        eVis = EffectLinkEffects(eVis, eSearch);
        eVis = EffectLinkEffects(eVis, eBlindfold);

        int iDex = GetAbilityScore(oPC, ABILITY_DEXTERITY);
        if (iDex > 10)
        {
            int iDecr = iDex - 10;
            effect eDex = EffectAbilityDecrease(ABILITY_DEXTERITY, iDecr);
            eVis = EffectLinkEffects(eVis, eDex);
        }

        eVis = SupernaturalEffect(eVis);

        AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVis, oPC));

        SendMessageToAllDMs(GetName(oPC) + " has put on a blindfold.");
    }
}


// Checks an effect to see if it is this blindness.
int GetIsDesiredBlindnessEffect(effect eScan, object oPC)
{
    if (   GetIsEffectValid(eScan)
        && GetEffectCreator(eScan) == oPC
        && GetEffectType(eScan) == EFFECT_TYPE_BLINDNESS
        && GetEffectSubType(eScan) == SUBTYPE_SUPERNATURAL)
    {
        return TRUE;
    }
    return FALSE;
}

// Fetches an effect-file to use for the blindfold-VFX.
string GetSpecialEffectFileForBlindfold(object oPC)
{
    string sEffectFile;

    switch (GetRacialType(oPC))
    {
        case RACIAL_TYPE_DWARF:     sEffectFile = "acme_fx_blackdomino_dd"; break;
        case RACIAL_TYPE_GNOME:     sEffectFile = "acme_fx_blackdomino_gg"; break;
        case RACIAL_TYPE_GRAYORC:
        case RACIAL_TYPE_HALFORC:   sEffectFile = "acme_fx_blackdomino_oo"; break;
        case RACIAL_TYPE_ELF:       sEffectFile = "acme_fx_blackdomino_dd"; break;
        default:                    sEffectFile = "acme_fx_blackdomino_hh"; break;
    }
    return sEffectFile;
}



but why would anyone do that to themself ........

  • up
    50%
  • down
    50%
Arianna0

My players feel they need a blind fold to go up against  Basalisks and Medusa

  • up
    50%
  • down
    50%
kevL's

ah :)

  • up
    50%
  • down
    50%
Arianna0

So I tried the above script for the blindfold item

Blindfold applies  and  Blindness effect seems in place 

Still can't see anything new that comes into area 

But biggest issue is that you cannot  click the item again and remove the  effects

  • up
    50%
  • down
    50%
kevL's

bugger... Anyway, it appears that in an OnActivated script, the module-object is the effect-creator even if the application has been assigned to the item-activator. Strangely (or not..) when i tested it as a console script that didn't happen. So I rigged up an actual item with the script and decided to bypass a bunch of malarky by giving the effect(s) a SpellId.

// 'i_blindfold_ac'
/*
    OnItemActivated script.

    This script will apply heavy blindness effects to the PC (item-activator).
    Additionally, it will create a blindfold-VFX and apply it.
*/


// The SpellId that is used for the effects on the PC.
const int SPELL_BLINDFOLD = -9999;

// Local variable kept on the PC to keep track of their blindfold status.
const string VAR_BLINDFOLDED = "TMP_BLINDFOLDED";



// Fetches an effect-file to use for the blindfold-VFX.
string GetSpecialEffectFileForBlindfold(object oPC);


//
void main()
{
    object oPC = GetItemActivator();

    if (GetLocalInt(oPC, VAR_BLINDFOLDED))
    {
        DeleteLocalInt(oPC, VAR_BLINDFOLDED);

        effect eScan = GetFirstEffect(oPC);
        while (GetIsEffectValid(eScan))
        {
            if (GetEffectSpellId(eScan) == SPELL_BLINDFOLD)
            {
                RemoveEffect(oPC, eScan);
                eScan = GetFirstEffect(oPC);
            }
            else
                eScan = GetNextEffect(oPC);
        }

        SendMessageToAllDMs(GetName(oPC) + " has taken off their blindfold.");
    }
    else
    {
        SetLocalInt(oPC, VAR_BLINDFOLDED, TRUE);

        effect eBlind     = EffectBlindness();
        effect eDeaf      = EffectDeaf();
        effect eAC        = EffectACDecrease(2);
        effect eMoveDec   = EffectMovementSpeedDecrease(50);
        effect eSpot      = EffectSkillDecrease(SKILL_SPOT, 50);
        effect eSearch    = EffectSkillDecrease(SKILL_SEARCH, 4);
        effect eBlindfold = EffectNWN2SpecialEffectFile(GetSpecialEffectFileForBlindfold(oPC));

        effect eVis = EffectVisualEffect(VFX_DUR_SPELL_BLIND_DEAF);

        eVis = EffectLinkEffects(eVis, eBlind);
        eVis = EffectLinkEffects(eVis, eDeaf);
        eVis = EffectLinkEffects(eVis, eAC);
        eVis = EffectLinkEffects(eVis, eMoveDec);
        eVis = EffectLinkEffects(eVis, eSpot);
        eVis = EffectLinkEffects(eVis, eSearch);
        eVis = EffectLinkEffects(eVis, eBlindfold);

        int iDex = GetAbilityScore(oPC, ABILITY_DEXTERITY);
        if (iDex > 10)
        {
            int iDecr = iDex - 10;
            effect eDex = EffectAbilityDecrease(ABILITY_DEXTERITY, iDecr);
            eVis = EffectLinkEffects(eVis, eDex);
        }

        eVis = SupernaturalEffect(eVis);
        eVis = SetEffectSpellId(eVis, SPELL_BLINDFOLD);

        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eVis, oPC);

        SendMessageToAllDMs(GetName(oPC) + " has put on a blindfold.");
    }
}


// Fetches an effect-file to use for the blindfold-VFX.
string GetSpecialEffectFileForBlindfold(object oPC)
{
    string sEffectFile;

    switch (GetRacialType(oPC))
    {
        case RACIAL_TYPE_DWARF:     sEffectFile = "acme_fx_blackdomino_dd"; break;
        case RACIAL_TYPE_GNOME:     sEffectFile = "acme_fx_blackdomino_gg"; break;
        case RACIAL_TYPE_GRAYORC:
        case RACIAL_TYPE_HALFORC:   sEffectFile = "acme_fx_blackdomino_oo"; break;
        case RACIAL_TYPE_ELF:       sEffectFile = "acme_fx_blackdomino_dd"; break;
        default:                    sEffectFile = "acme_fx_blackdomino_hh"; break;
    }
    return sEffectFile;
}



I used SPELL_BLINDFOLD=-9999. It's up to you, however, to ensure it doesn't conflict with any other custom SpellIds in the module. (obviously, -9999 won't conflict with any spells in Spells.2da)



and I noticed the glitch about creatures who spawn while the effect is active being not seen, at all.


the Deafness effect, btw, seems to be what causes Spells to Fail. (.. deafness could be removed from the script, 'cause it's only a blindfold.)


But working around the creatures-not-appearing at all thing, is gonna be troublesome. In fact, Blindness is in my opinion kinda borked in Nwn2. My PC can't attack physically and can cast spells only on himself; so, what's feat Blindfight (and potions of Blindfight, iirc) for ...

i even granted my character Blindfight in the hope it might change something. nopt



you might have to re-think things, Arianna - apply MissChance instead of Blindness, for example

  • up
    50%
  • down
    50%