Page 1 of 1

Problems with schedule/inventory retention

Posted: Fri Jan 27, 2006 11:50 am
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

Re: Problems with schedule/inventory retention

Posted: Fri Jan 27, 2006 12:02 pm
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

Re: Problems with schedule/inventory retention

Posted: Fri Jan 27, 2006 1:36 pm
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.

Re: Problems with schedule/inventory retention

Posted: Fri Jan 27, 2006 1:41 pm
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

Re: Problems with schedule/inventory retention

Posted: Sat Jan 28, 2006 9:06 am
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

Re: Problems with schedule/inventory retention

Posted: Sat Jan 28, 2006 12:12 pm
by marzo
By any chance: when the waitress disappears, is she to be found in any other map?

Re: Problems with schedule/inventory retention

Posted: Sat Jan 28, 2006 12:29 pm
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

Re: Problems with schedule/inventory retention

Posted: Sat Jan 28, 2006 1:18 pm
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.

Re: Problems with schedule/inventory retention

Posted: Sat Jan 28, 2006 4:34 pm
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

Re: Problems with schedule/inventory retention

Posted: Sat Jan 28, 2006 4:56 pm
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.

Re: Problems with schedule/inventory retention

Posted: Sat Jan 28, 2006 11:07 pm
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.

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 4:36 am
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.

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 12:39 pm
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)

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 1:06 pm
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

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 2:13 pm
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?

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 2:53 pm
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);
}
}
}
}
}

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 3:18 pm
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').

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 3:20 pm
by Wizardry Dragon
Killed the nesting didnt it? :P

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

~ Wizardry Dragon

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 3:25 pm
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

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 3:30 pm
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'.

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 3:37 pm
by Wizardry Dragon
So, like this?

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

~ Wizardry Dragon

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 3:58 pm
by marzo
More like
say("@Hello World!@");
or
say("\"Hello World!\"");

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 4:04 pm
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

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 4:27 pm
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.

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 4:39 pm
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

Re: Problems with schedule/inventory retention

Posted: Sun Jan 29, 2006 10:01 pm
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.

Re: Problems with schedule/inventory retention

Posted: Mon Jan 30, 2006 3:58 am
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...).

Re: Problems with schedule/inventory retention

Posted: Mon Jan 30, 2006 9:30 am
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.

Re: Problems with schedule/inventory retention

Posted: Mon Jan 30, 2006 9:31 am
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