Drinking out of bottle animation?

I’ve been searching for this for quite a while now. There are spoons and steins that your PC can hold, and you can drink from steins. However, I would like my NPC or PC to be able to drink from a bottle. That doesn’t seem possible. When I tried making a custom item I changed the Base Item to bottle, and I could actually let my character hold it in her hands. However there was just a question mark in the toolset as if the model for the bottle is missing or doesn’t exist, and maybe that’s the way it is…

That’s been implemented as an f/x:

2 Likes

Ah! Great! Thanks rjshae!

By the way, you wouldn’t know if there is something like food, an apple or chicken leg that an NPC can eat? An animation for that kind of thing? I haven’t been able to find anything like that but…

Not that I’m aware. But it’s quite do-able with a little modeling skill.

Ok. Sadly I have no modelling skills what-so-ever.

Here’s a sample bread-eating animation. Well it would be… if it were possible to eat bread through the nose. The standard “eat” animation doesn’t line up the hand with the mouth very well. But from a distance it might work.

eat_bread

It took a lot of trial-and-error to get the loaf to line up with the hand. I guess it beats a sharp stick (or a loaf of bread) in the eye.

2 Likes

Thank you so much for your effort with this!

The scene I had in mind is an NPC eating an apple in a dialogue. I’ll see if I can use this…
Again, thank you for taking time trying this.

It looks quite good in game, actually. :smiley: And it’s way better than having nothing at all, and just describing what’s happening with text. If it was an apple instead though, it really would be awesome, but I don’t want to be demanding…
Thank you for this!

Another thing. Though this works, somehow I can’t seem to stop the animation after it’s started. As I use this in a conversation and not the way you intended (in the SpawnScript variable) maybe that’s what’s hindering me from stopping the animation. I’ve edited your script example and it now looks like this:

void Loop(object oTarget) 
{
	
	// Eat F/X
	PlayCustomAnimation(oTarget, "eat", 0);
	DelayCommand(6.0f, Loop(oTarget));
}


void main(string sTagString)
{
	object oTarget = GetObjectByTag(sTagString);
	// F/X to display
	string sVFX = "fx_handr_bread.sef";
	// Assign VFX to spell id 100 (light spell)
	effect eDrink = SetEffectSpellId(EffectNWN2SpecialEffectFile(sVFX), 100);
	SetWeaponVisibility(OBJECT_SELF, 0, 0);//Make weapons and shields invisible
	ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrink, oTarget);
	
	DelayCommand(6.0f, Loop(oTarget));
}

and to stop the animation I edited a script that Aqvilinus originally wrote for my last module that will be released in few months:

#include "nw_i0_spells"
#include "ginc_param_const"
#include "ginc_actions"

void PlayCustomAnimationWrap(object oObject, string sAnimationName, int nLooping=FALSE)
{
    PlayCustomAnimation(oObject, sAnimationName, nLooping, 1.0);
}

void PlayCleanAnimation(object oTarget, string sAnim, int bLoop)
{

    AssignCommand(oTarget, ClearAllActions());
    PlayCustomAnimationWrap(oTarget, "%");
    DelayCommand(0.1, PlayCustomAnimationWrap(oTarget, sAnim, bLoop));
}

void main(string sTarget)
{

object oTarget = GetTarget(sTarget);
	
PlayCleanAnimation(oTarget,"eat",FALSE);
RemoveEffectsFromSpell(oTarget, 100);
SetWeaponVisibility(oTarget, 1, 0);//Make weapons and shields visible again
}

My scripting knowledge is still very limited so maybe I’m missing something. As it is right now the loop won’t stop.

Hi, @andgalf. I’ve edited the scripts above so they do what you want.

To play animation:

#include "ginc_param_const"

void Loop(object oTarget)
{
	if (!GetLocalInt(oTarget, "stop_animation"))
	{
		PlayCustomAnimation(oTarget, "eat", FALSE);
		DelayCommand(6.0f, Loop(oTarget));
	}
}

void main(string sTarget)
{
	object oTarget = GetTarget(sTarget);
	effect eDrink = EffectNWN2SpecialEffectFile("fx_handr_bread.sef");
		   eDrink = SetEffectSpellId(eDrink, SPELL_LIGHT);

	SetLocalInt(oTarget, "stop_animation", FALSE);
	SetWeaponVisibility(oTarget, FALSE); //Make weapons and shields invisible
	ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDrink, oTarget);

	DelayCommand(6.0f, Loop(oTarget));
}

To stop it:

#include "nw_i0_spells"
#include "ginc_param_const"

void main(string sTarget)
{
	object oTarget = GetTarget(sTarget);

	AssignCommand(oTarget, ClearAllActions());
	PlayCustomAnimation(oTarget, "%", FALSE);
	RemoveEffectsFromSpell(oTarget, SPELL_LIGHT);
	SetWeaponVisibility(oTarget, TRUE);
	SetLocalInt(oTarget, "stop_animation", TRUE);
}
2 Likes

Thanks @Aqvilinus ! I’ll try that then.

The script was only intended for testing, so I put it in a perpetual loop.

Ah yes, I understand. It all got sorted out so no worries. :slightly_smiling_face:
Again, thanks for helping me!