I try to make some area where you cant damage another player pet's

i got something like this bu this doesnt work.
Code:
            if (from is BaseCreature && m is BaseCreature && m.Region.Name == "XXXXXX")
            {
                BaseCreature bc = from as BaseCreature;
                PlayerMobile master = bc.ControlMaster as PlayerMobile;

                BaseCreature bc2 = m as BaseCreature;
                PlayerMobile master2 = bc2.ControlMaster as PlayerMobile;

                if (bc.ControlMaster != null && bc2.ControlMaster != null)
                {
                    if (bc.Controlled && bc2.Controlled)
                    {
                        if (totalDamage > 0)
                        {
                            totalDamage = 0;
                            master.SendMessage("You cannot damage pets here");
                        }
                    }
                }
            }
 
If you want to make a new region: http://www.runuo.com/community/threads/creating-a-new-region.9309/

Or you you can use XML regions by making it like so: https://github.com/zerodowned/ServUO/blob/master/Scripts/Regions/Jail.cs

but then you'd have to define the region here: https://github.com/zerodowned/ServUO/blob/master/Data/Regions.xml

if you're not familiar with Rec2D:
this.Coords.Add( new Rectangle2D( 6014, 390, 6135, 507 ) );
6014 is the X location of the top-left corner
390 is the Y loc of the corner
6135 is the x of the bottom right
507 is the Y of the bottom right

benefit to using xml over the first one? being able to define multiple regions with the same properties
 
Ok for example i use this region
Code:
		<region type="TownRegion" priority="50" name="Buccaneer's Den">
			<rect x="2612" y="2057" width="164" height="210" />
			<rect x="2604" y="2065" width="8" height="189" zmin="0" />
			<go x="2706" y="2163" z="0" />
			<music name="Bucsden" />
			<guards disabled="true" />
			<region>

And ther i define in te region something like this

Code:
            if (from is BaseCreature && m is BaseCreature && m.Region.Name == "Buccaneer's Den")
            {
                BaseCreature bc = from as BaseCreature;
                PlayerMobile master = bc.ControlMaster as PlayerMobile;
                BaseCreature bc2 = m as BaseCreature;
                PlayerMobile master2 = bc2.ControlMaster as PlayerMobile;
                if (bc.ControlMaster != null && bc2.ControlMaster != null)
                {
                    if (bc.Controlled && bc2.Controlled)
                    {
                        if (totalDamage > 0)
                        {
                            totalDamage = 0;
                            master.SendMessage("You cannot damage pets here");
                        }
                    }
                }
            }
And there i got it all setup properly yes ? So why this doesnt work properly ? And when i attack pet i see this message "You cannot damage pets here" but i can damage pet.
 
Back