I've been trying to add new texts for the books and scrolls in the game into the original shapes using the handy shape.original function. I know I could just make new shapes with identical book and scroll graphics, but I'd prefer to use this method if at all possible. Now, I've hit an impasse. Here's a sampling of the code I'm using:
void Book shape#(0x282) ()
{
var book_quality = get_item_quality();
if (event == DOUBLECLICK)
{
if (book_quality == 150)
{
UI_play_sound_effect2(SOUND_BOOK, item);
book_mode();
UI_close_gumps();
say("One by one*",
"We all fall down");
return;
}
else
{
Book.original();
}
}
}
void Scroll shape#(0x31d) ()
{
var scroll_quality = get_item_quality();
if (event == DOUBLECLICK)
{
if (scroll_quality == 55)
{
UI_play_sound_effect2(SOUND_BOOK, item);
book_mode();
UI_close_gumps();
say("One by one*",
"We all fall down");
return;
}
else
{
Scroll.original();
}
}
}
I deliberately made the code as identical as possible for testing purposes. The scroll works fine, but for no reason I can figure out, the book just shows "This is not a valid book." Is there some hardcoded limit I've run into? I am using the headers Marzo has so helpfully put together, but I didn't spot anything there that would cause a conflict.
I *think* (without really looking at your code) that you need a shape_info.txt in your patch folder that adds these shapes to books and scrolls.
Look in the code at data/bg/shape_info.txt and copy that over. Near the end of that file is a books section, I think.
Perhaps you can also add your book and scroll as frames to existing ones. Our one tool, which name I forgot and need to look up later, might be able to add frames to a patch shapes.vga. Not sure, though.
--
Read the documentation and the FAQ! There is no excuse for not reading them! RTFM
Read the Rules!
We do not support Piracy/Abandonware/Warez!
The original game hacked function 1592 into books with quality 100 - 179 (and perhaps higher in the original, but Exult only handles these). data/bg/shape_info.txt has that hack dehardcoded.
%%section frame_usecode
#
# Frame- and quality-dependent usecode. This is used only for books in standard BG/SI,
# and probably shouldn't be needed for new games because Exult supports 32-bit usecode.
#
# Format:
# :shapenum/frame/quality/type/funid
#
# frame: The frame that grants the flag or -1 for all frames.
# quality: The quality that grants the flag or -1 for all qualities.
# type: Nonzero if specifying a function name, zero if specifying a number.
#
# Books.
#
:642/-1/100/0/1592
:642/-1/101/0/1592
:642/-1/102/0/1592
:642/-1/103/0/1592
:642/-1/104/0/1592
:642/-1/105/0/1592
:642/-1/106/0/1592
:642/-1/107/0/1592
:642/-1/108/0/1592
:642/-1/109/0/1592
:642/-1/110/0/1592
:642/-1/111/0/1592
:642/-1/112/0/1592
:642/-1/113/0/1592
:642/-1/114/0/1592
:642/-1/115/0/1592
:642/-1/116/0/1592
:642/-1/117/0/1592
:642/-1/118/0/1592
:642/-1/119/0/1592
:642/-1/120/0/1592
:642/-1/121/0/1592
:642/-1/122/0/1592
:642/-1/123/0/1592
:642/-1/124/0/1592
:642/-1/125/0/1592
:642/-1/126/0/1592
:642/-1/127/0/1592
:642/-1/128/0/1592
:642/-1/129/0/1592
:642/-1/130/0/1592
:642/-1/131/0/1592
:642/-1/132/0/1592
:642/-1/133/0/1592
:642/-1/134/0/1592
:642/-1/135/0/1592
:642/-1/136/0/1592
:642/-1/137/0/1592
:642/-1/138/0/1592
:642/-1/139/0/1592
:642/-1/140/0/1592
:642/-1/141/0/1592
:642/-1/142/0/1592
:642/-1/143/0/1592
:642/-1/144/0/1592
:642/-1/145/0/1592
:642/-1/146/0/1592
:642/-1/147/0/1592
:642/-1/148/0/1592
:642/-1/149/0/1592
:642/-1/150/0/1592
:642/-1/151/0/1592
:642/-1/152/0/1592
:642/-1/153/0/1592
:642/-1/154/0/1592
:642/-1/155/0/1592
:642/-1/156/0/1592
:642/-1/157/0/1592
:642/-1/158/0/1592
:642/-1/159/0/1592
:642/-1/160/0/1592
:642/-1/161/0/1592
:642/-1/162/0/1592
:642/-1/163/0/1592
:642/-1/164/0/1592
:642/-1/165/0/1592
:642/-1/166/0/1592
:642/-1/167/0/1592
:642/-1/168/0/1592
:642/-1/169/0/1592
:642/-1/170/0/1592
:642/-1/171/0/1592
:642/-1/172/0/1592
:642/-1/173/0/1592
:642/-1/174/0/1592
:642/-1/175/0/1592
:642/-1/176/0/1592
:642/-1/177/0/1592
:642/-1/178/0/1592
:642/-1/179/0/1592
%%endsection
Okay, I've tried adding that shape_info.txt both to my mod's data folder and into the patch folder for the game, but the new text still does not show in the book.
Unfortunately, the specific settings Exult is using overwrites the general setting I posted. You would need to add
:642/-1/150/0/642
instead to overwrite that quality. You could just use the following instead of messing with shape_info.txt every time you use a quality from the long list above.
// handles book qualities 100-179 - this function could use a better name
void middleBookQualities object#(0x638)()
{
var book_quality = get_item_quality();
if (event == DOUBLECLICK)
{
if (book_quality == 150)
{
UI_play_sound_effect2(SOUND_BOOK, item);
book_mode();
UI_close_gumps();
say("One by one*",
"We all fall down");
return;
}
else
{
middleBookQualities.original();
}
}
}
You should also be able to use qualities 180-255 in the Book shape#(0x282) function.
Yes, those qualities should use the original shape 0x282 and work fine. 0x282 handles 0-99 and 180-255. 0x638 handles 100-179 if you do not make changes to shape_info.txt.
I ran into that problem too a while back. I just got fed up with trying to figure it out I copied the book shapes and made a separate shape for custom books and scrolls which seemed to work out fine.
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
I think that is the better option with an extensive mod like yours. I'm just looking to add a couple of things on top of what is already there. I've succesfully done new sign texts and crystal ball views using similar code.