Page 1 of 1

Help with usecode

Posted: Sat Nov 26, 2016 1:17 am
by Drew
Hi,

I have been working on a mod since early this summer. I'm hoping to get this done soon for a gift for someone.

I am now to the point where I need to be able to work with the usecode to (1) write a conversation for a new npc, (2) alter conversations for a couple of existing npcs, and (3) give attributes to a couple of items.

Problem is that I have no idea what I am doing. What file do I need to edit and what program do I need to edit it with in order to work with the code?

I'm hopeful that once I see the code itself is written I will be able to figure out what I need to do via trial and error. I don't have any programming experience.

Any help would be greatly appreciated.

Thanks!

Re: Help with usecode

Posted: Sat Nov 26, 2016 9:10 am
by Dominus
You will need to write Usecode in a text editor and then compile it with the ucc.exe in our tools snapshot (if you are on Windows).
A good easy test case is the SF Island mod at https://github.com/exult/exult/blob/mas ... usecode.uc

More elaborate and advanced but good for learning stuff are the BG Keyring https://github.com/exult/exult/tree/mas ... /bgkeyring and SI Fixes mod https://github.com/exult/exult/tree/mas ... nt/sifixes .
Both have their usecode.uc in the src subfolder and that pulls in different usecode files in the subfolders of src.

You will then assign usecode to NPCs you create. Changing usecode for existing NPCs can mean a lot of work as you may have to include the complete usecode of this NPC.

Once it is compiled, place the usecode file in your mod/patch folder.

Re: Help with usecode

Posted: Sat Nov 26, 2016 7:48 pm
by Knight Captain
Hopefully the awesome new UCXT will make future changes easier. :)

Drew, can you email me your latest versions of this? I forget if I sent you the conversation template I did for Vasculio.

Re: Help with usecode

Posted: Mon Nov 28, 2016 2:34 am
by Drew
Of course! Which specific files do I need to send you? You did send that to me and it should make this easier. I'm still not quite sure if I know how to get started though.

Re: Help with usecode

Posted: Mon Nov 28, 2016 2:41 am
by Drew
Dominus, thank you. So if I understand this correctly I need to write code in a notepad file, copy and paste it into the dos looking screen, and hit enter and that will compile it? And just so I understand, to compile it means what?

How do I assign the usecode to the specific npc?

Where do I find the complete code for the given npc?

Sorry, as I said I don't have any experience with this and am trying to learn.

Drew

Re: Help with usecode

Posted: Mon Nov 28, 2016 9:16 pm
by Knight Captain
Zip up whatever you've got.

Compile means to translate into computer-usable language.

By default each NPC uses a specific object number. You can see this in the F2 cheat menu. While you can change the default assigned object, I haven't found a reason to do so unless you run out of NPC spots (355 total).

To find the current code you'd need to use the UseCode eXtracTer UCXT to see it.

Re: Help with usecode

Posted: Mon Dec 12, 2016 3:28 pm
by Knight Captain
Drew, nice job on the lighthouse! I replied to your email.

Re: Help with usecode

Posted: Mon Dec 12, 2016 3:36 pm
by Dominus
Lighthouse? Need to see that! I've done a lighthouse in ES last week ;)

Re: Help with usecode

Posted: Mon Dec 12, 2016 9:23 pm
by Dale
Share everything!

Re: Help with usecode

Posted: Tue Dec 13, 2016 2:50 am
by Knight Captain

Re: Help with usecode

Posted: Wed Dec 14, 2016 2:04 am
by Dale
Nice! Hope you decide to share the whole project.

Also.. what an oversight! Surprised there aren't any lighthouses in either U7s.

Re: Help with usecode

Posted: Wed Dec 14, 2016 2:27 am
by Knight Captain
I wonder what the Z-limit is?

Re: Help with usecode

Posted: Wed Dec 14, 2016 6:53 am
by Dominus
I think the z-limit is 255 (at least according to Exult Studio when you can hide lift).

The lighthouse I've been working on last week:
Image

I also used the glasshouse walls and put the glass ceiling there as well and on top of it the pulsating "prism" (BG shape 1010 - anyone know where this gets used?), in it a teleporter platform with a campfire on top. I like the smaller footprint but the stair opening doesn't work correctly with the top right corner of the glasshouse wall edge. I tried adding a fence around the edges of the platform but that didn't look good.
And my rookie mistake: On my first draft I added the entrance door on the west wall :)
The map I'm working on is Castleton (google maps), Lord British's fantasy Village near the ruins of his Britain Manor III.
A quick look at the overall progress https://www.dropbox.com/s/82nbls1ntevsh ... n.png?dl=1

Re: Help with usecode

Posted: Wed Dec 14, 2016 7:23 am
by Knight Captain
While we're on the topic of map edits, why does a u7map file get created when saving some edits, but not others?

Re: Help with usecode

Posted: Wed Dec 14, 2016 8:32 am
by Dominus
Map changes:
- when you mess with the chunks (reorder, add or delete) the chunk numbering changes and Exult fixes that for u7map
- I guess when you edit a chunk
- possibly any change to the ifix files (when you place non-moveable items)

Re: Help with usecode

Posted: Wed Dec 14, 2016 10:27 am
by Knight Captain
I didn't do any of those things, so I deleted the u7map file and tested, and didn't find anything different or out of place. Unless deleting an egg counts?

Is there way to edit chunks off the main map so working with them is easier? Maybe a dedicated chunk editor?

Re: Help with usecode

Posted: Wed Dec 14, 2016 11:47 am
by Dominus
I don't think deleting an egg counts (as eggs are considered moveable objects and get saved in the u7ireg files in initgame.dat) but who knows :)
You'd need to test what triggers a map save.

There is no such chunk editor, but it sure would be helpful, Marzo commented similar. Overall chunk editing is not really a comfortable thing in Exult and you can end up with bad stuff, very easily. I resorted to hex editing the chunk file to iron out errors I made...

Maybe we should open a new topic about all this instead of hijacking Drew's topic :)

Re: Help with usecode

Posted: Wed Dec 14, 2016 2:26 pm
by marzo
Z limit in Exult is 255; in the original games it was 15.

Re: Help with usecode

Posted: Wed Dec 14, 2016 5:23 pm
by Drew
Dale, I do plan to share the whole project when it's done.

Drew

Re: Help with usecode

Posted: Wed Dec 14, 2016 8:52 pm
by Dale
Awesome, Drew! Really looking forward to checking it out!

Dominus.. is this part of a larger project you are working on? Details!?

Re: Help with usecode

Posted: Wed Dec 14, 2016 9:27 pm
by Dominus
Dale, I'll start a proper forum post on this tomorrow I guess ;)
It's a little side project https://github.com/DominusExult/Castleton

Re: Help with usecode

Posted: Sun Jun 03, 2018 12:32 pm
by Mark77
I realize this is an older thread, but...

Great work on the lighthouse, Drew! Because ship travel on Serpent Isle was largely restricted due to the Imbalance's teleport storms, there was little need for lighthouses there, but I thought the switching of the lighthouse with Britannia's mint added some nice flavor to the Serpent Isle story arc.

That being said, I am working on a project of using Exult Studio to reconstruct Furnace as the new city of Balance following the Avatar's adventures on Serpent Isle and Pagan. As part of this project, I turned the southeast battlements of Monitor into a lighthouse using Drew's model. Furnace will eventually have a southern entrance with a dock for ships.

As you had realized Drew, there is a steep learning curve for those of us without any programming experience. This is a rather ambitious project for me, one that will probably never be fully realized because of time constraints and know-how.

Drew, were you ever successful in finishing your mod? Any pointers you can offer? Especially in terms of adding/changing NPCs and conversations... Thanks.

Re: Help with usecode

Posted: Sun Jun 03, 2018 1:26 pm
by Dominus
Mark, take a look at Exult's sourcecode. In content/sfisland is the very simple Sourceforge Island mod that does NPCs etc.

Re: Help with usecode

Posted: Sun Jun 03, 2018 10:24 pm
by Mark77
Thanks Dominus. Are you referring to the Content folder on the GitHub Exult website? I do not see one called "sfisland". I've reviewed what you told Drew previously, but am still having trouble fully understanding the coding language. Simply writing the code seems to a feat in and of itself, much less trying to compile it without creating additional problems.

As I am just getting started and learning the ins and outs of Exult, I wanted to do something very basic with a new NPC requiring very little interaction. The character isn't even new to the series - it's Clint from The Black Gate. I created a new NPC in Exult Studio using the Edit menu. Exult assigned(?) him NPC #0xf0 and usecode #0x4f0.

Here are some screenshots of the lighthouse:
https://obrimark.wixsite.com/u7si/screenshots

Here is Clint's conversation:
https://obrimark.wixsite.com/u7si/narrative

Through all my brazen trial and error, I've really goofed up the files (chunks especially) over the last few months. Right now I'm mainly just trying to document all the changes and additions I've made so that when I wipe the slate clean and reinstall everything, I can (more carefully) go back and replicate what I have done without all the goofs.

Re: Help with usecode

Posted: Mon Jun 04, 2018 4:18 am
by Dominus
yeah, sorry, it's the islefaq folder https://github.com/exult/exult/tree/mas ... nt/islefaq - It's a very simple mod with a couple of new NPCs and some other usecode triggers.

Re: Help with usecode

Posted: Wed Jun 06, 2018 2:57 am
by Drew
Hi Mark,

Yes I was successful in finishing my mod. It was a far bigger undertaking than I ever imagined it to be with lots of changes along the way. I couldn't have completed it without the help of some of the people on here though. I haven't shared it yet because my brother hasn't completed it, but I do plan to do so at some point.

As far as pointers go, I would download a copy of notepad++ and use that to look at the individual .uc files from either the keyring mod or the SI fixes mod. See if you can follow what they are doing and how they are doing it. The npc code files would probably be the most helpful to you.

Let me know if that helps. I may be able to help you with some basic coding, things like writing conversations, but I still only know enough to be dangerous.

Drew

Re: Help with usecode

Posted: Thu Jun 07, 2018 3:21 am
by Mark77
Thanks for your response, Drew. Any help you could provide would be appreciated. I went ahead and "codified" the conversation with Clint I posted earlier at the same link:

https://obrimark.wixsite.com/u7si/narrative

I don't suppose I'm quite done with it, but I followed the islefaq code the best I could, although there's still a great deal of it I don't understand. I don't have any clue as to how I add it to the game or assign the code to that particular NPC, which would probably be the next step.

Re: Help with usecode

Posted: Fri Jun 08, 2018 2:25 am
by Knight Captain
I have a ton of code I need to clean and post. It should have working examples of almost everything you would need for a small mod.

Conversations are relatively easy, since the UseCode Compiler UCC allows for a easy syntax. I'll take a deeper dig into all this by next week.

Re: Help with usecode

Posted: Fri Jun 08, 2018 2:56 am
by Dominus
Mark, the NPC number needs to match the number in the new usecode you write. And you need to compile the usecode with ucc.exe and put the compiled usecode file in the patch folder.

Re: Help with usecode

Posted: Fri Jun 08, 2018 12:47 pm
by Donfrow
Mark, I took a look at your u7si site and I think it's a neat idea and hope to play this sometime! I noticed something in the screen shots that could be a pain for you later on though.

In the furnace docks and monitor lighthouse some of the chunks have the small squares of glowing colour. This happens when you delete "fixture" in the chunk and it impacts every chunk in the game world that is the same number from my experience.

I ran into this early on in my mod and caused me some headache in the long run. I'd recommend that if you want to modify any fixtures on a chunk you duplicate it and then modify the duplicate so it doesn't impact everything else using the chunk. You can add objects onto a chunk without issue; it's only removing or moving fixtures that are part of an existing chunk that cause the issue. Unless anyone else is aware of a way to fix it!

As to your question about adding code in game, the ucc compliler has a flag you need to use Serpent Isle (if you're using the actual SI game in Exult for your mod). For example, in the directory with ucc.exe:

Ucc -o usecode usecode.uc -s

The -s flag is used for Serpent Isle games. The above takes whatever is in usecode.uc and creates an Exult usecode file called usecode that you then place in a folder (don't recall where offhand by default) for the game to use. Usecode.uc can reference other .uc files so you don't need to compile every .uc file you have.

Re: Help with usecode

Posted: Fri Jun 08, 2018 9:00 pm
by Mark77
KC, the documentation on Exult and Exult Studio is very good, but for me a lot of it is hands-on learning, and I learn best by getting in there and getting my hands dirty. Working examples would be a great benefit to me, as at times it seems like I'm trying to reinvent the wheel...

Dominus, how do I determine the NPC number? For existing NPCs, I use the cheat sheet here:

https://tcrf.net/Notes:Ultima_VII_Part_ ... rpent_Isle

But it's only good if I need to use the F2 function to teleport to a NPC by number. The cheat menu when running the game through DOSBox had a way to display number IDs of NPCs, but I don't know if there is a way to do so with Exult. Double-clicking on a NPC in map editor mode yields a NPC# and usecode entry identifier; is that what you are referring to?

In reference to the UCC Compiler, are you talking about what can be downloaded here?

http://exult.info/snapshots/ExultTools.exe

Donfrow, yes, I've really messed up the chunks. The small squares of glowing color are the more minor of the issues I've created, the cavern chunks in particular are a real (likely irreversible) mess. I'm not showing screenshots of my major edits to the city in Furnace for this very reason although you can still pick them out in the few I've shown. I've taken to duplicating the chunks, rather than modifying original ones, as you suggest, but in some cases the damage has already been done. Is there a way to get original chunks back without simply just reinstalling everything in its entirety, thereby overwriting everything? Some of the mess-ups though seemingly come out of no where, but I realize that these are bound to arise simply by going in and making these kinds of edits to the game. I had specified in a previous post that I am working on documenting changes I've made so far, so at a later date, I can reinstall everything and start from scratch and redo everything more carefully from my notes, but this is time-consuming. Once I'm done and have started over I'll have to make frequent backups of my work. Right now my game is still a working canvas (and not a very pretty one at that) where I'm still experimenting through mostly trial and error (rather blindly at times). I would say I'm making some headway with my working knowledge of Exult, but I've got a very long way to go.

One of the hallmarks of the Ultima games (and I've really only played Ultima VII and a little of Ultima VI) is the Avatar comes to the world, "fixes" or "sets things straight" (not always for the better) and then simply leaves again. I can think of some real world examples of meddlesome nations over-extending their reach, and then simply splitting, but I won't get into it here. With this mod, I'm looking for it be a way to simply explore the world and the people within it (a guided tour package if you will) rather than being a quest-driven race to an endgame. This of course may change as my Exult abilities dictate.

Thank you all for your hard work with Exult and thanks for your patience with a newbie such as myself. It's good to see Exult is still going strong after 20+ years. Exult really adds more layers of enjoyment to an already great game!

Re: Help with usecode

Posted: Mon Jun 11, 2018 11:09 am
by Donfrow
I'm not aware of any way to revert the chunk back to its previous state. I ran into this exact issue and messed up a lot of in my mod in the very early days. My only fix at the time was to go through and modify every chunk that I broke. The caverns are indeed the worst and I think I know exactly what you mean...

Regarding NPC, the usecode entry identifier is what I used when creating the usecode. In your NPC usecode file you can then create the NPC by starting it out with that usecode number

void NPC150 object#(0x5db) ()

And then set the logic, conversation tree, etc. One thing to do is make sure you have an event occur for double click to initiate the conversation when the double click occurs. When you compile the usecode and put it into your mod the NPC will then have the usecode associated with it when you double click it. As far as I'm aware you don't need to make reference to the NPC number in any form in the file itself, this is useful for other usecode functions, such as killing an NPC. I'm not sure how you modify an existing NPC to modify an existing conversation/actions though as all of my mod was pretty much from scratch.

You can take a look at my Glimmerscape mod on the downloads page as I included all my usecode in it. Keep in mind that I'm an amateur and I'm certain there are better ways to do a lot of what I did. All my usecode was also done over the span of 10 years (or something like that) so there is a huge variation in quality.

Re: Help with usecode

Posted: Mon Jun 11, 2018 11:54 pm
by Mark77
Donfrow... Wow! I'm impressed! Took a look at your Glimmerscape mod... I would hesitate to call you an amateur; what an accomplishment - it looks quite advanced! I haven't done much yet but talk to the townspeople in Cotton Cove and kill the harpy, but several things I noticed:

1) You created your own books!
2) It looks as if you have incorporated shapes (or at least portraits) from BG.
3) New shapes? I don't recall trapdoors or chimney sweepers in U7...
4) The map reflects the new land of Desporia. Does this autopopulate when you change the chunks?
5) The caveman actually reacts to the killing of the harpy (his queen) and seeks revenge by attacking you. The caveman is tough to kill with that blowgun of his. I noticed the game locks up after I "die" twice (after waking up at the healer's).
6) You can pick grapes/apples, dig carrots, but still haven't quite figured out how to patch the roof. Perhaps these things could be done in BG? I can vaguely remember gathering vegetables for a farmer as a side quest in BG and picking berries on Monk Island in SI.

Great mod! Look forward to diving into it and studying the usecode! Thanks!

Re: Help with usecode

Posted: Tue Jun 12, 2018 11:58 am
by Mark77
One additional question, in building multiple storied structures in Exult Studio, can you have a z position of 16+? I'm trying to put a roof on a building at that position and it looks fine until I save the changes and then open Exult back up again. The roof "collapses" and becomes a floor!

Re: Help with usecode

Posted: Wed Jun 13, 2018 7:38 pm
by Donfrow
The map is a gump shape in Exult Studio. I replaced that with the new map that I edited in Photoshop. You can press shift-f3 (I think that's the key combination) to have the in game teleport map update based on your changed chunks though. I ended up putting a lot of new shapes in my mod and then associated usecode with those shapes for things like picking carrots from the ground. The portraits were from a BG face pack someone posted here many years ago but unfortunately forget who but it's very similar to adding new shapes in Exult Studio.

Interesting note about the locking up after dying. I experienced some issues with the usecode in the past with my death sequence where I don't exit the fade out/fade in properly which gives it the appearance of being locked up. I'll see if I can reproduce this sometime. The biggest problem with my mod is I started it without a plan and worked on and off for many years, often stopping and going back to something years later which lends itself to those kind of bugs (and my patchwork usecode).

If I remember correctly, to patch the roof you need to take a bucket of nails, a piece of wood and a hammer. You equip and double click the hammer, then click the bucket of nails, then a piece of wood, then a roof tile. I think others who played it had the same confusion as it is overly complicated so I added a book outside the house that gives the general idea of what to do and the sequence to do it in. You have to use the ladder to get onto the roof for this to work.

I believe Exult is capped at the z position of 16. One thing to keep in mind is that NPC schedules don't take into account the z position, so if you have 2 floors with a bed in the same x, y and set someone to sleep, they will usually find their way to the bed on the first floor.

Be weary of using my code as a base for anything you do though; while it is functional (mostly anyway...) it's very patchwork and I learned as I made the mod, with lots of help from these forums. Other mods likely have far cleaner source code. My NPC's should be alright to use to learn about conversations though. The file floyden.uc is one you can use as it's an NPC that shows some conversations and how to buy spells, check flags and the inventory for item counts, etc.

Re: Help with usecode

Posted: Wed Jun 13, 2018 7:48 pm
by Donfrow
One more item, have you seen the Usecode C page before? It's at http://exult.info/seventowers/downloads.php?section=1

This has all the Exult intrinsic references and some Usecode C scripting tutorial. The intrinsic reference page is especially useful. This information may be posted elsewhere as well, but I found this page to be incredibly useful.

Re: Help with usecode

Posted: Fri Jun 22, 2018 2:00 am
by Knight Captain
I can't get the Exult intrinsic reference to load, getting a 504 error for that.

Re: Help with usecode

Posted: Fri Jun 22, 2018 10:12 am
by Donfrow
I seem get that too now. It's been awhile since I last used it. I'm not sure if that information is hosted anywhere else? I made a copy of it sometime last year so if it's not something hosted elsewhere I can send it to someone if they need it.

I think that was Marzo's page? Not sure if he is still around?

Re: Help with usecode

Posted: Fri Jun 22, 2018 10:21 am
by Donfrow
And the intrinsic page loaded again!

Re: Help with usecode

Posted: Thu Aug 09, 2018 1:30 pm
by agentorangeguy
when I have to edit or make a custom chunk, what I do is make an extra "test" map, and get a garbage chunk that I don't plan on using or isn't used elsewhere, then make a huge "canvas" of it, then place the blank or other chunk i want to edit in the center of that "canvas". that way if you flinch, you don't damage a good chunk while you edit it.

Re: Help with usecode

Posted: Sat Aug 11, 2018 3:20 am
by Dale
I'm giggling with excitement..