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
Advice on delaying script re-fire
Débuté par
Arawan
, sept. 25 2010 07:05
#1
Posté 25 septembre 2010 - 07:05
#2
Posté 25 septembre 2010 - 10:14
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");
}
}
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 .
#3
Posté 25 septembre 2010 - 10:53
Works a charm.. Thanks redunct





Retour en haut






