Dian

Member
So I am sure you know about them, lets take the Pixie for example;

When you encounter a Pixie in Ilshenar and you have positive Karma, the Pixie will leave you alone unless you attack them first. However, if your character has negative Karma, a Pixie will attack you as any other normal creature would, like a dragon.

At the moment here, I am getting attacked by Pixies no matter what my Karma is.
The Pixie script has them set to InitialInnocent true which as far as I understand is what should be the method that would be set for this.
Looking into BaseCreature, I notice that the ServUO uses xmlData / xmlAttachments as a check reference for this.
I had removed that and swapped it back to the original RunUO method, but still no difference.

On my older shard, a RunUO 2.3 modified server, my pixies didnt attack a pos. Karma player, and I thought I had it sorted, but upon testing with a Negative Karma player, they still didnt attack, lol

Is this just me, and maybe something I need to straighten out with my code, or is this happening with a normal ServUO as well? Can someone check this out?

Thanks
 
I forgot, i had set my Pixies to my older server to be FightMode.Aggressor as a band-aid until I had time to code it correctly.. I guess no one had added this code for Karma checks on aggressive behavior yet.

Also, something interesting on the Lore of a Pixie I was reading..
UO Guide:
Pixies seem to enjoy pestering humans with a mischievous glee and have been known to harass a passerby for hours.
However, those that choose to dispose of a pixie by violent means, beware. They have powerful magics at their command and can leave behind a curse in death.


I have killed plenty of them on OSI, never noticed anything out of the ordinary when they died.. interesting. But I do seem to recall that they did almost seem to follow you around somewhat at times.. not sure though. :)
 
Code:
private Alignment alignment = Alignment.None;

        [CommandProperty(AccessLevel.GameMaster)]
        public Alignment CreatureAlignment
        {
            get { return alignment; }
            set { alignment = value; }
        }

        private int karmaThreshold = 0;

        public int KarmaThreshold
        {
            get { return karmaThreshold; }
            set { karmaThreshold = value; }
        }

        public enum Charge
        {
            None,
            Positive,
            Negative
        }

        private Charge charge = Charge.None;

        public Charge CreatureCharge
        {
            get { return charge; }
            set { charge = value; }
        }

        public virtual void OnThink()
        {
            if (!m_bSummoned && ControlMaster == null && Hits > (HitsMax * 0.15))
            {
                int mobsInRange = 0;

                foreach (Mobile m in GetMobilesInRange(16))
                {
                    mobsInRange++; break;
                }

                if (mobsInRange == 0)
                    return;

                if (Karma >= -400 && Karma <= 400) CreatureAlignment = Alignment.Neutral;

                else if (Karma > -4000 && Karma < -400) CreatureAlignment = Alignment.Chaotic;        
                else if (Karma > 400 && Karma < 4000) CreatureAlignment = Alignment.Lawful;

                else if (Karma <= -8000) CreatureAlignment = Alignment.Evil;
                else if (Karma >= 8000) CreatureAlignment = Alignment.Good;

                if (CreatureAlignment != Alignment.None)
                    FightMode = FightMode.Aggressor;

                if (this is EnergyVortex || this is BladeSpirits)
                {
                    FightMode = FightMode.Strongest;
                    CreatureAlignment = Alignment.None;
                }

                if (Combatant == null && Utility.RandomDouble() < 0.1667 &&
                    CreatureAlignment != Alignment.None && CreatureAlignment != Alignment.Neutral)
                {
                    switch (alignment)
                    {
                        case Alignment.Good:
                            {
                                KarmaThreshold = -400;
                                CreatureCharge = Charge.Positive;
                                break;
                            }

                        case Alignment.Lawful:
                            {
                                KarmaThreshold = -3000;
                                CreatureCharge = Charge.Positive;
                                break;
                            }

                        case Alignment.Chaotic:
                            {
                                KarmaThreshold = 100;
                                CreatureCharge = Charge.Negative;
                                break;
                            }

                        case Alignment.Evil:
                            {
                                KarmaThreshold = -400;
                                CreatureCharge = Charge.Negative;
                                break;
                            }

                        default: break;
                    }

                    foreach (Mobile m in this.GetMobilesInRange(12))
                    {
                        if (m != null && CanSee(m))
                        {
                            if (m is Player && ((Player)m).AccessLevel > AccessLevel.Player)
                                return;

                            if (CreatureCharge == Charge.Negative && m.Karma >= KarmaThreshold)
                            {
                                DoHarmful(m); return;
                            }

                            if (CreatureCharge == Charge.Positive && m.Karma <= KarmaThreshold)
                            {
                                DoHarmful(m); return;
                            }

                            if (m is BaseCreature)
                            {
                                BaseCreature bc = m as BaseCreature;

                                if (CreatureCharge == Charge.Negative &&
                                    (bc.CreatureAlignment == Alignment.Lawful || bc.CreatureAlignment == Alignment.Good))
                                {
                                    DoHarmful(m); return;
                                }

                                if (CreatureCharge == Charge.Positive &&
                                    (bc.CreatureAlignment == Alignment.Chaotic || bc.CreatureAlignment == Alignment.Evil))
                                {
                                    DoHarmful(m); return;
                                }

                                if (bc.Team != this.Team && CanSee(bc))
                                {
                                    DoHarmful(m); return;
                                }
                            }
                        }
                    }
                }
            }

This doesn't complete the OnThink method. Don't forget to serialize. I always do!

Also I should note that 0.1667 is basically going to determine the rate of recognition, which I'm always tinkering with. I think 0.1667 may be too low infact.
 
Last edited:
Cool, thanks @Enroq I wil lmess with that :)

Milva, I tried with/without Necro but no difference. I have been through the code, and have not found anything that does a karma check really.. yet. Thanks though :)
 
Pixie is FightMode.Evil:

Code:
  [Constructable]
public Pixie()
: base(AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4)

In Basecreature.cs, in the IsEnemy method:

Code:
  BaseCreature c = (BaseCreature)m;

if ((FightMode == FightMode.Evil && m.Karma < 0) || (c.FightMode == FightMode.Evil && Karma < 0))
{
return true;
}
 
HMMMMMMM lol, yeah i saw that while I was scanning code earlier.. looking for the right method to add support for karma check, and was wondering. I will play around with those settings and let you know.
Thanks Rave :)
 
Interestingly, I'm seeing the same thing, they should not attack according to that code and the aquire section of BaseAI. But I just got attacked by a pixie on the test server. Weird.
 
Yeah, that's why I said to hell with it and overrode the entire thing. I didn't feeling like looking for the problem.. well, actually I also wanted multiple levels of alignment.
 
naa, they work perfectly. Blue, wont attack positive karma, but will attack negitiva karma. :)

Set the FightMode.Evil and also the InitialInnocent return true;
 
no, I set the Pixie to FightMode.Evil and with the public override bool InitialInnocent { get {return true; } } it works just as it should.

I looked at the distro ServUO 54, and the pixie is already set that way.. I just had used my own Pixie script from my old converted RUO shard... and it was set at FightMode.Closest.

So I guess the whole problem was just on my end.. yep.. it does happen from time to time!
 
I'm lost, which fix worked? Did you do Enroq's fix?

Ravenwolfe, Curious if you still did not have that pixie working correct. I wasn't really paying attention that you mentioned they didn't work correct on your server.

I realized the Cu Sidhe wasn't working correct as well.. so I began tweaking I have a fix for them, but I think there's more involved with the pixie and the couple other Fey that only attack negative karma players.
The Cu Sidhe is suppose to be similar, in that it wont attack a player unless negative karma. What I did there, is set them typical AIType.AI_Animal, FightMode.Aggressor
I then override the IsEnemy method in the Cu script as so..
C#:
public override bool IsEnemy(Mobile m)
  {
      if (!this.Controlled && (m is PlayerMobile && m.Karma < 0) )
      {
           return true;
      }

      return base.IsEnemy(m);
  }

That seems to get them reacting as they do on OSI now. I am going to revisit the pixie, Dryad and uhh.. Satyre now :)
 
ok, Cu Sidhe is working as it should with AIType.AI_Animal, FightMode.Evil,
and IsEnemy override as so;

C#:
public override bool IsEnemy(Mobile m)
{
    if (!this.Controlled && (m is PlayerMobile && m.Karma < 0) )
    {
        return true;
    }
    return base.IsEnemy(m);
}
 
Well the Cu Sidhe attacks other creatures (like dire wolf) set this way. Still not quite accurate. I will test more thorough before I post a code fix noex time ;)
Still working on it.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back