Couple of dumb questions

NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Locked
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Couple of dumb questions

Post by Donfrow »

I have a couple of dumb and probably simple questions. Any help is appreciated.

1. Text on signs.

As I understand it one would use UI_book_mode_ex() to display text on a wooden or gold sign. As this does not perform any translation as indicated on Marzo's site how does one go about showing text on wooden signs that is actually translated (such as a sign that says "Working Sign" instead of an untranslated version)?

2. Fading the pallette.

To fade the screen UI_fade_palette is used. Depending on the true/false it fades it in/out.

How does one make it so it fades out, then back in? I tried along the lines of

UI_fade_palette(25, 0)
UI_fade_pallete(25, 1)

(or whichever the true/false values are... I get them mixed up a lot but have tried it the other way around to, also, is the ignored 'unk' put in so UI_fade_pallete(25, 0, 0)?)

It will fade and stay black and I have to end the program in order to get out of SI. Do I need some sort of pause in between so that it will fade back in, or is it incorrect how I am doing it altogether?

Thanks
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

As this does not perform any translation as indicated on Marzo's site how does one go about showing text on wooden signs that is actually translated
You would check the avatar's READ flag (flag 34) and display the translated/untranslated text depending on the case. This is implied (although not explicitly stated) by the text in the "Important Notes" box right under UI_book_mode_ex.
Fading the pallette
You must put the 'unk' parameter there, even if you just put a zero there -- otherwise, Exult will assume that the third parameter is zero.
or whichever the true/false values are
false is 0 or an empty array/uninitialized variable, true is everything else.
UI_fade_palette(25,0 , 0)
UI_fade_pallete(25,0 , 1)
Even with the correction I added above, this would not work: you need to add a time delay (using a script block to call a function which unfades the screen) between fading and unfading.
------
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]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Thanks, have the fading working now (sort of) in that it doesn't look up.

"You would check the avatar's READ flag (flag 34) and display the translated/untranslated text depending on the case. This is implied (although not explicitly stated) by the text in the "Important Notes" box right under UI_book_mode_ex."

Sorry for being so obtuse but I don't understand this. I understand setting the flags but when it states what's below I'm getting confused between what you're saying.

"Unlike the 'UI_book_mode' intrinsic, this intrinsic performs *no*
translation of any kind if the avatar's 'READ' flag is set."

But you seem to be saying if you check if the READ flag is there, it should translate it?

I've tried as follows:

signs shape#(379) ()
{

var quality = get_item_quality();

if (event == DOUBLECLICK)
{

UI_set_item_flag(AVATAR, 34); // read flag

UI_book_mode_ex(false, 1, 44);

if (quality == 0)
{
say("Test");
}
else
{
say("Generic Wooden Sign");
}

}
}
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

Thanks, have the fading working now (sort of) in that it doesn't look up.
A working screen fade comes from the moongate/orb of the moons code; here is a stripped-to-the-bones version:

Code: Select all

GenericPaletteUnfade object#() ()
{
	// Do stuff

	// Unfade the palette
	UI_fade_palette(12, 1, 1);

	// Do more stuff
}

GenericPaletteFade ()
{
	// Do stuff

	// Fade to black:		
	UI_fade_palette(12, 1, 0);

	// Do more stuff

	script AVATAR {nohalt;	call GenericPaletteUnfade;};

	// Do even more stuff
}
But you seem to be saying if you check if the READ flag is there, it should translate it?
No, I am saying that you should check the flag and then *you* should translate it if needed. Like this:

Code: Select all

GenericTextDisplay ()
{
	// Let's pretend this is a gargish sign.
	// Assuming AVATAR, SIGN_GUMP, GARGISH_FONT and NORMAL_FONT are defined elsewhere
	// Also assuming that there is a gargish font available
	if (!AVATAR->get_item_flag(READ))
	{
		UI_book_mode_ex(true, GARGISH_FONT, SIGN_GUMP);
		say("in mani lem");
	}
	else
	{
		UI_book_mode_ex(true, NORMAL_FONT, SIGN_GUMP);
		say("Healer");
	}
}
------
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]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Ok, I understand it now that you are using two different fonts.

What I'm trying to do is always have translation done since I find it annoying to have to translate in game, so I would always want the else statement to be the one done.

In SI, I'm trying to use font # 1 (the wooden sign font) which is 125 frames consisting of the untranslated lettering and the translated lettering. I made a scroll that sets the read flag to true (it is set to read in the F2 cheat menu to I know the read flag is set) but no matter what I do it's always coming up with something like € instead of e.

In your example it's changing the actual font used which I do understand, but I do not understand how to use the appropriate font frames that correspond to the lettering for the particular font shape.

Thanks for the link to the fading as well.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

If you take a look at the fonts in ES, you might get a better understanding of what is going on: in font #1, the uppercase letters are normal latin characters, while the lowercase letters are Britannian runes. Non-runic text, in this case, is composed of uppercase letters, numbers and some punctuation signs, while runic text would be composed of lowercase letters plus the characters "( ) * + , |" (without the quotes and spaces). The translation performed by Exult would consist of (a) changing all letters to uppercase and (b) converting "(" to "TH", ")" to "EE", "*" to NG", "+" to "EA", "," to "ST" and "|" to space. Also, in SI, there can be font substitution from fonts 10 and 8 to fonts 6 and 1, respectively.

BTW, the above applies to UI_display_runes only; UI_book_mode only does a simple font substitution when READ flag is set: from font 8 to font 4.
------
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]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Ohh I get it now. Thanks a ton
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Ok another dumb question that I can't seem to figure out.

A simple pause.

Say I want to have 2 delayed lightening bolts in a function.

Example such as the avatar triggers an egg.

egg()
{
UI_sprite_effect(17, 1400, 1108, 0, 0, 0, -1);

// I want the pause here, such as GenericPause()

UI_sprite_effect(17, 1400, 1108, 0, 0, 0, -1);
}

I think I would make another function, like a generic pause.

GenericPause()
{
script AVATAR
{
nohalt;
wait 10;
};
}

But that does not seem to work, both lightening bolts happen at the same time. I've fiddled with the numbers so I figure it's something to do with my script. Essentially, what I'm looking for is a function that, whenever I call it, will "pause" the game for a couple secionds so that different sprite effects can occur.

One more question.

As I've been modding Serpent Isle, I want to stop the monks from resurrecting the avatar when he dies. I haven't quite figured out what I want to do once the avatar dies, but simply resetting the game at the moment would suffice (such as what happens when you die in TFL).

However, I have no idea where to even start or how to change this.

Thanks
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

A simple pause.
Usecode is a 'modal' language in that everything will happen sequentially but "at once"; that is, no time (ideally) elapses between the first and last commands executed.

Similarly, the "GenericPause" function you wrote does not work as you would like it to; all scripts are 'queued' and only begin executing *after* the usecode machine finishes.

So, to do a 'pause' you will have to hatch the egg multiple times. One example of how this could be done, using your example:

Code: Select all

egg [b]object#()[/b] ()
{
	script item
	{
		call showsprite;
		wait 10;
		call showsprite;
	}
}

showsprite [b]object#()[/b] ()
{
	UI_sprite_effect(17, 1400, 1108, 0, 0, 0, -1);
}
This will make the egg call the 'showsprite' function twice, with a 10-tick delay (1 second at 10fps). BTW, the 'object#()' is for use with more recent versions of UCC ans ES.
------
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
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

As I've been modding Serpent Isle, I want to stop the monks from resurrecting the avatar when he dies.
Ooops, forgot about this. For that, and since you are using SI, you must edit function 0x400, which is called when the avatar dies.
------
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]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Thanks, I forgot about the object#().

For resurrecting, if I make a function with 0x400, if the Avatar is killed it will do whatever I made the new 0x400 function do, correct? Ie, avatar dies he's teleported to locx locy.

The "at once" explains why I could never figure out a pause on my own, but with your small script I finally have my first pause/wait. Hooray! However...

Suppose that I want to have multiple locations that I want to use sprite 17. For one location I can use a function like you created:

showsprite object#() ()
{
UI_sprite_effect(17, 1400, 1108, 0, 0, 0, -1);
}

But if I want to call the same function just with different location variables, is there a way to do it? I've tried things along the lines of

showsprite object#() (loc)
{
UI_sprite_effect(17, loc[1], loc[2], 0, 0, 0, -1);
}

But the compiler pops up with:

Functions declared with 'object#' cannot have arguments.

Is there a way to use the same function just with different values, or would I need multiple functions that do the same thing, just in different locations? Ie

showsprite1 object#() ()
{
UI_sprite_effect(17, 1, 1, 0, 0, 0, -1);
}
showsprite2 object#() ()
{
UI_sprite_effect(17, 2, 2, 0, 0, 0, -1);
}

Thanks again for all your help, and I'll keep trying to keep the questions at a minimum.
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Oh, one more related now that I understand how to put in delays.

Currently all my NPC's say nothing over their heads when double clicked. Now that I understand how it's done in TFL, is there any way to do it other than how you have it done in TFL?

You have it done (eliminated some of it for ease) like this:

script item
{
say bark;
wait 8;
call Iain;
}

Currently all my NPC text is in a npc file, such as testnpc.uc which has all the dialog. Is there a way to to avoid having to go through each NPC .uc file to make a seperate file of dialog (like you have for iain_dialog.uc)

Something like this is? (ignoring that this is not a complete NPC function)

script item
{
say bark;
wait 8;
}

UI_show_npc_face(item);
UI_add_answer("Name");
UI_add_answer("Job");
UI_add_answer("Bye");

If I understand usecode correctly now the script item will be running at the same time as UI_show_npc_face. This would result in there being no way without a seperate function and I would have to put all my dialog in another file and have something like:

script item
{
say bark;
wait 8;
call testnpc_dialog;
}
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Bah 3rd post in a row but realized something about the Avatar getting killed and my question. 0x400 is the Avatar's base usecode correct? If I didn't edit it (since I don't know how to edit the existing usecode, and as I understand it decompiling it doesn't return anything that is easily readable) and I just made a new function with 0x400, I would pretty much screw up everything about the Avatar right?
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

For question (1) -- making the sprite show in different locations: you can do this in two basic ways: (a) change the egg's quality and use it do determine the location you want or (b) pass a custom usecode event value to the script call.

For question (2) -- NPCs barking when double-clicked: you don't need to separate out the content, you can keep all the dialog in the same function if you want; but you will have to differentiate between double-clicks to the NPC and the scripted call (can easily be done through event) to determine if you should show the dialog or the bark. For example, in a function called testnpc:

Code: Select all

if (event == DOUBLECLICK)
{
    script item
    {
        say bark;
        wait 8;
        call testnpc, TALK;
    }
    // avatar's script here
    abort;
}

else if (event == TALK)
{
        // dialog here
}
Since you are using SI, you can also do it the SI way -- on a double-click, have the bark pop up on the NPC's head and set the schedule to talk; when the function gets fired again with the TALK event, reset the schedule and display the dialog.

As for question (3) -- editing function 0x400 and screwing up the avatar: don't worry, that function is only ever called when the avatar dies.
------
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]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Thanks, I understand it all except for 1(b).

I don't have much of an idea about that one. But no matter, the main problem is solved.

Thanks again!
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

I understand it all except for 1(b).
It is the basis of the example I gave:

Code: Select all

call testnpc, TALK;[/quote]
------
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]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Oh ok gotcha.
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by Donfrow »

Currently it seems the max characters to set the NPC name to (and appear over their heads) is 16.

Is this something that is hard coded into Ultima or can this be increased?
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Couple of dumb questions

Post by marzo »

Hard coded; changing this requires changing the savegame format.
------
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]
Locked