Page 1 of 1

ES Guides tutorial question

Posted: Mon Jul 04, 2005 9:54 am
by Tristan de Inés
Going through the usecode for dummies tutorial (adding an NPC and usecode for it), I can't get the usecode to work and I don't see whats wrong.

-The usecode function number is the same as the NPC function number
-the usecode is the same as in example 2b3
-the usecode.uc is in the patch folder of bg
-I compiled usecode.uc using ucc.exe and renamed "usecode.uco" into "usecode"
-"usecode" is in the patch folder
-I started a new game

Well, there's Bob in the middle of the pub, dancing happily, but he doesn't say a word.
Trying the conversation tutorial with the doubleclick event doesn't work either.

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 9:56 am
by Tristan de Inés
Using latest snapshots of Exult and ExultStudio.

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 11:34 am
by Tristan de Inés
nevermind... I didn't have the right "patch" directory set in exult.cfg

This is fun... usecode rocks! ;)

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 1:07 pm
by marzo
A good way to learn usecode is to see what others have done. I recommend that after the tutorials, you check out Alun Bestor's Quests and Iteractions mod and my SI Fixes.

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 1:53 pm
by Tristan de Inés
I just decompiled BG's usecode and ran Tawns Visual Basic tool over it, to make it more readable (nice work there, by the way). I'm hoping to find out what the intrinsics are and how they can be effectively used.

Or is there already an intrinsic list with descriptions somewhere?

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 2:31 pm
by marzo
It is my tool actually, but nevermind :-) Most of the documentation of the intrinsics are in the Exult source, but there was someone (Pertex IIRC) writting documentation for it; I think there is a homepage, but I can't find the URL anywhere.

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 2:43 pm
by marzo
And before I forget: there are some parts of the usecode (both BG's and SI's) which are horribly mangled by the tool. I haven't yet have time to figure out what is causing it... but I intend to fix it when I do. Usually, these places can be spotted easily, but I've run accross some usecode functions which had very subtle errors :-(

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 3:59 pm
by Tristan de Inés
> It is my tool actually, but nevermind

Oops, sorry! Anyways, nice work. Would you put the code to your tool online sometime? If I'm really bored once, I just might reimplement it in Java, to make it available to non-windows users, and perhaps perform some meaningful function-renaming while I'm at it.


Another thing I wanted to ask, what happens if you include an existing function in a patch-usecode? Is the old function overwritten or is the new function ignored?

Re: ES Guides tutorial question

Posted: Mon Jul 04, 2005 4:33 pm
by marzo
The old function is ignored, while the new one runs. You can still access the old function, though, if you need it; use "function_name.original();" for that.

Re: ES Guides tutorial question

Posted: Tue Jul 05, 2005 8:23 am
by artaxerxes
I have another question regarding the usecode tutorials and ucc:

I created a usecode egg that triggers when you approached a standing NPC. The NPC usecode is 0x401, so that's what I put in the egg. The usecode function itself contains the following code:
#include "ucdefs.h"

const int MONK = 1;

monk_dialogue 0x401 ()
{
var given = 0;
if(event == 0)
return;
if(event == 1){
item.say("The monk seems to ignore you");
item.hide();
return;
}
if(event == 3)
{
MONK.say("A cloaked individual stands still and silent, while a muffled voice comes from a cauldron. @Do you need help?@");
converse ([ "Bye", "Heal", "Uncurse","Donate"])
{
case "Bye":
say("@Keep safe.@");
break;
case "Heal" (remove):
say("@You have been healed!@");
case "Uncurse" (remove):
say("@You have been uncursed!@");
case "Donate" (remove):
given = given + 1;
say("@Thank you!@");
if(given == 5)
{
say("@You are blessed!@");
} else {
add("Donate");
}
}
MONK.hide();
}
}


If I replace "MONK" by "item", the function stops working. That is, if the function is called by the usecode egg, I have no access to the item variable. Is it me who does something wrong or am I missing something?

thx
Artaxerxes

Re: ES Guides tutorial question

Posted: Tue Jul 05, 2005 12:35 pm
by marzo
If you define MONK = -1 instead it will work; the usecode number of NPCs must is negative. As a general rule, the NPC's number in usecode is the negative of what you see in Exult Studio (or in the Cheat Screen). The exception is the Avatar, whose usecode id is -356.

Re: ES Guides tutorial question

Posted: Tue Jul 05, 2005 1:46 pm
by SB-X
The behavor is correct isn't it? If it's called by the egg, then that's the item.

Re: ES Guides tutorial question

Posted: Tue Jul 05, 2005 2:14 pm
by marzo
Yes, I forgot to say that. Actually, it seems that I have misunderstood Artaxerxes' question entirely :-) When the egg calls an usecode function, the egg is the 'item'; and since the egg cannot be translated to an NPC, it can't say anything, which is why the monk would not say anything.

Re: ES Guides tutorial question

Posted: Thu Jul 07, 2005 9:38 am
by artaxerxes
now this makes sense. Thx

Artaxerxes

Fatal: Not able to open ./cache/production/data_global.php