(solved) NWN1 1.69: Trouble with a cutscene

Hello!

I’ve some troule with a cutscene. The script runs in the on-spawn slot af a dragon. Bane should jump in and kill the dragon with an epic spell.

There are two problems:

  1. Bane wears heavy armor. How can I circument the spell-failure restriction? Sometime he seams to fail with getting off his spell. I already set concentration to 99 and spell-failure-property on the armor to -50. That is obviously not enough.

  2. Sometimes this guy decides to do something else (such as casting a buff). How can I make sure, that he does exactly what I told him to do?

Here is the code:
void main()
{
object oNPC = OBJECT_SELF; // A big, bad black Dragon
DelayCommand (1.0, SpeakString (“Now I’m really PISSED OFF!”));
object oBane = GetObjectByTag (“Bane”);
effect d = EffectCutsceneDominated ();

location l = GetLocation (GetObjectByTag (“WP_BANE”));
effect e = EffectVisualEffect (VFX_IMP_HEALING_X);

// Bane appears in a beam of light, he’s faction defender
DelayCommand (2.0, ApplyEffectAtLocation (DURATION_TYPE_INSTANT, e, l));
DelayCommand (3.0, AssignCommand (oBane, JumpToLocation(l)));

// DelayCommand (3.2, ApplyEffectToObject (DURATION_TYPE_TEMPORARY, d, oBane, 5.0));
DelayCommand (4.0, AssignCommand (oBane, SpeakString (“Hah, you are dead meat!”)));
DelayCommand (4.1, AssignCommand (oNPC, ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_HOSTILE)));
DelayCommand (4.5, AssignCommand (oBane, ClearAllActions(TRUE)));
DelayCommand (5.0, AssignCommand (oBane, ActionCastSpellAtObject (SPELL_EPIC_HELLBALL, oNPC, METAMAGIC_MAXIMIZE, TRUE)));
DelayCommand (10.0, AssignCommand (oBane, ActionAttack (oNPC)));

// Scotty beams Bane up
DelayCommand (60.0, JumpOut(oBane));
}

You can assign ActionCastSpellAtObject to Bane with the Cheat flag set.

To stop Bane doing other stuff, clear all actions, cast the spell, then use SetCommandable to block all other commands from the AI until it’s done (see Example, Note 3, on that page).

1 Like

Thanks.

Mmmh, the cheat flag is already set, maybe the phenomen i’ve seen is just another kind of disobedience. I can’t figure out what he’s doing instead of casting.

I’ll try to prepare the stack as described in the lexicon.

Epic Spells doesn’t fail because of concentration, I suspect that your problem is that vanilla AI is canceling your commands.

To fix that, you need to either set oBane uncommandable (SetCommandable(FALSE)) but that requires to code his actions in a completely different manner.

Or, you strip him from all scripts. That way vanilla AI won’t override anything.

1 Like

Thanks,

but can epic spells fail because of the armor class (heavy)?

Yup, I’ll try that “setcommandable = false”. It will be bit tricky since there are two actors.

Stripping all scripts is something I will try as well.

Epic spells ignore spell failure as well.

Hello,

I give up. I tried everything.

  • I ripped out any default-scripts from the actors (which is in general a good idea for cutscene-actors),
  • I tried to set “commandable” properly,
  • I used a different protagonist (new character from scratch).
  • I tested lot’s of changes and variants in scripting

Nothing works. This protagonist does everything, such as speaking the onliner and physical attacking, but he does not cast the spell. I fear I stumbled over a bug in the engine.

Well, no need for advanced magic, just let’s whack the baddie away? that’s the way, I solved it …

Would it be possible that oBane doesn’t see oNPC or is not in range to cast spell (cheat casting still follow usual rules, it is just that caster doesn’t need the spell prepared) and cannot move?

Other than that, this should not be the cause but try change METAMAGIC_MAXIMIZE to METAMAGIC_ANY, maximizing hellball will do nothing anyway.

Post your current script so we can see if you did that SetCommandable trick correctly or not.

Very well, here it is.
I tried any variant of metamagic and i tried a different spell (Greater missile storm, greater ruin). I took you suggestion and made a little perception script. I made a small mod to reproduce the fault in an isolated environment. Anything is fine, except the casting …

//This is in the on-spawn script of the Antangonist (A black dragon, faction hostile)
//The spawn of the antagonist is in a on-death script of another creature, Tag QNew
//-----------------------------------------------------------------------------------
void SpawnBane()
{
location l = GetLocation (GetObjectByTag (“WP_BANE”));
effect e = EffectVisualEffect (VFX_IMP_HEALING_X);
ApplyEffectAtLocation (DURATION_TYPE_INSTANT, e, l);
object oBane = CreateObject (OBJECT_TYPE_CREATURE, “deitybane”, l);
}

void main()
{
object oNPC = OBJECT_SELF;
DelayCommand (1.0, SpeakString (“Now I’m really PISSED OFF!”));
DelayCommand (2.0, SpawnBane());
}

//This is the on-death script of the antagonist
//here the protagonist disappears, which should be happen within 15 secs.

void JumpOut (object o)
{
effect e = EffectVisualEffect (VFX_IMP_HEALING_X);
location l = GetLocation (o);
ApplyEffectAtLocation (DURATION_TYPE_INSTANT, e, l);

AssignCommand(o, ClearAllActions(TRUE));
DestroyObject(o, 1.0);
}

void main()
{
object oPC = GetFirstPC();

SetLocalInt (GetModule(), “QNewIsDead”, 1);
SetLocalInt (GetModule(), “Silandraquest”, 4);
AddJournalQuestEntry (“P014”, 9, oPC);
object oDoor = GetObjectByTag(“QInnerDoor”);
SetLocked (oDoor, FALSE);
SetLocalInt (GetModule(), “ItIsSpring”, 1);

object oBane = GetObjectByTag (“BaneHimself”);
DelayCommand (2.5, JumpOut (oBane));
}

The on-spawn script of the protagonist (Bane, faction defender)

void JumpOut (object o, object q)
{
effect e = EffectDeath();
ApplyEffectToObject (DURATION_TYPE_INSTANT, e, q); //Better save than a living Dragon on the heels

e = EffectVisualEffect (VFX_IMP_HEALING_X);
location l = GetLocation (o);
ApplyEffectAtLocation (DURATION_TYPE_INSTANT, e, l); //Beamie, scotch me up
DelayCommand (0.5, AssignCommand(o, ClearAllActions(TRUE)));
DelayCommand (1.0, DestroyObject(o));
}

void BaneAction(object o)
{
SpeakString (“Hah, you are dead meat.”);
ActionCastSpellAtObject(SPELL_EPIC_RUIN, o, METAMAGIC_NONE, TRUE);
// ActionCastSpellAtObject (SPELL_ISAACS_GREATER_MISSILE_STORM, o, METAMAGIC_MAXIMIZE, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
DelayCommand (3.0, ActionAttack (o));
}

void main()
{
object oNPC = OBJECT_SELF;
object oVictim = GetObjectByTag (“QNew”);
DelayCommand (1.0, BaneAction(oVictim));

// jump out should be triggered by on-death of the victim.
// this instance is only there to make sure, that it happens
DelayCommand (30.0, JumpOut(oNPC, oVictim));
}

replace with

I encountered similar issue recently, not sure if it was EE related and I still don’t know what that happened but in my case npc refused to cast spell on distant placeable that she could see. What fixed it for me was commanding the npc to cast the spell on player first, then cast it on placeables and that somehow worked. If the code that I sent you won’t work (it might not compile if I made some mistake as I am typing it in web browser, I am expecting you to fix any such error) and npc still won’t cast, if you send me the module/area where I can reproduce it I can take a deeper look.

It’s funny, how things turn out. I tried a different creature as target, a killer penguin. It doesn’t work. Then I tried a bad urn construct (which is a placable) and the spell is cast. If I understood correctly, casting on a placable doesn’t work for you!

You can have the test mod, tell me how to transffer it.

Hmm. Isn’t the Bane npc hostile faction by any chance? Normally it should work anyway, but depending on a No-PvP/difficulty settings of the module it might treat both NPCs as “party members/friendly” and cancel the cast. So if the Bane npc is hostile try setting him defender faction.

Upload it on some cloud and give me link if this won’t solve it either.

After checking the module I found out that the OP issue is due to the newly spawned NPC unable to see the target.

It is because an engine limitation - when you spawn the Bane he can’t see the penguin. And he needs to see him to be able to cast on him.

One solution is to delay the spellcast by several seconds, I tried 4 and it was not enough. Another would be to move the spell cast from OnSpawn to OnPerception.

Different approach would be to cast the spell at location, but that won’t be good because the penguin could move between the cast + you would have to deal with the fact that the spell won’t harm him.

I tried to give the NPC long perception, high AI level, haste boots and even change his class but nothing helped. The only other thing you can do is to just make him Attack - that doesn’t require vision apparently…

Actually I just realized that there is another possibility to workaround this issue. I had similar problem with exploiting npc’s spellcasting range by players. Using Community Patch feature to override spell target, I modified the AI (using another community patch feature of AI being externalized into one script builder can modify and see changes without need to recompile all scripts with AI calls) to cast the spell on self and apply the spell effects on original target using the SPELL_TARGET_OVERRIDE local variable.

The same method can be used for this issue as well. I would post a code, but considering it is using community patch that nobody wants to use because everyone knows better it is pointless.

You can achieve the same result by direct modification of the spell anyway. Basically, let the Bane NPC cast the Greater Ruin on self instead of penguin, and modify Greater Ruin spellscript in a way so that if the spell target is BANE npc, it will replace the spell target with penguin. Since the spell doesn’t have projectile, it will work perfectly (spells with projectiles used this way will not fire projectile against the real target).

Hello!
After all, there is a workaround.

The problem was that a NPC “refused” to cast a spell on another NPC within a short cutscene. Meanwhile I tried 1000s of variants of my scripting. No matter what, the NPC doesn’t cast the spell on any creature, as intended.

As shadooow states it’s probably an Line of Sight or Perception issue, but I’m tired to ask why.

The solution is: The spell is cast on an invisible placable at the same position of the Creature which is the actually target of the spell. It works! Casting spells on placables seems to be somewhat different.

Thanks to shadooow, who provides lot’s of ideas how to solve this.