SphereCommunity
Is there easy way to know if player is in a city? - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Is there easy way to know if player is in a city? (/Thread-Is-there-easy-way-to-know-if-player-is-in-a-city)



Is there easy way to know if player is in a city? - fabiohvp - 08-01-2018 03:11 PM

1 - I want to forbid players from hiding and walk stealth inside cities if their skill is below 90.0, is there an easy way to know if the player is inside a city?
I could use region_flag_nobuilding but it would forbid to use inside houses and I don't want that.

2 - Also if is there a way to know if the player is inside a forest/swamp/desert would also be good to know.


RE: Is there easy way to know if player is in a city? - darksun84 - 08-01-2018 05:30 PM

Try this way open sphere_map0 and search for region blocks that starts with "a_town*", for each of these region add a tag like this:
Code:
[AREADEF a_townOcclo]
NAME=Ocllo
GROUP=Ocllo
P=3650,2519,0,0
RECT=3588,2460,3707,2685,0
RECT=3695,2558,3760,2705,0
FLAGS=region_flag_nobuilding|region_flag_guarded
EVENTS=r_default,r_default_rock,r_default_water,r_default_tree,r_default_grass
TAG.MUSIC=midi_ocllo
tag.city = 1

Then inside the @start (maybe better @prestart?) trigger of the hiding skill add this check
Code:
if <region.tag.city>  && <hiding> < 900
    sysmessage You can't hide here.


Same for wilderness region


RE: Is there easy way to know if player is in a city? - fabiohvp - 08-02-2018 11:16 AM

Thanks


RE: Is there easy way to know if player is in a city? - xwerswoodx - 09-21-2018 12:14 AM

But if every region defnames starts with a_town why does he need to add TAG.City for all of them,

Code:
IF (STRMATCH('<REGION.DEFNAME>', 'a_town*')) && <hiding> < 900
  SYSMESSAGE You can't hide here.
  RETURN 1
ENDIF



RE: Is there easy way to know if player is in a city? - darksun84 - 09-21-2018 12:57 AM

Maintenance.

If for example he wants to allow hiding in three different cities by using your IF he will have to add additional IF/ELSE statements, while by using a using tag he can just remove it from the areadef.