Jump to content

Home

Trouble with conditional scripts, again :P


Exile007

Recommended Posts

Hey, sorry to pester you guys about scripts again, but I wrote this script and it compiles fine, but it just doesn't work in game.

 

I'm trying to make a fairly simple one, the script is supposed to spawn a creature and start a conversation once something has happened. This is what I'm using to set the GlobalNumber:

 

void main() 
{
SetGlobalNumber("Sith_attack", 4);
}

 

And the check to see if the requirement has been fulfilled:

 

void main()
{
int nThingy=GetGlobalNumber("Sith_attack");

if (nThingy == 4)
{
object oPC=GetFirstPC();

CreateObject(OBJECT_TYPE_CREATURE, "n_zekk", Location(Vector(-0.22019,213.73494,17.49721), 269.35315));
object oZekk=GetObjectByTag("zekk");
AssignCommand(oZekk, ActionStartConversation(oPC, "zekk"));
}

}

 

Does anyone have any idea what I did wrong?

Link to comment
Share on other sites

Hey, sorry to pester you guys about scripts again, but I wrote this script and it compiles fine, but it just doesn't work in game.

 

Have you added the Sith_attack global number variable to the globalcat.2da file and put that in the override folder? Global variables needs to be listed in this file or the game won't keep track of them.

 

Is the n_zekk.utc file either in the module this is run from, or in the override folder? Also make sure the coordinates are valid, so it isn't spawned elsewhere.

 

That's the only things I can think of since I can't spot anything that's technically wrong with your script. :)

 

 

Though you can write it a bit shorter by eliminating a few variables that are only used once, and cutting off a few decimals from the coordinates since you won't notice any differences with fractions of a millimeter ingame. :) It's also better to assign the object reference directly to the object you create rather than get it by tag afterwards, since you're sure to get the correct object this way. Like:

 

void main() {
   if (GetGlobalNumber("Sith_attack") == 4) {      
       object oZekk = CreateObject(OBJECT_TYPE_CREATURE, "n_zekk", Location(Vector(-0.22, 213.73, 17.49), 269.35));
       AssignCommand(oZekk, ActionStartConversation(GetFirstPC(), "zekk"));
   }
}

Link to comment
Share on other sites

Have you added the Sith_attack global number variable to the globalcat.2da file and put that in the override folder? Global variables needs to be listed in this file or the game won't keep track of them.

 

Is the n_zekk.utc file either in the module this is run from, or in the override folder? Also make sure the coordinates are valid, so it isn't spawned elsewhere.

 

That's the only things I can think of since I can't spot anything that's technically wrong with your script. :)

 

 

Though you can write it a bit shorter by eliminating a few variables that are only used once, and cutting off a few decimals from the coordinates since you won't notice any differences with fractions of a millimeter ingame. :) It's also better to assign the object reference directly to the object you create rather than get it by tag afterwards, since you're sure to get the correct object this way. Like:

 

void main() {
   if (GetGlobalNumber("Sith_attack") == 4) {      
       object oZekk = CreateObject(OBJECT_TYPE_CREATURE, "n_zekk", Location(Vector(-0.22, 213.73, 17.49), 269.35));
       AssignCommand(oZekk, ActionStartConversation(GetFirstPC(), "zekk"));
   }
}

 

That was actually the original script, but I thought there was something wrong with it, so I changed it.

 

Whoops, didn't know that I needed to add anything to globalcat.2da, thanks stoffe!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...