So I have a working script which accomplishes exactly what I want when it is on the monster's heartbeat:
==================
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.c...=4683&id=625 */
//Goes on creature's OnHeartbeat. Fires when not fighting or talking.
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;
int nInt;
nInt = GetTimeHour();
if ((nInt < 7) || (nInt > 20))
return;
effect eEffect;
eEffect = EffectDamage(999, DAMAGE_TYPE_DIVINE, DAMAGE_POWER_ENERGY);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, OBJECT_SELF);
object oTarget;
oTarget = OBJECT_SELF;
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_DIVINE), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_DIVINE), GetLocation(oTarget));
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_HOLY_10), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_HOLY_10), GetLocation(oTarget));
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), GetLocation(oTarget));
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
eEffect = EffectVisualEffect(VFX_FNF_SMOKE_PUFF);
if (nInt != OBJECT_TYPE_WAYPOINT)
DelayCommand(3.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget));
else
DelayCommand(3.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget)));
DelayCommand(3.0, DestroyObject(oTarget, 3.0));
}
===========
...which gives a nice little light show as it kills the undead.
However, as you know, the Heartbeat script will not fire if the monster is in combat (which is likely). So I put this tweaked version in the Module's heartbeat instead...
===========
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.c...=4683&id=625 */
//Goes on creature's OnHeartbeat. Fires when not fighting or talking.
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;
int nInt;
nInt = GetTimeHour();
if ((nInt < 6) || (nInt > 20))
return;
effect eEffect;
eEffect = EffectDamage(999, DAMAGE_TYPE_DIVINE, DAMAGE_POWER_ENERGY);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, GetObjectByTag("vamp_me"));
object oTarget;
oTarget = GetObjectByTag("vamp_me");
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_DIVINE), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_DIVINE), GetLocation(oTarget));
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_HOLY_10), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_LOS_HOLY_10), GetLocation(oTarget));
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), GetLocation(oTarget));
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
nInt = GetObjectType(oTarget);
eEffect = EffectVisualEffect(VFX_FNF_SMOKE_PUFF);
if (nInt != OBJECT_TYPE_WAYPOINT)
DelayCommand(3.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget));
else
DelayCommand(3.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget)));
DelayCommand(3.0, DestroyObject(oTarget, 3.0));
}
===========
This works to kill the vamp, but it will not play the visual effects. Any guess why? Any work around?
Thanks!
Sunlight - Undead killer script
Débuté par
Walker_Boh
, déc. 12 2010 10:50
#1
Posté 12 décembre 2010 - 10:50
#2
Posté 13 décembre 2010 - 12:44
Walker_Boh wrote...
However, as you know, the Heartbeat script will not fire if the monster is in combat (which is likely). So I put this tweaked version in the Module's heartbeat instead...
When you override one of the default event scripts (like nw_c2_default1, the creature HB) it's usually best to run the contents of the script in addition to your own. There are various ways to do this:
1. Create a new version of that script with your content added in
2. Create your custom script that calls ExecuteScript for the default script
3. Create an override version of the default script, which looks for a local variable stored on the object (in this case, the creature) and executes that either at the beginning or the end of the default script.
Most of the default scripts have actually already been conveniently set up to allow option #3. For example, look at nw_c2_default9, the creature OnSpawn script. At the end, it has this section:
string sSpawnScript=GetLocalString(OBJECT_SELF,"SpawnScript"); if (sSpawnScript!="") ExecuteScript(sSpawnScript,OBJECT_SELF);
So if you create a script and put the name of that script as local string called "SpawnScript" on a creature, both that script and nw_c2_default9 will be run when the creature is spawned.
For no reason I've been able to figure out, nw_c2_default1, the creature HB script, doesn't have such a convenient handle, but that's easily modified by overriding it for your project.
I know this doesn't address your question about the VFX not showing up. However, I wanted to help you separate out the issues of your VFX not firing from the HB scripts working or not.
#3
Posté 13 décembre 2010 - 12:45
The visual effects in NWN2 can be finicky. When I write a script utilizing VFX, the first thing I do is create a test script which runs just the VFX to make sure they work by themselves. Once I have the VFX working, then I create the rest of the script.
here is a sample:
_______________________-
void main()
{
object oPC = GetFirstPC();
effect eEffect = EffectVisualEffect(Place effect here);
ApplyEffectToObject(Duration, effect, object, etc...)
}
___________
Now you can go into your game and test the VFX by itsself from the console using the "rs" command. This will let you make sure the VFX part of your script works before adding the conditions and such.
here is a sample:
_______________________-
void main()
{
object oPC = GetFirstPC();
effect eEffect = EffectVisualEffect(Place effect here);
ApplyEffectToObject(Duration, effect, object, etc...)
}
___________
Now you can go into your game and test the VFX by itsself from the console using the "rs" command. This will let you make sure the VFX part of your script works before adding the conditions and such.
Modifié par M. Rieder, 13 décembre 2010 - 12:51 .





Retour en haut






