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!

[1.0 & 2] Killable RP Guards

mehoo

Sorceror
Yeah it stopped for me to, but it seemed to happen when guards were called on a mob the killable guards were currently attacking.
 

Deimos

Page
Hmm strange
It's a shame, because it seems to happen whenever you approach an area with them in, or if you come through a portal/gate to an area.
Doesn't happen ALL the time mind you, but it's annoying either way.
 

Loyd123

Wanderer
first i'd like to say the script is awesome, thanks for releasing it.


Altho i would like to make the guards stick on a player's a$$ if they are not mounted, but if the player is mounted he might actually have a chance to get away from the guards.


Is that possible ? If yes, can someone show me the right way, thanks.



ALSO


I have found that guards following waypoints to let say patrol the city won't bother getting off their course to attack a criminal, even if i attack a guard directly they won't move from the waypoints they are following (tested using a player character)

Any way to fix that?
 

Palma

Sorceror
Hey Loyd,

Messing with speeds is quite hard if you want to find a correct one you need a lot of testing.
Altough I suggest you look at this guy's idea: http://www.runuo.com/forums/custom-script-releases/79231-creature-follow-speeds.html

My suggestion would be to make the warrior's speed equal to the criminal player's speed if he's not on a mount.
Perhaps make also some mounted guards that run at player's speed if they are mounted.
Actually this is a quite nice idea, might as well do this for my guards :p


If no one replies to your question about the fight mode as well as mine, I suggest you to turn them into paragons like I did.
It works great, as paragons they attack before reaching the way point as they attack right the moment the enemy shows up.

You'd just need to remove the artifact change from them and give them a normal hue :)

If you need any help feel free to Private message me.

Regards,
Pedro
 

MIKTHEBUG

Sorceror
mehoo;817696 said:
The" baseguardian" are being treated as GameMaster Chars ( Mobs don't cast spells on them or chase them if they run ) any ideas for a fix?

I just wanted to second that,but all the guardians are treated that way, unless you provoke monsters on to them then they are attacking in a normal way, but since i am a total noob at this i dont even know where to start looking:p

EDIT: I managed to copy and past abit and learn somethings by testing, so now i can make my own guards etc, but i can not figure out how to make the melee guards heal them selfs whit bandage, if this is possible.
 

Loki8213

Traveler
Thanks A Lot Bujinsho. This script really came in handy. Just a few questions.

1: I'd like to have the guards run after criminals and not just walk. Is there any way to make them actually "run"? I don't want to make them "faster walkers," I want them to actually run and I don't want to give them mounts.

2: They don't have backpacks and even if they did, I don't believe they'd have the AI to use bandages. Does anyone know a way to make them heal using bandages?

3: I know this sounds simple enough, but I'm having trouble getting them to attack Red, non-criminal players.
I tried:
if (m != null && (m.Kills > 4) )
return true;
 

Thagoras

Sorceror
Do NOT copy this directly because there are a number of mods that are just for my shard and will give you errors. However, your BaseGuardian should have an IsEnemy module. But if not, (I don't remember what the baseguardian looks like) this is a working module that does that...excepting, mine go after any murderer or criminal.

Code:
		public override bool IsEnemy( Mobile m )
		{
			if (m is BaseGuardian || m is BaseVendor || m is PlayerVendor || m is TownCrier ) return false;
			else if (m is PlayerMobile)
			{ 
				PlayerMobile pm = (PlayerMobile) m;
				if (pm.IsInnocent == true) return false;
				if (!pm.Criminal && (pm.Kills == 0)) return false;
				if (pm.Region.Name == "Umbra" && pm.Vampire > 0) return false;
				if (pm.BodyMod > 0) return false;
				return true;
			}
			else if (m is BaseCreature)
			{
				BaseCreature c = (BaseCreature)m;

				if( c.Murderer ) return true;
				if( c.Controlled || c.FightMode == FightMode.Aggressor || c.FightMode == FightMode.None ) return false;
				if ((c.AI == AIType.AI_Animal) || (c.AI == AIType.AI_Predator)) return false;
				return true;
			}
			else return true;

			//return true;
		}

As far as Backpacks, add
Code:
Container pack = new Backpack();

			pack.DropItem( new Bandages(10) );

			pack.Movable = false;

			AddItem( pack );
to their constructable... And as far as using them...I thought that Ravenal was working on an improved AI which was supposed to use their skills and stuff from their pack.

And running after criminals...that's an AI edit. LINK: http://www.runuo.com/forums/script-support/95499-make-run.html
 

Loki8213

Traveler
Ok, I already had the backpacks and the bandages. I thought it wasn't working because I kept restarting the server and checking guards that were already created. Upon adding a new one I realized that it does work.
As for using the bandages, I don't believe Revanal ever posted a solution.

Also, I still can't get my guards to attack reds. Sorry, but your example didn't exactly help. I also tried:
if (m is PlayerMobile && (m.Kills > 4))
return true;
I don't understand why the hell that doesn't work... It doesn't give me an error when I restart the server. Is it because I'm using already spawned guards? Do I have to create new guards in the game after I add that part of the script to get them to function properly?

I'm using RunUO 2.0 SVN 372. If anyone has a suggestion feel free to share. Here's my script:

using System;
using System.Collections;
using Server.Misc;
using Server.Items;
using Server.Mobiles;

namespace Server.Mobiles
{
public class Guards : BaseCreature
{

[Constructable]
public Guards()
: base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
{
Title = "Town Guard";

SpeechHue = Utility.RandomDyedHue();

Hue = Utility.RandomSkinHue();

SetStr(150, 150);
SetDex(100, 100);
SetInt(61, 75);

SetSkill(SkillName.MagicResist, 100.0, 100.0);
SetSkill(SkillName.Swords, 100.0, 100.0);
SetSkill(SkillName.Tactics, 100.0, 100.0);
SetSkill(SkillName.Anatomy, 100.0, 100.0);

SetDamage(30, 35);

AddItem(new Broadsword());
AddItem(new MetalShield());
AddItem(new PlateHelm());
AddItem(new PlateLegs());
AddItem(new PlateArms());
AddItem(new PlateGloves());
AddItem(new PlateGorget());
AddItem(new PlateChest());

Container pack = new Backpack();

pack.DropItem(new Bandage(25));

pack.Movable = false;

AddItem(pack);

if (Female = Utility.RandomBool())
{
Body = 401;
Name = NameList.RandomName("female");

}
else
{
Body = 400;
Name = NameList.RandomName("male");

}
}


public override bool IsEnemy(Mobile m)
{
if ((m is Guards))
return false;

if (m is BaseVendor || m is TownCrier || m is Guards || m is PlayerVendor)
return false;

if (m != null && (m.Criminal == true))
return true;

if (m is PlayerMobile && (m.Criminal == false))
return false;

if (((BaseCreature)m).FightMode == FightMode.None)
return false;

if (m is PlayerMobile && (m.Kills > 4))
return true;

if (((BaseCreature)m).FightMode != FightMode.Aggressor && !((BaseCreature)m).Controlled)
return true;

if (m != null && (m.Criminal == false))
return false;

BaseCreature c = (BaseCreature)m;

if (!(c is BaseCreature && !c.Controlled) || c is Server.Engines.Quests.Haven.MilitiaFighter)
return false;


return true;
}

public Guards(Serial serial)
: base(serial)
{
}

public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);

writer.Write((int)0); // version
}

public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);

int version = reader.ReadInt();
}
}
}
 

Thagoras

Sorceror
Please, when posting scripts, use the code tags...the # symbol in the message tool bar. You can also do it manually by [ code ] and [ / code ] (minus spaces).

I'm beginning to think that you may just need to respawn the guards with the new code. I've run into that before. Those guards are using an old instance of the Guard script, I would think. (someone please correct me if I'm wrong).
 

Bujinsho

Page
Thagoras is correct ... that is the old version and is not very elegant at all ... quite embarrassing looking at it now

Aside from that, the reason your mod didn't work is because the Reds are not automatically criminal. Therefore:

Code:
public override bool IsEnemy(Mobile m)
{
if ((m is Guards))
return false;

if (m is BaseVendor || m is TownCrier || m is Guards || m is PlayerVendor)
return false;

if (m != null && (m.Criminal == true))
return true;

[COLOR="Red"]if (m is PlayerMobile && (m.Criminal == false))
return false;
[/COLOR]
if (((BaseCreature)m).FightMode == FightMode.None)
return false;

if (m is PlayerMobile && (m.Kills > 4))
return true;

if (((BaseCreature)m).FightMode != FightMode.Aggressor && !((BaseCreature)m).Controlled)
return true;

if (m != null && (m.Criminal == false))
return false;

BaseCreature c = (BaseCreature)m;

if (!(c is BaseCreature && !c.Controlled) || c is Server.Engines.Quests.Haven.MilitiaFighter)
return false;


return true;
}

The line in red returns false before the code even reaches your change.

Best thing to do is switch to the new version ... but even then they won't attack reds by default unless they commit a criminal act.

Whichever version you use ... put your change before the line in red.

If you want them to heal themselves ... add this somewhere in BaseGuardian.cs (assuming you use the new version) ... for the old just put it in the guard script ... just after IsEnemy is a good place

Code:
private void HealSelf()
        {
            if (BandageContext.GetContext(this) == null)
            {
                BandageContext.BeginHeal(this, this);
            }

            return;
        }

        public override void OnThink()
        {
            if (Utility.RandomDouble() < 0.6 && Hits < (HitsMax - 15) && !Hidden)
                HealSelf();
        }

Don't forget to give them some bandages tho :rolleyes:
 

ntony

Sorceror
In fact, guards could be modified to be killable and does not perform insta-kill from RunUO 2.0 Final code.
Take a look on WarriorGuard.cs and ArcherGuard.cs.
The code is there and it is commented.
 

Bujinsho

Page
In fact, guards could be modified to be killable and does not perform insta-kill from RunUO 2.0 Final code.
Take a look on WarriorGuard.cs and ArcherGuard.cs.
The code is there and it is commented.

I think you might be missing the point a bit here :p
 

MontegroXD

Wanderer
Hey all, hope you don't mind, but I set up multiple types of guards for my server. My server only has Trammel as an active world, so I made 'Rangers' which are the base NPC's in the KillableGuards code (also rewrote BaseGuard to BaseRanger) and then made a new set of guards for every town in Trammel except Haven/Ocello because that's been taken over by Orcs. Hope you all enjoy!
 

Attachments

  • New Guard System.zip
    40.4 KB · Views: 37
Top