public bool OnCast(Character caster, string args)
        {
            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);

            if (target == null)
            {
                return(false);
            }

            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            int numMissiles = 1;

            if (Skills.GetSkillLevel(caster.magic) > 5 && caster.Mana >= ReferenceSpell.ManaCost * 2)
            {
                numMissiles++;                                                                                       // 2nd missile at magic skill level 6
            }
            if (Skills.GetSkillLevel(caster.magic) > 10 && caster.Mana >= ReferenceSpell.ManaCost * 3)
            {
                numMissiles++;                                                                                        // 3rd missile at magic skill level 11
            }
            if (Skills.GetSkillLevel(caster.magic) > 15 && caster.Mana >= ReferenceSpell.ManaCost * 4)
            {
                numMissiles++;                                                                                        // 3rd missile at magic skill level 16
            }
            if (Skills.GetSkillLevel(caster.magic) > 20 && caster.Mana >= ReferenceSpell.ManaCost * 5)
            {
                numMissiles++;                                                                                        // 3rd missile at magic skill level 21
            }
            while (numMissiles > 0)
            {
                if (target == null || target.IsDead)
                {
                    break;
                }

                if (Combat.DoSpellDamage(caster, target, null, (Skills.GetSkillLevel(caster.magic) * 3) + GameSpell.GetSpellDamageModifier(caster), ReferenceSpell.Name) == 1)
                {
                    Rules.GiveKillExp(caster, target);
                    Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
                }

                if (caster.Mana < ReferenceSpell.ManaCost)
                {
                    return(true);                                       // caster cannot cast any more orbs if no mana left
                }
                else if (numMissiles > 1)
                {
                    caster.Mana -= ReferenceSpell.ManaCost;                       // reduce mana for each orb past the first (first orb mana is reduced before this method is called)
                }
                numMissiles--;
            }
            return(true);
        }
        public bool OnCast(Character caster, string args)
        {
            #region Determine number of pets. Return false if at or above MAX_PETS.
            if (!caster.IsImmortal)
            {
                int petCount = 0;

                foreach (NPC pet in caster.Pets)
                {
                    if (pet.QuestList.Count == 0)
                    {
                        petCount++;
                    }
                }

                if (petCount >= GameSpell.MAX_PETS)
                {
                    caster.WriteToDisplay("You do not possess the mental fortitude to summon an ally.");
                    return(false);
                }
            }
            #endregion

            args = args.Replace(ReferenceSpell.Command, "");
            args = args.Trim();
            string[] sArgs = args.Split(" ".ToCharArray());

            #region Determine Power
            int magicSkillLevel = Skills.GetSkillLevel(caster.magic);
            int power           = magicSkillLevel;

            if (sArgs.Length > 0)
            {
                try
                {
                    power = Convert.ToInt32(sArgs[0]);

                    if (power > magicSkillLevel && !caster.IsImmortal)
                    {
                        power = magicSkillLevel;
                    }
                }
                catch (Exception)
                {
                    power = magicSkillLevel;
                }
            }

            // Rangers get the spell at skill level 3, acts as skill level 1.
            if (!caster.IsImmortal && caster.BaseProfession != Character.ClassType.Druid)
            {
                power = power - 3;
            }

            if (power < 1)
            {
                power = 1;
            }
            #endregion

            List <Entity> availableEntities = new List <Entity>();

            foreach (Tuple <int, Entity, bool> tuple in AlliesAvailable)
            {
                if (tuple.Item1 > power)
                {
                    break;                      // Allies are in sequential power order.
                }
                if (tuple.Item1 <= power)
                {
                    // Not all allies can be summoned indoors.
                    if (caster.CurrentCell.IsOutdoors || (!caster.CurrentCell.IsOutdoors && !tuple.Item3))
                    {
                        availableEntities.Add(tuple.Item2);
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            if (availableEntities.Count <= 0)
            {
                return(false);
            }

            Entity entity = availableEntities[Rules.Dice.Next(0, availableEntities.Count - 1)];

            Autonomy.EntityBuilding.EntityBuilder builder = new Autonomy.EntityBuilding.EntityBuilder();

            string profession = "fighter";

            // If human or humanoid, possibly switch to another profession besides fighter.
            if (Autonomy.EntityBuilding.EntityLists.IsHumanOrHumanoid(entity))
            {
                Character.ClassType[] availableProfessions = new Character.ClassType[] { Character.ClassType.Fighter, Character.ClassType.Thaumaturge, Character.ClassType.Wizard };

                Character.ClassType randomProfession = availableProfessions[Rules.Dice.Next(0, availableProfessions.Length - 1)];

                switch (randomProfession)
                {
                case Character.ClassType.Fighter:
                    profession = Autonomy.EntityBuilding.EntityBuilder.FIGHTER_SYNONYMS[Rules.Dice.Next(0, Autonomy.EntityBuilding.EntityBuilder.FIGHTER_SYNONYMS.Length - 1)];
                    break;

                case Character.ClassType.Thaumaturge:
                    profession = Autonomy.EntityBuilding.EntityBuilder.THAUMATURGE_SYNONYMS[Rules.Dice.Next(0, Autonomy.EntityBuilding.EntityBuilder.THAUMATURGE_SYNONYMS.Length - 1)];
                    break;

                case Character.ClassType.Wizard:
                    profession = Autonomy.EntityBuilding.EntityBuilder.WIZARD_SYNONYMS[Rules.Dice.Next(0, Autonomy.EntityBuilding.EntityBuilder.WIZARD_SYNONYMS.Length - 1)];
                    break;
                }
            }

            NPC ally = builder.BuildEntity("nature allied", entity, caster.Map.ZPlanes[caster.Z], profession);

            // Set level.
            ally.Level = Math.Max(caster.Level, magicSkillLevel) + Rules.Dice.Next(-1, 1); // magic skill should be set to higher skill if using impcast
            if (ally.Level <= 0)
            {
                ally.Level = 1;
            }

            builder.SetOnTheFlyVariables(ally);
            ally.Alignment = caster.Alignment;
            builder.SetName(ally, ally.BaseProfession.ToString());
            builder.SetDescriptions("", ally, caster.Map.ZPlanes[caster.Z], ally.BaseProfession.ToString().ToLower());
            Autonomy.EntityBuilding.EntityBuilder.SetGender(ally, caster.Map.ZPlanes[caster.Z]);
            Autonomy.EntityBuilding.EntityBuilder.SetVisualKey(ally.entity, ally);
            if (ally.spellDictionary.Count > 0)
            {
                ally.magic = Skills.GetSkillForLevel(ally.Level + Rules.Dice.Next(-1, 1));
            }
            GameSpell.FillSpellLists(ally);

            if (Autonomy.EntityBuilding.EntityLists.IsHumanOrHumanoid(ally))
            {
                List <int> armorToWear;

                if (power <= 13)
                {
                    armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_STUDDED_LEATHER].GetArmorList(ally);
                }
                else if (power < 16)
                {
                    armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_CHAINMAIL].GetArmorList(ally);
                }
                else
                {
                    armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_BANDED_MAIL].GetArmorList(ally);
                }

                foreach (int id in armorToWear)
                {
                    Item armor = Item.CopyItemFromDictionary(id);
                    // It's basic armor sets only. Label them as ethereal. (They will go back with the phantasm to their home plane. Given items drop.)
                    armor.special += " " + Item.EXTRAPLANAR;
                    ally.WearItem(armor);
                }
            }

            if (Autonomy.EntityBuilding.EntityLists.IsHumanOrHumanoid(ally) || Autonomy.EntityBuilding.EntityLists.ANIMALS_WIELDING_WEAPONS.Contains(ally.entity))
            {
                List <int> weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(ally, true);
                if (weaponsList.Count > 0)
                {
                    ally.EquipRightHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }
                weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(ally, false);
                if (weaponsList.Count > 0)
                {
                    ally.EquipLeftHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }

                if (ally.RightHand != null)
                {
                    ally.RightHand.special += " " + Item.EXTRAPLANAR;
                }
                if (ally.LeftHand != null)
                {
                    ally.LeftHand.special += " " + Item.EXTRAPLANAR;
                }
            }

            ally.Hits    = ally.HitsFull;
            ally.Mana    = ally.ManaFull;
            ally.Stamina = ally.StaminaFull;

            ally.Age     = GameWorld.World.AgeCycles[Rules.Dice.Next(0, GameWorld.World.AgeCycles.Count - 1)];
            ally.special = "despawn summonnaturesally";

            int twoMinutes = Utils.TimeSpanToRounds(new TimeSpan(0, 2, 0));
            // 18 minutes + 2 minutes for every skill level past 3
            ally.RoundsRemaining = (twoMinutes * 9) + ((magicSkillLevel - ReferenceSpell.RequiredLevel) * twoMinutes);
            //ally.species = Globals.eSpecies.Magical; // this may need to be changed for AI to work properly

            ally.canCommand = true;
            ally.IsMobile   = true;
            ally.IsSummoned = true;
            ally.IsUndead   = false;

            ally.FollowID = caster.UniqueID;

            ally.PetOwner = caster;
            caster.Pets.Add(ally);

            if (ally.CurrentCell != caster.CurrentCell)
            {
                ally.CurrentCell = caster.CurrentCell;
            }

            ReferenceSpell.SendGenericCastMessage(caster, null, true);

            ally.EmitSound(ally.idleSound);
            caster.WriteToDisplay((ally.longDesc.StartsWith("evil") ? "An " : "A ") + ally.longDesc + " answers your call for assistance.");
            ally.AddToWorld();
            return(true);
        }
Example #3
0
        public bool OnCast(Character caster, string args)
        {
            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);

            if (target == null)
            {
                return(false);
            }

            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            int totalDamage = (Skills.GetSkillLevel(caster.magic) * (caster.IsPC ? GameSpell.DEATH_SPELL_MULTIPLICAND_PC : GameSpell.DEATH_SPELL_MULTIPLICAND_NPC)) + GameSpell.GetSpellDamageModifier(caster);

            totalDamage += Rules.RollD(1, 2) == 1 ? Rules.RollD(1, 4) : -(Rules.RollD(1, 4));

            if (Combat.DoSpellDamage(caster, target, null, totalDamage, ReferenceSpell.Name.ToLower()) == 1)
            {
                Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
                Rules.GiveKillExp(caster, target);
            }

            return(true);
        }
        public bool OnCast(Character caster, string args)
        {
            try
            {
                Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);
                Cell      cell   = null;
                if (target == null)
                {
                    cell = Map.GetCellRelevantToCell(caster.CurrentCell, args, false);
                }
                else
                {
                    cell = target.CurrentCell;
                }

                if (cell == null && target == null)
                {
                    return(false);
                }

                #region Path testing.
                PathTest pathTest = new PathTest(PathTest.RESERVED_NAME_AREAEFFECT + PathTest.RESERVED_NAME_COMMANDSUFFIX, caster.CurrentCell);

                if (!pathTest.SuccessfulPathTest(cell))
                {
                    cell = caster.CurrentCell;
                }

                pathTest.RemoveFromWorld();
                #endregion

                cell.SendShout("a thunder clap!");
                cell.EmitSound(Sound.GetCommonSound(Sound.CommonSound.ThunderClap));

                List <Character> theAffected = new List <Character>(cell.Characters.Values);

                if (theAffected.Count > 0)
                {
                    int dmgMultiplier = 6;

                    if (caster is PC)
                    {
                        dmgMultiplier = 8;
                    }
                    int damage = 0;
                    if (Skills.GetSkillLevel(caster.magic) >= 4)
                    {
                        damage = Skills.GetSkillLevel(caster.magic) * dmgMultiplier + GameSpell.GetSpellDamageModifier(caster);
                    }
                    else
                    {
                        damage = 6 * dmgMultiplier + GameSpell.GetSpellDamageModifier(caster);
                    }

                    if (!caster.IsPC)
                    {
                        if (caster.species == Globals.eSpecies.LightningDrake)
                        {
                            damage = Rules.RollD(Skills.GetSkillLevel(caster.magic), 14);
                        }
                    }

                    foreach (Character affected in new List <Character>(theAffected))
                    {
                        if (Combat.DoSpellDamage(caster, affected, null, damage, "lightning") == 1)
                        {
                            Rules.GiveAEKillExp(caster, affected);
                            Skills.GiveSkillExp(caster, affected, Globals.eSkillType.Magic);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Utils.LogException(e);
                return(false);
            }
            return(true);
        }
Example #5
0
        public bool OnCast(Character caster, string args)
        {
            // There is no power level to this spell. Only one demon may be controlled, and if the caster has
            // any pets the spell will flail. The demon will be very powerful, this it's why it is a skill 17 spell.

            // First gather a list of unnamed demons.

            if (caster.Pets != null && caster.Pets.Count > 0 && (caster is PC) && (caster as PC).ImpLevel < Globals.eImpLevel.DEVJR)
            {
                caster.WriteToDisplay("Summoning a demon requires your full concentration.");
                return(false);
            }

            List <EntityLists.Entity> availableDemons = new List <EntityLists.Entity>();

            foreach (EntityLists.Entity entity in EntityLists.DEMONS)
            {
                if (!EntityLists.NAMED_DEMONS.Contains(entity))
                {
                    availableDemons.Add(entity);
                }
            }

            NPC demon = NPC.LoadNPC(Item.ID_SUMMONEDMOB, caster.FacetID, caster.LandID, caster.MapID, caster.X, caster.Y, caster.Z, -1);

            EntityLists.Entity chosenDemon = availableDemons[Rules.Dice.Next(availableDemons.Count)];

            EntityBuilder builder = new EntityBuilder();

            demon.Level  = caster.Level + Rules.RollD(3, 4);
            demon.entity = chosenDemon;
            List <Character.ClassType> allowedProfessions = new List <Character.ClassType>
            {
                Character.ClassType.Fighter,
                Character.ClassType.Ravager,
                //Character.ClassType.Sorcerer,
                //Character.ClassType.Thaumaturge,
                Character.ClassType.Thief,
                Character.ClassType.Wizard,
            };

            demon.BaseProfession = allowedProfessions[Rules.Dice.Next(0, allowedProfessions.Count - 1)];

            builder.SetOnTheFlyVariables(demon);
            EntityBuilder.SetVisualKey(demon.entity, demon);
            builder.SetName(demon, demon.BaseProfession.ToString().ToLower());
            builder.SetDescriptions("summoned", demon, caster.Map.ZPlanes[caster.Z], demon.BaseProfession.ToString().ToLower());
            EntityBuilder.SetGender(demon, caster.Map.ZPlanes[caster.Z]);
            EntityBuilder.SetVisualKey(demon.entity, demon);

            if (demon.IsSpellUser)
            {
                NPC.CreateGenericSpellList(demon);
                GameSpell.FillSpellLists(demon);
            }

            if (EntityLists.IsHumanOrHumanoid(demon))
            {
                demon.wearing.Clear();

                List <int> armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_STEEL].GetArmorList(demon);

                foreach (int id in armorToWear)
                {
                    Item armor = Item.CopyItemFromDictionary(id);
                    armor.special += " " + Item.EXTRAPLANAR;
                    demon.WearItem(armor);
                }
            }

            if (EntityLists.IsHumanOrHumanoid(demon) || EntityLists.ANIMALS_WIELDING_WEAPONS.Contains(demon.entity))
            {
                List <int> weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(demon, true);
                if (weaponsList.Count > 0)
                {
                    demon.EquipRightHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }
                weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(demon, false);
                if (weaponsList.Count > 0)
                {
                    demon.EquipLeftHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }

                if (demon.RightHand != null)
                {
                    demon.RightHand.special += " " + Item.EXTRAPLANAR;
                }
                if (demon.LeftHand != null)
                {
                    demon.LeftHand.special += " " + Item.EXTRAPLANAR;
                }
            }

            demon.castMode = NPC.CastMode.Limited;

            demon.Hits    = demon.HitsFull;
            demon.Mana    = demon.ManaFull;
            demon.Stamina = demon.StaminaFull;

            demon.Alignment = Globals.eAlignment.ChaoticEvil;
            demon.race      = "Hell";

            //demon.aiType = NPC.AIType.EmptySlot;
            demon.Age     = 0;
            demon.special = "despawn";
            int fiveMinutes = Utils.TimeSpanToRounds(new TimeSpan(0, 5, 0));

            // 5 minutes plus 1 minute per magic skill level
            demon.RoundsRemaining = fiveMinutes + Skills.GetSkillLevel(caster.magic) * Utils.TimeSpanToRounds(new TimeSpan(0, 1, 0));
            demon.species         = Globals.eSpecies.Demon; // this may need to be changed for AI to work properly
            demon.Alignment       = caster.Alignment;
            demon.canCommand      = true;
            demon.IsMobile        = true;
            demon.IsSummoned      = true;
            demon.IsUndead        = EntityLists.UNDEAD.Contains(demon.entity);

            demon.FollowID = caster.UniqueID;

            demon.PetOwner = caster;
            caster.Pets.Add(demon);

            if (demon.CurrentCell != caster.CurrentCell)
            {
                demon.CurrentCell = caster.CurrentCell;
            }

            demon.EmitSound(demon.idleSound);

            demon.AddToWorld();

            return(true);
        }
Example #6
0
        public bool OnCast(Character caster, string args)
        {
            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);

            if (target == null)
            {
                return(false);
            }

            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            target.WriteToDisplay("You have been hit by a " + ReferenceSpell.Name + "!");

            if (Combat.DoSpellDamage(caster, target, null, (Skills.GetSkillLevel(caster.magic) * 12) + GameSpell.GetSpellDamageModifier(caster), ReferenceSpell.Name) == 1)
            {
                Rules.GiveKillExp(caster, target);
                Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
            }
            return(true);
        }
Example #7
0
        public bool OnCast(Character caster, string args)
        {
            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);

            if (target == null)
            {
                return(false);
            }

            int dmgMultiplier = GameSpell.CURSE_SPELL_MULTIPLICAND_NPC;

            if (caster.IsPC)
            {
                dmgMultiplier = GameSpell.CURSE_SPELL_MULTIPLICAND_PC;              // allow players to do slightly more damage than critters at same skill level
            }
            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            if (Combat.DoSpellDamage(caster, target, null, Skills.GetSkillLevel(caster.magic) * dmgMultiplier + GameSpell.GetSpellDamageModifier(caster), "curse") == 1)
            {
                Rules.GiveKillExp(caster, target);
                Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
            }

            return(true);
        }
Example #8
0
        public bool OnCast(Character caster, string args)
        {
            /*      Power   Mana    Type        Armor (item IDs)            Skill (base)    Spells
             *      1       20      phantasm    leather (8010, 15010)       7               none
             *      2       23      eidolon     chain (8015, 15015)         8               magic missile
             *      3       30      djinn       banded mail (8020, 15020)   9               ice storm
             *      4       32      salamander  sally scales (8102)         10              firewall
             *      5       35      efreet      steel (8021, 15021)         11              concussion
             *      6       40      marid       steel (8021, 15021)         12              icespear
             *      7       42      dao         steel (8021, 15021)         13              lightninglance
             */

            args = args.Replace(ReferenceSpell.Command, "");

            args = args.Trim();

            string[] sArgs = args.Split(" ".ToCharArray());

            #region Determine power.
            PhantasmPower power = PhantasmPower.Phantasm; // default power

            if (sArgs.Length > 0)
            {
                try
                {
                    power = (PhantasmPower)Convert.ToInt32(sArgs[0]);

                    if (power > PhantasmPower.Dao)
                    {
                        power = PhantasmPower.Dao;
                    }
                }
                catch (Exception)
                {
                    power = PhantasmPower.Phantasm;
                }
            }
            #endregion

            int magicSkillLevel = Skills.GetSkillLevel(caster.magic);
            if (caster.IsImmortal)
            {
                magicSkillLevel = 19;
            }

            #region Verify skill level for power of spell.
            if (!caster.IsImmortal)
            {
                if (magicSkillLevel < 19)
                {
                    if (magicSkillLevel < 19 && power == PhantasmPower.Dao)
                    {
                        caster.WriteToDisplay("You are not skilled enough yet to summon dao.");
                        return(true);
                    }

                    if (magicSkillLevel < 18 && power == PhantasmPower.Marid)
                    {
                        caster.WriteToDisplay("You are not skilled enough yet to summon marid.");
                        return(true);
                    }

                    if (magicSkillLevel < 17 && power == PhantasmPower.Efreet)
                    {
                        caster.WriteToDisplay("You are not skilled enough yet to summon efreeti.");
                        return(true);
                    }

                    if (magicSkillLevel < 15 && power == PhantasmPower.Salamander)
                    {
                        caster.WriteToDisplay("You are not skilled enough yet to summon salamanders.");
                        return(true);
                    }

                    if (magicSkillLevel < 13 && power == PhantasmPower.Djinn)
                    {
                        caster.WriteToDisplay("You are not skilled enough yet to summon djinn.");
                        return(true);
                    }

                    if (magicSkillLevel < 12 && power == PhantasmPower.Eidolon)
                    {
                        caster.WriteToDisplay("You are not skilled enough yet to summon eidolon.");
                        return(true);
                    }
                }
            }
            #endregion

            #region Determine number of pets. Return false if at or above MAX_PETS.
            int petCount = 0;

            foreach (NPC pet in caster.Pets)
            {
                if (pet.QuestList.Count == 0)
                {
                    petCount++;
                }
            }

            // TODO: item or skill/talent to summon more pets
            if (!caster.IsImmortal && petCount >= GameSpell.MAX_PETS)
            {
                caster.WriteToDisplay("You do not possess the mental fortitude to control another pet.");
                return(false);
            }
            #endregion

            #region Setup the summoned spirit.
            int        npcID       = 902;
            List <int> armorToWear = new List <int>();

            Autonomy.EntityBuilding.EntityLists.Entity entity = Autonomy.EntityBuilding.EntityLists.Entity.None;

            switch (power)
            {
            case PhantasmPower.Phantasm:     // phantasm with leather
                if (caster.Mana < ReferenceSpell.ManaCost)
                {
                    return(false);
                }
                entity = Autonomy.EntityBuilding.EntityLists.Entity.Phantasm;
                break;

            case PhantasmPower.Eidolon:     // eidolon with chain
                if (caster.Mana < ReferenceSpell.ManaCost + 3)
                {
                    caster.Mana -= 3;
                    return(false);
                }
                entity       = Autonomy.EntityBuilding.EntityLists.Entity.Eidolon;
                caster.Mana -= 5;
                break;

            case PhantasmPower.Djinn:     // djinn with banded mail
                if (caster.Mana < ReferenceSpell.ManaCost + 10)
                {
                    caster.Mana -= 10;
                    return(false);
                }
                caster.Mana -= 10;
                npcID        = 903; // djinn with banded mail and icestorm
                entity       = Autonomy.EntityBuilding.EntityLists.Entity.Djinn;
                break;

            case PhantasmPower.Salamander:     // salamander
                if (caster.Mana < ReferenceSpell.ManaCost + 12)
                {
                    caster.Mana -= 12;
                    return(false);
                }
                caster.Mana -= 12;
                npcID        = 37; // salamander with scales and firewall
                entity       = Autonomy.EntityBuilding.EntityLists.Entity.Salamander;
                break;

            case PhantasmPower.Efreet:     // efreet with plate
                if (caster.Mana < ReferenceSpell.ManaCost + 15)
                {
                    caster.Mana -= 15;
                    return(false);
                }
                caster.Mana -= 15;
                npcID        = 904; // efreet with steel plate and concussion
                entity       = Autonomy.EntityBuilding.EntityLists.Entity.Efreet;
                break;

            case PhantasmPower.Marid:     // efreet with plate
                if (caster.Mana < ReferenceSpell.ManaCost + 20)
                {
                    caster.Mana -= 20;
                    return(false);
                }
                caster.Mana -= 20;
                npcID        = 904; // marid with steel plate and icespear
                entity       = Autonomy.EntityBuilding.EntityLists.Entity.Marid;
                break;

            case PhantasmPower.Dao:     // efreet with plate
                if (caster.Mana < ReferenceSpell.ManaCost + 23)
                {
                    caster.Mana -= 23;
                    return(false);
                }
                caster.Mana -= 23;
                npcID        = 904; // dao with steel plate and lightninglance
                entity       = Autonomy.EntityBuilding.EntityLists.Entity.Dao;
                break;

            default:
                break;
            }

            // Create the summoned spirit.
            NPC phantasm = NPC.LoadNPC(npcID, caster.FacetID, caster.LandID, caster.MapID, caster.X, caster.Y, caster.Z, -1);

            foreach (Item wornItem in new List <Item>(phantasm.wearing))
            {
                phantasm.RemoveWornItem(wornItem);
            }

            phantasm.wearing.Clear();

            Autonomy.EntityBuilding.EntityBuilder builder = new Autonomy.EntityBuilding.EntityBuilder();

            phantasm.Level = caster.Level + (int)power;

            phantasm.entity = entity;
            builder.SetOnTheFlyVariables(phantasm);
            builder.SetName(phantasm, phantasm.BaseProfession.ToString());
            builder.SetDescriptions("", phantasm, caster.Map.ZPlanes[caster.Z], phantasm.BaseProfession.ToString().ToLower());
            Autonomy.EntityBuilding.EntityBuilder.SetVisualKey(phantasm.entity, phantasm);

            /*      Power   Mana    Type        Armor (item IDs)            Skill (base)    Spells
             *      1       20      phantasm    leather (8010, 15010)       7               none
             *      2       23      eidolon     chain (8015, 15015)         8               magic missile
             *      3       30      djinn       banded mail (8020, 15020)   9               ice storm
             *      4       32      salamander  sally scales (8102)         10              firewall
             *      5       35      efreet      steel (8021, 15021)         11              concussion
             *      6       40      marid       steel (8021, 15021)         12              icespear
             *      7       43      dao         steel (8021, 15021)         13              lightninglance
             */

            // basic phantasm
            if (power <= PhantasmPower.Phantasm)
            {
                phantasm.HitsMax += (int)power * 100;
                phantasm.ManaMax  = 0;
                phantasm.castMode = NPC.CastMode.Never;
                phantasm.magic    = 0;
            }
            else
            {
                phantasm.ManaMax  = (int)power * (3 + Rules.RollD(1, 6));
                phantasm.castMode = NPC.CastMode.NoPrep;
                phantasm.magic    = Skills.GetSkillForLevel(((int)power * 2) + Rules.RollD(1, 3));
                phantasm.spellDictionary.Clear();

                switch (power)
                {
                case PhantasmPower.Eidolon:     // eidolon with magic missile
                    if (!phantasm.spellDictionary.ContainsKey((int)GameSpell.GameSpellID.Magic_Missile))
                    {
                        phantasm.spellDictionary.Add((int)GameSpell.GameSpellID.Magic_Missile, GameSpell.GenerateMagicWords());
                    }
                    break;

                case PhantasmPower.Djinn:     // djinn with icestorm
                    if (!phantasm.spellDictionary.ContainsKey((int)GameSpell.GameSpellID.Icestorm))
                    {
                        phantasm.spellDictionary.Add((int)GameSpell.GameSpellID.Icestorm, GameSpell.GenerateMagicWords());
                    }
                    // talents
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DualWield.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DualWield).Command, DateTime.UtcNow);
                    }
                    break;

                case PhantasmPower.Salamander:     // salamander with firewall and firebolt
                    if (!phantasm.spellDictionary.ContainsKey((int)GameSpell.GameSpellID.Firewall))
                    {
                        phantasm.spellDictionary.Add((int)GameSpell.GameSpellID.Firewall, GameSpell.GenerateMagicWords());
                    }
                    if (!phantasm.spellDictionary.ContainsKey((int)GameSpell.GameSpellID.Firebolt))
                    {
                        phantasm.spellDictionary.Add((int)GameSpell.GameSpellID.Firebolt, GameSpell.GenerateMagicWords());
                    }
                    // talent
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DoubleAttack.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DoubleAttack).Command, DateTime.UtcNow);
                    }
                    break;

                case PhantasmPower.Efreet:     // efreet with concussion
                    if (!phantasm.spellDictionary.ContainsKey((int)GameSpell.GameSpellID.Concussion))
                    {
                        phantasm.spellDictionary.Add((int)GameSpell.GameSpellID.Concussion, GameSpell.GenerateMagicWords());
                    }
                    // talents
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DualWield.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DualWield).Command, DateTime.UtcNow);
                    }
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DoubleAttack.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DoubleAttack).Command, DateTime.UtcNow);
                    }
                    break;

                case PhantasmPower.Marid:
                    if (!phantasm.spellDictionary.ContainsKey((int)GameSpell.GameSpellID.Icespear))
                    {
                        phantasm.spellDictionary.Add((int)GameSpell.GameSpellID.Icespear, GameSpell.GenerateMagicWords());
                    }
                    // talents
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DualWield.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DualWield).Command, DateTime.UtcNow);
                    }
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DoubleAttack.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DoubleAttack).Command, DateTime.UtcNow);
                    }
                    break;

                case PhantasmPower.Dao:
                    // lightning lance
                    if (!phantasm.spellDictionary.ContainsKey((int)GameSpell.GameSpellID.Lightning_Lance))
                    {
                        phantasm.spellDictionary.Add((int)GameSpell.GameSpellID.Lightning_Lance, GameSpell.GenerateMagicWords());
                    }
                    // talents (dual wield, double attack, riposte)
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DualWield.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DualWield).Command, DateTime.UtcNow);
                    }
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.DoubleAttack.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.DoubleAttack).Command, DateTime.UtcNow);
                    }
                    if (!phantasm.talentsDictionary.ContainsKey(Talents.GameTalent.TALENTS.Riposte.ToString().ToLower()))
                    {
                        phantasm.talentsDictionary.Add(Talents.GameTalent.GetTalent(Talents.GameTalent.TALENTS.Riposte).Command, DateTime.UtcNow);
                    }
                    break;

                default:
                    phantasm.spellDictionary.Clear();
                    break;
                }
            }

            // Armor sets.

            switch (power)
            {
            case PhantasmPower.Phantasm:     // phantasm with leather
                armorToWear = ArmorSet.ArmorSetDictionary[ArmorSet.BASIC_LEATHER].GetArmorList(phantasm);
                break;

            case PhantasmPower.Eidolon:     // eidolon with chain
                armorToWear = ArmorSet.ArmorSetDictionary[ArmorSet.BASIC_CHAINMAIL].GetArmorList(phantasm);
                break;

            case PhantasmPower.Djinn:     // djinn with banded mail
                armorToWear = ArmorSet.ArmorSetDictionary[ArmorSet.BASIC_BANDED_MAIL].GetArmorList(phantasm);
                break;

            case PhantasmPower.Salamander:     // salamander
                armorToWear.Add(Item.ID_FIRE_SALAMANDER_SCALE_VEST);
                break;

            case PhantasmPower.Efreet:     // efreet with plate
            case PhantasmPower.Marid:
            case PhantasmPower.Dao:
                armorToWear = ArmorSet.ArmorSetDictionary[ArmorSet.BASIC_STEEL].GetArmorList(phantasm);
                break;

            default:
                break;
            }

            // Wear armor.
            foreach (int id in armorToWear)
            {
                Item armor = Item.CopyItemFromDictionary(id);
                // It's basic armor sets only. Label them as ethereal. (They will go back with the phantasm to their home plane. Given items drop.)
                armor.special += " " + Item.EXTRAPLANAR;
                phantasm.WearItem(armor);
            }

            if (phantasm.RightHand != null)
            {
                phantasm.RightHand.special += " " + Item.EXTRAPLANAR;
            }
            if (phantasm.LeftHand != null)
            {
                phantasm.LeftHand.special += " " + Item.EXTRAPLANAR;
            }

            GameSpell.FillSpellLists(phantasm);

            phantasm.Hits    = phantasm.HitsFull;
            phantasm.Mana    = phantasm.ManaFull;
            phantasm.Stamina = phantasm.StaminaFull;

            //phantasm.Alignment = (Globals.eAlignment)Enum.Parse(typeof(Globals.eAlignment), caster.Alignment.ToString());
            phantasm.Alignment = caster.Alignment;
            phantasm.Age       = 0;
            phantasm.special   = "despawn";

            int fiveMinutes = Utils.TimeSpanToRounds(new TimeSpan(0, 5, 0));
            // 30 minutes + 5 minutes for every skill level past 11 minus 5 minutes for every power of the spell beyond 1.
            phantasm.RoundsRemaining = (fiveMinutes * 6) + ((magicSkillLevel - ReferenceSpell.RequiredLevel) * fiveMinutes) - (((int)power - 1) * fiveMinutes);
            phantasm.species         = Globals.eSpecies.Magical; // this may need to be changed for AI to work properly

            phantasm.canCommand = true;
            phantasm.IsMobile   = true;
            phantasm.IsSummoned = true;
            phantasm.IsUndead   = false;

            phantasm.FollowID = caster.UniqueID;

            phantasm.PetOwner = caster;
            caster.Pets.Add(phantasm);
            #endregion

            if (phantasm.CurrentCell != caster.CurrentCell)
            {
                phantasm.CurrentCell = caster.CurrentCell;
            }

            phantasm.EmitSound(phantasm.idleSound);

            phantasm.AddToWorld();

            return(true);
        }
        public bool OnCast(Character caster, string args)
        {
            if (string.IsNullOrEmpty(args))
            {
                return(false);
            }

            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);

            if (target == null)
            {
                return(false);
            }

            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            // Physically massive entities cannot be hooked.
            if (Autonomy.EntityBuilding.EntityLists.IsPhysicallyMassive(target))
            {
                caster.WriteToDisplay(target.GetNameForActionResult() + " is too massive to be strangled.");
                return(false);
            }

            // Automatic stun.
            // Why is the Stunned property/variable still a short? Waste of conversion. 1/12/2017 Eb
            if (!target.immuneStun && !Autonomy.EntityBuilding.EntityLists.IMMUNE_STUN.Contains(target.entity))
            {
                target.Stunned = (short)Rules.RollD(2, 4);

                target.WriteToDisplay("You are stunned!");

                if (target.preppedSpell != null)
                {
                    target.preppedSpell = null;
                    target.WriteToDisplay("Your spell has been lost.");
                    target.EmitSound(Sound.GetCommonSound(Sound.CommonSound.SpellFail));
                }

                target.SendToAllInSight(target.GetNameForActionResult() + " is stunned.");
            }
            else
            {
                caster.WriteToDisplay(target.GetNameForActionResult() + " is immune to being stunned.");
            }

            int dmgMultiplier = GameSpell.DEATH_SPELL_MULTIPLICAND_NPC;

            if (caster.IsPC)
            {
                dmgMultiplier = GameSpell.DEATH_SPELL_MULTIPLICAND_PC;              // allow players to do slightly more damage than critters at same skill level
            }
            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            if (Combat.DoSpellDamage(caster, target, null, Skills.GetSkillLevel(caster.magic) * 2 * dmgMultiplier + GameSpell.GetSpellDamageModifier(caster), "stranglehold") == 1)
            {
                Rules.GiveKillExp(caster, target);
                Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
            }

            return(true);
        }
Example #10
0
        public bool OnCast(Character caster, string args)
        {
            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, args);

            if (target == null)
            {
                return(false);
            }
            if (target == caster)
            {
                caster.WriteToDisplay("You cannot cast " + ReferenceSpell.Name + " at yourself."); return(false);
            }

            ReferenceSpell.SendGenericCastMessage(caster, target, false);

            int numShards = 1;

            if (Skills.GetSkillLevel(caster.magic) > 4 && caster.Mana >= ReferenceSpell.ManaCost * 2)
            {
                numShards++;                                                                                       // 2nd shard at magic skill level 5
            }
            if (Skills.GetSkillLevel(caster.magic) > 9 && caster.Mana >= ReferenceSpell.ManaCost * 3)
            {
                numShards++;                                                                                       // 3rd shard at magic skill level 10
            }
            if (Skills.GetSkillLevel(caster.magic) > 14 && caster.Mana >= ReferenceSpell.ManaCost * 4)
            {
                numShards++;                                                                                        // 4th shard at magic skill level 15
            }
            if (Skills.GetSkillLevel(caster.magic) > 18 && caster.Mana >= ReferenceSpell.ManaCost * 5)
            {
                numShards++;                                                                                        // 5th shard at magic skill level 19 (max as of 12/2/2015 Eb)
            }
            // add an orb for magic intensity
            if (caster.Map.HasRandomMagicIntensity && Rules.RollD(1, 100) >= 50)
            {
                numShards++;
            }

            int attackRoll = 0;

            while (numShards > 0)
            {
                caster.EmitSound(ReferenceSpell.SoundFile);

                int toHit      = Combat.DND_RollToHit(caster, target, this, ref attackRoll); // 0 is miss, 1 is hit, 2 is critical
                int multiplier = 3;

                Item totem = caster.FindHeldItem(Item.ID_TRUESPIRIT_TOTEM);

                if (totem != null && !totem.IsAttunedToOther(caster))
                {
                    multiplier += Rules.RollD(1, 3) + 1;
                }

                if (toHit > 0)
                {
                    target.WriteToDisplay(caster.GetNameForActionResult() + " hits with an " + ReferenceSpell.Name + "!");

                    if (toHit == 2)
                    {
                        multiplier = 4;
                        caster.WriteToDisplay("Your " + ReferenceSpell.Name + " does critical damage!");
                        target.WriteToDisplay("The " + ReferenceSpell.Name + " does critical damage!");
                    }

                    if (Combat.DoSpellDamage(caster, target, null, (Skills.GetSkillLevel(caster.magic) * multiplier) + GameSpell.GetSpellDamageModifier(caster), ReferenceSpell.Name) == 1)
                    {
                        Rules.GiveKillExp(caster, target);
                        Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
                        Skills.GiveSkillExp(caster, target, Globals.eSkillType.Shuriken);
                        return(true); // target is dead, break out of here
                    }
                    else
                    {
                        // magic skill is earned regardless
                        Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
                        // some shuriken, or throwing item skill is earned as well
                        Skills.GiveSkillExp(caster, target, Globals.eSkillType.Shuriken);
                    }
                }
                else
                {
                    caster.WriteToDisplay("Your " + ReferenceSpell.Name + " misses " + target.GetNameForActionResult(true) + ".");
                    target.WriteToDisplay(caster.GetNameForActionResult() + " misses you with " + Character.POSSESSIVE[(int)caster.gender].ToLower() + " " + ReferenceSpell.Name + "!");
                }

                if (caster.Mana < ReferenceSpell.ManaCost)
                {
                    return(true);                                       // caster cannot cast any more orbs if no mana left
                }
                else if (numShards > 1)
                {
                    caster.Mana -= ReferenceSpell.ManaCost;                     // reduce mana for each orb past the first (first orb mana is reduced before this method is called)
                }
                numShards--;
            }
            return(true);
        }
Example #11
0
        public bool OnCast(Character caster, string args)
        {
            string[] sArgs = args.Split(" ".ToCharArray());

            Character target = ReferenceSpell.FindAndConfirmSpellTarget(caster, sArgs[sArgs.Length - 1]);

            if (target == null)
            {
                return(false);
            }

            if (!target.IsUndead)
            {
                caster.WriteToDisplay("The " + ReferenceSpell.Name + " spell only works on the undead.");
                return(false);
            }

            ReferenceSpell.SendGenericCastMessage(caster, target, true);

            int totalDamage = (Skills.GetSkillLevel(caster.magic) * ((caster.IsPC ? GameSpell.DEATH_SPELL_MULTIPLICAND_PC : GameSpell.DEATH_SPELL_MULTIPLICAND_NPC) + 1)) + GameSpell.GetSpellDamageModifier(caster);

            totalDamage += Rules.RollD(1, 2) == 1 ? Rules.RollD(1, 4) : -(Rules.RollD(1, 4));

            Item totem = caster.FindHeldItem(Item.ID_BLOODWOOD_TOTEM);

            if (totem != null && !totem.IsAttunedToOther(caster))
            {
                totalDamage += Rules.RollD(3, 4);
            }

            if (Combat.DoSpellDamage(caster, target, null, totalDamage, ReferenceSpell.Name.ToLower()) == 1)
            {
                Skills.GiveSkillExp(caster, target, Globals.eSkillType.Magic);
                Rules.GiveKillExp(caster, target);
            }

            return(true);
        }
Example #12
0
 public bool OnCast(Character caster, string args)
 {
     ReferenceSpell.SendGenericCastMessage(caster, null, true);
     ReferenceSpell.CastGenericAreaSpell(caster, args, Effect.EffectTypes.Light, Skills.GetSkillLevel(caster.magic) * ReferenceSpell.RequiredLevel + GameSpell.GetSpellDamageModifier(caster), ReferenceSpell.Name);
     return(true);
 }
Example #13
0
        public bool OnCast(Character caster, string args)
        {
            #region Determine number of pets. Return false if at or above MAX_PETS.
            if (!caster.IsImmortal)
            {
                int petCount = 0;

                foreach (NPC pet in caster.Pets)
                {
                    if (pet.QuestList.Count == 0)
                    {
                        petCount++;
                    }
                }

                if (petCount >= GameSpell.MAX_PETS)
                {
                    caster.WriteToDisplay("You do not possess the mental fortitude to summon an ally.");
                    return(false);
                }
            }
            #endregion

            args = args.Replace(ReferenceSpell.Command, "");
            args = args.Trim();
            string[] sArgs = args.Split(" ".ToCharArray());

            #region Determine Power
            int magicSkillLevel = Skills.GetSkillLevel(caster.magic);
            int power           = magicSkillLevel;

            if (sArgs.Length > 0)
            {
                try
                {
                    power = Convert.ToInt32(sArgs[0]);

                    if (power > magicSkillLevel && !caster.IsImmortal)
                    {
                        power = magicSkillLevel;
                    }
                }
                catch (Exception)
                {
                    power = magicSkillLevel;
                }
            }

            if (power < 1)
            {
                power = caster.Level;
            }
            #endregion

            Entity entity = Entity.Fighter;

            Enum.TryParse(caster.BaseProfession.ToString(), true, out entity);

            EntityBuilder builder = new EntityBuilder();

            string profession = entity.ToString().ToLower();

            if (!EntityLists.IsHuman(caster) || Rules.RollD(1, 100) < 50)
            {
                string entityLowerCase = caster.entity.ToString().ToLower();
                if (entityLowerCase.StartsWith("drow"))
                {
                    entity = Entity.Drow;
                    // Drow.Master summons drow thieves, Drow.Matriarch summons drow priestesses unless uncomment below lines
                    //List<string> availableProfessions = new List<string>() {"anathema", "cleric", "ravager", "rogue", "sorcerer" };
                    //profession = availableProfessions[Rules.Dice.Next(0, availableProfessions.Count - 1)];
                }
                else if (EntityLists.ELVES.Contains(caster.entity))
                {
                    List <Entity> allyEntities = new List <Entity>()
                    {
                        Entity.Grey_Elf,
                        Entity.High_Elf,
                        Entity.Wood_Elf
                    };
                }
                else
                {
                    List <Entity> allyEntities = new List <Entity>()
                    {
                        Entity.Gnome, Entity.Goblin,
                        Entity.Kobold,
                        Entity.Orc,
                        Entity.Tengu,
                    };

                    entity = allyEntities[Rules.Dice.Next(0, allyEntities.Count - 1)];
                }

                //profession = EntityBuilder.THIEF_SYNONYMS[Rules.Dice.Next(0, EntityBuilder.THIEF_SYNONYMS.Length - 1)];
            }

            NPC ally = builder.BuildEntity("allied", entity, caster.Map.ZPlanes[caster.Z], profession);

            // Set level.
            ally.Level = Math.Max(caster.Level, magicSkillLevel) + Rules.Dice.Next(-1, 1); // magic skill should be set to higher skill if using impcast
            if (ally.Level <= 0)
            {
                ally.Level = 1;
            }

            builder.SetOnTheFlyVariables(ally);
            ally.Alignment = caster.Alignment;
            builder.SetName(ally, profession);
            builder.SetDescriptions("allied", ally, caster.Map.ZPlanes[caster.Z], ally.BaseProfession.ToString().ToLower());
            EntityBuilder.SetGender(ally, caster.Map.ZPlanes[caster.Z]);
            EntityBuilder.SetVisualKey(ally.entity, ally);
            if (ally.spellDictionary.Count > 0)
            {
                ally.magic = Skills.GetSkillForLevel(ally.Level + Rules.Dice.Next(-1, 1));
            }
            GameSpell.FillSpellLists(ally);

            if (EntityLists.IsHumanOrHumanoid(ally))
            {
                List <int> armorToWear;

                if (power <= 13)
                {
                    armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_STUDDED_LEATHER].GetArmorList(ally);
                }
                else if (power < 16)
                {
                    armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_CHAINMAIL].GetArmorList(ally);
                }
                else
                {
                    armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_BANDED_MAIL].GetArmorList(ally);
                }

                foreach (int id in armorToWear)
                {
                    Item armor = Item.CopyItemFromDictionary(id);
                    // It's basic armor sets only. Label them as ethereal. (They will go back with the phantasm to their home plane. Given items drop.)
                    armor.special += " " + Item.EXTRAPLANAR;
                    ally.WearItem(armor);
                }
            }

            if (EntityLists.IsHumanOrHumanoid(ally) || EntityLists.ANIMALS_WIELDING_WEAPONS.Contains(ally.entity))
            {
                List <int> weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(ally, true);
                if (weaponsList.Count > 0)
                {
                    ally.EquipRightHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }
                weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(ally, false);
                if (weaponsList.Count > 0)
                {
                    ally.EquipLeftHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }

                if (ally.RightHand != null)
                {
                    ally.RightHand.special += " " + Item.EXTRAPLANAR;
                }
                if (ally.LeftHand != null)
                {
                    ally.LeftHand.special += " " + Item.EXTRAPLANAR;
                }
            }

            ally.Hits    = ally.HitsFull;
            ally.Mana    = ally.ManaFull;
            ally.Stamina = ally.StaminaFull;

            ally.Age     = GameWorld.World.AgeCycles[Rules.Dice.Next(0, GameWorld.World.AgeCycles.Count - 1)];
            ally.special = "despawn summonthief";

            int oneMinute = Utils.TimeSpanToRounds(new TimeSpan(0, 1, 0));
            // 10 minutes + 2 minutes for every skill level past 3
            ally.RoundsRemaining = (oneMinute * 5) + ((power - ReferenceSpell.RequiredLevel) * oneMinute);
            //ally.species = Globals.eSpecies.Magical; // this may need to be changed for AI to work properly

            ally.canCommand = true;
            ally.IsMobile   = true;
            ally.IsSummoned = true;
            ally.IsUndead   = false;

            ally.FollowID = caster.UniqueID;

            ally.PetOwner = caster;
            caster.Pets.Add(ally);

            if (ally.CurrentCell != caster.CurrentCell)
            {
                ally.CurrentCell = caster.CurrentCell;
            }

            ReferenceSpell.SendGenericCastMessage(caster, null, true);

            ally.EmitSound(ally.idleSound);
            caster.WriteToDisplay((ally.longDesc.StartsWith("evil") ? "An " : "A ") + ally.longDesc + " answers your call for assistance.");
            caster.SendToAllInSight(caster.GetNameForActionResult() + " summons an ally.");
            if (caster is NPC)
            {
                ally.MostHated = (caster as NPC).MostHated;
            }
            ally.AddToWorld();
            return(true);
        }
Example #14
0
        public bool OnCast(Character caster, string args)
        {
            try
            {
                string[] sArgs = args.Split(" ".ToCharArray());

                Item iditem = caster.FindHeldItem(args);

                if (iditem == null)
                {
                    if (caster.RightHand != null)
                    {
                        iditem = caster.RightHand;
                    }
                    else if (caster.LeftHand != null)
                    {
                        iditem = caster.LeftHand;
                    }
                    else
                    {
                        caster.WriteToDisplay("You must hold the item to identify in your hands.");
                        return(false);
                    }
                }

                var itmeffect  = "";
                var itmspell   = "";
                var itmspecial = "";
                var itmalign   = "";
                var itmattuned = "";

                ReferenceSpell.SendGenericCastMessage(caster, caster, true);

                #region Spell and Charges
                if (iditem.spell > 0)
                {
                    var spell = GameSpell.GetSpell(iditem.spell);

                    itmspell = " It contains the spell of " + spell.Name;

                    if (iditem.charges == 0)
                    {
                        if (iditem.baseType == Globals.eItemBaseType.Scroll)
                        {
                            if (caster.IsSpellWarmingProfession && spell.IsClassSpell(caster.BaseProfession))
                            {
                                itmspell += " that you may scribe into your spellbook.";
                            }
                            else
                            {
                                itmspell += " that can be scribed into a spellbook.";
                            }
                        }
                        else
                        {
                            itmspell += ", but there are no charges remaining.";
                        }
                    }
                    else if (iditem.charges > 100)
                    {
                        itmspell += " with unlimited charges.";
                    }
                    else if (iditem.charges > 1)
                    {
                        itmspell += " with " + iditem.charges + " charges remaining.";
                    }
                    else if (iditem.charges == 1)
                    {
                        itmspell += " with 1 charge remaining.";
                    }
                    else // -1 or less
                    {
                        itmspell += " with unlimited charges.";
                    }
                }
                #endregion

                var sb = new System.Text.StringBuilder(100);

                // Figurine info.
                if (iditem.baseType == Globals.eItemBaseType.Figurine || iditem.figExp > 0)
                {
                    sb.AppendFormat(" The {0}'s avatar has " + iditem.figExp + " experience.", iditem.name);
                }

                // Combat adds.
                if (iditem.combatAdds > 0)
                {
                    sb.AppendFormat(" The combat adds are {0}.", iditem.combatAdds);
                }

                // Silver or mithril silver.
                if (iditem.silver)
                {
                    string silver = "silver";

                    if (iditem.longDesc.ToLower().Contains("mithril") || iditem.armorType == Globals.eArmorType.Mithril)
                    {
                        silver = "mithril silver";
                    }

                    sb.AppendFormat(" The {0} is " + silver + ".", iditem.name);
                }

                // Blue glow.
                if (iditem.blueglow)
                {
                    sb.AppendFormat(" The {0} is emitting a faint blue glow.", iditem.name);
                }

                itmspecial = sb.ToString();

                //item effects
                #region Enchantments
                if (iditem.effectType.Length > 0)
                {
                    string[] itmEffectType   = iditem.effectType.Split(" ".ToCharArray());
                    string[] itmEffectAmount = iditem.effectAmount.Split(" ".ToCharArray()); // GameSpell IDs for procs

                    #region Enchantment Effects
                    if (itmEffectType.Length == 1 && Effect.GetEffectName((Effect.EffectTypes)Convert.ToInt32(itmEffectType[0])) != "")
                    {
                        if (iditem.baseType == Globals.eItemBaseType.Bottle)
                        {
                            itmeffect = " Inside the bottle is a potion of " + Effect.GetEffectName((Effect.EffectTypes)Convert.ToInt32(itmEffectType[0])) + ".";
                        }
                        else
                        {
                            string effectName = Effect.GetEffectName((Effect.EffectTypes)Convert.ToInt32(itmEffectType[0]));

                            if (effectName.ToLower() != Effect.GetEffectName(Effect.EffectTypes.None).ToLower() && effectName.ToLower() != Effect.GetEffectName(Effect.EffectTypes.Weapon_Proc))
                            {
                                itmeffect = " The " + iditem.name + " contains the enchantment of " + Effect.GetEffectName((Effect.EffectTypes)Convert.ToInt32(itmEffectType[0])) + ".";
                            }
                        }
                    }
                    else
                    {
                        var itemEffectList = new ArrayList();

                        for (int a = 0; a < itmEffectType.Length; a++)
                        {
                            Effect.EffectTypes effectType = (Effect.EffectTypes)Convert.ToInt32(itmEffectType[a]);

                            if (effectType != Effect.EffectTypes.None &&
                                effectType != Effect.EffectTypes.Weapon_Proc)
                            {
                                itemEffectList.Add(Effect.GetEffectName(effectType));
                            }
                        }

                        if (itemEffectList.Count > 0)
                        {
                            if (itemEffectList.Count > 1)
                            {
                                itmeffect = " The " + iditem.name + " contains the enchantments of";
                                for (int a = 0; a < itemEffectList.Count; a++)
                                {
                                    if (a != itemEffectList.Count - 1)
                                    {
                                        itmeffect += " " + (string)itemEffectList[a] + ",";
                                    }
                                    else
                                    {
                                        itmeffect += " and " + (string)itemEffectList[a] + ".";
                                    }
                                }
                            }
                            else if (itemEffectList.Count == 1)
                            {
                                string effectName = Effect.GetEffectName((Effect.EffectTypes)Convert.ToInt32(itmEffectType[0]));

                                if (effectName.ToLower() != "none")
                                {
                                    if (iditem.baseType == Globals.eItemBaseType.Bottle)
                                    {
                                        itmeffect = " Inside the bottle is a potion of " + Effect.GetEffectName((Effect.EffectTypes)Convert.ToInt32(itmEffectType[0])) + ".";
                                    }
                                    else
                                    {
                                        itmeffect = " The " + iditem.name + " contains the enchantment of " + Effect.GetEffectName((Effect.EffectTypes)Convert.ToInt32(itmEffectType[0])) + ".";
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                }
                #endregion

                // Identify spell currently doesn't display weapon procs. 2/10/2017 Eb

                #region Alignment
                //item alignment
                if (iditem.alignment != Globals.eAlignment.None)
                {
                    string aligncolor = "";
                    switch (iditem.alignment)
                    {
                    case Globals.eAlignment.Lawful:
                        aligncolor = "white";
                        break;

                    case Globals.eAlignment.Neutral:
                        aligncolor = "green";
                        break;

                    case Globals.eAlignment.Chaotic:
                        aligncolor = "purple";
                        break;

                    case Globals.eAlignment.ChaoticEvil:
                    case Globals.eAlignment.Evil:
                        aligncolor = "red";
                        break;

                    case Globals.eAlignment.Amoral:
                        aligncolor = "yellow";
                        break;

                    default:
                        break;
                    }
                    itmalign = " The " + iditem.name + " briefly pulses with a " + aligncolor + " glow.";
                }
                #endregion

                #region Attuned
                //item attuned
                if (iditem.attunedID != 0)
                {
                    if (iditem.attunedID > 0)
                    {
                        if (iditem.attunedID == caster.UniqueID)
                        {
                            itmattuned = " The " + iditem.name + " is soulbound to you.";
                        }
                        else
                        {
                            itmattuned = " The " + iditem.name + " is soulbound to " + PC.GetName(iditem.attunedID) + ".";
                        }
                    }
                    else
                    {
                        itmattuned = " The " + iditem.name + " is soulbound to another being.";
                    }
                }
                #endregion

                //iditem.identified[iditem.identified.Length - 1] = caster.playerID;

                caster.WriteToDisplay("You are looking at " + iditem.longDesc + "." + itmeffect + itmspell + itmspecial + itmalign + itmattuned);

                #region Venom
                if (iditem.venom > 0)
                {
                    var desc = iditem.name;
                    if (iditem.baseType == Globals.eItemBaseType.Bow)
                    {
                        if (iditem.name.Contains("crossbow") || iditem.longDesc.Contains("crossbow"))
                        {
                            desc = "nocked bolt";
                        }
                        else
                        {
                            desc = "nocked arrow";
                        }
                    }

                    caster.WriteToDisplay("The " + desc + " drips with a caustic venom.");
                }
                #endregion

                return(true);
            }
            catch (Exception e)
            {
                Utils.LogException(e);
                return(false);
            }
        }