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
Imgur
my scene№ 2
Imgur

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

3 Likes