Will this script work?

Sorry but I really can’t face testing this as it’ll take me about an hour and a half to get to this point in the module and I don’t want to start putting in all the characters involved and setting their global ints etc.

I’ve never used a global int in a script so I just copied one that works for starting conversations from a journal condition and changed the

nInt=GetLocalInt(oPC,“NW_JOURNAL_ENTRYfind_primrose”); to
nInt=GetGlobalInt(“scythe_back”); instead.

It does compile but I don’t know if it’s going to work and can’t face testing it just in case it doesn’t. If something happens upstairs a conversation should fire when you go back down. I set the global int upstairs as 1 on the conversation line if it happens.

This is it, my scripting masterpiece !

void main()
{
object oPC=GetEnteringObject();
if(!GetIsPC(oPC))return;
int nInt;
nInt=GetGlobalInt(“scythe_back”);
if(nInt<1)
return;
object oTarget;
oTarget=GetObjectByTag(“h_guard1”);
AssignCommand(oTarget,ActionStartConversation(oPC,“h_guard”,TRUE));
}

Please feel free to tell me it’s a total mess and will never work !

I think it seems fine. How does your SetGlobalInt look? How do you set it and where? Do you use the ga_global_int perhaps in a conversation?

By the way, when writing code here on the forums write ```C before it and ``` after. That way it’s easier to read the code. Or just use the preformatted text sign.

1 Like

Ok, so you use ga_global_int first and then your code for firing the conversation, right?

Yes the global int is with the generic ga_global_int on the conversation line, nothing too technical from me ! Then when you leave the area and go downstairs this script is in the on enter box for the area to start the conversation.

I’ll leave it in as it is and hopefully it’ll all work as planned when I test the module. I just discovered the n2_killerweapon to give to myself with the console and it makes testing a lot easier and faster, so long as you’ve already made sure it’s balanced of course !

Thank you for giving me some hope that finally this conversation will work. I’ve used triggers with scripts, normal triggers and even created invisible kobolds that own conversations ( yes I do that ) but it never worked… Fingers crossed this time I can finally get it going.

I’d check if oTarget exists and do a clear actions on oTarget first in case it is doing some action.

oTarget is just an npc in the tavern, is he likely to be doing something or could he be doing something by accident that I wouldn’t know about, he’s just standing there ? Is it better to just stick in a companion’s tag instead as they’re following you and the conversation has all the speakers and listeners put in ?

You mean to put a companion tag in this?

You could do that, of course. Or something like this perhaps (taking into account what rjshae said)?

void main()
{
	
object oPC=GetEnteringObject();
if(!GetIsPC(oPC)) return;

int nInt;
nInt=GetGlobalInt("scythe_back");

if(nInt<1) return;

object oTarget;
oTarget=GetObjectByTag("h_guard1");

   if(GetIsObjectValid(oTarget))
   {
   AssignCommand(oTarget, ClearAllActions());
   AssignCommand(oTarget,ActionStartConversation(oPC,"h_guard",TRUE));
   }
}
2 Likes

If you want to you could even do the code a bit more compact, like this:

void main()
{
	
object oPC=GetEnteringObject();
if(!GetIsPC(oPC)) return;

if(!GetGlobalInt("scythe_back")) return;

object oTarget=GetObjectByTag("h_guard1");

   if(GetIsObjectValid(oTarget))
   {
   AssignCommand(oTarget, ClearAllActions());
   AssignCommand(oTarget,ActionStartConversation(oPC,"h_guard",TRUE));
   }
}
2 Likes

Thank you very much andgalf, I think I’ll stick in the extra lines as in your first suggestion because I’ve changed the script so the global int is <2 that way I can set it as two in the first conversation node and change it to 1 in the second conversation. As I was thinking this conversation could now happen every time you walked into the area !

I know I could probably set it to 0 with the same effect but I feel safer with whole numbers !

I’ve just put it in and it’s all compiled and ready to go, maybe I will finally get a working conversation now !

1 Like

It worked perfectly ! This is the first time that a certain conversation which I gave up on years ago actually fired. The original conversation I used the script for was fine first time so I stuck it on a long lost conversation but had to use one of my invisible tiny kobolds as the conversation owner as everybody else in the area was dead. I went through the module very fast with the lethal sword and tested a few hours of module in about 30 minutes leaving lots of baddies running after me !

:smiley: :smiley: :smiley: Very happy me :smiley: :smiley: :smiley: Thank you !

3 Likes