call Guards function in BG

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
agentorangeguy
Posts: 565
Joined: Thu May 14, 2020 1:34 pm

call Guards function in BG

Post by agentorangeguy »

Which function would I need to overwrite to handle what happens when guards are called? I need to rewrite it to handle being arrested in U6 , and make sure guards cannot be called outside of towns and such. Let me know, thanks!
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

Do you have a Locate function or similar that defines the towns as x,y coordinates?

There is a Usecode Intrinsic for calling the guards and another for canceling the arrest. Those to my knowledge are built into Exult. The more advanced behavior of SI calling specific local guards is via Usecode.
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Donfrow »

When you say the guards are build into Exult, is that for both BG and SI? You mention specific guards are via usecode in SI, but is the rest of that via Exult itself? Ie, type of guard is the usecode but guards/arrest is Exult?
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

It seems I may be wrong here. Exult actually uses this in a very helpful way.

The Usecode Intrinsic is UI_call_guards();

I'm testing it now in SI.
Silver Seed keep - No reaction.
Moonshade - Rangers
Fawn - Fawn Guards
Sleeping Bull - UI_attack_avatar();
Monitor - Pikemen
Furnace - Zhelkas has no reaction.
Mad Mage Isle - UI_attack_avatar(); with Erstam killing himself with a botched attack. No skeletons, apparently.

If the bribe is paid, the guards are called off with UI_stop_arresting();

As to how it figures out which to send, I'm not certain.
agentorangeguy
Posts: 565
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by agentorangeguy »

I wonder though, is there a specific "event" called from the Avatar regarding arrests? Like, death is what, if (event == 4 (or DEATH)) or something then you can call a custom function to handle the death events.
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

There is no Arrest event. You could set a DEATH condition that would move the Avatar to jail if you wanted though.
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Donfrow »

If I'm understanding correctly, there are the intrinsics used for calling the guards, but the engine itself is is triggering the the intrinsic calls and are hard coded?
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

In my test case I was using the UI_call_guards intrinsic via Erinon's Axe by dropping it (event == UNREADIED). After that everything was via the engine rather than my Usecode. So the determination of which guards to send or even if to send any at all was not mine to pick.

If I had to guess a way to do this, I'd also set a gflag when the guards come. Then if that flag is set when the Avatar dies, another function could be called to resurrect him, heal him, move him to a jail cell, and clear the gflag and any NPC flags on the party.

The gflag would have to also be unset if the bribe is paid.
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Donfrow »

Ah thanks, I was wondering since I've never found a way to disable the guard call in my mod if you happen to attach a friendly in the location that used to be a city, it calls the original SI guards. For me, it would be nice to disable that altogether.

That was different than what agentorangeguy was looking for though, so I won't hijack his thread further!
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

It's probably worthwhile to keep the thread together.

I imagine Dominus or myself would need to poke into the engine code to see if anything is hard-coded.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Dominus »

I took a look and so far I can confirm that guards will not be called when the place is considered a dungeon.
How guards are called depending on the place is done by looking up what guards are near:
Function at https://github.com/exult/exult/blob/mas ... n.cc#L2675
and in that this will look up what guard shape (gshape) is around https://github.com/exult/exult/blob/mas ... n.cc#L2706
So when there are no guards in the area then no guards will be called.

As to when guards are called is also dependent on the alignment of the crime witness, though I don't completely understand that part.
https://github.com/exult/exult/blob/mas ... n.cc#L2589
--
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!
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

Might be fun to change the Avatar's alignment and test.

Looks like the locations are hardcoded for SI to determine the guard shape:
https://github.com/exult/exult/blob/mas ... n.cc#L2545

Any non-SI game (BG, any hypothetical new game) the hardcoded location check is skipped. Shouldn't the guards only be called if there is a witness, Dominus?
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Dominus »

Yes, but I'm not entirely sure how when partymembers step in as witnesses. There is also a relevant function in actors.cc when you become a bully

And yes, I didn't see the hardcoding for SI cities. I wonder how that came to be. At first glance I'd have thought the other way should work there as well. Probably need to go through the history of gamewin to learn that. But that is no fun ;)
--
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!
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Donfrow »

That's strange. I will have to retest but I could have sworn in my original mod if I attacked a friendly NPC near where Fawn used to be the Fawn guards came and arrested me, despite no NPC's with the Fawn guard shape in the area. I may not be remembering accurately though as it's been awhile.

I will have to retest this sometime to see. Not a big issue for me overall. Since the thread popped up figured I would see what was known about it (you are all wonderful people). I have other things to keep me busy rather than some guards for now.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Dominus »

Yes, for SI it is hardcoded.
--
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!
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

This is a tricky one because of the way Mods are used. They are still the main game (BG/SI) to the engine even if the map is entirely clean and new.
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Dominus »

this could be another area that might need a de-hardcoding...
It probably needed to be hardcoded because the way we did for BG was not sufficient in SI. Different guard types and larger areas that needed to be guarded (think of fellowship camp just near Fawn).
Or no one took a look again :)

AND what I'm unsure about in the code: if there are no guards in the area, it *should* still not call any guards, even if the shape is hardcoded for that area.
--
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!
Alexander

Re: call Guards function in BG

Post by Alexander »

The title of this thread got me thinking, it would be neat if YOU could call the guards when people attack you in town (De Snel, Lydia, and Voldin come to mind, as a few examples), and they'd come help. Ultima Online has this feature, which even works if you witness a theft.

It would definitely help with the problem of guards being completely useless in the single-player Ultima games, although I'm sure it would be very difficult, if not impossible, to implement. Maybe it could be a dialogue option when you talk to a guard.
agentorangeguy
Posts: 565
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by agentorangeguy »

Guards WILL show up if you eat food that isn't yours...so it would be very helpful to be able to set regions where they won't show up.. I just tested it. I created some bread, just the Avatar, ate it and guards came rolling in out of nowhere. :O
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Dominus
Site Admin
Posts: 5656
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Dominus »

So no guards in the greater area or maybe even guard eggs?
I saw no code that is specific to stealing food...
--
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!
Knight Captain
Posts: 1219
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by Knight Captain »

This sort of thing was so problematic that the Usecode for parts of it was disabled in SI. That's why the party never complains about theft. I wonder if the behavior changes if there is no one in the party in your mod, AgentOrangeGuy?

This may be related to the item flag OKAY_TO_TAKE.

Alexander, yes it would be a ton of work. Similar to the idea to have Julia be able to make musket balls out of iron.
agentorangeguy
Posts: 565
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by agentorangeguy »

I don't know what area it would have been in on the standard U7 BG game, but on my mod it was kind of an area that would have been the deep forest on U7 also. Was only the Avatar in the party. I dropped some bread via ES and no other npcs were around. I ate one then I got swarmed by guards lol.

It would be good to be able to determine where and what type of guards show up as in SI that way there is no weird behavior by the guards out in the middle of the wilderness haha
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
agentorangeguy
Posts: 565
Joined: Thu May 14, 2020 1:34 pm

Re: call Guards function in BG

Post by agentorangeguy »

What are the chances we could get this de-hardcoded so we have more ability to alter how it's handled?

Specifically, what guards show up and where. In BG I think its the standard guard, then another shape for the Trinsic guards. If you code those shapes specifically, you can change how they handle arrests and where they send you, but I'm not sure how to change which areas they do and don't show up
-------------------------------------------------------------------------------------
Ultima 6 Mod for Exult site: http://www.ultima6.realmofultima.com/
Locked