Author Topic: aboveground check, help  (Read 466 times)

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
aboveground check, help
« on: June 04, 2015, 07:11:37 am »


               

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!");

}


               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
aboveground check, help
« Reply #1 on: June 04, 2015, 09:58:10 am »


               

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



               
               

               
            

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
aboveground check, help
« Reply #2 on: June 05, 2015, 04:50:48 am »


               

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!");

}


 


 



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
aboveground check, help
« Reply #3 on: June 06, 2015, 07:26:19 pm »


               

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



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
aboveground check, help
« Reply #4 on: June 06, 2015, 11:13:15 pm »


               

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?



               
               

               
            

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
aboveground check, help
« Reply #5 on: June 07, 2015, 08:13:59 am »


               

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.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
aboveground check, help
« Reply #6 on: June 08, 2015, 04:02:11 pm »


               

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