How to script this kind of effect in a cutscene

I’m trying something I’ve never done before. I know Shallina had some kind of system for this kind of thing, but looking at the script she posted (it was in the thread about Gestalt Cutscene Scripting) it feels like way over my head at the moment.

So, to explain:

  1. It’s a cutscene (NWN2 style conversation with static camera and all that)
  2. In one node I would like a placeable to cast a lightbeam (maybe there’s some spell that looks like a lightbeam? I don’t want an explosion on the target, just a very bright light beam hitting the target)
  3. The target is a companion (or it might be the PC)

So, I think I need a visual effect like in Shallina’s script, perhaps something like:

effect eAbjCast = EffectVisualEffect(vfx_abjuration_cast());

and maybe something like:

ApplyEffectToObject(DURATION_TYPE_INSTANT, AbjCast, oNPC));

Still, this feels like I don’t know where to start to do this script. Maybe someone can help?

/*
	Creates a beam effect from a placeable to the oPC.
*/

void main()
{
	object oSource = GetNearestObjectByTag("placeable_tag");
	object oPC = GetFirstPC(FALSE);
	effect eBeam = EffectBeam(VFX_BEAM_ABJURATION, oSource, BODY_NODE_CHEST);

	ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oPC, 5.0f);	
}

Eh…it’s that easy? It can’t be that easy, can it?

I would never have come up with something like this. I’ll try it out. Thanks, @travus !

1 Like

@travus - Testing this further…Is there a way to make the beam aim for the head of the creature? When looking at the Globals in the Script Assist there only seems to be BODY_NODE_CHEST and BODY_NODE_HAND, so maybe that’s impossible?

/*
	Creates a beam effect from a placeable to the head of oPC.
*/

#include "ginc_reflection"

void main()
{
	object oSource = GetNearestObjectByTag("placeable_tag");
	object oPC = GetFirstPC(FALSE);
	effect eBeam = EffectBeam(VFX_BEAM_ABJURATION, oSource, BODY_NODE_CHEST);
	string sHeight = Get2DAString("appearance", "height", GetRacialType(oPC));
	float fHeight = StringToFloat(sHeight);
		
	AssignCommand(oPC, ClearAllActions());
	
	location lLoc = ModifyLocationPosition(GetLocation(oPC), 0.0f, 0.0f, fHeight);
	object oIP = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_ipoint ", lLoc);
	
	ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oIP, 3.0f);
	SetPlotFlag(oIP, FALSE);	
	DestroyObject(oIP, 4.0f);	// make this delay longer than the duration of the beam
}
5 Likes

Wow that looks great, travus! I wonder if it still works while the oPC or the companion sits down…

Sadly it didn’t. The script worked as advertized, but since the character is sitting down with the sit_4 animation from kemo animations suite it didn’t work. I’ll go back to your first version then, unless you think even this could be solved (but I think that would be difficult to calculate where the head is when the character is sitting down). Perhaps I could manually put in an ipoint where I think the head will be and do a few tests but…ah, nevermind. It still looks good even if it doesn’t hit the head.

EDIT: Tested things again ingame and it really looks good the way it is. You don’t have to put any more effort into this, travus. I’m very grateful for your scripts!

Assuming the character is already sitting down when the script fires, try changing this:
float fHeight = StringToFloat(sHeight);
to this:
float fHeight = StringToFloat(sHeight) * 0.8;

3 Likes

Ah, ok. Could try that then, I guess. Thanks!

And yes, the character is sitting down already when the script fires.

I tried with:

float fHeight = StringToFloat(sHeight) * 0.45;

and now it’s perfect. Thanks again, @travus !

2 Likes