Page 1 of 1

Usecode for Shapes above 1024?

Posted: Fri Apr 07, 2017 6:09 pm
by Knight Captain
This old thread says NPCs must be in the 0x400+ range, but if that's the case, how can I add a new shape with Usecode short of overwriting ones below 1024?

Re: Usecode for Shapes above 1024?

Posted: Sat Apr 08, 2017 5:21 am
by drcode
For higher numbered shapes, you can specify usecode for them using the "#shape(nnnn)" or "#object(nnnn)" directive in a function's definition.

So if you have, say, a piano with shape 0x701, you could write

void piano_function #object(0x701) {
...

Re: Usecode for Shapes above 1024?

Posted: Sat Apr 08, 2017 10:09 am
by agentorangeguy
I was actually wondering about that again a few days ago, the npcs thing. NPC's higher than 255(?) or whatever it was, has the 0xffffffff or something that can be deleted and renamed... so i'm assuming you could make a function like "testnpc" which would be like a regular npc conversation, and call it by putting "testnpc" in ES npc window where you can delete the 0xffffff number?

Re: Usecode for Shapes above 1024?

Posted: Sat Apr 08, 2017 10:20 am
by Knight Captain
So void shapeTest shape#(0x405) () would not work?

The maximum number of shapes is 2048 (0-2047) currently, well beyond what mods would need. Or even a combined BG+SI.

Re: Usecode for Shapes above 1024?

Posted: Sat Apr 08, 2017 10:28 am
by agentorangeguy
I'm actually up to shape number 1223 with no issues.

If i'm not mistaken, you can actually have more than one shapes.vga file? I've not tried this but seems like it might work.

Re: Usecode for Shapes above 1024?

Posted: Sat Apr 08, 2017 10:29 am
by agentorangeguy
hah dyslexic moment, just realized you said 2048 instead of 1248 :D

Re: Usecode for Shapes above 1024?

Posted: Sat Apr 08, 2017 10:43 am
by Knight Captain
NPCs set to Usecode 0xffffffff use the function connected to their shape. It is possible to change any NPC to use any function, and there is a Usecode intrinsic to do this as well.

Both BG and SI use 0x400-x04FF for the 0-255 NPCs, but did not use the 0x500-0x5FF space much. It looks like this was intended for NPCs 256-355 (0x500-0x563) but largely unimplemented.

So it is possible to assign them in sequence.

Image

But as near as I can tell, there's no reason in a new mod to keep the 0x400-0x563 NPC functions tied to that range.

I hope that I can reimplement the NPCs in a higher range. Usecode seems to allow into several thousand functions. 0x5nnn worked in a quick test earlier.

Re: Usecode for Shapes above 1024?

Posted: Sat Apr 08, 2017 10:45 am
by Knight Captain
Only one shapes file can be used, with the mod one acting as a patch on the original file. This is due to the way the shape number is tightly integrated with Usecode.