Author Topic: help finishing a puzzle script please.  (Read 917 times)

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« on: December 12, 2010, 08:31:53 am »


               got a puzzle script here that dosn't quite work how it should, not even sure if it can work to be honest. the original scripter dropped off the face of the planet and i have no way to contact them to finish it... so after 3 months of waiting, it's up for the public to help me, if you can... it would be greatly appreciated.

the current problem is that the rune plates spawn below the floor a bit making them look as if they are colors other than what they should be. this might also be the reason the plates aren't useable as well, or that could be a whole new problem.

// puzzle OnEnter script
// place this on the OnEnter event of the area or on a trigger
// by: Yukiakari, 2010

int RandomColour()
    {
    int nInt = d4();
    int nColour;
    switch(nInt)
        {
        case 1: nColour = VFX_DUR_GLOW_BLUE;
                break;
        case 2: nColour = VFX_DUR_GLOW_RED;
                break;
        case 3: nColour = VFX_DUR_GLOW_YELLOW;
                break;
        case 4: nColour = VFX_DUR_GLOW_GREEN;
        }
    return nColour;
    SendMessageToPC(GetFirstPC(), "Colour: " + IntToString(nColour));
    }

void main()
{
object oPC = GetEnteringObject();
if(!GetIsPC(oPC)) return;
string s1 = "rune_switch"; // enter the ResRef HERE!!!
object oWP = GetFirstObjectInArea();
string sTag;
string sWP;
while(GetIsObjectValid(oWP))
    {
    sWP = GetTag(oWP);
        // debug
        //SendMessageToPC(GetFirstPC(), "WP Tag: " + sWP);
    string sSub1 = GetSubString(sWP, 0,3);
        // debug
        //SendMessageToPC(GetFirstPC(), "SubString 1: " + sSub1);
    string sSub2 = GetSubString(sWP, 3,2);
        // debug
        //SendMessageToPC(GetFirstPC(), "SubString 2: " + sSub2);
    if(sSub1 == "WP_")
        {
        sTag = "PP_" + sSub2;
        object oRune = CreateObject(OBJECT_TYPE_PLACEABLE, s1, GetLocation(oWP), FALSE, sTag);
        int nColour = RandomColour();
        DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(nColour), oRune, 0.0));
        SetLocalInt(oRune, "COLOUR", nColour);
        // debug
        //SendMessageToPC(GetFirstPC(), "Colour: " + IntToString(nColour));
        //SendMessageToPC(GetFirstPC(), "COLOUR: " + IntToString(GetLocalInt(oRune, "COLOUR")));
        //DestroyObject(oWP, 0.0);
        oWP = GetNextObjectInArea();
        }
   oWP = GetNextObjectInArea();
    }
}

this is the OnUsed script thats attached to the rune plates

// script that checks, if the puzzle has been solved and locks the colours
// OnUsed script for a lever
// by: Yukiakari, 2010

void main()
{
/*
Block
A: line <=4, row <=4 blueBlock
B: line <=4, row >=5 yellowBlock
C: line >=5, row <=4 greenBlock
D: line >=5, row >=5 red
*/
   object oObject = GetFirstObjectInArea();
   string sLine;
   int nLine;
   string sRow;
   int nRow;
   int nColour;
   int nBlue = 0;
   int nYellow = 0;
   int nGreen = 0;
   int nRed = 0;
   int nSpell = SPELL_LIGHTNING_BOLT;
// WAYPOINT for the location (and facing) of the chest
   object oWaypoint = GetObjectByTag ("SP_chest");
   location lLocation = GetLocation (oWaypoint);
   object oStatue;
   while(GetIsObjectValid(oObject))
      {
      sLine = GetSubString(GetTag(oObject), 3,1);
      nLine = StringToInt(sLine);
      sRow = GetSubString(GetTag(oObject), 3,1);
      nRow = StringToInt(sRow);
      nColour = GetLocalInt(oObject, "COLOUR");
// BLUE
      if((nLine <= 4) && (nRow <=4) && (nColour == VFX_DUR_GLOW_BLUE))
         {
         nBlue++;
         oObject = GetNextObjectInArea();
         }
// YELLOW
      if((nLine <= 4) && (nRow >=5) && (nColour == VFX_DUR_GLOW_YELLOW))
         {
         nYellow++;
         oObject = GetNextObjectInArea();
         }
// GREEN
      if( (nLine >=5) && (nRow <=4) && (nColour == VFX_DUR_GLOW_GREEN) )
         {
         nGreen++;
         oObject = GetNextObjectInArea();
         }
// RED
      if((nLine >=5) || (nRow >=5) || (nColour == VFX_DUR_GLOW_RED))
         {
         nRed++;
         oObject = GetNextObjectInArea();
         }
      oObject = GetNextObjectInArea();
      }
//**************************************
// Lock the placeables
// BLUE
   if(nBlue == 16)
      {
      oStatue = GetObjectByTag("ap_puzz_statue_b");
      while(GetIsObjectValid(oObject))
         {
         if((nLine <= 4) && (nRow <=4) )
            {
            DeleteLocalInt(oObject, "COlOUR");
            AssignCommand(oObject, ActionCastFakeSpellAtObject(nSpell, oStatue, PROJECTILE_PATH_TYPE_DEFAULT));
            SetUseableFlag(oObject, FALSE);
            oObject = GetNextObjectInArea();
            }
         oObject = GetNextObjectInArea();
         }
// statue
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GLOW_BLUE), oStatue, 0.0);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_ELECTRIC_EXPLOSION), oStatue, 0.0);
      int nInt = GetLocalInt(OBJECT_SELF, "PUZZLE");
      SetLocalInt(OBJECT_SELF, "PUZZLE", nInt+1);
      }
   if(nYellow == 16)
      {
      oStatue = GetObjectByTag("ap_puzz_statue_y");
      while(GetIsObjectValid(oObject))
         {
         if((nLine <= 4) && (nRow >=5) )
            {
            DeleteLocalInt(oObject, "COlOUR");
            AssignCommand(oObject, ActionCastFakeSpellAtObject(nSpell, oStatue, PROJECTILE_PATH_TYPE_DEFAULT));
            SetUseableFlag(oObject, FALSE);
            oObject = GetNextObjectInArea();
            }
         oObject = GetNextObjectInArea();
         }
// statue
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GLOW_YELLOW), oStatue, 0.0);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_ELECTRIC_EXPLOSION), oStatue, 0.0);
      int nInt = GetLocalInt(OBJECT_SELF, "PUZZLE");
      SetLocalInt(OBJECT_SELF, "PUZZLE", nInt+1);
      }
   if(nGreen == 16)
      {
      oStatue = GetObjectByTag("ap_puzz_statue_g");
      while(GetIsObjectValid(oObject))
         {
         if((nLine <=5) && (nRow <=4) )
            {
            DeleteLocalInt(oObject, "COlOUR");
            AssignCommand(oObject, ActionCastFakeSpellAtObject(nSpell, oStatue, PROJECTILE_PATH_TYPE_DEFAULT));
            SetUseableFlag(oObject, FALSE);
            oObject = GetNextObjectInArea();
            }
         oObject = GetNextObjectInArea();
         }
// statue
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GLOW_GREEN), oStatue, 0.0);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_ELECTRIC_EXPLOSION), oStatue, 0.0);
      int nInt = GetLocalInt(OBJECT_SELF, "PUZZLE");
      SetLocalInt(OBJECT_SELF, "PUZZLE", nInt+1);
      }
   if(nRed == 16)
      {
      oStatue = GetObjectByTag("ap_puzz_statue_r");
      while(GetIsObjectValid(oObject))
         {
         if((nLine >=5) && (nRow >=5) )
            {
            DeleteLocalInt(oObject, "COlOUR");
            AssignCommand(oObject, ActionCastFakeSpellAtObject(nSpell, oStatue, PROJECTILE_PATH_TYPE_DEFAULT));
            SetUseableFlag(oObject, FALSE);
            oObject = GetNextObjectInArea();
            }
         oObject = GetNextObjectInArea();
         }
// statue
      ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GLOW_RED), oStatue, 0.0);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_ELECTRIC_EXPLOSION), oStatue, 0.0);
      int nInt = GetLocalInt(OBJECT_SELF, "PUZZLE");
      SetLocalInt(OBJECT_SELF, "PUZZLE", nInt+1);
      }
// finale, when all colours are finished
   if(GetLocalInt(OBJECT_SELF, "PUZZLE") == 4)
      {
// make lever unuseable
      SetUseableFlag(OBJECT_SELF, FALSE);
// create chest
      CreateObject(OBJECT_TYPE_PLACEABLE, "ap_puzz_chest", lLocation, FALSE, "");
// destroy statues
      object oStatueBlue = GetObjectByTag("ap_puzz_statue_b");
      object oStatueYellow = GetObjectByTag("ap_puzz_statue_y");
      object oStatueGreen = GetObjectByTag("ap_puzz_statue_g");
      object oStatueRed = GetObjectByTag("ap_puzz_statue_r");
      SetPlotFlag(oStatueBlue, FALSE);
      SetPlotFlag(oStatueYellow, FALSE);
      SetPlotFlag(oStatueGreen, FALSE);
      SetPlotFlag(oStatueRed, FALSE);
      DelayCommand(5.0, ActionCastFakeSpellAtObject(SPELL_MAGIC_MISSILE, oStatueBlue, PROJECTILE_PATH_TYPE_DEFAULT));
      DelayCommand(5.0, ActionCastFakeSpellAtObject(SPELL_MAGIC_MISSILE, oStatueYellow, PROJECTILE_PATH_TYPE_DEFAULT));
      DelayCommand(5.0, ActionCastFakeSpellAtObject(SPELL_MAGIC_MISSILE, oStatueRed, PROJECTILE_PATH_TYPE_DEFAULT));
      DelayCommand(5.0, ActionCastFakeSpellAtObject(SPELL_MAGIC_MISSILE, oStatueGreen, PROJECTILE_PATH_TYPE_DEFAULT));
      DestroyObject(oStatueBlue, 6.0);
      DestroyObject(oStatueYellow, 6.0);
      DestroyObject(oStatueGreen, 6.0);
      DestroyObject(oStatueRed, 6.0);
// VFX, sound, message, etc.....
      }
}


thanks in advance
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #1 on: December 13, 2010, 04:14:38 am »


               Have you tried raising the waypoints manually in the toolset? If you set the z axis of the waypoints higher, then the objects spawned at those locations should also be higher. Fiddle around with the height of those to see if that helps you.

Good luck.
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #2 on: December 13, 2010, 03:34:42 pm »


               actually i did that already, was suggested by the original scripter for another issue before they dissapeared. the last thing they did before being swallowed up by existance was change a line or two in the script, this is what caused the problem i'm having. wish i could be more help, but only other thing i could do is sen a copy of the area to anyone that wants to fiddle with it.
just let me know if anyone wants this.
thanks


EDIT:
before this latest problem, the puzzle did work.... up to a point, it was actually useable, the colors did change, but there was a problem with the order. that was the last thing the scripter was fixing. i appologize for being so vage, but the script was done and has been sitting for about 3-5 months now. finally got caught up on other stuff and need this now.

thanks again.
               
               

               


                     Modifié par zero-feeling, 13 décembre 2010 - 03:39 .
                     
                  


            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #3 on: December 13, 2010, 10:23:26 pm »


               Your code looks like it has some errors in it.  You don't test that the objects you get are the type you are looking for.  For example one of the object you get is going to be the PC, and the PC won't have the variables you need.  

Also, you call GetNextObjectInArea() two times for each time around your loops. That should make you skip an object each time around the loop.  I'm pretty sure that isn't what you want.

 If you can describe the puzzle in detail.  People may be more able to help you fix it.
               
               

               


                     Modifié par Mudeye, 13 décembre 2010 - 10:24 .
                     
                  


            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #4 on: December 14, 2010, 01:09:55 am »


               i suppose i should have discribed how it should work in the first place, so...

when the player enters the room, the placeables spawn, all WPs have been raised 0.20 from the ground and they show the colors how they should be now. (had been raised to .1 with no success)

placeables include: 4 color coded statues, corrisponding to the colors on the rune plates and 16 rune plates of each color. (blue, green, red, yellow)
one final placeable, a chest appears when the puzzle is finished.

basicly the player needs to take all the colors of one kind and seperate them to thier own quarter, 16 to each quarter of the puzzle. the colors of the plates are supposed to change in order, clockwise, to ad a bit of difficulty. this might be where the puzzle becomes undoable, but i haven't gotten far enough in the prosses to figure that out.

once the player gets all 16 runes of one color, that color gets locked down, and there will only be three colors rotating the player has to deal with. once a color if finished it's no longer supposed to be in the cycle. to show the color has been locked down, a beam is supposed to shoot from every plate to it's corrisponding statue and the statue should glow that color.

once all 4 colors are finished, the chest spawns, you get the reward, and your done.

hope that explains what the puzzle is meant to do, and maybe it can be fixed easier now 'Posted

thanks
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #5 on: December 15, 2010, 06:19:21 pm »


               anyone got anything for me here? anything at all?

i can send anyone the area all set up for you...

thanks
               
               

               


                     Modifié par zero-feeling, 15 décembre 2010 - 06:20 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #6 on: December 15, 2010, 09:10:28 pm »


               Like Mudeye  said, you've got an extra GetNextObjectInArea() function. Get rid of the first one (in the if statement). Other than that I would try placing the statues in the toolset  where they are supposed to spawn and see what their coordinates are, some tilesets are much higher or lower than 0 on the z-axis by default.



-420
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #7 on: December 15, 2010, 11:55:04 pm »


               getting rid of the extra GetNextObjectInArea() didn't have any effect. i have the rune plates set to a proper hight, the colors are corect, the placeables are all there that should be, everything is good now except the colors don't change when used.

thats the current problem. any suggestions? could it have something to do with the part where it locks the colors? could it be doing this too soon?



thanks
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #8 on: December 16, 2010, 01:04:24 am »


               It looks like there may be a problem with the loop in the OnUsed script. GetNextObjectInArea() will return you to right below the line GetFirstObjectInArea() so the GetFirstObjectInArea() function should always be right above while(GetIsObjectValid(oObject)). I'm guessing that, because of the placement of GetFirstObjectInArea(), every time GetNextObjectInArea() is called the values for nBlue, nYellow   etc. get reset to 0.



-420
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #9 on: December 16, 2010, 03:26:38 am »


               as much as id love to just say "oh, hey, i get what ya mean now", im a bit lost. i can for the most part understand whats going on in each section, but the structuring of code is not something i'm very good at, nor understand very well yet.

if it's not too much trouble, possibly a bit of explination to what section in that monster your refering to?

thanks
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #10 on: December 16, 2010, 04:22:25 am »


               Move this line from here:

   [b]object oObject = GetFirstObjectInArea();[/b]
   string sLine;
   int nLine;
   string sRow;
   int nRow;
   int nColour;
   int nBlue = 0;
   int nYellow = 0;
   int nGreen = 0;
   int nRed = 0;
   int nSpell = SPELL_LIGHTNING_BOLT;
// WAYPOINT for the location (and facing) of the chest
   object oWaypoint = GetObjectByTag ("SP_chest");
   location lLocation = GetLocation (oWaypoint);
   object oStatue;
   while(GetIsObjectValid(oObject))

To here:

   string sLine;
   int nLine;
   string sRow;
   int nRow;
   int nColour;
   int nBlue = 0;
   int nYellow = 0;
   int nGreen = 0;
   int nRed = 0;
   int nSpell = SPELL_LIGHTNING_BOLT;
// WAYPOINT for the location (and facing) of the chest
   object oWaypoint = GetObjectByTag ("SP_chest");
   location lLocation = GetLocation (oWaypoint);
   object oStatue;
   [b]object oObject = GetFirstObjectInArea();[/b]
   while(GetIsObjectValid(oObject))
  
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #11 on: December 16, 2010, 05:49:36 am »


               ok, moved the line.

still no change from before. the colors are bright and briliant, but not changing.

thanks
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #12 on: December 16, 2010, 06:30:52 am »


               

zero-feeling wrote...

ok, moved the line.

still no change from before. the colors are bright and briliant, but not changing.

thanks

Alright, then my next guess is that the existing light VFX needs to be removed before the new one is applied. That will mean cycling through all the existing effects on the object and removing the glow before changing to a new color. This is best done by using a specific object to apply the effect then checking for the effect's creator.

It's getting late but I'd be happy to go into more detail on this tomorrow.

-420
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #13 on: December 17, 2010, 11:04:25 am »


               

420 wrote...

It's getting late but I'd be happy to go into more detail on this tomorrow.

-420


ready when you are. the sooner this puzzle works, the better.
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
help finishing a puzzle script please.
« Reply #14 on: December 19, 2010, 02:01:07 am »


               bump... still need help here.... please

thanks