Skip to content

Tell me why this script is not firing?

Just want to do an evil check on the PC when he uses the altar...
string sSound;

void main()
{

  object oPC = GetLastUsedBy();
    if (GetIsPC(oPC))
        {
        return;
        }

        int nGetAlign = GetAlignmentGoodEvil(oPC);

        if (nGetAlign == ALIGNMENT_EVIL)
        {
        effect eUnholy = EffectVisualEffect(VFX_FNF_LOS_EVIL_10);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eUnholy, oPC);

        effect eVFX = EffectVisualEffect(VFX_IMP_HEAD_EVIL);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oPC);

        sSound = "gui_learnspell";
        AssignCommand(oPC, PlaySound(sSound));

        AssignCommand(oPC, ActionSpeakString("You are not penitent!"));


        ActionLockObject(OBJECT_SELF);
    }
    else
    {

      effect eHoly = EffectVisualEffect(VFX_IMP_HOLY_AID);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eHoly, oPC);

    }
  }



I get nothing with this, not sure what's going on?

Comments

  • DazDaz Member Posts: 125
    You check if the user is a PC, and if so, you return and basically end the script.

    You want:
    if (!GetIsPC(oPC))
    
    or
    if (GetIsPC(oPC) == FALSE)
    
  • ZephiriusZephirius Member Posts: 411
    Hey thanks Daz...
    Now I just can't figure out why the altar wont unlock?
    string sSound;
    
    #include "x3_inc_string"
    void main()
    {
    
      ActionLockObject(OBJECT_SELF);
    
      object oPC = GetLastUsedBy();
        if (GetIsPC(oPC))
            {
    
            int nGetAlign = GetAlignmentGoodEvil(oPC);
    
            if (nGetAlign == ALIGNMENT_EVIL)
            {
            AssignCommand(oPC, ActionLockObject(OBJECT_SELF));
    
            effect eUnholy = EffectVisualEffect(VFX_FNF_LOS_EVIL_10);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eUnholy, oPC);
    
            effect eVFX = EffectVisualEffect(VFX_IMP_HEAD_EVIL);
            DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oPC));
    
            sSound = "gui_learnspell";
            AssignCommand(oPC, PlaySound(sSound));
    
            string sChat = "You are not penitent!";
            string sString = StringToRGBString(sChat, "770");
            ActionSpeakString(sString);
    
            }
    
        else
        {
    
          AssignCommand(oPC, ClearAllActions(TRUE));
          AssignCommand(oPC, SetCommandable(TRUE, oPC));
    
          AssignCommand(oPC, SetLockUnlockDC(OBJECT_SELF, 0));
          DelayCommand(0.3, AssignCommand(oPC, ActionUnlockObject(OBJECT_SELF)));
    
          effect eHoly = EffectVisualEffect(VFX_IMP_HOLY_AID);
          DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eHoly, oPC));
    
    
          string sChat = "You are penitent and worthy to pass...!";
          string sString = StringToRGBString(sChat, "770");
          ActionSpeakString(sString);
    
         }
       }
    }
    
    
    

    ... it's in the else part of the script where I can't get it to unlock?
    I threw in a bunch of commands that are probable useless, but I'm trying anything... Lol
  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited September 2021
    Try this -
    #include "x3_inc_string"
    
    const string csUnHoly = StringToRGBString("You are not penitent!", "770");
    const string csHoly = StringToRGBString("You are penitent and worthy to pass...!", "770");
    
    void main()
    {
        object oPC = GetLastUsedBy();
        string sSound;
        
        if(GetIsPC(oPC))
        {
            int nGetAlign = GetAlignmentGoodEvil(oPC);
    
            if(nGetAlign == ALIGNMENT_EVIL)
            {
                SetLocked(OBJECT_SELF, TRUE);
    
                effect eUnholy = EffectVisualEffect(VFX_FNF_LOS_EVIL_10);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eUnholy, oPC);
    
                effect eVFX = EffectVisualEffect(VFX_IMP_HEAD_EVIL);
                DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oPC));
    
                sSound = "gui_learnspell";
    
                PlaySound(sSound);
                AssignCommand(OBJECT_SELF, SpeakString(csUnHoly));
            }
            else
            {
                SetLocked(OBJECT_SELF, FALSE);
    
                effect eHoly = EffectVisualEffect(VFX_IMP_HOLY_AID);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eHoly, oPC);
    
                AssignCommand(OBJECT_SELF, SpeakString(csHoly));
            }
        }
    }
    

    Relying on oPC to actually do the unlocking is quite probably the reason why it fails to unlock because ActionUnlockObject() and ActionLockObject() represents the oPC's use of the 'Open Locks' skill which they may have too few points in. In this case I'm suggesting you try the SetLocked() function instead.

    TR
  • ZephiriusZephirius Member Posts: 411
    Thanks I'll give this a try
  • TarotRedhandTarotRedhand Member Posts: 1,481
    From what I've been reading elsewhere, it is possible that the above script might not work. If that is the case, the recommended thing to do is to use AssignCommand(OBJECT_SELF, SetLocked(OBJECT_SELF, TRUE)); instead.

    TR
Sign In or Register to comment.