Cast Stone to Flesh on NPC - convo reflects this?

Hi everyone,
Today’s challenge is, I am trying to setup an NPC (who is petrified), to have it so that if/when a PC casts stone to flesh, their conversation file can update to reflect this. Lilac’s can’t help me with this one either.

I have found scripts that come with the game and they work nicely, but there doesn’t seem to be a script I can find, that factors the above in (I’ll paste the scripts down below, that I am using on the NPC, that come with the game).

I’ll try to explain the issue better: The NPC has a conversation attached to them. I am having trouble finding a conditional check script, that will know the NPC is not a statue anymore. PC’s can cast stone to flesh (if they have it). So would an “on_spell_cast_at” script work that maybe sets a global_int, that the conversation can reference?
I am open to whatever solution is easiest for this one, as once again, once the conversation starts correctly after stone-to-flesh, then I can do the rest of the script work in the conversation (journal updates etc).

Here are the scripts that come with the game, that I am using: (maybe i don’t need to share these, but I will in case it helps)

gb_statue_sp: (using variable: int “Effect” = 721)

// gb_statue_sp
/*
    Causes creature to spawn in as a statue.
	
	Clears all creature scripts, sets as plot, applies petrify, etc.
	
	Local vars used with this script:
	(variable set "b_effect")
	int EFFECT - the visual duration effect (defualts to 0 - VFX_DUR_BLUR)
				Example duration effect values:
					int VFX_NONE                        = -1;
					int VFX_DUR_BLUR                    = 0;
					int VFX_DUR_SPELL_FLESH_TO_STONE    = 721;
					int VFX_SPELL_DUR_BODY_SUN			= 924;
	
*/
// ChazM 3/28/07

#include "NW_I0_GENERIC"
#include "ginc_event_handlers"

void main()
{
    object oTarget = OBJECT_SELF;
	SetOrientOnDialog(oTarget, FALSE);
	
    effect ePetrify = EffectPetrify();
	
	int iEffect = GetLocalInt(oTarget, "EFFECT");
	
	if (iEffect != VFX_NONE)
	{
		effect eDur = EffectVisualEffect( iEffect );
	    ePetrify = EffectLinkEffects(eDur, ePetrify);
	}	
	
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePetrify, oTarget);
    PrettyDebug(GetName(oTarget) + " - petrified by spawn");
	
	// prevent from being bumpable
	SetBumpState(oTarget, BUMPSTATE_UNBUMPABLE);
	

	// No need to have event handlers if we are just standing here
	// (Actually, the empty set defualts to something.  To get truly 
	// nothing we must use the nothing scripts).
	SetAllEventHandlers(oTarget, SCRIPT_OBJECT_NOTHING);
	
	// except for dialog in case we want to talk. (need special conv. script)
    SetEventHandler(oTarget, CREATURE_SCRIPT_ON_DIALOGUE, "gb_statue_conv");
	
	// make plot so creature is indestructable	
	SetPlotFlag(oTarget, TRUE);
	
	// Don't run the standard script since all we want is for the creature
	// to be permanently paralyzed like a statue, so no treasure generation,
	// setting AI flags, etc.
	
    // ===================================================================
    // now run the standard spawn.  This may run other scripts, create treasure, and set various flags
    //ExecuteScript(SCRIPT_DEFAULT_SPAWN, OBJECT_SELF);
	
}

gb_statue_hb:(heartbeat script)

// gb_statue_hb
/*
    Statue creature hb script to make sure that they will re-petrify after loaded save.
*/
// MDiekmann 8/30/07

#include "ginc_debug"

void main()
{
    object oTarget = OBJECT_SELF;
	SetOrientOnDialog(oTarget, FALSE);
	
    effect ePetrify = EffectPetrify();	
		
	// remove plot flag so that petrify effect can be used
	SetPlotFlag(oTarget, FALSE);
	
	// reapply effect
	ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePetrify, oTarget);
	PrettyDebug(GetName(oTarget) + " petrified");
		
	// make plot so creature is indestructable	
	SetPlotFlag(oTarget, TRUE);
}

gb_statue_conv: (on conversation statue)

//gb_statue_conv
/*
  OnConversation event handler for statue creatures.
  
*/
// ChazM 3/30/07

#include "nw_i0_generic"
#include "ginc_behavior"

//  The defualt handler won't have creatures talk when they are petrified
//  and also the commandable stuff causes problems.
void main()
{
	PrettyDebug("NW_C2_DEFAULT4");
    ClearActions(CLEAR_NW_C2_DEFAULT4_29);
	
    BeginConversation();
	//SetFacing(GetFacing(OBJECT_SELF), TRUE);	
    return;
}	

EDIT: to clarify, the script doesn’t need to start a conversation. Players will do that themselves after they turn it from stone to flesh (I assume!).

The way I would try to do it I believe is to create a starting conditional script checking if the NPC is petrified or not on the first node of the conversation. It should be doable. I may have some time to look into this later today, but that will have to be in about 3 hours at the earliest. Otherwise I’ll let travus and kevL_s or someone handle this one for you. Lance is not around on sundays so if you need his help he’ll be back tomorrow at the earliest.

That’s cool @andgalf , no stress about the timeframe. This is one of the last things I think I’ll need, scriptwise. I had the same thought as well, about using a global conditional script.

I even thought I was smug, by trying to create my own first ever script: gc_is_plot conditional script. I’ve since deleted it, because it didn’t work. I noticed in the scripts it sets the NPC’s plot state, to true. I had hoped to use that, but then realized that it would still be the same, after stone-to-flesh. So that didn’t work.

So I’m not quite clear on what you’re trying to do here: is there ever any need to talk to the NPC prior to being unpetrified?

Making a check within the conversation to see if they’re not petrified is simple enough, and in fact the regular OnConversation script prevents the conversation from starting if they’re petrified. Is there a reason this isn’t good enough?

1 Like

@Akhacha
I’m glad you mentioned that, because from what I could understand reading the script, i thought it did that. However, clicking on the petrified NPC is still resulting in a conversation starting. I have the conversation set, in the properties tab for the NPC… perhaps this means then, that if I remove the conversation from the NPC, it will work? -although i thought i tried that and it didn’t work.

Or perhaps, does it require me to add the variable “gb_statue_conv” to the NPC with the conversation set that way, is that what it is implying, in the first script then?

gb_statue_sp has the following line:

SetEventHandler(oTarget, CREATURE_SCRIPT_ON_DIALOGUE, "gb_statue_conv");

So if you’re using that, it changes the OnConversation script to gb_statue_conv, which does not prevent a conversation from happening. Copying the script and commenting out that line should make it work properly

Looking at it, it also changes all the other event handlers to no script at all, which may be potentially undesirable.

2 Likes

Alright, I’ll let Akhacha handle this one. He/she is a lot better than me with scripting anyway.

1 Like

Ahh, I see. Yeah i would have thought it would be a simple thing, but it’s a tough one to get going. So if what I understand, you are saying that if I don’t give the NPC that variable and don’t attach the conversation to the NPC, then no conversation will fire. The only issue there is, that when PC’s turn the NPC back to flesh, the NPC will have no conversation to start. Or am I missing something?

Otherwise, open to any other solutions.
Thanks

You probably want to use a different script to petrify the NPC. The one you use is seemingly intended for making NPCs statues, permanently, and doesn’t intend for them to be turned back. The script you use petrifies them on spawn, changes all the event handlers (these are all the scripts you see in the properties list for the creature, On Blocked, On Conversation, On Heartbeat etc.), and… then there’s gb_statue_hb that attempts to repetrify it, except since the initial script doesn’t set that one, it’s not gonna work.

So if you use this, all the things like heartbeat scripts will be set to none, with the exception of On Conversation which is set to a script which specifically allows for conversations to happen.

You’ll want a new On Spawn script that only does the petrification. Using the one you posted as a base, try this:

void main()
{
    object oTarget = OBJECT_SELF;
	SetOrientOnDialog(oTarget, FALSE);
	
    effect ePetrify = EffectPetrify();
	
	int iEffect = GetLocalInt(oTarget, "EFFECT");
	
	if (iEffect != VFX_NONE)
	{
		effect eDur = EffectVisualEffect( iEffect );
	    ePetrify = EffectLinkEffects(eDur, ePetrify);
	}	
	
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePetrify, oTarget);
	
	// prevent from being bumpable
	SetBumpState(oTarget, BUMPSTATE_UNBUMPABLE);

   	// make plot so creature is indestructable	
	SetPlotFlag(oTarget, TRUE);
}

There’s some things in there that may or may not be problematic, depending on what you intend to do with the NPC after, since it changes various flags on the NPC, you can reset them with a On Spell Cast At script, such as:

void main()
{
	if (GetLastSpell() == SPELL_STONE_TO_FLESH)
	{
		SetOrientOnDialog(OBJECT_SELF, TRUE);
		SetBumpState(OBJECT_SELF, BUMPSTATE_BUMPABLE);
		SetPlotFlag(OBJECT_SELF, FALSE);
	}
	ExecuteScript("nw_c2_defaultb", OBJECT_SELF);	// default script, use another if you so wish
}
2 Likes

@Akhacha Thank you very much for your help. The scripters on these forums are all bloody legends, let it be known!

2 Likes

I did this in the MotB Makeover when you encounter the statue of Shandra. She is spawned in as a statue and after stone to flesh is cast she turns to flesh and a conversation is initiated. You wouldn’t have to initiate the conversation automatically but I chose to. If you open the module X1_Makeover_A and look at area 1210_scrypt1 you can see Shandra and the variables that are set on her that control this. The scripts needed are bb_statue_sp, bb_startconv, and co_shandra_ud.

3 Likes