Aller au contenu

Photo

help finishing a puzzle script please.


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

#1
zero-feeling

zero-feeling
  • Members
  • 144 messages
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

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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.

#3
zero-feeling

zero-feeling
  • Members
  • 144 messages
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 .


#4
Mudeye

Mudeye
  • Members
  • 126 messages
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 .


#5
zero-feeling

zero-feeling
  • Members
  • 144 messages
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 Image

thanks

#6
zero-feeling

zero-feeling
  • Members
  • 144 messages
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 .


#7
420

420
  • Members
  • 190 messages
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

#8
zero-feeling

zero-feeling
  • Members
  • 144 messages
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

#9
420

420
  • Members
  • 190 messages
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

#10
zero-feeling

zero-feeling
  • Members
  • 144 messages
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

#11
420

420
  • Members
  • 190 messages
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))
  

#12
zero-feeling

zero-feeling
  • Members
  • 144 messages
ok, moved the line.

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

thanks

#13
420

420
  • Members
  • 190 messages

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

#14
zero-feeling

zero-feeling
  • Members
  • 144 messages

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.

#15
zero-feeling

zero-feeling
  • Members
  • 144 messages
bump... still need help here.... please

thanks

#16
zero-feeling

zero-feeling
  • Members
  • 144 messages
one more go at this.... bump.

#17
420

420
  • Members
  • 190 messages

zero-feeling wrote...

one more go at this.... bump.

Sorry about that, I completely forgot.

You'll want to do something like this before applying the visual effect:
effect eRemove = GetFirstEffect(OBJECT_SELF);
while(GetIsEffectValid(eRemove))
    {
    if(GetEffectCreator(eRemove) == OBJECT_SELF) RemoveEffect(OBJECT_SELF, eRemove);
    eRemove = GetNextEffect(OBJECT_SELF);
    }

-420

#18
zero-feeling

zero-feeling
  • Members
  • 144 messages
like so?

      effect eRemove = GetFirstEffect(OBJECT_SELF);
      while(GetIsEffectValid(eRemove))
         {
         if(GetEffectCreator(eRemove) == OBJECT_SELF) RemoveEffect(OBJECT_SELF, eRemove);
         eRemove = GetNextEffect(OBJECT_SELF);
         }
      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);
      }

#19
zero-feeling

zero-feeling
  • Members
  • 144 messages
well thats not right..... now they are unuseable again....

#20
Tarot Redhand

Tarot Redhand
  • Members
  • 2 677 messages
Have you got dropbox? I'd be willing to take a look if you have. If you have just drop it into your public folder and PM me with the address and I'll download it.



TR

#21
zero-feeling

zero-feeling
  • Members
  • 144 messages
dropbox? i don't kow what this is. right now, funky is looking into it, not sure of his progress, but i can send you the same mod i sent him if you'd like. just PM me with your e-mail.

#22
Tarot Redhand

Tarot Redhand
  • Members
  • 2 677 messages
If funky is looking at it, you probably don't need my help. I expect funky will have it fixed for you shortly. In the very unlikely event they can't, just pm me and I'll get back to you and try to fix it myself.

Dropbox is a free tool that gives you access to a free amount of web storage (like a tiny 2 gig hard drive). Best of all it allows you to share stuff with other people. Another great thing is that they only require the absolute minimum of information from you to get it. To check it out just go here.

They also have a scheme whereby if you send someone to sign up for it via a special link, both you and the person signing up to it get an extra 250 meg of storage each. For example if you were to sign up for it via this link, both you and I would get the extra space.

TR

Modifié par Tarot Redhand, 24 décembre 2010 - 12:43 .


#23
zero-feeling

zero-feeling
  • Members
  • 144 messages
got a dropbox... thanks for telling me about it. will be adding the mod to it for future help i guess :)

#24
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

zero-feeling wrote...

got a dropbox... thanks for telling me about it. will be adding the mod to it for future help i guess :)



Also dont forget that you can always upload files to your project.

#25
Tarot Redhand

Tarot Redhand
  • Members
  • 2 677 messages

zero-feeling wrote...

got a dropbox... thanks for telling me about it. will be adding the mod to it for future help i guess :)


You're welcome. Also don't forget you can update any file that is in any folder under your main dropbox folder simply by overwriting it as long as you are connected to the internet.

TR