Trying to do an npc script but it won't compile properly. how do you "end" an NPC conversation?
case "bye":
say("\Goodbye." *");
is basically what I have at the end but it says syntax error. I've altered the damn thing so many times I don't know what to do. Does anyone have a basic template for doing NPC conversations? thanks
NPC scripts..
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
-
- Posts: 565
- Joined: Thu May 14, 2020 1:34 pm
NPC scripts..
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Re: NPC scripts..
Like this:
(there is a great deal of usecode in the Exult source which can be used for a bit of learning: Keyring, SI Fixes and Isle FAQ all have it)
Code: Select all
converse(0)
{
case "bye":
// say whatever needs to be said, set whatever flags need to be set
break;
}
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
-
- Posts: 565
- Joined: Thu May 14, 2020 1:34 pm
Re: NPC scripts..
I don't know how to decompile any of that, I can never get it to work.
The error I keep getting is "syntax error, unexpected identifier, expecting '('
The error I keep getting is "syntax error, unexpected identifier, expecting '('
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
-
- Posts: 565
- Joined: Thu May 14, 2020 1:34 pm
Re: NPC scripts..
Ok tell me if I have this right:
case "example":
("\backslashes for every conversation line?\");
break;
}
Is that the correct way to do a conversation line? I was looking around on the quest and interactions mod and that is how most of the convo lines were. Is there something else?
case "example":
("\backslashes for every conversation line?\");
break;
}
Is that the correct way to do a conversation line? I was looking around on the quest and interactions mod and that is how most of the convo lines were. Is there something else?
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Re: NPC scripts..
What is there to decompile? The usecode examples I mentioned are plain text files that even Notepad can read.I don't know how to decompile any of that, I can never get it to work.
There are several errors here; the "proper" form would be this:("\backslashes for every conversation line?\");
Code: Select all
say("\"backslashes for every conversation line?\"");
Code: Select all
say("@backslashes for every conversation line?@");
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
-
- Posts: 565
- Joined: Thu May 14, 2020 1:34 pm
Re: NPC scripts..
I did some playing around and figured that much out, but I'm having trouble with the npc not responding to the doubleclick. I saw the Iolo example here not too long ago, with the
var IOLO = -1;
var DOUBLECLICK= 1;
lines, I assume the 1 in the double click line is the NPC number. what is the -1? How do you determine this number?
I know how to find the object number, but I can't seem to figure out how to get the npc to come up in conversation. Like for example, for npc 147 or something, what would the first line be?
var "NPC(whoever it is)" = ?
var DOUBLECLICK = 147
my usecode compiles perfectly, it just doesn't register with the npc for some reason when i double click.
thanks for your help!
var IOLO = -1;
var DOUBLECLICK= 1;
lines, I assume the 1 in the double click line is the NPC number. what is the -1? How do you determine this number?
I know how to find the object number, but I can't seem to figure out how to get the npc to come up in conversation. Like for example, for npc 147 or something, what would the first line be?
var "NPC(whoever it is)" = ?
var DOUBLECLICK = 147
my usecode compiles perfectly, it just doesn't register with the npc for some reason when i double click.
thanks for your help!
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Re: NPC scripts..
The value of "DOUBLECLICK" has nothing to do with the NPC in question; it is fixed. Whenever an NPC is double-clicked, his usecode function is called with the 'event' set to 1. Likewise, when the function is called by an script, 'event' is usually 2, when you spend too much time near an NPC (that is not on the party) 'event' is 0, etc. There is a list of values in "content/bgkeyring/src/headers/constants.uc".
"var IOLO = -1;" is because Iolo's NPC number is 1. NPCs are referred to by negative numbers; take the number from the cheat screen and multiply by -1. The exception is the avatar, which is identified by -356.
You assign a function to an NPC by the function's identification number. When the function is declared, you have one of the following syntaxes:
In order:
* 'void' means that a function does not return anything. 'object#' and 'shape#' require 'void'.
* 'arglist' is an optional list of parameters passed to the function. 'shape#' and 'object#' functions cannot have any arguments.
* 'shape#' and 'object#' mean that the function can be used in scripted animations. A 'shape#' function will automagically work for the shape it represents (see 'numberhere') and will be called as needed when an object of the given shape is double-clicked. For NPCs, eggs and weapons, you will want an 'object#' function instead; see 'numberhere' for details. Both types of functions have/require an item reference that must be supplied when the function is called; this is accessed by the 'item' variable, and it is a reference to the object in question (that is, the NPC/shape/egg for which the function was called).
* 'var' means that the function returns a value.
* 'numberhere': this identifies the function. In most cases, you will want to omit it or set it to -1; 'object#' and 'shape#' do not let you omit it, and 'shape#' functions do not let you set it to -1. If 'numberhere' is -1, the function will be autonumbered by UCC (and I *strongly* suggest adding "#autonumber 0xC00" at the top of your usecode file, at about the same place you add the "#game" directive).
For the first 256 NPCs (*zero* to 255), 'numberhere' *must* be 1024 + NPC number; for Iolo, that would be 1025 (note that 1025 = 0x401 in hexadecimal numbers). For these NPCs, a function with that usecode number will be called if such a function exists.
For NPCs whose numbers are 256 or more, you can set the function by name in Exult Studio when you edit the NPC; likewise, you can set the function by name for eggs. In both cases, you can set 'numberhere' to -1. In these cases, the function will be called only if you assign it in ES; if an NPC has no function assigned to it, its shape function will be called instead, while nothing at all will happen for eggs.
For shapes, 'numberhere' *must* be the shape number as seen in ES. If such a function exists for a given number, the function will be automatically called. The first 1024 shapes (*zero* to 1023) correspond to the first 1024 usecode functions (again, *zero* to 1023); you should avoid having functions in that range unless you want to override the shape's function.
For weapons, you still have to specify the function by usecode number; in that case, 'numberhere' must be the same as what was specified in the weapon tab in ES.
In all cases: if a function overrides a pre-existing function from the original game, you can call the latter by appending ".original" to the function name when calling it; thus, "Iolo.original()" would call Iolo's original usecode function (assuming you have a function named "Iolo").
"var IOLO = -1;" is because Iolo's NPC number is 1. NPCs are referred to by negative numbers; take the number from the cheat screen and multiply by -1. The exception is the avatar, which is identified by -356.
You assign a function to an NPC by the function's identification number. When the function is declared, you have one of the following syntaxes:
Code: Select all
void FunctionName_1 object#(numberhere) ()
{
// code here
}
void FunctionName_2 shape#(numberhere) ()
{
// code here
}
void FunctionName_3 numberhere (arglist)
{
// code here
}
var FunctionName_4 numberhere (arglist)
{
// code here
}
* 'void' means that a function does not return anything. 'object#' and 'shape#' require 'void'.
* 'arglist' is an optional list of parameters passed to the function. 'shape#' and 'object#' functions cannot have any arguments.
* 'shape#' and 'object#' mean that the function can be used in scripted animations. A 'shape#' function will automagically work for the shape it represents (see 'numberhere') and will be called as needed when an object of the given shape is double-clicked. For NPCs, eggs and weapons, you will want an 'object#' function instead; see 'numberhere' for details. Both types of functions have/require an item reference that must be supplied when the function is called; this is accessed by the 'item' variable, and it is a reference to the object in question (that is, the NPC/shape/egg for which the function was called).
* 'var' means that the function returns a value.
* 'numberhere': this identifies the function. In most cases, you will want to omit it or set it to -1; 'object#' and 'shape#' do not let you omit it, and 'shape#' functions do not let you set it to -1. If 'numberhere' is -1, the function will be autonumbered by UCC (and I *strongly* suggest adding "#autonumber 0xC00" at the top of your usecode file, at about the same place you add the "#game" directive).
For the first 256 NPCs (*zero* to 255), 'numberhere' *must* be 1024 + NPC number; for Iolo, that would be 1025 (note that 1025 = 0x401 in hexadecimal numbers). For these NPCs, a function with that usecode number will be called if such a function exists.
For NPCs whose numbers are 256 or more, you can set the function by name in Exult Studio when you edit the NPC; likewise, you can set the function by name for eggs. In both cases, you can set 'numberhere' to -1. In these cases, the function will be called only if you assign it in ES; if an NPC has no function assigned to it, its shape function will be called instead, while nothing at all will happen for eggs.
For shapes, 'numberhere' *must* be the shape number as seen in ES. If such a function exists for a given number, the function will be automatically called. The first 1024 shapes (*zero* to 1023) correspond to the first 1024 usecode functions (again, *zero* to 1023); you should avoid having functions in that range unless you want to override the shape's function.
For weapons, you still have to specify the function by usecode number; in that case, 'numberhere' must be the same as what was specified in the weapon tab in ES.
In all cases: if a function overrides a pre-existing function from the original game, you can call the latter by appending ".original" to the function name when calling it; thus, "Iolo.original()" would call Iolo's original usecode function (assuming you have a function named "Iolo").
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
-
- Posts: 565
- Joined: Thu May 14, 2020 1:34 pm
Re: NPC scripts..
Alright, I fixed it, thanks a lot man!
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/