Author Topic: Attack of the statues...  (Read 303 times)

Legacy_HotrodHunter

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Attack of the statues...
« on: May 05, 2011, 04:46:28 pm »


               Aight, lets see, im kind of a nublet scrpier, and i havnt really worked on my module for about 3years now, trying to get back into it, now, im trying to make a chamber where creatures on spawn turn to stone, and i think i figured that part out, cast effect petrify.  my problem ismaking a script on a door that disables the petrify effect, and unlocks the door on the death of all the mobs... or if thats a little much to ask, then just a script that will unpetrify all creatures, i can always put a key in the inventory of one '<img'> lol
thanks!
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Attack of the statues...
« Reply #1 on: May 05, 2011, 07:51:38 pm »


               OnUsed

do a loop through all the object in the area, and if it's an Encounter Creature, remove the effect from them..

Use a special function to remove the effect, because you will need to do 2 loops in one script...
You can't use a loop inside a loop or you will get the TMI error (Too Many Instructions)..

If you need help with loops or the custom function let me know..
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Attack of the statues...
« Reply #2 on: May 06, 2011, 02:17:31 am »


               There is no problem with nesting loops.  You can nest as many of them as you want to.  There is a limit to the number of instructions that a script can have.  However moving an inner loop off to its own function will increase the number of instructions in the script, not decrease them.  

As far as looping for encounter creatures that could work if you are spawning you statues from an encounter. For some reason I do not think you are.  

Here is what I would do.  I would give all of your statues the same Tag.   then place this script in the OnOpen event for the door.

Just change "TagOfStatue"  in the two places in the script to the tag you are useing.

void main()
{
   object oStat = GetNearestObjectByTag ("TagOfStatue");
   object oDoor  =  OBJECT_SELF;
   int nCount= 1;
   effect eLook;
   // if the object is valid the statues are still there.
   if (GetIsObjectValid(oStat))
   {
     // Stop the door from opening by reclosing it.
     // let the area do it to make sure it gets done.  doors are fickle
        ActionCloseDoor(oDoor);
   
     // remove the paralisis from the statues.
     do
     {
        eLook = GetFirstEffect(oStat);

        while(GetIsEffectValid(eLook))
        {
            if(GetEffectType(eLook) == EFFECT_TYPE_PETRIFY)
            {
                SetCommandable(TRUE, oStat);
                RemoveEffect(oStat, eLook);
                ApplyEffectToObject
                (
                  DURATION_TYPE_PERMANENT,
                  EffectVisualEffect(VFX_DUR_PROT_STONESKIN),
                  oStat
                );
            }
            eLook = GetNextEffect(oStat);
        }


       // change the target for next loop.
       nCount = nCount +1 ;
       oStat = GetNearestObjectByTag ("TagOfStatue",OBJECT_SELF,nCount);
     }while (GetIsObjectValid(oStat));
   }
}