Author Topic: Advice on delaying script re-fire  (Read 454 times)

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Advice on delaying script re-fire
« on: September 25, 2010, 08:05:45 pm »


               Hi all,

Using the lilac I devised the below script in order for a PC during night time to have a chance at spotting a hole leading to a cave. However, I couldnt figure out how to delay the script so it dosent fire everytime the player runs over the trigger but rather only once every 30 seconds.
I suppose its something with adding a variable or something, but just out of my reach although I have tried a few things with no success.

Also, if you spot any error in the script, please do point it out as well..

effect eEffect;
int nInt;
location lTarget;
object oSpawn;
object oTarget;
/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...=4683&id=625テつ テつ テつ  */

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

//Make sure it only fires at night
if (!GetIsNight())
   return;


//First skill attempt to reveal the hole. This one using search
if (GetIsSkillSuccessful(oPC, SKILL_SEARCH, 18))       //set required roll skill + d20
   {
   oTarget = GetWaypointByTag("WP_HoleCementaryHalbrook");

   lTarget = GetLocation(oTarget);

   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "holecementhalbro", lTarget);

   oTarget = oSpawn;

   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), oTarget));
   else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), GetLocation(oTarget)));

   DelayCommand(1.0, SendMessageToPC(oPC, "You found what appears to be a freshly dug hole leading down into a cave"));

   oTarget = GetObjectByTag("tr_HoleCementaryHalbrook");

   nInt = GetObjectType(oTarget);

   eEffect = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION);

   if (nInt != OBJECT_TYPE_WAYPOINT)
      DelayCommand(20.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget));
   else
      DelayCommand(20.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget)));

   DelayCommand(20.0, DestroyObject(oTarget, 3.0));

   }

//Second skill attempte to reveal the hole. This one using spot
else if (GetIsSkillSuccessful(oPC, SKILL_SPOT, 18))      //set required roll skill + d20
   {
   oTarget = GetWaypointByTag("WP_HoleCementaryHalbrook");

   lTarget = GetLocation(oTarget);

   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "holecementhalbro", lTarget);

   oTarget = oSpawn;

   nInt = GetObjectType(oTarget);

   if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), oTarget));
   else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), GetLocation(oTarget)));

   DelayCommand(1.0, SendMessageToPC(oPC, "You found what appears to be a freshly dug hole leading down into a cave"));

   oTarget = GetObjectByTag("tr_HoleCementaryHalbrook");

   nInt = GetObjectType(oTarget);

   eEffect = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION);

   if (nInt != OBJECT_TYPE_WAYPOINT)
      DelayCommand(30.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget));
   else
      DelayCommand(30.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget)));

   DelayCommand(30.0, DestroyObject(oTarget, 3.0));

   }

   //If PC fails both skillrolls, he gets a message
else
   {
   SendMessageToPC(oPC, "You sense something is amiss here, but you are not quite able to spot what it is");

   }

}


Thank you
               
               

               
            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Advice on delaying script re-fire
« Reply #1 on: September 25, 2010, 11:14:38 pm »


               Try this:






effect eEffect;
int nInt;
location lTarget;
object oSpawn;
object oTarget;
/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...=4683&id=625テつ テつ テつ  */

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();


if (!GetIsPC(oPC)) return;

//Make sure it only fires at night
if (!GetIsNight())
   return;

if (GetLocalInt(oPC,"ResetC")==1) { return;} // checks to see if player has triggered w/30 seconds

SetLocalInt(oPC,"ResetC",1); //Sets up the check

DelayCommand(30.0,SetLocalInt(oPC,"ResetC",0)); //Undoes the checking integer in 30 seconds

//First skill attempt to reveal the hole. This one using search
if (GetIsSkillSuccessful(oPC, SKILL_SEARCH, 18))       //set required roll skill + d20
   {
   oTarget = GetWaypointByTag("WP_HoleCementaryHalbrook");

   lTarget = GetLocation(oTarget);

   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "holecementhalbro", lTarget);

   oTarget = oSpawn;

   nInt = GetObjectType(oTarget);

  
if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5,
ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), oTarget));
   else
DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), GetLocation(oTarget)));

   DelayCommand(1.0, SendMessageToPC(oPC, "You found what appears to be a freshly dug hole leading down into a cave"));

   oTarget = GetObjectByTag("tr_HoleCementaryHalbrook");

   nInt = GetObjectType(oTarget);

   eEffect = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION);

   if (nInt != OBJECT_TYPE_WAYPOINT)
      DelayCommand(20.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget));
   else
      DelayCommand(20.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget)));

   DelayCommand(20.0, DestroyObject(oTarget, 3.0));

   }

//Second skill attempte to reveal the hole. This one using spot
else if (GetIsSkillSuccessful(oPC, SKILL_SPOT, 18))      //set required roll skill + d20
   {
   oTarget = GetWaypointByTag("WP_HoleCementaryHalbrook");

   lTarget = GetLocation(oTarget);

   oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "holecementhalbro", lTarget);

   oTarget = oSpawn;

   nInt = GetObjectType(oTarget);

  
if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5,
ApplyEffectToObject(DURATION_TYPE_INSTANT,
EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), oTarget));
   else
DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), GetLocation(oTarget)));

   DelayCommand(1.0, SendMessageToPC(oPC, "You found what appears to be a freshly dug hole leading down into a cave"));

   oTarget = GetObjectByTag("tr_HoleCementaryHalbrook");

   nInt = GetObjectType(oTarget);

   eEffect = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION);

   if (nInt != OBJECT_TYPE_WAYPOINT)
      DelayCommand(30.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget));
   else
      DelayCommand(30.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget)));

   DelayCommand(30.0, DestroyObject(oTarget, 3.0));

   }

   //If PC fails both skillrolls, he gets a message
else
   {
   SendMessageToPC(oPC, "You sense something is amiss here, but you are not quite able to spot what it is");

   }

}
               
               

               


                     Modifiテδゥ par Redunct, 25 septembre 2010 - 10:16 .
                     
                  


            

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Advice on delaying script re-fire
« Reply #2 on: September 25, 2010, 11:53:00 pm »


               Works a charm.. Thanks redunct '<img'>