Problems with schedule/inventory retention

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
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Problems with schedule/inventory retention

Post by Wizardry Dragon »

Hey there strangers,

I was fiddling around with constructing a city/castle/thing on a second map thats supposed to be besieged. I have some guards/warrior types spawn with eggs, and they come with the equipment fine to do battle with the Forces of Evil (TM), but I also want to have a few Leftenant types which have an active schedul (eat, sleep, fight), and my problem is that whenever they change schedules, they seem to lose the inventory I gave them. Is there something I need to do for them to retain inventory?

"Perhaps you should get a sword if you want to fight evil today."
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Also, just remembered this when I had waiter quips coming out of nowhere.

Are NPCs generally supposed to just disappear? I placed a waiter for the mess hall in my castle, and she was fine until her schedule changed, and then she disappeared. Shes still 'there' (waiter quips appear) but you can't see her shape. I think I recall something similar happening in the original SI, but not in U7. Is there a way I can fix this?

"Im invisible! Can you see me?"
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by drcode »

I'm guessing there might be a bug involving schedules of NPC's on a second map. I'll have to give it a try at home.
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Might be, the schedules seem to be rather dodgy on my second map, I just thought it was a general thing, but I must confess I havent tried adding NPCs to the original map, well not with the latest snapshot anyways.

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

It seems that fiddling with flags for the NPC fixed it, can't be more specific because I wasn't being particularly attentive, but I'll try to reproduce the bug.

The bug with my invisible waitress persists, though =\

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

By any chance: when the waitress disappears, is she to be found in any other map?
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

No. Teleporting to her via the cheat screen takes me to the mess hall, and you can hear her calls ('Can I help you?, yadda yadda, etc.), you just can't see the shape.

"I thought ghosts had a shape?"
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

The cheat screen teleport seems not to be up to the task; it doesn't change you to another map. I will fix that one; but try cycling throught the maps with Ctrl+Alt+T to see if she is in another map. I *seem* to recall hearing Lady Tory's calls from the Flame of Courage's chamber when I was checking the intermap eggs, so that you may be seeing her calls even from another map.
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Nonononono, its taking me to HER. I just cant SEE her. She *IS* there. (You dont hear her calls on the second map. Itd be hard to miss, since its right in the middle of the ocean in Britannia :P

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

What I am saying is that it seems you *do* hear NPCs calls from other maps; I have just tested it with Apollonia: I can hear her even if I am in one map and she is not.

And when I tested the teleport to NPC function, it took me to the right spot (x, y coord) in the wrong map: I tried teleporting to Klog from the Shrine of Spirituality (in the second map -- from my mod) and I remained in the second map. I fixed this last one now, but I am still working in the former; that is why I am insisting on this point.
------
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]
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by drcode »

I haven't heard the NPC's from other maps, but we definitely shouldn't allow that. I could take a look if you haven't already fixed it.

Also, NPC schedules are currently limited to a single map. I'm thinking about enhancing them so you can have an NPC go between maps.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

I could take a look if you haven't already fixed it.
I will take you up on that offer. For what I could gather, the bug only happens if you change maps while the NPC is near the avatar; you will then continue to hear his/her calls until you move far enough away and return.
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

And Im not saying its not a valid point Marzo, just that I dont think it's the problem ^_~

Also, Dr. Code, a few other issues that arise:

> How do we code a handler for when the avatar dies on another map?

> Is it possible to have a creature on the 'hostile' team and combat schedule fight with a creature with a creature on combat on the 'friendly' team? As is, friendly guys on combat sched will attack hostile creatures, but hostile creatures barrel straight for the avatar, even if the freidnly guys are more numbered, or more of a threat. Kinda would be a clincher for a siege scenario that Im building.

> Also, it would be nice if creatures and the avatar could fire over obstacles that are z 2 or less, youd think you could fire over an obstacle half your height (otherwise having archers on the battlements is purely cosmetic)
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

I'm not DrCode, but here are some answers:
How do we code a handler for when the avatar dies on another map?
You override usecode function 0x60e (BG) or 0x400 (SI) with your custom code. You can use the brand-new intrinsic UI_get_map_num(object) to see which map the avatar is on (although you will likely need to wait for a new version of the UCC compiler to be posted) and call the original function on the default map. (now that you mention this, I realize I will have to include a modified version of this function on the keyring mod too... thanks).
Is it possible to have a creature on the 'hostile' team and combat schedule fight with a creature with a creature on combat on the 'friendly' team?
If the battle has a scripted start, you can use intrinsics to get the derired effect; use "npc1->set_opponent(npc2)" to make npc1 attack npc2, or set the attack mode of "npc" to "mode" with "npc->set_attack_mode(mode)" intrinsic; values for "mode" are:
NEAREST = 0
WEAKEST = 1
STRONGEST = 2
BERSERK = 3
PROTECT = 4
DEFEND = 5
FLANK = 6
FLEE = 7
RANDOM = 8
MANUAL = 9
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Im creating the monsters via eggs and they don't have 100% prob, so it'd be nice if it didnt have to be done with Usecode.

Also, how do I call the original function from an override?
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

You call the function as normal with a ".original" appended to the function's name. For example: suppose you have made some changes to the InAntiMagicZone function (# 0x906 -- it controls whether or not spells fail). You want the function to work as it does in the normal game except when you are in Covetous. You might do something like this:
InAntiMagicZone 0x906 ()
{
if (IsInsideCovetous() || InAntiMagicZone.original()) return true;
return false;
}
As for the battle scene, here is an idea: you can have the monster eggs create them all in a 'wait' schedule (so they don't have preassigned targets). Another egg (with a 100% chance of working) calls a usecode function which (after a small time delay) sets all created 'monsters' (hostile or friendly, but not any party members) to 'nearest' attack mode and then sets their schedule to combat. An example (hope formatting is not screwed up):
eggBeginCombat 0xD00 ()
{
if (event == 3)
//egg event; call this function again with a time delay.
//Also, use a different event id to differentiate.
script item after 10 ticks call eggBeginCombat, 2;

else if (event == 2) //scripted event
{
const int distance = 30;
const int mask = 4; //NPCs
const int any_shape = -359;

//Get a list with the party members:
var party = UI_get_party_list();

//Find all NPCs at a distance find_nearby
var nearby_npcs = find_nearby(any_shape, distance, mask);

//Loop variables:
var index;
var max;
var npc;

for (npc in nearby_npcs with index to max)
{
if (!(npc in party_list))
{
//NPC is not in party.
//Get NPC's alignment:
var align = npc->get_alignment();
if (align == 0 || align == 2)
{
//Ignore neutral NPCs.
//Set NPC to attack nearest foe:
npc->set_attack_mode(0);
//Put NPC in 'combat' schedule:
npc->set_schedule_type(0);
}
}
}
}
}
------
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: Problems with schedule/inventory retention

Post by marzo »

Well, formatting was indeed screwed up. For better readability, ident by one tab between each pair of curly braces (and also the three lines below the first 'if').
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Killed the nesting didnt it? :P

It's a 'patch' approach, but it'll work for now, thank you ^_^

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Oh, and a stupid question, but how do I properly escape a " so that I can use a " in conversation?

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

There are two ways: you can use \" or @. I myself prefer to use @, but the original game used \" for dialogs and @ for 'barks'.
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

So, like this?

say("@"Hello World!@"");

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

More like
say("@Hello World!@");
or
say("\"Hello World!\"");
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Ah, so the @ takes the place of a quotation mark within the sentence? Sweet, thanks ^_^ One of those things I was always trying to figure out but never did xD

Is it just me or has Usecode gotten a long ways since I was tinkering with it this time two years ago? :D

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

There has been a lot of changes and improvements, yes. It is quite addictive now :-) There are some more improvements on the horizon too, and any suggestions for improvements are welcome.

*shameless plug* There is a tutorial/documentation on UCC scripting in ESGuides (as well as a few general UCC tutorials); I am thinking about making something similar for intrinsics and maybe a general UCC tutorial/documentation.
------
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]
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

I'll have you know that as far as I know, Im the first one to have written UCC documentation. Its still floating around on the intraweb somewheres, I forget where though, its been a while.

(I can still remember trying to figure out how to explain execute_usecode_array, but now we dont even need to worry about it :P )

But geez, I need to catch up with the times, eh? ^_~

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Gunnar
Posts: 73
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Gunnar »

@Wizardry Dragon: I don't think we can find your ucc docs anymore since your wiki died. I still have it on file though. You should add it to esguides too.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by marzo »

I'll have you know that as far as I know, Im the first one to have written UCC documentation.
Yes, it is coming back to me now; I think I saw what you wrote some time ago.
(I can still remember trying to figure out how to explain execute_usecode_array, but now we dont even need to worry about it :P )
In some rare cases, you still need them; for example, there is no way I can think of to do something like the earthquake spell with UCC script blocks... (well, there *is* one way, but it involves multiple calls to a given function for each affected NPC to see what will be done next...).
------
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]
drcode
Site Admin
Posts: 2267
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by drcode »

The "phantom NPC talking" bug should be fixed now. I wouldn't be surprised if there are some other cases where it shows up, so let me know.
Wizardry Dragon
Posts: 1241
Joined: Thu May 14, 2020 1:34 pm

Re: Problems with schedule/inventory retention

Post by Wizardry Dragon »

Gunnar - thats because the domain for my old RPG website expired. It's still on that webserver somewhere, I'll have my freind Paul who owns it poke around and find it.

~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Locked