Aller au contenu

Photo

Arcane Lock


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

#1
WhenTheNightComes

WhenTheNightComes
  • Members
  • 27 messages
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?

#2
Ribouldingue

Ribouldingue
  • Members
  • 27 messages
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?

#3
WhenTheNightComes

WhenTheNightComes
  • Members
  • 27 messages
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;
}
}

#4
Ribouldingue

Ribouldingue
  • Members
  • 27 messages
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...

#5
meaglyn

meaglyn
  • Members
  • 817 messages
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

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
 
#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);

  }
}

#7
meaglyn

meaglyn
  • Members
  • 817 messages
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 ...