示例#1
0
        private void LoadData(Actor a)
        {
            // declar vars
            int oldLvl = a.Level;
            int oldHP  = a.HPBaseMax;
            int oldMP  = a.MPBaseMax;
            int oldAtt = a.CurrentAttack;
            int oldDef = a.CurrentDefense;

            RPGCalc calc = new RPGCalc();

            calc.LevelUpActor(a);

            int newLvl = a.Level;
            int newHP  = a.HPBaseMax;
            int newMP  = a.MPBaseMax;
            int newAtt = a.CurrentAttack;
            int newDef = a.CurrentDefense;

            // display change in vars
            Add("Level: " + '\t' + oldLvl.ToString() + '\t' + " -> " + '\t' + newLvl);
            Add("HP: " + '\t' + oldHP.ToString() + '\t' + " -> " + '\t' + newHP);
            Add("MP: " + '\t' + oldMP.ToString() + '\t' + " -> " + '\t' + newMP);
            Add("Att: " + '\t' + oldAtt.ToString() + '\t' + " -> " + '\t' + newAtt);
            Add("Def: " + '\t' + oldDef.ToString() + '\t' + " -> " + '\t' + newDef);
        }
示例#2
0
        private int GetThisDmg(bool critical)
        {
            int projDmg = new RPGCalc().RollDmg(this.minDmg, this.maxDmg);

            if (critical)
            {
                projDmg *= 2;
            }

            RPGWeapon w = this.Owner.inventory.GetWpn();

            if (w == null)
            {
                return(projDmg);
            }

            if (w.weaponType == RPGWeapon.WeaponType.Launcher)
            {
                if (w.minDmg == w.maxDmg)
                {
                    projDmg += w.minDmg;
                }
                else
                {
                    projDmg += new RPGCalc().RollDmg(w.minDmg, w.maxDmg);
                }
            }
            return(projDmg);
        }
示例#3
0
        public static RPGArmor CreateRandomShield()
        {
            int        c  = new RPGCalc().Roll(3) + 8;
            ArmorClass ac = (ArmorClass)Enum.Parse(typeof(ArmorClass), c.ToString());

            return(new RPGArmor(ac));
        }
示例#4
0
        public static RPGArmor CreateRandomArmorPiece()
        {
            int        c  = new RPGCalc().Roll(Enum.GetValues(typeof(ArmorClass)).Length);
            ArmorClass ac = (ArmorClass)Enum.Parse(typeof(ArmorClass), c.ToString());

            return(new RPGArmor(ac));
        }
示例#5
0
        public ArrayList GetItemsNear(Point point)
        {
            RPGCalc   calc    = new RPGCalc();
            ArrayList results = new ArrayList();

            foreach (RPGObject obj in RPGObjects)
            {
                if (obj == null)
                {
                    continue;
                }
                // if object is not actor
                if (obj.GetType() != typeof(Actor) &&
                    obj.GetType() != typeof(PlayerCharacter))
                {
                    // and if object is near point
                    if (calc.DistanceBetween(obj, point) < GRAB_MAX_DISTANCE)
                    {
                        results.Add(obj);
                    }
                }
            }

            // if nothing found...
            return(results);
        }
示例#6
0
        public static RPGItem CreateRandomWeapon()
        {
            // roll for all types of weapons
            int c = new RPGCalc().Roll(Enum.GetValues(typeof(WeaponClass)).Length);
            // create a weapon of that type
            WeaponClass wc = (WeaponClass)Enum.Parse(typeof(WeaponClass), c.ToString());

            return(new RPGWeapon(wc));
        }
示例#7
0
        public bool IsCorrectTarget(RPGObject source, RPGObject target, Point targetLocation)
        {
            if (source == null || target == null)
            {
                return(false);
            }

            bool    result = false;
            RPGCalc calc   = new RPGCalc();

            switch (range)
            {
            case (EffectRange.Self):
            {
                result = (source == target);
                break;
            }

            case (EffectRange.Target):
            {
                // target is roughly at location
                result = calc.ObjectOnPoint(target, targetLocation);
                break;
            }

            case (EffectRange.Touch):
            {
                // target within touch distance
                int d = calc.DistanceBetween(source, target);
                result = (d <= RPGCalc.DEFAULT_TOUCH_RANGE);
                break;
            }

            case (EffectRange.Area):
            {
                // target within item distance
                int d = calc.DistanceBetween(source, target);
                result = (d <= this.distance);
                break;
            }

            case (EffectRange.TargetArea):
            {
                // target within item distance and radius
                int d = calc.DistanceBetween(target, targetLocation);
                result = (d <= this.radius);
                break;
            }

            default:
            {
                break;
            }
            } // end switch
            return(result);
        }
示例#8
0
        public int GetActorCurrentPhysicalDamage(Actor a)
        {
            int d = a.BaseDamage;

            d += new RPGCalc().RollDmg(a.inventory.GetWpn().minDmg,
                                       a.inventory.GetWpn().maxDmg);

            // add any effects from any items, etc.
            return(d);
        }
示例#9
0
        public static Actor CreateRandomActor(Actor.Attribute PrimaryAttribute, Actor.Attribute SecondaryAttribute)
        {
            RPGCalc calc = new RPGCalc();

            Actor newActor = new Actor();

            int[] rolls = calc.RollAttributes();

            // order int array by value
            Array.Sort(rolls, 0, rolls.Length);

            // clear actor's current attributes
            for (int i = 0; i < newActor.BaseAttributes.Length; i++)
            {
                newActor.BaseAttributes[i] = 0;
            }

            // fill important attributes with values
            int next = 5;

            newActor.BaseAttributes[(int)PrimaryAttribute]   = rolls[next--];
            newActor.BaseAttributes[(int)SecondaryAttribute] = rolls[next--];

            // fill rest
            for (int i = 0; i < newActor.BaseAttributes.Length; i++)
            {
                // find blank and fill with next
                if (newActor.BaseAttributes[i] == 0)
                {
                    newActor.BaseAttributes[i] = rolls[next--];
                }
            }

            newActor.Name = "Random Actor";

            // set current stats to match
            newActor.ResetAttributes();
            newActor.HPBaseMax = calc.GetBaseHP(newActor);
            newActor.MPBaseMax = calc.GetBaseMP(newActor);
            newActor.ResetStats();

            newActor.BaseSpeed    = RPGCalc.DEFAULT_SPEED;
            newActor.CurrentSpeed = newActor.BaseSpeed;
            newActor.lastAttack   = System.DateTime.Now;
            newActor.lastDamage   = new DateTime();

            newActor.SetAlignment(calc.RollAlignment());

            newActor.inventory.AddPackItem(RPGPotion.CreateRandomPotion());

            //newActor.SpellBook = RPGSpellBook.CreateRandomSpellbook();
            newActor.SpellBook = RPGSpellBook.CreateTestSpellbook();

            return(newActor);
        }
示例#10
0
        public static Actor CreateRandomFighter()
        {
            Actor a = CreateRandomActor(Attribute.Strength, Attribute.Constitution);

            a.Name = "Random Fighter";

            // equip with fighter gear
            a.inventory.AddBodyItem(RPGArmor.CreateRandomTorsoArmor());
            a.inventory.AddBodyItem(RPGArmor.CreateRandomShield());

            // 50/50 for a belt
            if (new RPGCalc().Roll(100) > 50)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.Belt));
            }

            // boots
            // 20% heavy, 40% light, 40% none
            int bootsRoll = new RPGCalc().Roll(100);

            if (bootsRoll > 80)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.HeavyBoots));
            }
            else if (bootsRoll > 40)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.LightBoots));
            }

            // helm
            // 20% full, 40% small, 40% none
            int helmRoll = new RPGCalc().Roll(100);

            if (helmRoll > 80)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.FullHelm));
            }
            else if (helmRoll > 40)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.SmallHelm));
            }

            // add random melee weapon
            RPGWeapon wpn = RPGWeapon.CreateRandomMeleeWeapon();

            if (a.inventory.AddBodyItem(wpn) == false)
            {
                a.inventory.AddPackItem(wpn);
            }

            a.AI.RunToAttackMelee = true;

            return(a);
        }
示例#11
0
        public static RPGItem CreateRandomThrownWeapon()
        {
            /*
             * ThrowingAxe = 5,
             * Dart = 6,
             */

            int         c  = new RPGCalc().Roll(2) + 4;
            WeaponClass wc = (WeaponClass)Enum.Parse(typeof(WeaponClass), c.ToString());

            return(new RPGWeapon(wc));
        }
示例#12
0
        public static RPGItem CreateRandomLauncherWeapon()
        {
            /*
             * Bow = 7,
             * Crossbow = 8,
             * Sling = 9,
             */

            int         c  = new RPGCalc().Roll(3) + 6;
            WeaponClass wc = (WeaponClass)Enum.Parse(typeof(WeaponClass), c.ToString());

            return(new RPGWeapon(wc));
        }
示例#13
0
        public static RPGWeapon CreateRandomMeleeWeapon()
        {
            /*
             * Sword = 1,
             * Axe = 2,
             * Mace = 3,
             * Staff = 4,
             */

            int         c  = new RPGCalc().Roll(4);
            WeaponClass wc = (WeaponClass)Enum.Parse(typeof(WeaponClass), c.ToString());

            return(new RPGWeapon(wc));
        }
示例#14
0
        public static Actor CreateRandomActor()
        {
            RPGCalc calc      = new RPGCalc();
            int     primary   = calc.Roll(6);
            int     secondary = calc.Roll(6);

            while (primary == secondary)
            {
                secondary = calc.Roll(6);
            }

            return(CreateRandomActor((Attribute)Enum.Parse(typeof(Attribute), primary.ToString()),
                                     (Attribute)Enum.Parse(typeof(Attribute), secondary.ToString())));
        }
示例#15
0
        private void SetBonus(Label lbl, int att)
        {
            int b = new RPGCalc().GetBonusFromAttribute(att);

            lbl.Text = b.ToString();
            if (b > 0)
            {
                lbl.ForeColor = Color.Green;
            }
            else if (b < 0)
            {
                lbl.ForeColor = Color.Red;
            }
        }
示例#16
0
        public static RPGSpellBook CreateTestSpellbook()
        {
            RPGCalc      calc = new RPGCalc();
            int          size = DEFAULT_MAX_SPELL_COUNT * 2;
            RPGSpellBook book = new RPGSpellBook(size);

            int count = size;

            for (int i = 0; i < count; i++)
            {
                book.AddSpell(RPGSpell.CreateRandomSpell());
            }

            return(book);
        }
示例#17
0
        private bool CheckLvlUp()
        {
            RPGCalc calc      = new RPGCalc();
            bool    bMelee    = calc.CheckXPForLevel(m_ExperienceMelee, m_LvlMelee);
            bool    bThrown   = calc.CheckXPForLevel(m_ExperienceThrown, m_LvlThrown);
            bool    bLauncher = calc.CheckXPForLevel(m_ExperienceThrown, m_LvlLauncher);

            if (bMelee || bThrown || bLauncher)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#18
0
        public RPGObject GetObjectAt(Point point)
        {
            RPGCalc calc = new RPGCalc();

            foreach (RPGObject obj in RPGObjects)
            {
                if (obj != null &&
                    calc.ObjectOnPoint(obj, point))
                {
                    return(obj);
                }
            }

            // if nothing found...
            return(null);
        }
示例#19
0
        public RPGObject()
        {
            // start in random place
            size = new Size(25, 40);
            loc  = new Point(new RPGCalc().Roll(PanelAction.PANEL_WIDTH - this.Width),
                             new RPGCalc().Roll(PanelAction.PANEL_HEIGHT - this.Height));
            dir = FacingDirection.South;

            // start with random colors
            Color1 = new RPGCalc().RandomColor();
            Color2 = new RPGCalc().RandomColor();

            currentState = ActionState.Standing;
            Actions      = new ActionQueue(this);
            Effects      = new RPGEffect[RPGEffect.MAX_EFFECTS];
        }
示例#20
0
        public Actor()
        {
            SetAttributesToDefault();

            this.HPBaseMax = new RPGCalc().GetBaseHP(this);
            this.MPBaseMax = new RPGCalc().GetBaseMP(this);

            Name = "Joseph";

            BaseSpeed    = RPGCalc.DEFAULT_SPEED;
            CurrentSpeed = BaseSpeed;

            m_baseAttack  = RPGCalc.DEFAULT_BASE_ATTACK;
            m_baseDefense = RPGCalc.DEFAULT_BASE_DEFENSE;
            m_baseDamage  = RPGCalc.DEFAULT_BASE_DAMAGE;

            LOSRange = RPGCalc.DEFAULT_LOS_RANGE;

            inventory = new Inventory(this);

            m_SpellBook = new RPGSpellBook();
            m_QuickBook = new RPGSpellBook(3);

            lastAttack = System.DateTime.Now;
            lastDamage = new DateTime();

            this.ImpedesWalking = true;

            Relation = RelationToPC.Neutral;

            RPGCalc calc = new RPGCalc();

            m_Lvl        = 1;
            m_ExpForKill = calc.GetExpForKill(this);

            AI = new ArtificialIntelligence(this);
            //AIActive = false; // enemies don't respond.
            AIActive = true;

            States = new ActionStates(this);

            // use all we have so far to calc complex numbers (HP/MP/Att/Def, etc);
            this.HPBaseMax = calc.GetBaseHP(this);
            this.MPBaseMax = calc.GetBaseMP(this);
            this.ResetStats();
        }
示例#21
0
        public static Actor CreateRandomArcher()
        {
            Actor a = CreateRandomActor(Attribute.Dexterity, Attribute.Intelligence);

            a.Name = "Random Archer";

            // equip with archer gear
            a.inventory.AddBodyItem(RPGArmor.CreateRandomTorsoArmor());

            a.AI.RunToAttackMelee = false;

            // 25% for a belt
            if (new RPGCalc().Roll(100) > 75)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.Belt));
            }

            // boots
            // 35% light, 65% none
            int bootsRoll = new RPGCalc().Roll(100);

            if (bootsRoll > 65)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.LightBoots));
            }

            // helm
            // 25% small
            int helmRoll = new RPGCalc().Roll(100);

            if (helmRoll > 75)
            {
                a.inventory.AddBodyItem(new RPGArmor(RPGArmor.ArmorClass.SmallHelm));
            }

            // bow or crossbow or sling
            RPGWeapon wpn = (RPGWeapon)RPGWeapon.CreateRandomLauncherWeapon();

            a.inventory.AddBodyItem(wpn);
            a.inventory.AddBodyItem(new Projectile(a, wpn.GetProjectileType(), null));

            return(a);
        }
示例#22
0
 public RPGObject GetRandomItem()
 {
     RPGObject[] items = GetItems();
     if (items.Length == 0)
     {
         return(null);
     }
     else if (items.Length == 1)
     {
         return(items[0]);
     }
     else
     {
         // roll for a random item
         int index = new RPGCalc().Roll(items.Length) - 1;
         // remove it from the list of items
         RemoveItem(items[index]);
         // return the removed item
         return(items[index]);
     }
 }
示例#23
0
        private void btn_Done_Click(object sender, EventArgs e)
        {
            if (m_currentPointsLeft > 0)
            {
                DialogResult dr = MessageBox.Show("You have points left to spend, are you sure you are done?", "", MessageBoxButtons.YesNo);
                if (dr != DialogResult.Yes)
                {
                    return;
                }
            }

            RPGCalc calc = new RPGCalc();

            ThisActor.HPBaseMax = calc.GetBaseHP(ThisActor);
            ThisActor.MPBaseMax = calc.GetBaseMP(ThisActor);

            this.ThisActor.ResetStats();

            cmd = Game.ExitCommand.Done;
            this.Close();
        }
示例#24
0
        public static RPGEffect CreateRandomSpellEffect()
        {
            #region Setup Vars
            RPGCalc            calc         = new RPGCalc();
            DurationType       t            = DurationType.Permanent;
            TimeSpan           duration     = new TimeSpan(0, 0, 0);
            EffectRange        r            = (EffectRange)calc.GetRandomEnum(typeof(EffectRange));
            EffectTrigger      trigger      = EffectTrigger.Immediately;
            EffectTargetBuff   targetBuff   = EffectTargetBuff.RestoreHP;
            EffectTargetAttack targetAttack = EffectTargetAttack.DoMagicalDamage;
            bool isBuff = true;

            int dist     = 0;
            int radius   = 0;
            int minPower = 0;
            int maxPower = 0;

            bool reverse = true;
            #endregion

            #region Buff or Attack
            // 50/50 percent of offensive for completely random
            if (calc.Roll(2) == 1)
            {
                isBuff = true;
            }
            else
            {
                isBuff = false;
            }
            #endregion

            #region Range and Distance
            // check to avoid attacking self
            while (!isBuff && r == EffectRange.Self)
            {
                r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange));
            }
            // roll for distance depending on range
            dist = 0;
            switch (r)
            {
            case (EffectRange.Self):
            {
                break;
            }

            case (EffectRange.Touch):
            {
                dist = RPGCalc.DEFAULT_TOUCH_RANGE;
                break;
            }

            case (EffectRange.Target):
            {
                dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.Area):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.TargetArea):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }
            } // end switch
            #endregion

            #region Attack and Buff Effects
            // target buff effect
            targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff));

            // target attack effect
            // 20% chance of being completely random
            if (calc.Roll(10) >= 8)
            {
                targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack));
            }
            else // 80% chance of being magical damage
            {
                targetAttack = EffectTargetAttack.DoMagicalDamage;
            }
            #endregion

            #region Set Duration Types based on effect
            // isBuff and is restore, or isNotBuff and is Dmg
            if (isBuff)
            {
                // then we want to reverse all but the restore
                if (targetBuff == EffectTargetBuff.RestoreHP ||
                    targetBuff == EffectTargetBuff.RestoreMP)
                {
                    reverse = false;
                    t       = DurationType.Permanent;
                }
                else
                {
                    reverse  = true;
                    duration = calc.RollRandomEffectDuration(0, 0, 0, 60);
                    t        = DurationType.ForTime;
                }
            }
            else // it's an attack
            {
                // check to avoid reverse on dmg spells
                if (targetAttack == EffectTargetAttack.DoMagicalDamage ||
                    targetAttack == EffectTargetAttack.DoPhysicalDamage)
                {
                    reverse = false;
                    t       = DurationType.Permanent;
                }
                else
                {
                    reverse  = true;
                    duration = calc.RollRandomEffectDuration(0, 0, 0, 60);
                    t        = DurationType.ForTime;
                }
            }
            #endregion

            #region Power
            // roll for min/max power - start with generic
            minPower = calc.Roll(10);
            maxPower = minPower + calc.Roll(10);

            // NOTE: dmg depends on duration and duration type - if long, then small dmg...

            #endregion

            #region Trigger
            // trigger - spell will cause effect immediately.
            trigger = EffectTrigger.Immediately;
            #endregion

            RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse);
            return(e);
        }
示例#25
0
        public static RPGEffect CreateRandomPotionEffect()
        {
            RPGCalc            calc         = new RPGCalc();
            DurationType       t            = DurationType.ForTime;
            TimeSpan           duration     = new TimeSpan(0, 0, 0);
            EffectRange        r            = EffectRange.Touch;
            EffectTrigger      trigger      = EffectTrigger.Immediately;
            EffectTargetBuff   targetBuff   = EffectTargetBuff.RestoreHP;
            EffectTargetAttack targetAttack = EffectTargetAttack.DoPhysicalDamage;
            bool isBuff = true;

            int dist     = 0;
            int radius   = 0;
            int minPower = 0;
            int maxPower = 0;

            bool reverse = true;

            // roll for target
            targetBuff   = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff));
            targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack));

            if (targetBuff == EffectTargetBuff.RestoreHP ||
                targetBuff == EffectTargetBuff.RestoreMP)
            {
                reverse = false;
            }
            else
            {
                duration = calc.RollRandomEffectDuration();
            }

            // roll for range
            while (r == EffectRange.Touch)
            {
                r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange));
            }

            // roll for distance depending on range
            dist = 0;
            switch (r)
            {
            case (EffectRange.Self):
            {
                break;
            }

            case (EffectRange.Touch):
            {
                dist = RPGCalc.DEFAULT_TOUCH_RANGE;
                break;
            }

            case (EffectRange.Target):
            {
                dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.Area):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.TargetArea):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }
            } // end switch

            // roll for min/max power
            minPower = calc.Roll(10);
            maxPower = minPower + calc.Roll(10);

            // trigger - potion will cause effect to be used immediately.
            trigger = EffectTrigger.Immediately;

            RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse);

            return(e);
        }
示例#26
0
        public static RPGEffect CreateRandomWeaponEffect()
        {
            RPGCalc            calc     = new RPGCalc();
            DurationType       t        = DurationType.WhileEquipped;
            TimeSpan           duration = new TimeSpan(0, 0, 0);
            EffectRange        r;
            EffectTrigger      trigger = EffectTrigger.onAttackLanded;
            EffectTargetBuff   targetBuff;
            EffectTargetAttack targetAttack;
            bool isBuff  = false;
            bool reverse = true;

            int dist     = 0;
            int radius   = 0;
            int minPower = 0;
            int maxPower = 0;

            // roll for range
            r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange));

            // roll for distance depending on range
            switch (r)
            {
            case (EffectRange.Self):
            {
                isBuff = true;
                break;
            }

            case (EffectRange.Touch):
            {
                dist = RPGCalc.DEFAULT_TOUCH_RANGE;
                break;
            }

            case (EffectRange.Target):
            {
                dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.Area):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.TargetArea):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }
            } // end switch

            // roll for target
            targetBuff   = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff));
            targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack));

            // roll for min/max power
            minPower = calc.Roll(10);
            maxPower = minPower + calc.Roll(10);

            // roll for trigger
            while (trigger == EffectTrigger.onUse || trigger == EffectTrigger.onHit)
            {
                trigger = (EffectTrigger)calc.GetRandomEnum(typeof(EffectTrigger));
            }

            RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse);

            return(e);
        }
示例#27
0
        public static RPGEffect CreateRandomEffect()
        {
            RPGCalc            calc     = new RPGCalc();
            DurationType       t        = DurationType.ForTime;
            TimeSpan           duration = new TimeSpan(0, 0, 0);
            EffectRange        r        = EffectRange.Target;
            EffectTrigger      trigger  = EffectTrigger.Immediately;
            EffectTargetBuff   targetBuff;
            EffectTargetAttack targetAttack;
            bool isBuff  = true;
            bool reverse = true;

            int dist     = 0;
            int radius   = 0;
            int minPower = 0;
            int maxPower = 0;

            // roll for type
            t        = (DurationType)calc.GetRandomEnum(typeof(DurationType));
            duration = new TimeSpan(0);

            if (t == DurationType.ForTime)
            {
                duration = calc.RollRandomEffectDuration(); // ticks (I think)
            }

            // roll for range
            r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange));

            // roll for distance depending on range
            dist = 0;
            switch (r)
            {
            case (EffectRange.Self):
            {
                break;
            }

            case (EffectRange.Touch):
            {
                dist = RPGCalc.DEFAULT_TOUCH_RANGE;
                break;
            }

            case (EffectRange.Target):
            {
                dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.Area):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }

            case (EffectRange.TargetArea):
            {
                dist   = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE);
                break;
            }
            } // end switch

            // roll for target
            targetBuff   = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff));
            targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack));
            isBuff       = (calc.Roll(2) == 1);

            // roll for min/max power
            minPower = calc.Roll(10);
            maxPower = minPower + calc.Roll(10);

            // roll for trigger
            trigger = (EffectTrigger)calc.GetRandomEnum(typeof(EffectTrigger));

            RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse);

            return(e);
        }
        public void DecideWhatToDo()
        {
            // this is if nothing is happening and the actor is just standing there...

            // assess the state of 'self' and add new actions.
            LastUpdate = System.DateTime.Now;

            #region if Is Being Attacked
            if (self.States.IsBeingAttacked)
            {
                // make sure our attacker is still alive
                if (lastAttacker == null ||
                    lastAttacker.DeleteMe == true ||
                    lastAttacker.States.IsDying)
                {
                    // or we're not being attacked anymore
                    self.States.IsBeingAttacked = false;
                }
                else
                {
                    // if not already attacking target
                    if (self.Actions.Contains(RPGAction.ActionType.Attack, self, lastAttacker) == false)
                    {
                        // make sure our AI wants us to retaliate
                        if (this.RetaliateOnAttacker)
                        {
                            self.Act(RPGObject.Action.Attack, lastAttacker.Location, lastAttacker);
                        }
                    }
                }
            }
            #endregion

            else
            {
                // go through surroundings and stimulous

                RPGObject[] objs = Session.thisSession.thisArea.GetObjects();
                foreach (RPGObject obj in objs)
                {
                    // maybe attack other actors
                    if (obj == null ||
                        !obj.isOfType(typeof(Actor)))
                    {
                        continue;
                    }

                    Actor objActor = obj as Actor;

                    // maybe attack certain alignments
                    Actor.Alignment a = objActor.GetAlignment();
                    if (!ShouldAttackAlignment(objActor))
                    {
                        continue;
                    }

                    // maybe attack if within LOS
                    RPGCalc calc = new RPGCalc();
                    int     dist = calc.DistanceBetween(self, objActor);
                    if (dist > self.LOSRange)
                    {
                        continue;
                    }

                    // we've passed all other checks, so attack
                    self.Act(RPGObject.Action.Attack, objActor.Location, obj);
                }
            }
        } // end DecideWhatToDo
        private void LoadDataTable(Actor a)
        {
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();

            dtAttributes = new DataTable();
            dtAttributes.Columns.Add("Attribute");
            dtAttributes.Columns.Add("Base");
            dtAttributes.Columns.Add("Current");
            dtAttributes.Columns.Add("Bonus");

            DataRow drStr = dtAttributes.NewRow();

            drStr[0] = "Strength";
            drStr[1] = a.BaseStrength;
            drStr[2] = a.CurrentStrength;
            drStr[3] = new RPGCalc().GetBonusFromAttribute(a.CurrentStrength);
            dtAttributes.Rows.Add(drStr);

            DataRow drDex = dtAttributes.NewRow();

            drDex[0] = "Dexterity";
            drDex[1] = a.BaseDexterity;
            drDex[2] = a.CurrentDexterity;
            drDex[3] = new RPGCalc().GetBonusFromAttribute(a.CurrentDexterity);
            dtAttributes.Rows.Add(drDex);

            DataRow drCon = dtAttributes.NewRow();

            drCon[0] = "Constitution";
            drCon[1] = a.BaseConstitution;
            drCon[2] = a.CurrentConstitution;
            drCon[3] = new RPGCalc().GetBonusFromAttribute(a.CurrentConstitution);
            dtAttributes.Rows.Add(drCon);

            DataRow drInt = dtAttributes.NewRow();

            drInt[0] = "Intelligence";
            drInt[1] = a.BaseIntelligence;
            drInt[2] = a.CurrentIntelligence;
            drInt[3] = new RPGCalc().GetBonusFromAttribute(a.CurrentIntelligence);
            dtAttributes.Rows.Add(drInt);

            DataRow drWis = dtAttributes.NewRow();

            drWis[0] = "Wisdom";
            drWis[1] = a.BaseWisdom;
            drWis[2] = a.CurrentWisdom;
            drWis[3] = new RPGCalc().GetBonusFromAttribute(a.CurrentWisdom);
            dtAttributes.Rows.Add(drWis);

            DataRow drCha = dtAttributes.NewRow();

            drCha[0] = "Charisma";
            drCha[1] = a.BaseCharisma;
            drCha[2] = a.CurrentCharisma;
            drCha[3] = new RPGCalc().GetBonusFromAttribute(a.CurrentCharisma);
            dtAttributes.Rows.Add(drCha);

            dataGridView1.DataSource = dtAttributes;
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
        }
示例#30
0
        public override void UpdateSelf()
        {
            if (this.currentState == ActionState.Dying)
            {
                this.Actions.Clear();
                this.currentAction = null;

                // do any effects that triger 'on death'...

                // check if we've been dying long enough
                if (System.DateTime.Now.CompareTo(lastDamage.AddMilliseconds(new RPGDraw().DAMAGE_DURATION)) > 0)
                {
                    this.DeleteMe = true;
                }
            }
            else
            {
                // before the actor can do anything, do any effects
                CheckEffects();

                // double check our priorities periodically
                if (System.DateTime.Now.CompareTo(this.AI.LastUpdate.AddMilliseconds(this.AI.AIUpdateDelay)) > 0)
                {
                    if (this.AIActive)
                    {
                        this.AI.DecideWhatToDo();
                    }
                }

                #region Do Current Action
                if (currentAction != null && currentAction.Accomplished == false)
                {
                    // then do action.
                    switch (currentAction.type)
                    {
                        #region Case: Walk
                    case (RPGAction.ActionType.Walk):
                    {
                        // see if action has been accomplished
                        bool Near;
                        if (currentAction.target != null)
                        {
                            Near = new RPGCalc().ActorStandingNearPoint(this, currentAction.target.Location);
                        }
                        else
                        {
                            Near = new RPGCalc().ActorStandingNearPoint(this, currentAction.destination);
                        }
                        if (Near)
                        {
                            currentAction.Accomplished = true;
                            this.currentState          = ActionState.Standing;
                            StopMoving();
                        }
                        else
                        {
                            // try to walk towards target.

                            // Pathing -check for obstacles and plan to go around

                            if (currentAction.NeedsUpdating == true)
                            {
                                if (currentAction.target != null)
                                {
                                    CalculateMovement(currentAction.target.Location);
                                }
                                else
                                {
                                    CalculateMovement(currentAction.destination);
                                }
                                currentAction.NeedsUpdating = false;
                            }
                            else
                            {
                                currentAction.Check();         // maybe needs updating next time...
                            }

                            if (Move() == false)
                            {
                                // stopped moving because we hit something,
                                currentAction.Accomplished = true;
                                this.currentState          = ActionState.Standing;
                                StopMoving();
                                currentAction = null;
                            }
                            else
                            {
                                // we took a step, so turn toward direction walking
                                Turn(currentAction.destination);
                            }
                        }
                        break;
                    }
                        #endregion

                        #region Case: Attack
                    case (RPGAction.ActionType.Attack):
                    {
                        // if target it dead or dying
                        if (currentAction.target == null ||
                            currentAction.target.currentState == ActionState.Dying)
                        {
                            currentAction.Accomplished = true;

                            // stop attacking
                            this.currentState = ActionState.Standing;
                        }
                        else
                        {
                            // turn toward target
                            Turn(currentAction.target.Location);

                            // try to attack - check if in range
                            int dist = new RPGCalc().DistanceBetween(this, currentAction.target);

                            if (this.inventory.GetWpn() == null && dist <= 30)
                            {
                                AttemptToEngageTarget();
                            }
                            else if (this.inventory.GetWpn() != null &&
                                     dist <= this.inventory.GetWpn().Range)
                            {
                                AttemptToEngageTarget();
                            }         // if dist ok
                            else
                            {
                                // add action to attack to front of list
                                Actions.AddFirst(currentAction);

                                // add action to walk to target to front of list. (before attack);
                                RPGAction walk = new RPGAction(RPGAction.ActionType.Walk, currentAction.target);

                                if (this.inventory.GetWpn() == null ||
                                    this.inventory.GetWpn().weaponType == RPGWeapon.WeaponType.Melee)
                                {
                                    walk.target = currentAction.target;
                                }
                                else
                                {
                                    walk.destination = new RPGCalc().PointToBeInRange(this, currentAction.target);
                                }
                                walk.UpdateFrequency = 100;         // update really often

                                Actions.AddFirst(walk);

                                // CRUCIAL: switch to walking, since target out of range.
                                currentAction = walk;
                            }
                        }
                        break;
                    }
                        #endregion

                        #region Case: Get
                    case (RPGAction.ActionType.Get):
                    {
                        // if target is gone
                        if (currentAction.target == null)
                        {
                            currentAction.Accomplished = true;

                            // stop getting
                            this.currentState = ActionState.Standing;
                        }
                        else
                        {
                            // turn toward target
                            Turn(currentAction.target.Location);

                            // try to get - check if in range
                            int dist = new RPGCalc().DistanceBetween(this, currentAction.target);

                            if (dist <= 40)         // arbitrary reach of actor
                            {
                                this.inventory.AddItem(currentAction.target);
                                Session.thisSession.thisArea.RemoveObject(currentAction.target);
                                currentAction.Accomplished = true;
                                Session.Print(this.Name + " picked up something.");
                            }         // if dist ok
                            else
                            {
                                // add get action to front of list
                                Actions.AddFirst(currentAction);

                                // add action to walk to target to front of list. (before the get);
                                RPGAction walk = new RPGAction(RPGAction.ActionType.Walk, currentAction.target);

                                walk.UpdateFrequency = 500;         // update not too often because it is a get action

                                Actions.AddFirst(walk);

                                // CRUCIAL: switch to walking, since target out of range.
                                currentAction = walk;
                            }
                        } break;
                    }

                        #endregion
                    default:
                    {
                        break;
                    }
                    } // end switch
                }     // end if currentAction
                #endregion

                #region or GetNextAction
                else
                {
                    currentAction = Actions.GetNextAction();

                    // if nothing in queue
                    if (currentAction == null)
                    {
                        // check object's AI to determine what to do next.
                    }
                }
                #endregion
            } // end if still alive
        }