Aller au contenu

Photo

aboveground check, help


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Surek

Surek
  • Members
  • 94 messages
I was hoping I could get some help with this script. I'm trying to get this to work only if the PC is an outdoor area but I can't figure out what i'm doing wrong. Any help would be great on this.
/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625    */

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

//if (GetSubRace(oPC)!="Rune Caster")
//SendMessageToPC(oPC, "You lack the skill to use this item!");
//   return;

object oTarget;
oTarget = GetItemActivatedTarget();


int nInt;
nInt = GetObjectType(oTarget);



if(GetIsAreaAboveGround(GetArea(oPC)))
{


ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(74), oTarget);


AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(d10() ,DAMAGE_TYPE_ELECTRICAL), oTarget));
}
else
SendMessageToPC(oPC, "This rune can only be used outdoors!");

}


#2
Tarot Redhand

Tarot Redhand
  • Members
  • 2 688 messages

Try using either version of the lexicon.

 

This following code is untested but should work.

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


    if(!(GetIsPC(oPC))) //error check 1
        return;


    //if (GetSubRace(oPC)!="Rune Caster")
    //SendMessageToPC(oPC, "You lack the skill to use this item!");
    //   return;


    object oPCsArea = GetArea(oPC);


    if(oPCsArea == OBJECT_INVALID)// error check 2
        return;


    effect eZap;
    effect;
    effect;
    object oTarget = GetItemActivatedTarget();
    int nInt = GetObjectType(oTarget); //unused variable - why?


    if(!(GetIsAreaInterior(oPCsArea)) && GetIsAreaAboveGround(oPCsArea))
    {
        eZap = EffectVisualEffect(VFX_IMP_LIGHTNING_M), oTarget); //Always use the constant never the value
        eOuch = EffectDamage(d10() ,DAMAGE_TYPE_ELECTRICAL);
        eLinked = EffectLinkEffects(eZap, eOuch);                 //stops visual effect if oPC immune electrical damage 


        ApplyEffectToObject(DURATION_TYPE_INSTANT, eLinked, oPC);
    }
    else
        SendMessageToPC(oPC, "This rune can only be used outdoors!");
}

TR



#3
Surek

Surek
  • Members
  • 94 messages

If any ones interested here is the final script I'm using , It works exactly the way I wanted it to.  Enjoy.

 

 

/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...=4683&id=625   */

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

 

object oTarget;
oTarget = GetItemActivatedTarget();

object Area = GetArea(oPC);

if(!(GetIsAreaInterior(Area)))
{

ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(74), oTarget);

AssignCommand(oPC,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(d10() ,DAMAGE_TYPE_ELECTRICAL), oTarget));
    }
    else
        SendMessageToPC(oPC, "This rune can only be used outdoors!");
}

 

 



#4
Tarot Redhand

Tarot Redhand
  • Members
  • 2 688 messages

Why ask for help and then ignore it? In fact to not even acknowledge its existence. I know who I will ignore in the future.

 

TR



#5
WhiZard

WhiZard
  • Members
  • 1 204 messages

TR, the OP did use your advice.  He changed the check from above ground to interior.

 

That said there is an oddity here:

 

If this is a tag based script then the script could fire from equipping/unequipping so you probably should check how this script fired (see GetUserDefinedItemEventNumber() in x2_inc_switches).  If this is from the Module's ActivateItem script, then are you using other items that activate to do different things?



#6
Surek

Surek
  • Members
  • 94 messages

Tarot Redhand I apologize to you if you think I ignored your help, I did not in fact I studied and tried your script several different ways. I learned a lot from it, thank you very much, I did not mean to offend you and for this I'm sorry.

 

I am using tag based scripting in my module for this item. As far as the equipping/unequipping  event handler for the module those are blank I have left those event handlers empty with no scripts running in them. I have many, many scripts running with tagbased scripting done this way and no problems so far that I can see.



#7
WhiZard

WhiZard
  • Members
  • 1 204 messages

Well if you disable many of the tag-based events then you do not need to check for them.