Page 1 of 1

Region functions

Posted: Wed Jun 03, 2020 8:36 pm
by ThisIsMe
As I am fairly new to the region stuff, since I do not think anyone has fully bothered to define in detail large swaths of the map into territories, I thought I would try my hand at it.

First things first, I wanted to see what these two functions returned if I was in a region not defined:
GetRegionName( object )
GetRegionNameAtLocation( x, y, realm := _DEFAULT_REALM )

In the documentation I should have errortext returned because I am in a region not defined, this is not happening.

Second, when I am in a region that is defined, nothing is returned. The region is in regions.cfg and is set to Guarded, just in case the Justice tidbit is required for this function which brings me to an actual question.

Do these functions only work for "justice" regions or the entirety of the regions.cfg file? I am hoping they are supposed to work for the entirety of the regions.cfg file as just applying to "justice" areas seems very limiting?

Okay I lied, I have two questions, when a region is defined, say this one:

Code: Select all

Region Moonglow
    Range       4379 1045 4487 1178
    Realm		britannia
    Guarded     1
    EnterText   You have entered the protection of the town guards.
    LeaveText   You have left the protection of the town guards.
    midi        48
Can we have multiple Range properties defined in one region and if not, could that possibly be something added as it would allow for a tighter region definition for a single region? If you take Britain as an example, it is not just one big square.

Anyhow, I will put this on hold until the boffins can jump in and set me straight or tell me I have stumbled upon something no one else has found. (If I have, my apologies.)

Re: Region functions

Posted: Wed Jun 03, 2020 9:49 pm
by ThisIsMe
Well, not a bug, turns out these functions do not play nice if you have an empty justice.cfg, ugh.

And it turns out, you can define multiple Range props for a single region so yay!

Re: Region functions

Posted: Tue Jun 23, 2020 2:45 pm
by ThisIsMe
Its me again.

So ive been playing around with regions, I was wondering if some additional functionality could be added with some relative ease.

GetNearestRegion( object, direction:=-1 ) - return the nearest region other than the region the object might be in. If the direction (this would use facing values) is not defaulted, it'll return the nearest region in that direction.

GetNearestRegionAtLocation( x, y, realm, direction:=-1 ) - same as above just using xy coordinates.

Next, this is not a function but if we could define regions, say britain, then below that definition define a smaller region inside Britain using say a new member in the regions.cfg region definition named 'PartOf' where if a smaller region is part of a larger region, entering the smaller region wouldnt trigger the leaving enter text of the larger region. I defined a few shops in Britain and when I entered the shop I was hit with the leave area message and when I exited the shop I was hit with the entered area text for britain but the shop is part of britain. Not sure if that makes any sense but i can explain further if needed.

Anyhow, thanks, really liking the region stuff that I've never used but has great potential.

Re: Region functions

Posted: Tue Jun 23, 2020 5:39 pm
by DevGIB
i can't really comment on the find nearest stuff because i don't really know how the internals of the region system works. I wonder however if they could end up being expensive calculations if it has to sweep outwards until it finds a new region.

With regards to the enter/exit noise. Just to confirm. does your subarea have its own entry/exit text?

Re: Region functions

Posted: Tue Jun 23, 2020 6:52 pm
by ThisIsMe
I suspect there'd be some calculations involved that are troublesome depending how regions are read in and stored.

In terms of my sub region stuff, to your question no, I dont have an enter or leave text for these smaller regions within Britain.

In some regards I would be fine with:
PartOf <regionname>

If there's entertext, leavetext, enterscript or leavescript, only then fire any one of these for the smaller region, otherwise don't fire anything including from the region the smaller region is part of as youre still technically in that larger region just a small corner of it.

Re: Region functions

Posted: Wed Jun 24, 2020 8:30 pm
by Yukiko
So what you are asking for is to:
1. Be able to define child-regions within parent regions.
2. Have the ability to have an on enter script and on leave script defined for that child-region.
3. Have the ability to define an entered text and a leave text defined for that child-region.
4. Have the ability to define for that child-region all of the other fiddly bits that regions can have defined.
1. When entering a child-region, the leave text of the parent region should not fire.
2. When leaving a child-region returning to the parent region, the enter text of the parent region should not fire
3. Have any fiddly bits defined within the child-region will override the same fiddly bits of the parent region.

Fiddly bits refer to the various other settings regions may have.

And I assume you would want the ability to have child regions defined within child-regions.

Whilst I was compiling the above list a question arose in my mind. Should the leave and enter scripts fire for the parent region when you enter or leave the child-region?

Re: Region functions

Posted: Wed Jun 24, 2020 10:35 pm
by ThisIsMe
Yes to the above.

In terms of firing the enter/leave script fire for a parent region when entering/leaving a child region, I'd say no because you're still in the parent region, just in a child region.

I would like to be able to have child regions of child regions.

Re: Region functions

Posted: Wed Jul 01, 2020 2:30 pm
by ThisIsMe
Thought of another function for regions.

ListMobilesInRegion( region_name, flags := PLAYERS )

Just like it sounds, returns an array of mobile references for mobiles in region.

Flags would allow us to differentiate between Players, NPCs or both. Typically I'd assume it'd mainly be used to look for players so it'd default to the player flag.

Sorry I didn't post this with everything else but it just came to mind.

Re: Region functions

Posted: Wed Jul 01, 2020 3:44 pm
by Yukiko
Except for missing the PC and NPC flags you could use ListObjectsInBoxOfClass( POL_Class, x1,y1,z1, x2,y2,z2, realm := _DEFAULT_REALM ) to find characters in a region. With a little extra programming you can filter out PCs from NPCs and vice-versa.

Re: Region functions

Posted: Wed Jul 01, 2020 4:39 pm
by ThisIsMe
Yep, I know.

But looking at how regions are defined with multiple Range elements i figured it be a nice addition to the region based functions to just have a list mobiles function specifically for regions.