Author Topic: Arcane Lock  (Read 351 times)

Legacy_WhenTheNightComes

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +0/-0
Arcane Lock
« on: February 18, 2013, 05:17:14 pm »


               I have this script here..
void main()
{
GetLastSpellCaster();
GetLastSpell();

if(GetLastSpell() == SPELL_GREATER_DISPELLING)
    {

    DeleteLocalInt(OBJECT_SELF,"Arcane_Lock");
    SetLocked(OBJECT_SELF, FALSE);
    ActionOpenDoor(OBJECT_SELF);
    SetLockKeyRequired(OBJECT_SELF, FALSE);


    }
    if(GetLastSpell() == SPELL_MORDENKAINENS_DISJUNCTION)
    {

    DeleteLocalInt(OBJECT_SELF,"Arcane_Lock");
    SetLocked(OBJECT_SELF, FALSE);
    ActionOpenDoor(OBJECT_SELF);
    SetLockKeyRequired(OBJECT_SELF, FALSE);


    }
}

Now, how do I make it so it will only go if the variable Arcane_Lock is on it, and set to 5?
               
               

               
            

Legacy_Ribouldingue

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Arcane Lock
« Reply #1 on: February 18, 2013, 05:46:42 pm »


               I'll maybe say something wrong but whatever I'll try...

What if you make a variable check in the very beginning of your script, then an if Arcane_Lock == 5, the rest of your script, and a return on the else after it?
               
               

               
            

Legacy_WhenTheNightComes

  • Jr. Member
  • **
  • Posts: 53
  • Karma: +0/-0
Arcane Lock
« Reply #2 on: February 18, 2013, 06:55:05 pm »


               Okay, new script... It seems not to be unlocking and opening the door, though.

#include "nw_i0_spells"
void main()
{
GetLastSpellCaster();
GetLastSpell();
object oPC = OBJECT_SELF;
if ( GetLocalInt(oPC, "Arcane_Lock") == 5 )
   {
   }
else if(GetLastSpell() == SPELL_GREATER_DISPELLING)
   {

   DeleteLocalInt(OBJECT_SELF,"Arcane_Lock");
   SetLocked(OBJECT_SELF, FALSE);
   ActionOpenDoor(OBJECT_SELF);
   SetLockKeyRequired(OBJECT_SELF, FALSE);
   RemoveSpecificEffect(EFFECT_TYPE_VISUALEFFECT, OBJECT_SELF);

   return;
   }
else if(GetLastSpell() == SPELL_MORDENKAINENS_DISJUNCTION)
   {

   DeleteLocalInt(OBJECT_SELF,"Arcane_Lock");
   SetLocked(OBJECT_SELF, FALSE);
   ActionOpenDoor(OBJECT_SELF);
   SetLockKeyRequired(OBJECT_SELF, FALSE);
   RemoveSpecificEffect(EFFECT_TYPE_VISUALEFFECT, OBJECT_SELF);

   return;
   }
}
               
               

               
            

Legacy_Ribouldingue

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Arcane Lock
« Reply #3 on: February 18, 2013, 09:28:46 pm »


               Something looks strange with your brackets. I think you've got nothing under the condition Arcane_Lock = 5 because the following brackets are just empty.

By the way I'm not sure we can have multiple if statements in a single script, I've read something like that somewhere... and well I'm a newbie so forgive me if I say anything... just trying to help...
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Arcane Lock
« Reply #4 on: February 19, 2013, 02:17:42 am »


               If I understand what you want it to do correctly:
Take out the  } and the else right before the line with the SPELL_GREATER_DISPELLING conditional. and add another one at the end of the script.  That will put the 2 GetLastSpell() checks
inside the condition for Arcane_lock == 5 so that only if that is true and one of the two spells is cast will the lock open.

Also, you're looking for the Arcane_Lock variable on the PC not the door.

For most practical purposes you can have as many if statements as you need in a script.

Cheers,
Meaglyn
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Arcane Lock
« Reply #5 on: February 19, 2013, 02:41:22 am »


                
#include "nw_i0_spells"
void main()
{
  int nSpellIndex = GetLastSpell();
  //   object oPC = OBJECT_SELF;  // If you are running this from a door event OBJECT_SELF would be the door.
  if ( GetLocalInt(oPC, "Arcane_Lock") == 5&&(nSpellIndex  == SPELL_GREATER_DISPELLING ||   nSpellIndex == SPELL_MORDENKAINENS_DISJUNCTION )  )
  {
     DeleteLocalInt(OBJECT_SELF,"Arcane_Lock");
    SetLocked(OBJECT_SELF, FALSE);
    ActionOpenDoor(OBJECT_SELF);
    SetLockKeyRequired(OBJECT_SELF, FALSE);
    RemoveSpecificEffect(EFFECT_TYPE_VISUALEFFECT, OBJECT_SELF);

  }
}
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Arcane Lock
« Reply #6 on: February 19, 2013, 06:38:50 pm »


               Good point LF. I didn't notice the line where he was setting oPC to object self.  
However, if you comment that out then the check for Arcane_lock == 5 is again on the wrong
object ...