示例#1
0
        public Player(string playerName, int positionX, int positionY, string entityMapIcon) : base(positionX, positionY, entityMapIcon)
        {
            Name = playerName;
            Fists newPlayerWeapon = new Fists("Fists");

            EntityWeapon  = newPlayerWeapon;
            PlayerWeapon2 = newPlayerWeapon;
        }
示例#2
0
        public Player(int slot, int playerId, string imageName)
        {
            ControllerId = slot;
            PlayerId     = playerId;
            ImageName    = imageName;

            Layer            = ObjectLayers.Players;
            excludeCollision = new HashSet <Entity>();
            UpgradeQueue     = new Queue <Upgrade>();
            UpgradeCapacity  = 1;

            InitController();

            SetHitbox(30, 60, 15, 60);

            Type = Collision;

            IsAlive    = false;
            Invincible = false;
            Rebounding = false;

            Physics         = AddComponent(new PhysicsBody(Platform.Collision, Type));
            Movement        = AddComponent(new Movement(Physics, Direction));
            DodgeController = AddComponent(new DodgeController(Dodge, Direction));

            player = AddComponent(new Image(Library.GetTexture("players/" + imageName + ".png")));
            player.Source.Smooth = true;
            player.Scale         = 0.5f;
            player.OriginX       = player.Width / 2;
            player.OriginY       = player.Height;

            AddComponent(new OffscreenCursor(ImageName));
            Fists = AddComponent(new Fists());

            states   = AddComponent(new StateMachine());
            Standing = states.AddState(BeginStand, WhileStanding, null);
            Jumping  = states.AddState(BeginJump, WhileJumping, null);
            Falling  = states.AddState(BeginFalling, WhileFalling, null);
            Dodging  = states.AddState(WhileDodging);

            AddResponse(Message.Damage, OnDamage);
            AddResponse(Fist.Message.PunchConnected, OnPunchConnected);
            AddResponse(EffectMessage.Message.OnEffect, OnEffect);
            AddResponse(Shield.Message.Set, SetShield);
            AddResponse(Rebound.Message.Set, SetRebound);
        }
示例#3
0
 public Human()
 {
     name   = "Nobody";
     title  = "";
     race   = "Human";
     Str    = 10 + 1;
     Dex    = 10 + 1;
     Con    = 10 + 1;
     Int    = 10 + 1;
     Wis    = 10 + 1;
     Cha    = 10 + 1;
     hp     = 10 + Helper.Helper.Mod(Con);
     weapon = new Fists();
     armor  = new Unarmored();
     AC     = Helper.Helper.AC(this);
     Attack = new Attack();
     Block  = new Block();
     Evade  = new Evade();
 }
示例#4
0
 public Player()
 {
     MaxHp  = Hp;
     MaxExp = 200 * Level;
     Weapon = new Fists();
 }
示例#5
0
        public override bool DoActionCombat()
        {
            try
            {
                Mobile c = m_Mobile.Combatant;                 //this will get set to null if something happens via combattimer

                //m_Mobile.Warmode = false; //setting this to false will cause combatant to become null!!

                if (m_Mobile.FocusMob != null && m_Mobile.FocusMob.Hidden)
                {
                    m_Mobile.UseSkill(SkillName.DetectHidden);
                    Target targ = m_Mobile.Target;
                    targ.Invoke(m_Mobile, m_Mobile);                   //target are self
                    if (!m_Mobile.FocusMob.Hidden)                     //we revealed set are combatant back right
                    {
                        Mobile oldCombatant = m_Mobile.FocusMob;
                        m_Mobile.Combatant = oldCombatant;                         //switch are target back to who we revealed
                        c = m_Mobile.Combatant;
                    }
                }

                if (c == null || c.Deleted || !c.Alive || c.IsDeadBondedPet || !m_Mobile.CanSee(c) || !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map)
                {
                    // Our combatant is deleted, dead, hidden, or we cannot hurt them
                    // Try to find another combatant
                    m_Mobile.NextReacquireTime = DateTime.Now;
                    if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                    {
                        if (m_Mobile.Debug)
                        {
                            m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name);
                        }

                        m_Mobile.Combatant = c = m_Mobile.FocusMob;
                        m_Mobile.FocusMob  = c;                        //remember who we would Acquired so we can reveal them later!
                    }
                    else
                    {
                        m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard.");
                        Action = ActionType.Guard;
                        return(true);
                    }
                }

                //Mobile got to far away find another target
                if (!m_Mobile.InLOS(c))
                {
                    if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
                    {
                        m_Mobile.Combatant = c = m_Mobile.FocusMob;
                        m_Mobile.FocusMob  = null;
                    }
                }

                try
                {
                    if (c != null && c.Alive && m_Mobile.CanSee(c) && (c is BaseCreature))
                    {
                        //check if there are players around if so forget about the pet there afraid of us anyways
                        IPooledEnumerable eable = m_Mobile.GetMobilesInRange(m_Mobile.RangePerception);
                        foreach (Mobile trg in eable)
                        {
                            if (trg != null && trg != m_Mobile && trg is PlayerMobile && !trg.Hidden && trg.AccessLevel == AccessLevel.Player && trg.Alive && m_Mobile.CanSee(trg))
                            {
                                //we found a player in range
                                c = trg;
                                m_Mobile.Combatant = trg;
                            }
                        }
                        eable.Free();
                    }
                }
                catch (Exception exc)
                {
                    LogHelper.LogException(exc);
                    System.Console.WriteLine("catch I: Send to Zen please: ");
                    System.Console.WriteLine("Exception caught in Vampire.OnCombat: " + exc.Message);
                    System.Console.WriteLine(exc.StackTrace);
                    return(false);
                }

                // STUN PUNCH: 50% chance to try an stun punch if we have stamina available, we are human form and our hands are free.
                //	(Hypnotize on the other hand is only used if the vampire has something in his hands)
                if (DateTime.Now >= m_NextStunTime)
                {
                    bool stunChance = Utility.RandomBool();
                    bool isBat      = m_Mobile is Vampire && ((Vampire)m_Mobile).BatForm == true;
                    bool isFrozen   = c != null && c.Frozen;
                    if (m_Mobile.Stam >= 40 && stunChance == true && !m_Mobile.StunReady && Fists.HasFreeHands(m_Mobile) && isFrozen == false &&
                        m_Mobile.Skills[SkillName.Wrestling].Value >= 80.0 && m_Mobile.Skills[SkillName.Anatomy].Value >= 80.0 &&
                        isBat == false)
                    {
                        EventSink.InvokeStunRequest(new StunRequestEventArgs(m_Mobile));
                        m_NextStunTime = DateTime.Now + m_StunDelay;
                    }
                }

                if (m_Mobile is Vampire && ((Vampire)m_Mobile).BatForm == true)
                {
                    m_Mobile.CanFly = true;
                }

                // wea: switch to chase action type instead of hacking at it
                if (!m_Mobile.InRange(c, 6))                 //Mobile is 6 tiles away or more Take to the air unless we're already chasing them!!
                {
                    Action = ActionType.Chase;
                    RunTo(c, CanRun);
                    return(true);
                }

                if (m_Mobile.InRange(c, 1))                                                                                    //ok where close we will walk and look cool vs trying to run all fast 1 tile at a time
                {                                                                                                              // Design error: See above comment
                    if (m_Mobile is Vampire && ((Vampire)m_Mobile).BatForm == true && (CheckNight(m_Mobile)) && (CheckLand())) //change to human form
                    {
                        ((Vampire)m_Mobile).DoTransform((Vampire)m_Mobile, (m_Mobile.Female) ? 0x191 : 0x190, ((Vampire)m_Mobile).Hue, ((Vampire)m_Mobile).toHumanForm);
                        m_Mobile.ActiveSpeed  = ActiveSpeedNormal;
                        m_Mobile.CurrentSpeed = ActiveSpeedNormal;
                        m_Mobile.CanFly       = false;
                    }
                    RunTo(c, false);                     //walk no need to run
                }
                //taunt if there stunned
                if (DateTime.Now >= m_NextSpeakTime && c.Frozen && c is PlayerMobile && m_Mobile is Vampire && ((Vampire)m_Mobile).BatForm == false && m_Mobile.InRange(c, 1))
                {
                    string s = GetMsg(c);
                    m_Mobile.Say(s);
                    m_NextSpeakTime = DateTime.Now + m_SpeakDelay;
                }

                // HYPNOTIZE: may only hypnotize if holding a weapon OR you are a bat (otherwise we stun)
                //	both bats and human-form vamps can hypnotize
                // Note: WalkingDead and Vampire Champ hold weapons
                if (DateTime.Now >= m_NextHypnotizeTime)
                {
                    if (c != null)
                    {
                        bool isBat        = m_Mobile is Vampire && ((Vampire)m_Mobile).BatForm == true;
                        bool bardPacified = c is BaseCreature && ((BaseCreature)c).BardPacified == true;
                        if ((Fists.HasFreeHands(m_Mobile) == false || isBat == true) && bardPacified == false && m_Mobile.InRange(c, 1))
                        {
                            if (m_Mobile is Vampire)
                            {
                                if (((Vampire)m_Mobile).Hypnotize(c))
                                {
                                    if (c is PlayerMobile)
                                    {
                                        m_Mobile.Emote("Look into my eyes...");
                                    }
                                    else
                                    {
                                        m_Mobile.Emote("I am your master, do not fight me.");
                                    }

                                    m_NextHypnotizeTime = DateTime.Now + m_HypnotizeDelay;
                                }
                            }
                        }
                    }
                }

                RunTo(c, CanRun);

                if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100 && (c is PlayerMobile || (c is BaseCreature && c.HitsMax >= 200)))
                {
                    // We are low on health, should we flee?
                    bool flee = false;

                    if (m_Mobile.Hits < c.Hits)
                    {
                        // We are more hurt than them

                        int diff = c.Hits - m_Mobile.Hits;

                        flee = (Utility.Random(0, 100) < (10 + diff));                         // (10 + diff)% chance to flee
                    }
                    else
                    {
                        flee = Utility.Random(0, 100) < 10;                         // 10% chance to flee
                    }

                    if (flee)
                    {
                        if (m_Mobile.Debug)
                        {
                            m_Mobile.DebugSay("I am going to flee from {0}", c.Name);
                        }

                        Action = ActionType.Flee;
                    }
                }
                return(true);
            }
            catch (Exception exc)
            {
                LogHelper.LogException(exc);
                System.Console.WriteLine("catch II: Send to Zen please: ");
                System.Console.WriteLine("Exception caught in Vampire.OnCombat: " + exc.Message);
                System.Console.WriteLine(exc.StackTrace);
                return(false);
            }
        }
示例#6
0
        public Monster CreateTroll()
        {
            ItemFactory code              = new ItemFactory();
            Troll       troll             = new Troll(0, 0, "");
            int         positionX         = GetRandom(1, 6);
            int         positionY         = GetRandom(1, 6);
            int         level             = GetRandom(troll.MinLevel, troll.MaxLevel);
            int         amplifier         = GetRandom(0, level);
            int         pickedMonsterName = GetRandom(1, 8);

            if (pickedMonsterName == 1 || pickedMonsterName == 2 || pickedMonsterName == 3)
            {
                Barg_The_Ugly_Brute Enemy = new Barg_The_Ugly_Brute(level, positionX, positionY, "B");
                troll = Enemy;
                int doesbarggetweapon = GetRandom(0, 5);
                if (doesbarggetweapon == 3)
                {
                    troll.EntityWeapon = code.CreateRandomWeapon(GetRandom(0, 5));
                }
                else if (troll.EntityWeapon == null)
                {
                    Fists trollBaseWeapon = new Fists("Fists");
                    troll.EntityWeapon = trollBaseWeapon;
                }
                int doesbarggetarmor = GetRandom(0, 5);
                if (doesbarggetarmor == 3)
                {
                    troll.EntityArmor = code.CreateRandomArmor(GetRandom(0, 5));
                }
                else if (troll.EntityArmor == null)
                {
                    Hides newTrollArmor = new Hides("");
                    troll.EntityArmor = newTrollArmor;
                }
                int doesBargGetPotion = GetRandom(0, 5);
                if (doesBargGetPotion == 3)
                {
                    int howManyPotions = GetRandom(-2, 4);
                    if (howManyPotions < 1)
                    {
                        howManyPotions = 0;
                    }
                    else
                    {
                        int whichPotion = 0;
                        while (howManyPotions > 0)
                        {
                            whichPotion = GetRandom(1, 3);
                            if (whichPotion == 1)
                            {
                                Health_Potion newPotion = new Health_Potion("Health_Potion", level);
                                newPotion.potionNumber = troll.entityPotions.Count + 1;
                                troll.entityPotions.Add(newPotion);
                            }
                            else if (whichPotion == 2)
                            {
                                Fire_Potion newPotion1 = new Fire_Potion("Fire_Potion", level);
                                newPotion1.potionNumber = troll.entityPotions.Count + 1;
                                troll.entityPotions.Add(newPotion1);
                            }
                            howManyPotions -= 1;
                        }
                        while (troll.entityPotions.Count < 3)
                        {
                            Potion empty = new Potion("Empty_Potion", troll.entityPotions.Count + 1);
                            troll.entityPotions.Add(empty);
                        }
                    }
                }
                Enemy.DoBargAmplifiers(amplifier);
            }
            else if (pickedMonsterName == 4 || pickedMonsterName == 5 || pickedMonsterName == 6)
            {
                Klerg_The_Iceberg Enemy = new Klerg_The_Iceberg(level, positionX, positionY, "K");
                troll = Enemy;
                int doesklerggetweapon = GetRandom(0, 5);
                if (doesklerggetweapon == 3)
                {
                    troll.EntityWeapon = code.CreateRandomWeapon(GetRandom(0, 5));
                }
                else if (troll.EntityWeapon == null)
                {
                    Fists trollBaseWeapon = new Fists("Fists");
                    troll.EntityWeapon = trollBaseWeapon;
                }
                int doesklerggetarmor = GetRandom(0, 5);
                if (doesklerggetarmor == 3)
                {
                    troll.EntityArmor = code.CreateRandomArmor(GetRandom(0, 5));
                }
                else if (troll.EntityArmor == null)
                {
                    Hides newTrollArmor = new Hides("");
                    troll.EntityArmor = newTrollArmor;
                }
                int doesKlergGetPotion = GetRandom(0, 5);
                if (doesKlergGetPotion == 3)
                {
                    int howManyPotions = GetRandom(-2, 4);
                    if (howManyPotions < 1)
                    {
                        howManyPotions = 0;
                    }
                    else
                    {
                        int whichPotion = 0;
                        while (howManyPotions > 0)
                        {
                            whichPotion = GetRandom(1, 3);
                            if (whichPotion == 1)
                            {
                                Health_Potion newPotion = new Health_Potion("Health_Potion", level);
                                newPotion.potionNumber = troll.entityPotions.Count + 1;
                                troll.entityPotions.Add(newPotion);
                            }
                            else if (whichPotion == 2)
                            {
                                Fire_Potion newPotion1 = new Fire_Potion("Fire_Potion", level);
                                newPotion1.potionNumber = troll.entityPotions.Count + 1;
                                troll.entityPotions.Add(newPotion1);
                            }
                            howManyPotions -= 1;
                        }
                        while (troll.entityPotions.Count < 3)
                        {
                            Potion empty = new Potion("Empty_Potion", troll.entityPotions.Count + 1);
                            troll.entityPotions.Add(empty);
                        }
                    }
                }
                Enemy.DoKlergAmplifiers(amplifier);
            }
            else if (pickedMonsterName == 7)
            {
                Grauldog Enemy = new Grauldog(level, positionX, positionY, "$");
                troll = Enemy;
                Grauldogs_Trusty_Club newWeaponForGrauldog = new Grauldogs_Trusty_Club("Grauldog's Trusty Club", GetRandom(1, 10));
                troll.EntityWeapon = newWeaponForGrauldog;
                if (troll.EntityWeapon == null)
                {
                    Fists trollBaseWeapon = new Fists("Fists");
                    troll.EntityWeapon = trollBaseWeapon;
                }
                int doesGrauldoggetarmor = GetRandom(2, 4);
                if (doesGrauldoggetarmor == 3)
                {
                    troll.EntityArmor = code.CreateRandomArmor(GetRandom(0, 10));
                }
                else if (troll.EntityArmor == null)
                {
                    Hides newTrollArmor = new Hides("");
                    troll.EntityArmor = newTrollArmor;
                }
                int doesGrauldogGetPotion = GetRandom(0, 5);
                if (doesGrauldogGetPotion == 3)
                {
                    int howManyPotions = GetRandom(-2, 4);
                    if (howManyPotions < 1)
                    {
                        howManyPotions = 0;
                    }
                    else
                    {
                        int whichPotion = 0;
                        while (howManyPotions > 0)
                        {
                            whichPotion = GetRandom(1, 3);
                            if (whichPotion == 1)
                            {
                                Health_Potion newPotion = new Health_Potion("Health_Potion", level);
                                newPotion.potionNumber = troll.entityPotions.Count + 1;
                                troll.entityPotions.Add(newPotion);
                            }
                            else if (whichPotion == 2)
                            {
                                Fire_Potion newPotion1 = new Fire_Potion("Fire_Potion", level);
                                newPotion1.potionNumber = troll.entityPotions.Count + 1;
                                troll.entityPotions.Add(newPotion1);
                            }
                            howManyPotions -= 1;
                        }
                        while (troll.entityPotions.Count < 3)
                        {
                            Potion empty = new Potion("Empty_Potion", troll.entityPotions.Count + 1);
                            troll.entityPotions.Add(empty);
                        }
                    }
                }
                Enemy.DoGrauldogAmplifiers(amplifier);
            }
            return(troll);
        }
示例#7
0
        public Monster CreateHuman()
        {
            ItemFactory code              = new ItemFactory();
            Human       barbarian         = new Human(0, 0, "");
            int         positionX         = GetRandom(1, 6);
            int         positionY         = GetRandom(1, 6);
            int         level             = GetRandom(barbarian.MinLevel, barbarian.MaxLevel);
            int         amplifier         = GetRandom(0, level);
            int         pickedMonsterName = GetRandom(1, 3);

            if (pickedMonsterName == 1)
            {
                Gulfard_The_Wolfherd Enemy = new Gulfard_The_Wolfherd(level, positionX, positionY, "G");
                barbarian = Enemy;
                int doesGulfardgetweapon = GetRandom(1, 4);
                if (doesGulfardgetweapon == 3)
                {
                    barbarian.EntityWeapon = code.CreateRandomWeapon(GetRandom(1, 5));
                }
                else if (barbarian.EntityWeapon == null)
                {
                    Fists barbarianBaseWeapon = new Fists("Fists");
                    barbarian.EntityWeapon = barbarianBaseWeapon;
                }
                int doesGulfardgetarmor = GetRandom(1, 4);
                if (doesGulfardgetarmor == 3)
                {
                    barbarian.EntityArmor = code.CreateRandomArmor(GetRandom(1, 5));
                }
                else if (barbarian.EntityArmor == null)
                {
                    Hides newBarbarianArmor = new Hides("");
                    barbarian.EntityArmor = newBarbarianArmor;
                }
                int doesGulfardGetPotion = GetRandom(0, 5);
                if (doesGulfardGetPotion == 3)
                {
                    int howManyPotions = GetRandom(-2, 4);
                    if (howManyPotions < 1)
                    {
                        howManyPotions = 0;
                    }
                    else
                    {
                        int whichPotion = 0;
                        while (howManyPotions > 0)
                        {
                            whichPotion = GetRandom(1, 3);
                            if (whichPotion == 1)
                            {
                                Health_Potion newPotion = new Health_Potion("Health_Potion", level);
                                newPotion.potionNumber = barbarian.entityPotions.Count + 1;
                                barbarian.entityPotions.Add(newPotion);
                            }
                            else if (whichPotion == 2)
                            {
                                Fire_Potion newPotion1 = new Fire_Potion("Fire_Potion", level);
                                newPotion1.potionNumber = barbarian.entityPotions.Count + 1;
                                barbarian.entityPotions.Add(newPotion1);
                            }
                            howManyPotions -= 1;
                        }
                        while (barbarian.entityPotions.Count < 3)
                        {
                            Potion empty = new Potion("Empty_Potion", barbarian.entityPotions.Count + 1);
                            barbarian.entityPotions.Add(empty);
                        }
                    }
                }
                Enemy.DoGulfardAmplifiers(amplifier);
            }
            else if (pickedMonsterName == 2)
            {
                Berk_The_Jerk Enemy = new Berk_The_Jerk(level, positionX, positionY, "J");
                barbarian = Enemy;
                int doesBerkgetweapon = GetRandom(1, 4);
                if (doesBerkgetweapon == 3)
                {
                    barbarian.EntityWeapon = code.CreateRandomWeapon(GetRandom(1, 5));
                }
                else if (barbarian.EntityWeapon == null)
                {
                    Fists BerkBaseWeapon = new Fists("Fists");
                    barbarian.EntityWeapon = BerkBaseWeapon;
                }
                int doesberkgetarmor = GetRandom(0, 5);
                if (doesberkgetarmor == 3)
                {
                    barbarian.EntityArmor = code.CreateRandomArmor(GetRandom(1, 5));
                }
                else if (barbarian.EntityArmor == null)
                {
                    Hides newBerkArmor = new Hides("");
                    barbarian.EntityArmor = newBerkArmor;
                }
                int doesBerkGetPotion = GetRandom(0, 5);
                if (doesBerkGetPotion == 3)
                {
                    int howManyPotions = GetRandom(-2, 4);
                    if (howManyPotions < 1)
                    {
                        howManyPotions = 0;
                    }
                    else
                    {
                        int whichPotion = 0;
                        while (howManyPotions > 0)
                        {
                            whichPotion = GetRandom(1, 3);
                            if (whichPotion == 1)
                            {
                                Health_Potion newPotion = new Health_Potion("Health_Potion", level);
                                newPotion.potionNumber = barbarian.entityPotions.Count + 1;
                                barbarian.entityPotions.Add(newPotion);
                            }
                            else if (whichPotion == 2)
                            {
                                Fire_Potion newPotion1 = new Fire_Potion("Fire_Potion", level);
                                newPotion1.potionNumber = barbarian.entityPotions.Count + 1;
                                barbarian.entityPotions.Add(newPotion1);
                            }
                            howManyPotions -= 1;
                        }
                        while (barbarian.entityPotions.Count < 3)
                        {
                            Potion empty = new Potion("Empty_Potion", barbarian.entityPotions.Count + 1);
                            barbarian.entityPotions.Add(empty);
                        }
                    }
                }
                Enemy.DoBerkAmplifiers(amplifier);
            }
            return(barbarian);
        }