PigPen

Member
I have a Server using RunUO - [www.runuo.com] Version 2.1, Build 6905.732
Core: Running on .NET Framework Version 4.0.30319
Core: Optimizing for 12 64-bit processors

A week ago I decided to tweak the rewards dropped when a Champion is killed.

My hope is to encourage more 'group activity' and give special rewards if a group is used as opposed to having them soloed. (if they are soloed then the reward is sufficient because it does not need to be shared).

Well . . with my limited experience scripting (specifically with Lists and DamageStore), I am stumbling badly trying to identify the 'group members' to drop my reward in their backpack.

I have tried numerous variations and done several searches trying to find a solution but now I'm dead in the water.

If anyone can help out on this your help would be much appreciated.

Here is my latest set of Errors:
Code:
Errors:
+ Mobiles/Special/BaseChampion.cs:
    CS0103: Line 362: The name 'm' does not exist in the current context
    CS0103: Line 367: The name 'm' does not exist in the current context
    CS0103: Line 372: The name 'm' does not exist in the current context
    CS0103: Line 378: The name 'm' does not exist in the current context

and . . here is where the Errors are (the 'OnDeath' section of my BaseChampion.cs)
Code:
        public override void OnDeath( Container c )
        {
            List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );
            List<Mobile> toGive = new List<Mobile>();

            for ( int i = rights.Count - 1; i >= 0; --i )
            {
                DamageStore ds = rights[i];

                if ( ds.m_HasRight )
                    toGive.Add( ds.m_Mobile );
            }

            if ( toGive.Count == 1 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain by one person.");
                m.AddToBackpack(new BronzeRewardBag());
            }
            if ( toGive.Count == 2 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain with injuries from two hunters.");
                m.AddToBackpack( new SilverRewardBag() );
            }
            if ( toGive.Count == 3 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain with injuries from three hunters.");
                m.AddToBackpack( new GoldRewardBag() );
            }

            if ( toGive.Count > 3 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain with injuries from a group of hunters.");
                m.AddToBackpack( new Aegis() );
            }

            if ( toGive.Count > 0 )
                toGive[Utility.Random( toGive.Count )].AddToBackpack( new ChampionSkull( SkullType ) );
            else
                c.DropItem( new ChampionSkull( SkullType ) );

            base.OnDeath( c );
        }

and . . here is my complete BaseChampion.cs
Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Engines.CannedEvil;
using System.Collections.Generic;

namespace Server.Mobiles
{
    public abstract class BaseChampion : BaseCreature
    {
        public BaseChampion( AIType aiType ) : this( aiType, FightMode.Closest )
        {
        }

        public BaseChampion( AIType aiType, FightMode mode ) : base( aiType, mode, 18, 1, 0.1, 0.2 )
        {
        }

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

        public abstract ChampionSkullType SkullType{ get; }

        public abstract Type[] UniqueArtifacts { get; }
        public abstract Type[] SharedArtifacts { get; }
        public abstract Type[] DecorationArtifacts { get; }
        public abstract MonsterStatuetteType[] StatueTypes { get; }

        public virtual bool NoGoodies{ get{ return false; } }

        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();
        }

        public Item GetArtifact()
        {
            double random = Utility.RandomDouble();

            if (random < 0.30)
            {
                double random1 = Utility.Random(29);
                if (random1 <= 4)
                    return CreateArtifact(UniqueArtifacts);
                else if (random1 >= 5 && random1 <= 14)
                    return CreateArtifact(SharedArtifacts);
                else
                    return CreateArtifact(DecorationArtifacts);
            }
            return null;
        }

        public Item CreateArtifact(Type[] list)
        {
            if (list.Length == 0)
                return null;

            int random = Utility.Random(list.Length);

            Type type = list[random];

            Item artifact = Loot.Construct(type);

            if (artifact is MonsterStatuette && StatueTypes.Length > 0)
            {
                ((MonsterStatuette)artifact).Type = StatueTypes[Utility.Random(StatueTypes.Length)];
                ((MonsterStatuette)artifact).LootType = LootType.Regular;
            }

            return artifact;
        }

        private PowerScroll CreateRandomPowerScroll()
            {
                int level;
                double random = Utility.RandomDouble();

                if( this is LordOaks )
                {
                    if ( 0.2 >= random )
                      level = 20;
                    else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Mephitis )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Neira )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Rikktor )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Semidar )
                {
                        if ( 0.3 >= random )
                        level = 20;
                else if ( 0.6 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Serado )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                level = 10;
                return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Ilhenir )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Twaulo )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Meraktus )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }

                else // calculating it the original way
                {
                    if ( 0.05 >= random )
                        level = 20;
                else if ( 0.2 >= random )
                        level = 15;
                else if ( 0.5 >= random )
                        level = 10;
                else
                level = 5;

                return PowerScroll.CreateRandomNoCraft( level, level );
                }
            }

        public void GivePowerScrolls()
        {

            List<Mobile> toGive = new List<Mobile>();
            List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );

            for ( int i = rights.Count - 1; i >= 0; --i )
            {
                DamageStore ds = rights[i];

                if ( ds.m_HasRight )
                    toGive.Add( ds.m_Mobile );
            }

            if ( toGive.Count == 0 )
                return;

            for( int i = 0; i < toGive.Count; i++ )
            {
                Mobile m = toGive[i];

                if( !(m is PlayerMobile) )
                    continue;

                bool gainedPath = false;

                int pointsToGain = 800;

                if( VirtueHelper.Award( m, VirtueName.Valor, pointsToGain, ref gainedPath ) )
                {
                    if( gainedPath )
                        m.SendLocalizedMessage( 1054032 ); // You have gained a path in Valor!
                    else
                        m.SendLocalizedMessage( 1054030 ); // You have gained in Valor!

                    //No delay on Valor gains
                }
            }

            // Randomize
            for ( int i = 0; i < toGive.Count; ++i )
            {
                int rand = Utility.Random( toGive.Count );
                Mobile hold = toGive[i];
                toGive[i] = toGive[rand];
                toGive[rand] = hold;
            }

            for ( int i = 0; i < 8; ++i )
            {
                Mobile m = toGive[i % toGive.Count];

                PowerScroll ps = CreateRandomPowerScroll();

                GivePowerScrollTo( m, ps );
            }
        }

        public static void GivePowerScrollTo( Mobile m, PowerScroll ps )
        {
            if( ps == null || m == null )    //sanity
                return;

            m.SendLocalizedMessage( 1049524 ); // You have received a scroll of power!

            if( !Core.SE || m.Alive )
                m.AddToBackpack( ps );
            else
            {
                if( m.Corpse != null && !m.Corpse.Deleted )
                    m.Corpse.DropItem( ps );
                else
                    m.AddToBackpack( ps );
            }

            if( m is PlayerMobile )
            {
                PlayerMobile pm = (PlayerMobile)m;

                for( int j = 0; j < pm.JusticeProtectors.Count; ++j )
                {
                    Mobile prot = pm.JusticeProtectors[j];

                    if( prot.Map != m.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion( m, prot ) )
                        continue;

                    int chance = 0;

                    switch( VirtueHelper.GetLevel( prot, VirtueName.Justice ) )
                    {
                        case VirtueLevel.Seeker: chance = 60; break;
                        case VirtueLevel.Follower: chance = 80; break;
                        case VirtueLevel.Knight: chance = 100; break;
                    }

                    if( chance > Utility.Random( 100 ) )
                    {
                        PowerScroll powerScroll = new PowerScroll( ps.Skill, ps.Value );

                        prot.SendLocalizedMessage( 1049368 ); // You have been rewarded for your dedication to Justice!

                        if( !Core.SE || prot.Alive )
                            prot.AddToBackpack( powerScroll );
                        else
                        {
                            if( prot.Corpse != null && !prot.Corpse.Deleted )
                                prot.Corpse.DropItem( powerScroll );
                            else
                                prot.AddToBackpack( powerScroll );
                        }
                    }
                }
            }
        }

        public override bool OnBeforeDeath()
        {
            if ( !NoKillAwards )
            {
                GivePowerScrolls();


                if ( (this is StoneManChamp) || (this is CPSemidar)  )
                {
                    return base.OnBeforeDeath();
                }

                if( NoGoodies )
                    return base.OnBeforeDeath();

                Map map = this.Map;

                if ( map != null )
                {
                    for ( int x = -12; x <= 12; ++x )
                    {
                        for ( int y = -12; y <= 12; ++y )
                        {
                            double dist = Math.Sqrt(x*x+y*y);

                            if ( dist <= 12 )
                                new GoodiesTimer( map, X + x, Y + y ).Start();
                        }
                    }
                }
            }

            return base.OnBeforeDeath();
        }

        public override void OnDeath( Container c )
        {
                //TODO: Confirm SE change or AoS one too?
                List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );
                List<Mobile> toGive = new List<Mobile>();

                for ( int i = rights.Count - 1; i >= 0; --i )
                {
                    DamageStore ds = rights[i];

                    if ( ds.m_HasRight )
                        toGive.Add( ds.m_Mobile );
                }

            if ( toGive.Count == 1 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain by one person.");
                m.AddToBackpack(new BronzeRewardBag());
            }
            if ( toGive.Count == 2 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain with injuries from two hunters.");
                m.AddToBackpack( new SilverRewardBag() );
            }
            if ( toGive.Count == 3 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain with injuries from three hunters.");
                m.AddToBackpack( new GoldRewardBag() );
            }

                if ( toGive.Count > 0 )
                    toGive[Utility.Random( toGive.Count )].AddToBackpack( new ChampionSkull( SkullType ) );
                else
                    c.DropItem( new ChampionSkull( SkullType ) );

            base.OnDeath( c );
        }

        private class GoodiesTimer : Timer
        {
            private Map m_Map;
            private int m_X, m_Y;

            public GoodiesTimer( Map map, int x, int y ) : base( TimeSpan.FromSeconds( Utility.RandomDouble() * 10.0 ) )
            {
                m_Map = map;
                m_X = x;
                m_Y = y;
            }

            protected override void OnTick()
            {
                int z = m_Map.GetAverageZ( m_X, m_Y );
                bool canFit = m_Map.CanFit( m_X, m_Y, z, 6, false, false );

                for ( int i = -3; !canFit && i <= 3; ++i )
                {
                    canFit = m_Map.CanFit( m_X, m_Y, z + i, 6, false, false );

                    if ( canFit )
                        z += i;
                }

                if ( !canFit )
                    return;

                Gold g = new Gold( 100, 150 );
              
                g.MoveToWorld( new Point3D( m_X, m_Y, z ), m_Map );

                if ( 0.5 >= Utility.RandomDouble() )
                {
                    switch ( Utility.Random( 3 ) )
                    {
                        case 0: // Fire column
                        {
                            Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x3709, 10, 30, 5052 );
                            Effects.PlaySound( g, g.Map, 0x208 );

                            break;
                        }
                        case 1: // Explosion
                        {
                            Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x36BD, 20, 10, 5044 );
                            Effects.PlaySound( g, g.Map, 0x307 );

                            break;
                        }
                        case 2: // Ball of fire
                        {
                            Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x36FE, 10, 10, 5052 );

                            break;
                        }
                    }
                }
            }
        }
    }
}

Thank you for your time looking at this one.

*bows*
 
Last edited:
Just change your
Code:
m.AddToBackpack(new BronzeRewardBag());

to

Code:
c.DropItem(new BronzeRewardBag());

because since you're overriding OnDeath, the "c" refers to the pack of the killed mob and the reward you drop will go there. Do the same fix for each of the instances and you should be good to go!
Post automatically merged:

And if you want to give the reward to each of the fighters you'll need a for loop in each of the Count cases that rewards all members in the "toGive" list with the appropriate reward. No time now to figure out the syntax for that one but I'll give it a shot when I have some free time if nobody else steps up!
 
Last edited:
I've attached a modified script I use to distribute EvoEggs for the evolution creatures. You can see on line 105 I define the Type "eggs" and then on line 138 I create the instance and then on line 163 I use begin the actual distribution using line 173 with GiveEggsTo (corpse.Killer)

Not sure how to implement that for the "party" but it works when using a single player. Hope this helps a bit.
 

Attachments

  • MadBreederAbomination.cs
    6 KB · Views: 3
Just change your
Code:
m.AddToBackpack(new BronzeRewardBag());

to

Code:
c.DropItem(new BronzeRewardBag());

because since you're overriding OnDeath, the "c" refers to the pack of the killed mob and the reward you drop will go there. Do the same fix for each of the instances and you should be good to go!
Post automatically merged:

And if you want to give the reward to each of the fighters you'll need a for loop in each of the Count cases that rewards all members in the "toGive" list with the appropriate reward. No time now to figure out the syntax for that one but I'll give it a shot when I have some free time if nobody else steps up!
Thank you Falkor.

I hear you about 'c' in OnDeath and that is one option. However . . . I really wanted to drop the Reward into the backpacks of those who were doing damage to the Champion. There might well be others attending who were more observers than participants. Also did not want to set up a situation where the person (or leader) in the group had to decide which people did damage.

If you (or anyone) can think up the syntax than might work here (or elsewhere) in the script . . that would be the cherries.

You time and eyes are appreciated.

*bows*
Post automatically merged:

I've attached a modified script I use to distribute EvoEggs for the evolution creatures. You can see on line 105 I define the Type "eggs" and then on line 138 I create the instance and then on line 163 I use begin the actual distribution using line 173 with GiveEggsTo (corpse.Killer)

Not sure how to implement that for the "party" but it works when using a single player. Hope this helps a bit.
Thank you kfritz411. That is an interesting way of rewarding the 'Killer'. I have used similar methods myself.

In the case though . . I am trying to reward not just the 'Killer' but anyone with the 'Killer' who contributed to the victory by also doing damage. So yes . . I am also not sure how to implement rewarding others in the group. (I was not thinking about the use of 'Party' but that may open some possibilities).

A solution on this might be of interest to others here but so far its above my abilities.
 
Last edited:
Still at it and still losing.

Falkor and kfritz411 got me thinking I should move my attempt (to give special rewards) out of the OnDeath section of BaseChampion.cs so I have been trying several variations working in the 'GivePowerScrolls' and 'GivePowerScrollTo( Mobile m, PowerScroll ps )' sections of the script.

When trying the sample shown below with the 'GivePowerScrolls()' section . . 'm' is not recognized as the Players. Yet . . if I try placing my reward giving text in the 'GivePowerScrollTo( Mobile m, PowerScroll ps )' section, it will not recognize 'toGive.Count'.

Seems like I'm stuck no matter which section I try to use and I don't know how to pass the 'toGive.Count' value from 'GivePowerScrolls()' to 'GivePowerScrollTo( Mobile m, PowerScroll ps )' . . . or for that matter . . . from either of these into the 'OnDeath' section in my original attempts.

This is my latest set of Errors:
Code:
Errors:
+ Mobiles/Special/BaseChampion.cs:
    CS0103: Line 257: The name 'm' does not exist in the current context
    CS0103: Line 262: The name 'm' does not exist in the current context
    CS0103: Line 269: The name 'm' does not exist in the current context

and . . this is the GivePowerScrolls section of my BaseChampion.cs where the Errors occur:
Code:
        public void GivePowerScrolls()
        {
            List<Mobile> toGive = new List<Mobile>();
            List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );

            for ( int i = rights.Count - 1; i >= 0; --i )
            {
                DamageStore ds = rights[i];

                if ( ds.m_HasRight )
                    toGive.Add( ds.m_Mobile );
            }

            if ( toGive.Count == 0 )
                return;

            for( int i = 0; i < toGive.Count; i++ )
            {
                Mobile m = toGive[i];

                if( !(m is PlayerMobile) )
                    continue;

                bool gainedPath = false;

                int pointsToGain = 800;

                if( VirtueHelper.Award( m, VirtueName.Valor, pointsToGain, ref gainedPath ) )
                {
                    if( gainedPath )
                        m.SendLocalizedMessage( 1054032 ); // You have gained a path in Valor!
                    else
                        m.SendLocalizedMessage( 1054030 ); // You have gained in Valor!

                    //No delay on Valor gains
                }
            }

            // Randomize
            for ( int i = 0; i < toGive.Count; ++i )
            {
                int rand = Utility.Random( toGive.Count );
                Mobile hold = toGive[i];
                toGive[i] = toGive[rand];
                toGive[rand] = hold;
            }

            for ( int i = 0; i < 8; ++i )
            {
                Mobile m = toGive[i % toGive.Count];

                PowerScroll ps = CreateRandomPowerScroll();

                GivePowerScrollTo( m, ps );
            }

//Edit - Try Giving Special Rewards Here:

            if ( toGive.Count < 2 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain by one person.");
                m.AddToBackpack(new BronzeRewardBag());
            }
            else if ( toGive.Count < 3 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain by two people.");
                m.AddToBackpack(new SilverRewardBag());
            }
            else
            {
                if ( toGive.Count > 3 )
                {
                    World.Broadcast( 0x35, true, "A Champion was just slain by one person.");
                    m.AddToBackpack(new GoldRewardBag());
                }
            }
        }

and . . this is the complete 'current' version of my BaseChampion.cs
Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Engines.CannedEvil;
using System.Collections.Generic;

namespace Server.Mobiles
{
    public abstract class BaseChampion : BaseCreature
    {

        public BaseChampion( AIType aiType ) : this( aiType, FightMode.Closest )
        {
        }

        public BaseChampion( AIType aiType, FightMode mode ) : base( aiType, mode, 18, 1, 0.1, 0.2 )
        {
        }

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

        public abstract ChampionSkullType SkullType{ get; }

        public abstract Type[] UniqueArtifacts { get; }
        public abstract Type[] SharedArtifacts { get; }
        public abstract Type[] DecorationArtifacts { get; }
        public abstract MonsterStatuetteType[] StatueTypes { get; }

        public virtual bool NoGoodies{ get{ return false; } }

        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();
        }

        public Item GetArtifact()
        {
            double random = Utility.RandomDouble();

            if (random < 0.30)
            {
                double random1 = Utility.Random(29);
                if (random1 <= 4)
                    return CreateArtifact(UniqueArtifacts);
                else if (random1 >= 5 && random1 <= 14)
                    return CreateArtifact(SharedArtifacts);
                else
                    return CreateArtifact(DecorationArtifacts);
            }
            return null;
        }

        public Item CreateArtifact(Type[] list)
        {
            if (list.Length == 0)
                return null;

            int random = Utility.Random(list.Length);

            Type type = list[random];

            Item artifact = Loot.Construct(type);

            if (artifact is MonsterStatuette && StatueTypes.Length > 0)
            {
                ((MonsterStatuette)artifact).Type = StatueTypes[Utility.Random(StatueTypes.Length)];
                ((MonsterStatuette)artifact).LootType = LootType.Regular;
            }

            return artifact;
        }

        private PowerScroll CreateRandomPowerScroll()
            {
                int level;
                double random = Utility.RandomDouble();

                if( this is LordOaks )
                {
                    if ( 0.2 >= random )
                      level = 20;
                    else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Mephitis )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Neira )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Rikktor )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Semidar )
                {
                        if ( 0.3 >= random )
                        level = 20;
                else if ( 0.6 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Serado )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                level = 10;
                return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Ilhenir )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Twaulo )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }
                if( this is Meraktus )
                {
                        if ( 0.2 >= random )
                        level = 20;
                else if ( 0.5 >= random )
                        level = 15;
                else
                        level = 10;
                        return PowerScroll.CreateRandomNoCraft( level, level );
                }

                else // calculating it the original way
                {
                    if ( 0.05 >= random )
                        level = 20;
                else if ( 0.2 >= random )
                        level = 15;
                else if ( 0.5 >= random )
                        level = 10;
                else
                level = 5;

                return PowerScroll.CreateRandomNoCraft( level, level );
                }
            }

        public void GivePowerScrolls()
        {
            List<Mobile> toGive = new List<Mobile>();
            List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );

            for ( int i = rights.Count - 1; i >= 0; --i )
            {
                DamageStore ds = rights[i];

                if ( ds.m_HasRight )
                    toGive.Add( ds.m_Mobile );
            }

            if ( toGive.Count == 0 )
                return;

            for( int i = 0; i < toGive.Count; i++ )
            {
                Mobile m = toGive[i];

                if( !(m is PlayerMobile) )
                    continue;

                bool gainedPath = false;

                int pointsToGain = 800;

                if( VirtueHelper.Award( m, VirtueName.Valor, pointsToGain, ref gainedPath ) )
                {
                    if( gainedPath )
                        m.SendLocalizedMessage( 1054032 ); // You have gained a path in Valor!
                    else
                        m.SendLocalizedMessage( 1054030 ); // You have gained in Valor!

                    //No delay on Valor gains
                }
            }

            // Randomize
            for ( int i = 0; i < toGive.Count; ++i )
            {
                int rand = Utility.Random( toGive.Count );
                Mobile hold = toGive[i];
                toGive[i] = toGive[rand];
                toGive[rand] = hold;
            }

            for ( int i = 0; i < 8; ++i )
            {
                Mobile m = toGive[i % toGive.Count];

                PowerScroll ps = CreateRandomPowerScroll();

                GivePowerScrollTo( m, ps );
            }

//Edit - Try Giving Special Rewards Here:

            if ( toGive.Count < 2 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain by one person.");
                m.AddToBackpack(new BronzeRewardBag());
            }
            else if ( toGive.Count < 3 )
            {
                World.Broadcast( 0x35, true, "A Champion was just slain by two people.");
                m.AddToBackpack(new SilverRewardBag());
            }
            else
            {
                if ( toGive.Count > 3 )
                {
                    World.Broadcast( 0x35, true, "A Champion was just slain by one person.");
                    m.AddToBackpack(new GoldRewardBag());
                }
            }
        }

        public static void GivePowerScrollTo( Mobile m, PowerScroll ps )
        {
            if( ps == null || m == null )    //sanity
                return;

            m.SendLocalizedMessage( 1049524 ); // You have received a scroll of power!

            if( !Core.SE || m.Alive )
            {
                m.AddToBackpack( ps );
            }

            else
            {
                if( m.Corpse != null && !m.Corpse.Deleted )
                {
                    m.Corpse.DropItem( ps );
                }
                else
                {
                    m.AddToBackpack( ps );
                }
            }

            if( m is PlayerMobile )
            {
                PlayerMobile pm = (PlayerMobile)m;

                for( int j = 0; j < pm.JusticeProtectors.Count; ++j )
                {
                    Mobile prot = pm.JusticeProtectors[j];

                    if( prot.Map != m.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion( m, prot ) )
                        continue;

                    int chance = 0;

                    switch( VirtueHelper.GetLevel( prot, VirtueName.Justice ) )
                    {
                        case VirtueLevel.Seeker: chance = 60; break;
                        case VirtueLevel.Follower: chance = 80; break;
                        case VirtueLevel.Knight: chance = 100; break;
                    }

                    if( chance > Utility.Random( 100 ) )
                    {
                        PowerScroll powerScroll = new PowerScroll( ps.Skill, ps.Value );

                        prot.SendLocalizedMessage( 1049368 ); // You have been rewarded for your dedication to Justice!

                        if( !Core.SE || prot.Alive )
                            prot.AddToBackpack( powerScroll );
                        else
                        {
                            if( prot.Corpse != null && !prot.Corpse.Deleted )
                                prot.Corpse.DropItem( powerScroll );
                            else
                                prot.AddToBackpack( powerScroll );
                        }
                    }
                }
            }
        }

        public override bool OnBeforeDeath()
        {
            if ( !NoKillAwards )
            {
                GivePowerScrolls();


                if ( (this is StoneManChamp) || (this is CPSemidar)  )
                {
                    return base.OnBeforeDeath();
                }

                if( NoGoodies )
                    return base.OnBeforeDeath();

                Map map = this.Map;

                if ( map != null )
                {
                    for ( int x = -12; x <= 12; ++x )
                    {
                        for ( int y = -12; y <= 12; ++y )
                        {
                            double dist = Math.Sqrt(x*x+y*y);

                            if ( dist <= 12 )
                                new GoodiesTimer( map, X + x, Y + y ).Start();
                        }
                    }
                }
            }

            return base.OnBeforeDeath();
        }

        public override void OnDeath( Container c )
        {
                //TODO: Confirm SE change or AoS one too?
                List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );
                List<Mobile> toGive = new List<Mobile>();

                for ( int i = rights.Count - 1; i >= 0; --i )
                {
                    DamageStore ds = rights[i];

                    if ( ds.m_HasRight )
                        toGive.Add( ds.m_Mobile );
                }

                if ( toGive.Count > 0 )
                    toGive[Utility.Random( toGive.Count )].AddToBackpack( new ChampionSkull( SkullType ) );
                else
                    c.DropItem( new ChampionSkull( SkullType ) );

            base.OnDeath( c );
        }

        private class GoodiesTimer : Timer
        {
            private Map m_Map;
            private int m_X, m_Y;

            public GoodiesTimer( Map map, int x, int y ) : base( TimeSpan.FromSeconds( Utility.RandomDouble() * 10.0 ) )
            {
                m_Map = map;
                m_X = x;
                m_Y = y;
            }

            protected override void OnTick()
            {
                int z = m_Map.GetAverageZ( m_X, m_Y );
                bool canFit = m_Map.CanFit( m_X, m_Y, z, 6, false, false );

                for ( int i = -3; !canFit && i <= 3; ++i )
                {
                    canFit = m_Map.CanFit( m_X, m_Y, z + i, 6, false, false );

                    if ( canFit )
                        z += i;
                }

                if ( !canFit )
                    return;

//***************************************************
//Gold Ground Drop:
                Gold g = new Gold( 100, 150 );
//***************************************************
            
                g.MoveToWorld( new Point3D( m_X, m_Y, z ), m_Map );

                if ( 0.5 >= Utility.RandomDouble() )
                {
                    switch ( Utility.Random( 3 ) )
                    {
                        case 0: // Fire column
                        {
                            Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x3709, 10, 30, 5052 );
                            Effects.PlaySound( g, g.Map, 0x208 );

                            break;
                        }
                        case 1: // Explosion
                        {
                            Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x36BD, 20, 10, 5044 );
                            Effects.PlaySound( g, g.Map, 0x307 );

                            break;
                        }
                        case 2: // Ball of fire
                        {
                            Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x36FE, 10, 10, 5052 );

                            break;
                        }
                    }
                }
            }
        }
    }
}

I still think something like this might be useful to others so I'm open to ideas and appreciative of any guidance.

Many Thanks
 
Last edited:
Hey Visam,

Now we're talking. I didn't think of foreach.

but, I think he's trying to take a tiered approach

1 player exists in toGive - give X
2 players exist in toGive- give Y
3 players exist in toGive- give Z
 
Thank you Visam . . but yes kfritz411 . . that is what I am trying for . . . . in an attempt to encourage/reward for Group Champ activity I am hoping to offer a bit better rewards for group members (who contribute to damage) based on how many are involved and doing damage.
 
idk should be done with this?

C#:
toGive[Utility.Random(toGive.Count)].AddToBackpack(new BronzeRewardBag());

unless you do want to give each of them the reward. But then its what visam said.
But in each of your ifs bodys for example, with different rewards
 
Thank you everyone and . . special thanks to Visam for the syntax and Falkor for turning my lights on.

This works perfectly and gives me the flexibility to grant special rewards based on the number of participants causing damage to the Champ.

I really appreciate the help folks.

*bows*
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back