RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RunUO 2.0 RC1] Shivan Spawneable Guards

shivan

Sorceror
What i do in baseevilguard.cs is emulation of a basic "fightmode.good" mode, i found using this system have a reduced CPU usage (because the check is only do it when a player moves in the persention range of the guard). and also less distro change in this way.

I do no know about the criminal thing, when i first tested it, it works, but maybe because i tried with a criminal who already in negative karma. But i already edited the system to work with all criminals, anyway, there will be some changes in 1.8, i going to introduce a improved version of the order/chaos faction guards.
 

dotosco

Sorceror
may it help?

public override bool IsEnemy(Mobile m)
{
if (m.Criminal == true && !(m is BaseVendor) || (m.Karma <= -10) && !(m is BaseVendor) && (m is BaseCreature && !this.Controlled && CanBeHarmful(m)))
return true;
else
return base.IsEnemy(m);
}
 

Greystar

Wanderer
Instead of using this code
Code:
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (e.Mobile.InRange(this, 6))
            {
                if ((e.Speech.ToLower() == "guards"))
                {
                    if (base.Combatant != null)
                    {
                        if (!(base.InLOS(base.Combatant)))
                        {
                            base.Say("I got him.");
                            Point3D from = (Point3D)this.Location;
                            Point3D to = new Point3D((Point3D)base.Combatant.Location);
                            base.Location = to;
                            Effects.SendLocationParticles(EffectItem.Create(from, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                            Effects.SendLocationParticles(EffectItem.Create(to, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                            base.PlaySound(0x1FE);
                        }
                    }
                    else if (AdvancedGuardsCommand)
                    {
                        foreach (Mobile m in base.GetMobilesInRange(base.RangePerception))
                        {
                            if (m is PlayerMobile && !(m.Hidden) && m.Alive && m.AccessLevel == AccessLevel.Player)
                            {
                                if ((m.Kills > 5) && (m.Karma <= -1000) || (m.Criminal))
                                {
                                    base.Combatant = m;
                                    base.Warmode = true;

                                    if (!(base.InLOS(m)))
                                    {
                                        base.Say("I got him.");
                                        Point3D fromt = (Point3D)this.Location;
                                        Point3D tot = new Point3D((Point3D)base.Combatant.Location);
                                        base.Location = tot;
                                        Effects.SendLocationParticles(EffectItem.Create(fromt, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                                        Effects.SendLocationParticles(EffectItem.Create(tot, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                                        base.PlaySound(0x1FE);
                                    }
                                    break;
                                }
                            }
                        }
                    }

                }
                else
                {
                    base.OnSpeech(e);
                }
            }

        }
you might want to try (Changes in Green)
Code:
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (e.Mobile.InRange(this, 6))
            {
                if ([COLOR="Green"]Insensitive.Contains(e.Speech,"guards")[/COLOR])
                {
                    if (base.Combatant != null)
                    {
                        if (!(base.InLOS(base.Combatant)))
                        {
                            base.Say("I got him.");
                            Point3D from = (Point3D)this.Location;
                            Point3D to = new Point3D((Point3D)base.Combatant.Location);
                            base.Location = to;
                            Effects.SendLocationParticles(EffectItem.Create(from, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                            Effects.SendLocationParticles(EffectItem.Create(to, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                            base.PlaySound(0x1FE);
                        }
                    }
                    else if (AdvancedGuardsCommand)
                    {
                        foreach (Mobile m in base.GetMobilesInRange(base.RangePerception))
                        {
                            if (m is PlayerMobile && !(m.Hidden) && m.Alive && m.AccessLevel == AccessLevel.Player)
                            {
[COLOR="Red"]                                if ((m.Kills > 5) && (m.Karma <= -1000) || (m.Criminal))
[/COLOR]                                {
                                    base.Combatant = m;
                                    base.Warmode = true;

                                    if (!(base.InLOS(m)))
                                    {
                                        base.Say("I got him.");
                                        Point3D fromt = (Point3D)this.Location;
                                        Point3D tot = new Point3D((Point3D)base.Combatant.Location);
                                        base.Location = tot;
                                        Effects.SendLocationParticles(EffectItem.Create(fromt, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                                        Effects.SendLocationParticles(EffectItem.Create(tot, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                                        base.PlaySound(0x1FE);
                                    }
                                    break;
                                }
                            }
                        }
                    }

                }
                else
                {
                    base.OnSpeech(e);
                }
            }

        }

The one I added will make it so if someone says "Guards Help" or "*Guards*" it'll still call a guard.

Also you code doesn't allow for Murderers in town if AllowReds is set on a region. The stuff I highlighted in red will prevent anyone with murdercounts who is evil into town (I know this is from GoodGuard code). Just wanted to point that out and I also know that it won't be used unless you have AdvancedGuardsCommand = true;
 

shivan

Sorceror
Thats is easily fixed, i going to add in the next update, a question, in the allowred regions guards should still attack criminals???
 

Greystar

Wanderer
shivan;741290 said:
Thats is easily fixed, i going to add in the next update, a question, in the allowred regions guards should still attack criminals???

yes they still attack criminals... just allow reds...

using Server.Regions; at the top of your Base<Good/Evil>Guard script


then in the section where the checks are something along the lines of

if (m.Region is GuardedRegion && (!(GuardedRegion(m.Region)).AllowReds && m.Kills >= 5))

I'm sure you can figure out where that needs to go. But code along those line will allow reds in town if AllowReds is set on the region.
 

shivan

Sorceror
Yeah i been testing this...

Code:
                        foreach (Mobile m in base.GetMobilesInRange(base.RangePerception))
                        {
                            if (m is PlayerMobile && !(m.Hidden) && m.Alive && m.AccessLevel == AccessLevel.Player)
                            {
                                Regions.GuardedRegion reg = (Regions.GuardedRegion)m.Region.GetRegion(typeof(Regions.GuardedRegion));
                                if ((reg != null && !(reg.AllowReds) && m.Kills >= 5) || reg == null && m.Kills >= 5 || (m.Criminal))
                                {
                                    base.Combatant = m;
                                    base.Warmode = true;

                                    if (!(base.InLOS(m)))
                                    {
                                        base.Say("I got him.");
                                        Point3D fromt = (Point3D)this.Location;
                                        Point3D tot = new Point3D((Point3D)base.Combatant.Location);
                                        base.Location = tot;
                                        Effects.SendLocationParticles(EffectItem.Create(fromt, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                                        Effects.SendLocationParticles(EffectItem.Create(tot, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                                        base.PlaySound(0x1FE);
                                    }
                                    break;
                                }
                            }
                        }

But i discover that all guarded regions are allowred by default, i undestand why when i see this in guardedregion

Code:
		public virtual bool AllowReds{ get{ return Core.AOS; } }

But also the fightmode.evil ignore that, i could change the fightmode and do a manual fightmode as the evil guards, but even so the allowreds is true by default...

There is a way to change that manually ingame for each region?

Anyway, maybe could be better to do a "attack only criminals" variant of the good guards.
 

Greystar

Wanderer
shivan;741332 said:
Yeah i been testing this...

Code:
                        foreach (Mobile m in base.GetMobilesInRange(base.RangePerception))
                        {
                            if (m is PlayerMobile && !(m.Hidden) && m.Alive && m.AccessLevel == AccessLevel.Player)
                            {
                                Regions.GuardedRegion reg = (Regions.GuardedRegion)m.Region.GetRegion(typeof(Regions.GuardedRegion));
                                if ((reg != null && !(reg.AllowReds) && m.Kills >= 5) || reg == null && m.Kills >= 5 || (m.Criminal))
                                {
                                    base.Combatant = m;
                                    base.Warmode = true;

                                    if (!(base.InLOS(m)))
                                    {
                                        base.Say("I got him.");
                                        Point3D fromt = (Point3D)this.Location;
                                        Point3D tot = new Point3D((Point3D)base.Combatant.Location);
                                        base.Location = tot;
                                        Effects.SendLocationParticles(EffectItem.Create(fromt, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                                        Effects.SendLocationParticles(EffectItem.Create(tot, base.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                                        base.PlaySound(0x1FE);
                                    }
                                    break;
                                }
                            }
                        }

But i discover that all guarded regions are allowred by default, i undestand why when i see this in guardedregion

Code:
		public virtual bool AllowReds{ get{ return Core.AOS; } }

But also the fightmode.evil ignore that, i could change the fightmode and do a manual fightmode as the evil guards, but even so the allowreds is true by default...

There is a way to change that manually ingame for each region?

Anyway, maybe could be better to do a "attack only criminals" variant of the good guards.


FightMode.Evil I though only checks if a player or a mobile has -1000 karma if so it attacks. It doesn't do anything for criminals (that I am aware of) or if you KILLS are any such number. You only turn red once your kills >= 5 or AlwaysMurderer is set on the mobile. Anything else and as far as I can tell things are just "Grey" meaning it's safe to attack them without loosing karma. I'm just looking into trying to create a new FightMode specifically for the guards, but that's just me.
 

shivan

Sorceror
Yeah, but i will drop the allowreds check, most of the people dont change that.
Instead i will make a anti-criminal and monsters only variant. Just to keep the easy to use and install.

And looking in the forums i see some people requesting that type of guard.

BTW, just to know, where are the fightmode scritps???
 

Greystar

Wanderer
shivan;741521 said:
Yeah, but i will drop the allowreds check, most of the people dont change that.
Instead i will make a anti-criminal and monsters only variant. Just to keep the easy to use and install.

And looking in the forums i see some people requesting that type of guard.

BTW, just to know, where are the fightmode scritps???

The enum is Defined in BaseCreature and they are used in BaseAI.cs.
 

Jasonntn

Wanderer
OK guys, I have a couple of questions.

1. How do I completely remove the insta-kill guards from my server? I tried manually removing them in each city. But when I restarted my server they were back. :(
(I'm using Nerun's latest release, btw)

2. If I increase the range for your guards and more than one hears 'guards' being called will two (or more) of them come after the criminal?

I'm wanting these guards on my server to be tough (particularly in the bigger towns) but mortal.

And thanks for the great work. This is the most promising guard system I've ever seen.
 

Greystar

Wanderer
Jasonntn;741608 said:
OK guys, I have a couple of questions.

1. How do I completely remove the insta-kill guards from my server? I tried manually removing them in each city. But when I restarted my server they were back. :(
(I'm using Nerun's latest release, btw)

2. If I increase the range for your guards and more than one hears 'guards' being called will two (or more) of them come after the criminal?

I'm wanting these guards on my server to be tough (particularly in the bigger towns) but mortal.

And thanks for the great work. This is the most promising guard system I've ever seen.

If you want to leave guarded regions but remove guards it could be difficult... otherwise just go into GuardedRegion.cs and make this

private bool m_Disabled;

look like

private bool m_Disabled = true;

Theoretically that should do it. However you can also disable it from the XML file for the regions... Not sure were it needs to be entered but if you place disabled in the xml file it's supposed to disable the guards for the region. So you could leave guards around all the moongates but disable them everywhere else.
 

shivan

Sorceror
1.8 released, everyone using this guards should update to 1.8 ASAP, because this version fix the problem with the archer crashing clients.
 

Jasonntn

Wanderer
3) How open you BaseCreature.cs, find this line:


Code:
public virtual OppositionGroup OppositionGroup
{
get { return null; }
}change it for this


Code:
public virtual OppositionGroup OppositionGroup
{
get { return OppositionGroup.newguards; }
}





I looked everywhere in my BaseCreature.cs file for this (all 4807 lines) and couldn't find it anywhere(?)
 

Jasonntn

Wanderer
Thanks for the tip. I searched all the way down that script twice and missed it both times until just now when I knew where to be expecting it.
 

Jasonntn

Wanderer
Errors:
+ Engines/AI/Creature/BaseCreature.cs:
CS0201: Line 657: Only assignment, call, increment, decrement, and new objec
t expressions can be used as a statement
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.





This is with the latest (1.8) release of this script and pasting in the updates - something seems to be wrong with the BaseCreature.cs
 

Jasonntn

Wanderer
Here are the offending lines:

public BaseAI AIObject{ get{ return m_AI; } }

public const int MaxOwners = 5;

public virtual OppositionGroup OppositionGroup
{
get { OppositionGroup.newguards; }
}


I also attatched my file if this helps.
 

Attachments

  • BaseCreature.cs
    115.7 KB · Views: 19
Top