Author Topic: EOB 2 Script, need help!  (Read 405 times)

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« on: June 19, 2013, 05:02:42 pm »


               Hey all,

I’ve been working on the Eye of the Beholder 2 project for a while now, and the mod is jsut about completed.

I’ve run into a problem with this script and I’m unable to figure out why it keeps failing. I was hoping someone here could look this over and fix it up so it works.

This is what it’s supposed to do.

You have all four horns; they have the Unique Spell cast on them so they can be used.

The first part of the script works fine, I get the message and the sound of the Horn being used and the pop up text.

I then also hear the sound being used for the Howl of the horn.

But I do not get the message “A hollow sound comes from the horn”.

It’s then supposed to go to the OpenWall section and check the variable. That it not happening from what I can see.

I cannot get the wall to disappear after all four horns have been used.

Would someone please take a look at this and fix it up for me? Its driving me crazy trying to get this working.

Thanks all, Appreciate any help I can get.

Here is the script.


#include "debug"
#include "nw_i0_tool"
void BlowHorn(string sHorn, string sMessage2);
void OpenWall();
object oActivatedItem = GetItemActivated();
object oPlayer  = GetItemActivated();
void main()
{
    ExecuteScript("eb_recall_oa", OBJECT_SELF);
    if (GetTag(oActivatedItem) == "CreateFoodItem")
    {

        object oUser = GetItemActivator();
        object oTarget = GetItemActivatedTarget();
        location oLocation = GetItemActivatedTargetLocation();
        effect eVis = EffectVisualEffect(VFX_IMP_HEAD_HEAL);
        CreateItemOnObject("food001", oTarget);
        CreateItemOnObject("food001", oTarget);
        CreateItemOnObject("food001", oTarget);
        CreateItemOnObject("food001", oTarget);
        SendMessageToPC (oTarget, "Food Created");
        AssignCommand(oTarget,PlaySound("sca_outholy01"));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    }
    if(GetTag(oActivatedItem) == "NorthWind")
    {
        //debug("NorthWind");
        object oTarget = GetItemActivatedTarget();
        string sMessage = "You feel a cold draft from the north.";
        AssignCommand(oTarget,PlaySound("as_wt_gustsoft1"));
        BlowHorn(GetTag(oActivatedItem), sMessage);
        OpenWall();
    }
    if(GetTag(oActivatedItem) == "SouthWind")
    {
        //debug("SouthWind");
        object oTarget = GetItemActivatedTarget();
        string sMessage = "You feel a warm  breeze from the south.";
        AssignCommand(oTarget,PlaySound("as_wt_gusforst1"));
        BlowHorn(GetTag(oActivatedItem), sMessage);
        OpenWall();
    }
    if(GetTag(oActivatedItem) == "EastWind")
    {
        //debug("EastWind");
        object oTarget = GetItemActivatedTarget();
        string sMessage = "You feel a slight breeze from the east.";
        AssignCommand(oTarget,PlaySound("as_wt_gustgrass1"));
        BlowHorn(GetTag(oActivatedItem), sMessage);
        OpenWall();
    }
    if(GetTag(oActivatedItem) == "WestWind")
    {
        //debug("WestWind");
        object oTarget = GetItemActivatedTarget();
        string sMessage = "You feel a gust of wind from the west.";
        AssignCommand(oTarget,PlaySound("as_wt_gustchasm1"));
        BlowHorn(GetTag(oActivatedItem), sMessage);
        OpenWall();
    }
}
void OpenWall()
{
    //object oWindWallWP = GetWaypointByTag("WP_FourWindWall");
    debug("OpenWall");
    object oPlayer = GetLastUsedBy();
    if(GetLocalInt(oPlayer, "NorthWind") && GetLocalInt(oPlayer, "SouthWind") &&
        GetLocalInt(oPlayer, "EastWind") && GetLocalInt(oPlayer, "WestWind"))
    {
        SetLocalInt(oPlayer, "WallIsOpen", 1);
        //SetLocalInt(oPlayer(), sHorn, 1);
            object UnlockedSound = GetNearestObjectByTag("WindRmvSnd");
            object oObject1 = GetNearestObjectByTag("WindSeal1");
            object oObject2 = GetNearestObjectByTag("WindSeal2");
            object oObject3 = GetNearestObjectByTag("WindSeal3");
            object oObject4 = GetNearestObjectByTag("WindSeal4");
            object oObject5 = GetNearestObjectByTag("SealoftheFourWinds");
            DestroyObject(oObject1, 0.0 );
            DestroyObject(oObject2, 0.1 );
            DestroyObject(oObject3, 0.2 );
            DestroyObject(oObject4, 0.3 );
            DestroyObject(oObject5, 0.5 );
            SoundObjectPlay(UnlockedSound);
            PlaySound("as_dr_stonvlgcl1");
            FloatingTextStringOnCreature("The wall of the four winds has been removed.", oPlayer, FALSE);
            AddJournalQuestEntry("TheFourHorns", 5, oPlayer);
            RewardPartyXP(750, oPlayer, TRUE);
            //DelayCommand(0.5, DestroyObject(OBJECT_SELF));
            ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SCREEN_SHAKE), OBJECT_SELF);
            DestroyObject(UnlockedSound, 4.0 );
    }
}
void BlowHorn(string sHorn, string sMessage2)
{
    //debug("BlowHorn");
    object oPC = GetItemActivator();
    object oWindWallWP = GetWaypointByTag("WP_FourWindWall");
    float fDistance = GetDistanceBetweenLocations(GetLocation(oPC), GetLocation(oWindWallWP));
    if(fDistance < 5.0)
    {
        //debug("Distance = " + FloatToString(fDistance));
        string sMessage1 = "A hollow sound comes from the horn.";
        SetLocalInt(oPlayer, GetTag(oActivatedItem), 1);
        SetLocalInt(GetLastUsedBy(), sHorn, 1);
        // Insert Sound Effect here
        // sff_howlmind
        AssignCommand(GetItemActivator(), PlaySound("sff_howlmind"));
        AssignCommand(GetItemActivator(), ActionSpeakString(sMessage1));
        AssignCommand(GetItemActivator(), ActionSpeakString(sMessage2));
        //DelayCommand(60.0, SetLocalInt(oWindWallWP, GetTag(oActivatedItem), 0));
    }
}
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #1 on: June 19, 2013, 09:05:04 pm »


               The problem with OpenWall() is that you're using wrong function to get the PC. You used GetLastUsedBy() when it should be GetItemActivator().

The problem with BlowHorn() is trickier. I suspect that the script is working correctly, but the second message gets spoken so soon after the first message that you don't get to see it on screen. Look in the chat window to see if it shows up there. If that's correct, try DelayCommand-ing the second SpeakString() or changing it to a FloatingTextStringOnCreature().

I cleaned this up a bit if you wanna try to use my edits. Not at a computer with the toolset right now, so I can't confirm whether it works, but it's a step in the right direction.

#include "debug"
#include "nw_i0_tool"

void BlowHorn(string sHorn, string sMessage, object oPC);
void OpenWall(object oPC);

void main()
{
    object oPC     = GetItemActivator();
    object oItem   = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    string sTag    = GetTag(oItem);
   
    ExecuteScript("eb_recall_oa", OBJECT_SELF);

    if (sTag == "CreateFoodItem")
    {
        CreateItemOnObject("food001", oTarget);
        CreateItemOnObject("food001", oTarget);
        CreateItemOnObject("food001", oTarget);
        CreateItemOnObject("food001", oTarget);
        SendMessageToPC(oPC, "Food Created");
        AssignCommand(oTarget, PlaySound("sca_outholy01"));
        effect eVis = EffectVisualEffect(VFX_IMP_HEAD_HEAL);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    }
    else if (sTag == "NorthWind")
    {
        //debug("NorthWind");
        AssignCommand(oTarget, PlaySound("as_wt_gustsoft1"));
        BlowHorn(sTag, "You feel a cold draft from the north.", oPC);
        OpenWall(oPC);
    }
    else if (sTag == "SouthWind")
    {
        //debug("SouthWind");
        AssignCommand(oTarget, PlaySound("as_wt_gusforst1"));
        BlowHorn(sTag, "You feel a warm  breeze from the south.", oPC);
        OpenWall(oPC);
    }
    else if (sTag == "EastWind")
    {
        //debug("EastWind");
        AssignCommand(oTarget, PlaySound("as_wt_gustgrass1"));
        BlowHorn(sTag, "You feel a slight breeze from the east.", oPC);
        OpenWall(oPC);
    }
    else if (sTag == "WestWind")
    {
        //debug("WestWind");
        AssignCommand(oTarget, PlaySound("as_wt_gustchasm1"));
        BlowHorn(sTag, "You feel a gust of wind from the west.", oPC);
        OpenWall(oPC);
    }
}

void OpenWall(object oPC)
{
    //object oWindWallWP = GetWaypointByTag("WP_FourWindWall");
    debug("OpenWall");
    if (GetLocalInt(oPC, "NorthWind") && GetLocalInt(oPC, "SouthWind") &&
        GetLocalInt(oPC, "EastWind")  && GetLocalInt(oPC, "WestWind"))
    {
        SetLocalInt(oPC, "WallIsOpen", 1);
        //SetLocalInt(oPC(), sHorn, 1);
        object UnlockedSound = GetNearestObjectByTag("WindRmvSnd");
        object oObject1 = GetNearestObjectByTag("WindSeal1");
        object oObject2 = GetNearestObjectByTag("WindSeal2");
        object oObject3 = GetNearestObjectByTag("WindSeal3");
        object oObject4 = GetNearestObjectByTag("WindSeal4");
        object oObject5 = GetNearestObjectByTag("SealoftheFourWinds");
        DestroyObject(oObject1, 0.0);
        DestroyObject(oObject2, 0.1);
        DestroyObject(oObject3, 0.2);
        DestroyObject(oObject4, 0.3);
        DestroyObject(oObject5, 0.5);
        SoundObjectPlay(UnlockedSound);
        PlaySound("as_dr_stonvlgcl1");
        FloatingTextStringOnCreature("The wall of the four winds has been removed.", oPC, FALSE);
        AddJournalQuestEntry("TheFourHorns", 5, oPC);
        RewardPartyXP(750, oPC, TRUE);
        //DelayCommand(0.5, DestroyObject(OBJECT_SELF));
        effect eVis = EffectVisualEffect(VFX_FNF_SCREEN_SHAKE);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
        DestroyObject(UnlockedSound, 4.0);
    }
}

void BlowHorn(string sHorn, string sMessage, object oPC)
{
    //debug("BlowHorn");
    object oWindWallWP = GetWaypointByTag("WP_FourWindWall");
    float fDistance = GetDistanceBetweenLocations(GetLocation(oPC), GetLocation(oWindWallWP));
    if (fDistance < 5.0)
    {
        //debug("Distance = " + FloatToString(fDistance));
        SetLocalInt(oPC, sHorn, 1);

        // Insert Sound Effect here
        // sff_howlmind
        AssignCommand(oPC, PlaySound("sff_howlmind"));
        FloatingTextStringOnCreature("A hollow sound comes from the horn.", oPC, FALSE);
        FloatingTextStringOnCreature(sMessage, oPC, FALSE);
        //DelayCommand(60.0, SetLocalInt(oWindWallWP, sHorn, 0));
    }
}

               
               

               


                     Modifié par Squatting Monk, 20 juin 2013 - 07:44 .
                     
                  


            

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #2 on: June 19, 2013, 09:18:12 pm »


               Thank you Monk, ill give this a try.  I apprecite your help.  Thank you!!!
               
               

               
            

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #3 on: June 19, 2013, 10:38:40 pm »


               Squatting Monk, I just tested it out and Its now working, but there is one thing that's weird, I had to blow / use the horns 5 times in order to get it to work. Why would a fifth usage be needed? I cant see anything In the script that would cause that.  When I say five times I only mean uses them 5 times total not all of them five times.
               
               

               


                     Modifié par Dark, 19 juin 2013 - 09:39 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #4 on: June 20, 2013, 01:18:56 pm »


               Monk's code won't compile as is due to the oPlayer in BlowHorn. Did you use his code exactly and fix that or did you merge it into your original? Your original has oPlayer defined as the activated item in the script wide scope. Something may have gotten mixed up in the merge if you went that route. What does your version of blowhorn look like now?
               
               

               
            

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #5 on: June 20, 2013, 02:04:30 pm »


               meaglyn, you are correct on that part, and I did catch that and change it to oPC. And it compiled. the issue I’m having though is that you have to use the horns 5 times instead of the four times it supposed to be used.

Anyone seeing anything that might be causing it to need 5 uses?
               
               

               


                     Modifié par Dark, 20 juin 2013 - 01:05 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #6 on: June 20, 2013, 02:46:16 pm »


               Yes, I understand that. Not having the variable written to the right object would be one way to make it not behave correctly so I was poking at that.  So your version of blowhorn is exactly what monk posted with that one oPlayer to oPC change?  None of the delaycommands are uncommented?

The code looks like it should work. Do you see the blowhorn message all 5 times? Does it matter which horn you use the 5th time?

Put a debug in OpenWall before the if that prints the value of all 4 of those variables. That should tell you something...
               
               

               
            

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #7 on: June 20, 2013, 04:24:45 pm »


               I don’t see the message the 5th time, I see it four times only. And it does not matter which horn is used on the fifth use. On the fifth use, I get the Quest completed and the XP given to the player. I added those delay commands to my final version which does make both text messages show up now. As I said, the only issue is you have to use the horns five times now.


As for that commented line for the delay command destroy Object Self. That can’t be used in this variation of the script. This script was modified from an OnDisturbd when I was using it to just place the items in the Seal to remove the wall once the fourth horn was placed inside. Ignore that line please.
               
               

               


                     Modifié par Dark, 20 juin 2013 - 03:29 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #8 on: June 20, 2013, 04:53:31 pm »


               "As I said, the only issue is you have to use the horns five times now."

Yes, you keep saying that as if I'm not hearing you.  The questions I asked were directly related to trying to help you debug that very problem.

Do you see the "OpenWall" debug output all 5 times?
               
               

               
            

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #9 on: June 20, 2013, 05:17:16 pm »


               meaglyn,  I won’t be able to test this until later today when I get home.  At work now, sorry if I seemed to be repeating myself.  

Looking over the mod, I’m wondering if the delay commands on the pop up text may also be causing this issue too?  

Thank you for your help, I appreciate your feedback.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #10 on: June 20, 2013, 06:22:07 pm »


               You shouldn't need the delays if using the floatingtextstring calls I think.

Can you post your exact code when you get back to the toolset?
               
               

               
            

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #11 on: June 20, 2013, 07:26:40 pm »


               Sure thing, here you go.  I’m remoted home so I can grab that for you now.

And the only thing adding the delays did was allow the second pop up text to appear.  I’m most likely going to remove that line.  This script works, but it’s not exactly how it should work in terms of the player when the find the horn and use it. They get the wind sound and the text popping up.  That should only occur when you are in range of the wall.  Otherwise the sound of the horn should just happen not the wind blowing effect.

Here’s the code.


#include "debug"
#include "nw_i0_tool"

void BlowHorn(string sHorn, string sMessage, object oPC);
void OpenWall(object oPC);

void main()
{
   object oPC     = GetItemActivator();
   object oItem   = GetItemActivated();
   object oTarget = GetItemActivatedTarget();
   string sTag    = GetTag(oItem);

   ExecuteScript("eb_recall_oa", OBJECT_SELF);

   if (sTag == "CreateFoodItem")
   {
       CreateItemOnObject("food001", oTarget);
       CreateItemOnObject("food001", oTarget);
       CreateItemOnObject("food001", oTarget);
       CreateItemOnObject("food001", oTarget);
       SendMessageToPC(oPC, "Food Created");
       AssignCommand(oTarget, PlaySound("sca_outholy01"));
       effect eVis = EffectVisualEffect(VFX_IMP_HEAD_HEAL);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
   }
   else if (sTag == "NorthWind")
   {
       //debug("NorthWind");
       AssignCommand(oTarget, PlaySound("as_wt_gustsoft1"));
       DelayCommand(2.5, BlowHorn(sTag, "You feel a cold draft from the north.", oPC));
       OpenWall(oPC);
   }
   else if (sTag == "SouthWind")
   {
       //debug("SouthWind");
       AssignCommand(oTarget, PlaySound("as_wt_gusforst1"));
       DelayCommand(2.5, BlowHorn(sTag, "You feel a warm breeze from the south.", oPC));
       OpenWall(oPC);
   }
   else if (sTag == "EastWind")
   {
       //debug("EastWind");
       AssignCommand(oTarget, PlaySound("as_wt_gustgrass1"));
       DelayCommand(2.5, BlowHorn(sTag, "You feel a slight breeze from the east.", oPC));
       OpenWall(oPC);
   }
   else if (sTag == "WestWind")
   {
       //debug("WestWind");
       AssignCommand(oTarget, PlaySound("as_wt_gustchasm1"));
       DelayCommand(2.5, BlowHorn(sTag, "You feel a gust of wind from the west.", oPC));
       OpenWall(oPC);
   }
}

void OpenWall(object oPC)
{
   object oWP = GetWaypointByTag("WP_FourWindWall");
   debug("OpenWall");
   if (GetLocalInt(oPC, "NorthWind") && GetLocalInt(oPC, "SouthWind") &&
       GetLocalInt(oPC, "EastWind") && GetLocalInt(oPC, "WestWind"))
   {
       SetLocalInt(oPC, "WallIsOpen", 1);

       object UnlockedSound = GetObjectByTag("WindRmvSnd");
       object oObject1 = GetObjectByTag("WindSeal1");
       object oObject2 = GetObjectByTag("WindSeal2");
       object oObject3 = GetObjectByTag("WindSeal3");
       object oObject4 = GetObjectByTag("WindSeal4");
       object oObject5 = GetObjectByTag("SealoftheFourWinds");
       DestroyObject(oObject1, 0.0);
       DestroyObject(oObject2, 0.1);
       DestroyObject(oObject3, 0.2);
       DestroyObject(oObject4, 0.3);
       DestroyObject(oObject5, 0.5);
       SoundObjectPlay(UnlockedSound);
       PlaySound("as_dr_stonvlgcl1");
       FloatingTextStringOnCreature("The wall of the four winds has been removed.", oPC, FALSE);
       AddJournalQuestEntry("TheFourHorns", 5, oPC);
       RewardPartyXP(750, oPC, TRUE);

       effect eShake = EffectVisualEffect(356);
       ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eShake, GetLocation(oWP));

       DestroyObject(UnlockedSound, 4.0);
   }
}

void BlowHorn(string sHorn, string sMessage, object oPC)
{
   //debug("BlowHorn");
   object oWindWallWP = GetWaypointByTag("WP_FourWindWall");
   float fDistance = GetDistanceBetweenLocations(GetLocation(oPC), GetLocation(oWindWallWP));
   if(fDistance < 10.0  &&  fDistance >= 0.0)
   //if (fDistance < 10.0)
   {
       //debug("Distance = " + FloatToString(fDistance));
       SetLocalInt(oPC, sHorn, 1);

       // Insert Sound Effect here
       // sff_howlmind
       AssignCommand(oPC, PlaySound("sff_howlmind"));
       DelayCommand(0.0, FloatingTextStringOnCreature("A hollow sound comes from the horn.", oPC, FALSE));
       FloatingTextStringOnCreature(sMessage, oPC, FALSE);
       //DelayCommand(60.0, SetLocalInt(oWindWallWP, sHorn, 0));
   }
}
               
               

               
            

Legacy_Dark

  • Full Member
  • ***
  • Posts: 123
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #12 on: June 20, 2013, 08:14:54 pm »


               meaglyn,  I just ran a test and its working.  After removing the delay commands. And removing the pop text from below this one: A hollow sound comes from the horn

I only needed to use the horns four times.   I would like to keep that last line of pop up text in there, but I may not be able too since its apparently causing issues with it firing off correctly.

Any suggestions?
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #13 on: June 20, 2013, 08:55:10 pm »


               

meaglyn wrote...

Monk's code won't compile as is due to the oPlayer in BlowHorn.

D'oh! Hazard of scripting in a text editor at work. Fixed now.

Dark wrote...
DelayCommand(2.5, BlowHorn(sTag, "You feel a cold draft from the north.", oPC));
OpenWall(oPC);

Yeah, that's your problem there: OpenWall() checks for ints that were set by BlowHorn(). This is effectively running OpenWall() before BlowHorn(). If you wanna delay something, delay the OpenWall() call:

BlowHorn(sTag, "You feel a cold draft from the north.", oPC);
DelayCommand(2.5, OpenWall(oPC));

Dark wrote...

And removing the pop text from below this one: A hollow sound comes from the horn

I only needed to use the horns four times. I would like to keep that last line of pop up text in there, but I may not be able too since its apparently causing issues with it firing off correctly.

That shouldn't have anything do do with it. But just to ensure your messages are spaced out enough to see, try setting those two lines like this:

FloatingTextStringOnCreature("A hollow sound comes from the horn.", oPC, FALSE);
DelayCommand(1.0, FloatingTextStringOnCreature(sMessage, oPC, FALSE));

               
               

               


                     Modifié par Squatting Monk, 20 juin 2013 - 08:16 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
EOB 2 Script, need help!
« Reply #14 on: June 20, 2013, 09:19:29 pm »


               

Squatting Monk wrote...

Dark wrote...
DelayCommand(2.5, BlowHorn(sTag, "You feel a cold draft from the north.", oPC));
OpenWall(oPC);

Yeah, that's your problem there: OpenWall() checks for ints that were set by BlowHorn(). This is effectively running OpenWall() before BlowHorn(). If you wanna delay something, delay the OpenWall() call.


I was suspecting something like that was going on. You beat me to the punch '<img'>