How to cast a spell in cutscene(IN Progress)

how to force npc
cast a spell in dialogue.
examples of OK cutscenes.
Garius kill Lorne or Qara make fireball.
Many thanks!
Thanks in advance for your time and
any advice.
I understand scripting very badly
I can only make change scripts a little

spell script
void ActionCastSpellAtObject(int n808, object oLorne, int nMetaMagic=METAMAGIC_ANY, int bCheat=TRUE, int nDomainLevel=3, int nProjectilePathType=PROJECTILE_PATH_TYPE_DEFAULT, int bInstantSpell=TRUE);

i know sheme how to create script (i only began read book
https://neverwintervault.org/project/nwn2/other/scripting-tutorial-beginners-nwn2 )

STEP ONE: What does your script do?
STEP TWO: Which approach should we take?
STEP THREE: Think about the variables we will be working with.
STEP FOUR: Declaring Variables
STEP FIVE: Add More Features
STEP SIX: Adding More Features
STEP SEVEN: LOOP
but
i dont know all scripting rules
so i tried do this
STEP ONE: What does your script do?
script must create animation cast spells and create vfx.

script must run when on conversation. when npc_garious say
keyphrase(something like :pizza time!)
(donā€™t know wherte find event hook
on user defined event script ?
STEP TWO: Which approach should we take?(donā€™t know)
STEP THREE: Think about the variables we will be working with.(donā€™t know)
STEP FOUR: Declaring Variables(Y=keyphrase)
STEP FIVE: Add More Features(donā€™t know)
STEP SIX: Adding More Features(donā€™t know)
STEP SEVEN: LOOP(how?)

judging because the function exists it should work
why is this script not working? (i put it in actions in dialog)
or maybe this function not working in cutscenes.(or becasuse i donā€™t have event hook ad other steps)
i hope spell script ok

but i think need make check tag speaker
need make this

Declaring Variables
need Variable Y
when Y true npc_garious said keyphrase;= true run script;
when Y false npc_garious donā€™t say keyphrase;=make DelayComand ;

maybe Y must be string variable but i donā€™t know how to check this in script language.
so what i get
i have
1 condition
need check Y
if Y true
run spell script
if Y false
return)

how to put this all together?
i try also use ga_cast_fake_spell_at_object but it not work donā€™t know why .
Many thanks!

example
// 20_cs_trialend
//
// Black Garius chides his minions for a job poorly done

// EPF 1/5/06

#include ā€œginc_debugā€

void MyPlayCustomAnimation(object oObj, string sAnim, int bLoop)
{
PlayCustomAnimation(oObj,sAnim,bLoop);
}

void main(int nScene)
{
object oPC = GetPCSpeaker();

object oBG = GetNearestObjectByTag("garius",oPC);
object oLorne = GetNearestObjectByTag("lorne",oPC);
object oTorio = GetNearestObjectByTag("torio",oPC);
object oSound;
effect eIgnition = EffectNWN2SpecialEffectFile("fx_ignition_red");

switch(nScene)
{
case 1:
	break;
case 2:	//garius kills Lorne

// AssignCutsceneActionToObject(oBG, ActionCastFakeSpellAtLocation(SPELL_FIREBALL,GetLocation(oLorne)));
// ActionCastSpellAtObject(SPELL_FINGER_OF_DEATH, oLorne,METAMAGIC_NONE,TRUE,9);
// AssignCommand(oBG, ClearAllActions(TRUE));
AssignCommand(oLorne, SetIsDestroyable(FALSE,FALSE,FALSE));

	ActionPauseCutscene(9000);
	AssignCutsceneActionToObject(oBG, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSavingThrowDecrease(SAVING_THROW_ALL,100), oLorne));
	AssignCutsceneActionToObject(oBG, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSpellResistanceDecrease(100), oLorne));
	
	//cast 1: lorne lifted off the ground
	//AssignCutsceneActionToObject(oBG, ActionPlayAnimation(ANIMATION_LOOPING_CAST1, 1.f, 2.f));
	PlayCustomAnimation(oBG, "gen_conjureloop",TRUE);
	AssignCutsceneActionToObject(oBG, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile("sp_necromancy_cast"),OBJECT_SELF));
	DelayCommand(0.3, MyPlayCustomAnimation(oLorne,"mjr_conjureloop",TRUE));
	
	//cast 2: lorne is ignited
	oSound = GetNearestObjectByTag("20_sfx_lorne_scream",oLorne);
	
	DelayCommand(0.8f, MyPlayCustomAnimation(oBG,"%",FALSE));
	DelayCommand(1.f, MyPlayCustomAnimation(oBG,"sp_touch",FALSE));
	DelayCommand(1.3f, AssignCutsceneActionToObject(oBG,ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eIgnition,oLorne,2.9f)));
	DelayCommand(1.5f, SoundObjectPlay(oSound));	//Lorne screams
	
	//cast 3: bg casts finger of death
	DelayCommand(4.f, MyPlayCustomAnimation(oBG, "sp_lightning", FALSE));
	DelayCommand(4.2f, AssignCutsceneActionToObject(oBG,ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile("sp_finger_of_death"),oLorne)));
	DelayCommand(4.4f, MyPlayCustomAnimation(oLorne,"%",FALSE));
	DelayCommand(4.5f, MyPlayCustomAnimation(oLorne,"collapseB",FALSE));
	DelayCommand(5.2f, AssignCommand(oLorne, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(GetCurrentHitPoints(oLorne) + 11), oLorne)));

// AssignCutsceneActionToObject(oBG, ActionCastSpellAtObject(SPELL_FINGER_OF_DEATH, oLorne,METAMAGIC_NONE,TRUE,9));
// AssignCutsceneActionToObject(oBG, ActionCastFakeSpellAtLocation(SPELL_FINGER_OF_DEATH,GetLocation(oLorne)));
AssignCutsceneActionToObject(oBG, ActionWait(9.f));

// PrettyDebug("BGā€™s tag = " + GetTag(oBG));
// PrettyDebug(ā€œCurrent garius action is " + IntToString(GetCurrentAction(oBG)));
// PrettyDebug(ā€œGarius has " + IntToString(GetNumActions(oBG)) + " actions pending.ā€);
// PrettyDebug(IntToString(GetNumCutsceneActionsPending()) + " cutscene actions.ā€);
//just in case he resists

// DelayCommand(2.f, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_HIT_SPELL_NECROMANCY),oLorne));

	break;
}

}

Many thanks!
Thanks in advance for your time and
any advice.

slow down there. Do you want an npc to cast a spell in a dialog (during a conversation, or perhaps at the end of the dialog) or in a cutscene (as part of a scripted sequence of actions)

?

Isnā€™t there a cast spell at object / fake spell at object generic script in the conversation editor that does it for you ? If so then just use cameras so you see the bit you want in the cut scene.

HI kevL_s!
Iā€™m sorry, I mean
I want to do a cutscene.
example how it should work
1.the talk trigger is triggered(itā€™s done)
2.NWN2 style dialogue starts( in progress)
cutscene begun
pc =listener allways
npc talk to each other
then npc garius speak and cast spell ( target lorne)
then npc lorne speak and cast spell ( target garius )
then npc garius speak and cast spell ( target lorne)
lorne get ignited and die .
the scene ends

Option 1 to make a spell script and run it at a specific moment
(in this moment looking for a way to do it )
1 var

i think at the end of the dialog.
i just want to run spell script
why spell script donā€™t run?
even spell script fake spells donā€™t run(npc only speak (fake spells wonā€™t run)
i do something vrong?

Option 2 to make a script of the entire scene and run it at a specific moment. As in the examples ( later )

i dont think that real spells can be cast in dialogs/cutscenes because they break the conversation.

ā€˜ga_cast_fake_spell_at_objectā€™ is bugged : it tries to cast a real spell.

 
soā€¦ notice how the script you posted above does it. roughly speaking ( cutscene scripts get notoriously intricate and to get this right id have to work with the cutscene ā€¦ which i donā€™t have ) so this is just the idea

- assign caster to play a casting animation
- apply some casting VFX to the caster

- stop the casting animation and remove the VFX
- apply the final effect along with a visual FX to the target

 
There are various ways to do this. The script you posted shows a way and its base functions. The wrapper functions like DelayCommand() and AssignCommand() and/or AssignCutsceneActionToObject() and even ActionDoCommand() are often the most complicated bits ā€¦

Oh, I donā€™t think so
Thanks you kevL_s.
I figured it out myselfā€¦
I thought it was very difficult.
now I will understand scripting better
hello there!
me in begin= i too weak
me now=Power !UNLIMITED Power!XD

my sceneā„–1

my sceneā„– 2

i found way
I carefully studied everything .and i learned some basics.
and now i have a scheme that anyone can use for ur own cutscenes.
for those who do not understand, I will try to explain later(need time).

scheme

#include "ginc_debug"

void MyPlayCustomAnimation(object oObj, string sAnim, int bLoop)
{
	PlayCustomAnimation(oObj,sAnim,bLoop);
}

void main(int nScene)
{
	object oPC = GetPCSpeaker();
	
	object oBG = GetNearestObjectByTag("garius",oPC);
	object oLorne = GetNearestObjectByTag("lorne",oPC);
	object oSound;
	effect eIgnition = EffectNWN2SpecialEffectFile("fx_ignition_red");

	switch(nScene)
	{
	case 1:	
put actions here
		break;
	}
}

and now i wil try make all scene

small review(i hope it help someone .
if you donā€™t understand .you need ask someone
because i need time for creating better tutorial .

scheme
scheme 1 part (just write)
#include ā€œginc_debugā€

void MyPlayCustomAnimation(object oObj, string sAnim, int bLoop)
{
PlayCustomAnimation(oObj,sAnim,bLoop);
}
scheme 2 part (need think what you write)
then
void main(int nScene)
{
object oPC = GetPCSpeaker();

object oBG = GetNearestObjectByTag("garius",oPC);
object oLorne = GetNearestObjectByTag("lorne",oPC);
object oSound;
effect eIgnition = EffectNWN2SpecialEffectFile("fx_ignition_red");

make
void main(int nScene)=here are the objects that are used in the scene
for example
i have creature with tag fox

object oname =itā€™s just name object in cutscene script
example
object oBG
object ofoX
donā€™t forget add tag npc

void main(int nScene)
{
object oPC = GetPCSpeaker();
object oBG = GetNearestObjectByTag(ā€œgariusā€,oPC);
object ofoX= GetNearestObjectByTag(ā€œfoxā€,oPC);
object oSound;
effect eIgnition = EffectNWN2SpecialEffectFile(ā€œfx_ignition_redā€);
here are the objects that are used in the scene

scheme 3 part (just write )
switch(nScene)
{
case 1:
put actions here
break;
}
}

if you want create chain event
just add
case number:
put actions here
break;

for example i want three event
switch(nScene)
{
case 1:
put actions here
break;
case 2:
put actions here
break;
case 3:
put actions here
break;
}
}

1 Like

glad you got it going Ā :)

1 Like

@lord_XD Have a look at this pinned thread to see how to post code in those code boxes you see everywhere on this site. This is important for a few reasons, 3 of which are -

  1. The software that drives these forums is called Discourse. Due to requests from users of non-coding users on other sites across the internet, this software renders quotation marks using the 66/99 style of quotation marks except in the code boxes. The consequence of this is that code posted outside of such boxes will not compile when that code is copied and pasted.
  2. Code posted in code-boxes has its layout (indenting) preserved.
  3. When you hover the mouse pointer over code in code-boxes an icon appears in the top-right corner of that box. Clicking on that icon automatically copies all of the code in the code-box to the clipoard without having to fiddle about hi-lighting it first.

TR

4 Likes

Hi all
I found a bunch of errors in my post.
Because of which
you might not be able to use my information.

I can add the module file. Fixed version text .
(I will download soon / I am preparing the text to make it clearer.)

In general, anyone is interested in the topic?
(although Iā€™ll probably download a tutorial for everyone anyway)
Iā€™m just asking. does anyone want to see posts
occasionally?
because Iā€™m disassembling now and try to make a scene (like a battle / but it will take a long time)

No answers, so I wonā€™t post.
Well, okay.
I will upload a simple version for those who need / need it.
after a while after about 1-2 weeks, maybe earlier
and complex version (do not know when)
links will be here
(maybe Iā€™ll create a topic
where then I will move everything I do so that it was easier for you to find everything I do)

2 Likes

1_Cutscene_Tutorial.7z (3.4 MB) here simple version for not very beginners(for begginners maybe i can create later
i dont have time for this sorry
maybe its not very good tutorial but /i m not sure can i create better now
(i create text version+explanations maybe later =i very busy
i maybe download some vide on youtube
(links
( https://youtu.be/bM7N2eTqlj4 )
will be update (i just need some time)

1 Like

Casting a real spell during a cutscene may break the cutscen or just not work for various reason.

When you want something bullet proof in somme case you need to script every single VFX without spell components. I recommend doing this only if the normal approach doesn 't give good result beceause itā€™s between 10 to 20 times more work.

2 Likes

If you want to cast a spell in a cut-scene but you want total control, there is a script for that (assuming it made it over to NwN 2). From the Lexicon -

ActionCastFakeSpellAtObject(int, object, int)

Display casting animation and spell visuals without subsequent spell effects.

void ActionCastFakeSpellAtObject(
    int nSpell,
    object oTarget,
    int nProjectilePathType = PROJECTILE_PATH_TYPE_DEFAULT
);

Parameters

nSpell

SPELL_*

oTarget

The target object for the animation to be fake-cast at

nProjectilePathType

PROJECTILE_* (Default: PROJECTILE_PATH_TYPE_DEFAULT)

Description

The Action recipient will have the appearance of casting nSpell, but there will no corresponding game effects as a result. The spell effect will be centered on or aimed at oTarget.

SPECULATION: if oTarget is invalid the Action will fail.

Remarks

It will have the same projectile visual effects (Such as Phantasmal Killerā€™s illisionary beast that leaps from the caster to the target), and casting visuals, as the spells.2da entry, but not fire the spell script, and the caster doesnā€™t need to know the spell.

Also note that ActionCastFakeSpell still incurs Attacks-of-oppotunity in combat, for some reason.

Known Bugs

For some reason stacking this Action doesnā€™t seem to produce a predictable string of castings. The creature will cast the first FakeSpell and when reaching the next FakeSpell in its Action Queue will halt all following queued Actions.

Version
1.61

Example

//Function made by Lilac Soul to illustrate the use of
//ActionCastFakeSpellAtObject - in this function, I use it
//to have the NPC speaker "cast a spell" at the PC which
//sets him or her at 1 experience point...

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

    //Wave my hands and talk like I'm casting the
    //wail of the banshee spell

    ActionCastFakeSpellAtObject(SPELL_WAIL_OF_THE_BANSHEE, oPC);

    //Apply a couple of visual effects to the PC

    int nDur=DURATION_TYPE_INSTANT;
    effect e1=EffectVisualEffect(VFX_FNF_HOWL_MIND);
    effect e2=EffectVisualEffect(VFX_FNF_PWKILL);

    ActionDoCommand(ApplyEffectToObject(nDur, e2, oPC));
    DelayCommand(4.5, ApplyEffectToObject(nDur, e1, oPC));

    //Set the PC to 1 XP - he won't be too happy with this spell!

    DelayCommand(4.5, SetXP(oPC, 1));
}

My guess is that the mentioned bugs may have been ironed out by the time (assuming it did) this function made it to NwN 2.

TR

2 Likes