Esempio n. 1
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Quench OnSpellEffect");
        // duration is 1d4 hours if implementing 2nd part of quench
        spell.duration = 0;
        var target_item = spell.Targets[0];
        var damage_dice = Dice.D6;

        damage_dice = damage_dice.WithCount(Math.Min(spell.casterLevel, 15));
        target_item.ParticleSystem = AttachParticles("sp-Quench", target_item.Object);
        // only damages fire elementals (and flaming sphere Darmagon)
        if (Co8.is_spell_flag_set(target_item.Object, Co8SpellFlag.FlamingSphere))
        {
            target_item.Object.Destroy();
        }
        else
        {
            if ((target_item.Object.IsMonsterCategory(MonsterCategory.elemental)) && (target_item.Object.IsMonsterSubtype(MonsterSubtype.fire)))
            {
                // no save, full damage
                target_item.Object.DealSpellDamage(spell.caster, DamageType.Unspecified, damage_dice, D20AttackPower.UNSPECIFIED, D20ActionType.CAST_SPELL, spell.spellId);
                spell.RemoveTarget(target_item.Object);
            }
            else
            {
                // allowing targeting of creatures? 2nd part of quench
                target_item.Object.FloatMesFileLine("mes/spell.mes", 31013);
                AttachParticles("Fizzle", target_item.Object);
                spell.RemoveTarget(target_item.Object);
            }
        }

        spell.EndSpell();
    }
    public override void OnEndSpellCast(SpellPacketBody spell)
    {
        Logger.Info("Tensers Transformation OnEndSpellCast");
        Co8.destroy_spell_obj_with_flag(spell.caster, 6400, Co8SpellFlag.TensersTransformation);
        var item_wielded = spell.caster.ItemWornAt(EquipSlot.WeaponPrimary);

        if ((item_wielded != null))
        {
            if ((item_wielded.GetNameId() == spell.dc) && (Co8.is_spell_flag_set(item_wielded, Co8SpellFlag.TensersTransformation)))
            {
                var new_weapon = GameSystems.MapObject.CreateObject(spell.dc, spell.caster.GetLocation());
                item_wielded.SetInt(obj_f.weapon_type, new_weapon.GetInt(obj_f.weapon_type));
                Co8.unset_spell_flag(item_wielded, Co8SpellFlag.TensersTransformation);
                item_wielded.ClearItemFlag(ItemFlag.NO_DROP);
                new_weapon.Destroy();
            }
        }
        else
        {
            if (spell.dc != 0)
            {
                var weapon = Co8.find_spell_obj_with_flag(spell.caster, spell.dc, Co8SpellFlag.TensersTransformation);
                if (weapon != null) // this shouldn't ever happen but better check
                {
                    var new_weapon = GameSystems.MapObject.CreateObject(spell.dc, spell.caster.GetLocation());
                    weapon.SetInt(obj_f.weapon_type, new_weapon.GetInt(obj_f.weapon_type));
                    Co8.unset_spell_flag(weapon, Co8SpellFlag.TensersTransformation);
                    weapon.ClearItemFlag(ItemFlag.NO_DROP);
                    new_weapon.Destroy();
                }
            }
        }
    }
Esempio n. 3
0
    public static void reenableWeapons(GameObject critter)
    {
        for (var num = 4000; num < 5000; num++)
        {
            var weapon = critter.FindItemByProto(num);
            if ((weapon != null && Co8.is_spell_flag_set(weapon, Co8SpellFlag.HezrouStench)))
            {
                Logger.Info("Enabling weapon {0} for {1}", weapon, critter);
                weapon.SetInt(obj_f.weapon_damage_dice, weapon.GetInt(obj_f.weapon_pad_i_2));
                Co8.unset_spell_flag(weapon, Co8SpellFlag.HezrouStench);
                weapon.ClearItemFlag(ItemFlag.NO_DROP);
            }
        }

        return;
    }
Esempio n. 4
0
    public static GameObject getStenchObj(GameObject critter)
    {
        var it         = 0;
        var stench_obj = critter.FindItemByName(OBJ_SPELL_STENCH);

        while ((stench_obj != null && !Co8.is_spell_flag_set(stench_obj, Co8SpellFlag.HezrouStench) && it < 217))
        {
            stench_obj = critter.GetInventoryItem(it);
            it        += 1;
        }

        if ((it >= 217))
        {
            Logger.Info("Search for Stench Object a lot of times!");
        }

        return(stench_obj);
    }
Esempio n. 5
0
    public override void OnBeginRound(SpellPacketBody spell)
    {
        Logger.Info("Flaming Sphere OnBeginRound");
        var dam    = Dice.D4;
        var m_list = ObjList.ListCone(spell.Targets[0].Object, ObjectListFilter.OLC_CRITTERS, 5, -180, 360);

        foreach (var m in m_list)
        {
            if (m != spell.Targets[0].Object && m != spell.caster && !Co8.is_spell_flag_set(m, Co8SpellFlag.FlamingSphere))
            {
                if (!m.SavingThrow(spell.dc, SavingThrowType.Reflex, D20SavingThrowFlag.NONE, spell.Targets[0].Object))
                {
                    m.Damage(null, DamageType.Fire, dam, D20AttackPower.NORMAL);
                }
                else
                {
                    m.FloatMesFileLine("mes/spell.mes", 30001);
                }
            }
        }
    }
Esempio n. 6
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Destruction OnSpellEffect");
        var dam = Dice.Parse("10d6");

        spell.duration = 0;
        // changed_con = 0
        var target_item = spell.Targets[0];
        // determine focus
        var focus = 0;

        if ((spell.caster.type != ObjectType.pc) && (spell.caster.GetLeader() == null))
        {
            // for NPCs not in game party
            focus = 1;
        }
        else
        {
            if (spell.caster.GetMoney() >= 50000)
            {
                focus = 1;
            }
        }

        // check for focus
        if (focus == 1)
        {
            AttachParticles("sp-Disintegrate-Hit", target_item.Object);
            if ((target_item.Object.GetNameId() == 14629 || target_item.Object.GetNameId() == 14621 || target_item.Object.GetNameId() == 14604) && !Co8.is_spell_flag_set(target_item.Object, Co8SpellFlag.FlamingSphere))
            {
                SpawnParticles("sp-Stoneskin", target_item.Object.GetLocation());
                target_item.Object.Destroy();
            }
            else if (target_item.Object.IsMonsterCategory(MonsterCategory.construct) || target_item.Object.IsMonsterCategory(MonsterCategory.undead))
            {
                AttachParticles("Fizzle", target_item.Object);
            }
            // if target_item.obj.stat_base_get(stat_constitution) < 0:
            // target_item.obj.stat_base_set(stat_constitution, 10)
            // changed_con = 1
            else if ((target_item.Object.type == ObjectType.pc) || (target_item.Object.type == ObjectType.npc))
            {
                if (target_item.Object.SavingThrowSpell(spell.dc, SavingThrowType.Fortitude, D20SavingThrowFlag.NONE, spell.caster, spell.spellId))
                {
                    target_item.Object.FloatMesFileLine("mes/spell.mes", 30001);
                    target_item.Object.DealSpellDamage(spell.caster, DamageType.Force, dam, D20AttackPower.UNSPECIFIED, D20ActionType.CAST_SPELL, spell.spellId);
                }
                else
                {
                    // So you'll get awarded XP for the kill
                    if (!((SelectedPartyLeader.GetPartyMembers()).Contains(target_item.Object)))
                    {
                        target_item.Object.Damage(SelectedPartyLeader, DamageType.Unspecified, Dice.Parse("1d1"));
                    }

                    target_item.Object.KillWithDeathEffect();
                    target_item.Object.AddCondition("sp-Animate Dead", spell.spellId, spell.duration, 3);
                    AttachParticles("sp-Stoneskin", target_item.Object);
                }
            }
            else
            {
                target_item.Object.FloatMesFileLine("mes/spell.mes", 30003);
                AttachParticles("Fizzle", target_item.Object);
            }
        }
        else
        {
            // no focus
            spell.caster.FloatMesFileLine("mes/spell.mes", 16009);
        }

        // if changed_con == 1:
        // target_item.obj.stat_base_set(stat_constitution, -1)
        spell.RemoveTarget(target_item.Object);
        spell.EndSpell();
    }
Esempio n. 7
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Warp Wood OnSpellEffect");
        var number_items = spell.casterLevel;
        var remove_list  = new List <GameObject>();
        var itemref      = 0;

        foreach (var target_item in spell.Targets)
        {
            if (number_items > 0)
            {
                // First, check creatures for held wooden items
                if ((target_item.Object.type == ObjectType.pc) || (target_item.Object.type == ObjectType.npc))
                {
                    // Check for a wooden missile weapon and destroy that
                    var item_affected = target_item.Object.ItemWornAt(EquipSlot.WeaponPrimary);
                    if ((item_affected.GetInt(obj_f.weapon_ammo_type) < 2) && (number_items >= Warp_Size_by_Item_Size(item_affected)))
                    {
                        var FLAGS = item_affected.GetItemFlags();
                        // Only works on nonmagic wood, and the item gets its owner's Will save
                        if ((item_affected.GetMaterial() == Material.wood) && (FLAGS & ItemFlag.IS_MAGICAL) == 0 && !(target_item.Object.SavingThrowSpell(spell.dc, SavingThrowType.Will, D20SavingThrowFlag.NONE, spell.caster, spell.spellId)))
                        {
                            target_item.Object.FloatMesFileLine("mes/combat.mes", 22);
                            number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                            AttachParticles("Blight", target_item.Object);
                            item_affected.Destroy();
                        }
                    }

                    // Check for a wooden melee weapon and warp that (-4 to attack rolls)
                    item_affected = target_item.Object.ItemWornAt(EquipSlot.WeaponPrimary);
                    if ((item_affected != null) && (number_items >= Warp_Size_by_Item_Size(item_affected)))
                    {
                        var FLAGS = item_affected.GetItemFlags();
                        // Only works on nonmagic wood, and the item gets its owner's Will save
                        if ((item_affected.GetMaterial() == Material.wood) && (FLAGS & ItemFlag.IS_MAGICAL) == 0 && !(target_item.Object.SavingThrowSpell(spell.dc, SavingThrowType.Will, D20SavingThrowFlag.NONE, spell.caster, spell.spellId)))
                        {
                            if (!(Co8.is_spell_flag_set(item_affected, Co8SpellFlag.Summoned)))
                            {
                                item_affected.AddConditionToItem("To Hit Bonus", -4);
                                Co8.set_spell_flag(item_affected, Co8SpellFlag.Summoned);
                                AttachParticles("Blight", target_item.Object);
                                target_item.Object.FloatMesFileLine("mes/combat.mes", 8);
                            }

                            number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                        }
                    }
                }
                // Done with creature checks
                // Check for unattended weapons targeted and warp, unwarp, or destroy them
                else if ((target_item.Object.type == ObjectType.weapon))
                {
                    var item_affected = target_item.Object;
                    var FLAGS         = item_affected.GetItemFlags();
                    // Only works on nonmagical wooden items
                    if ((item_affected.GetMaterial() == Material.wood) && (FLAGS & ItemFlag.IS_MAGICAL) == 0 && (number_items >= Warp_Size_by_Item_Size(item_affected)))
                    {
                        // Missile weapons are destroyed
                        if ((item_affected.GetInt(obj_f.weapon_ammo_type) < 2))
                        {
                            target_item.Object.FloatMesFileLine("mes/combat.mes", 22);
                            AttachParticles("Blight", target_item.Object);
                            number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                            item_affected.Destroy();
                        }
                        // Melee weapons that are warped are replaced with an unwarped version
                        else if ((Co8.is_spell_flag_set(item_affected, Co8SpellFlag.Summoned)))
                        {
                            var proto  = item_affected.GetNameId();
                            var holder = GameSystems.MapObject.CreateObject(proto, item_affected.GetLocation());
                            number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                            item_affected.Destroy();
                        }
                        else
                        {
                            // Melee weapons that are unwarped are warped (-4 to attack rolls)
                            item_affected.AddConditionToItem("To Hit Bonus", -4);
                            Co8.set_spell_flag(item_affected, Co8SpellFlag.Summoned);
                            AttachParticles("Blight", target_item.Object);
                            number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                            target_item.Object.FloatMesFileLine("mes/combat.mes", 8);
                        }
                    }

                    number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                }
                // Check for locked wooden chests, and unlock them
                else if ((target_item.Object.type == ObjectType.container))
                {
                    var item_affected = target_item.Object;
                    if ((target_item.Object.GetMaterial() == Material.wood))
                    {
                        if (((target_item.Object.GetContainerFlags() & ContainerFlag.LOCKED)) != 0 && (number_items >= Warp_Size_by_Item_Size(item_affected)))
                        {
                            target_item.Object.ClearContainerFlag(ContainerFlag.LOCKED);
                            target_item.Object.FloatMesFileLine("mes/spell.mes", 30004);
                            number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                        }
                    }
                    else
                    {
                        AttachParticles("Fizzle", target_item.Object);
                        target_item.Object.FloatMesFileLine("mes/spell.mes", 30003);
                    }
                }
                // Check for locked wooden doors, and unlock and open them
                else if ((target_item.Object.type == ObjectType.portal))
                {
                    var item_affected = target_item.Object;
                    if ((target_item.Object.GetMaterial() == Material.wood))
                    {
                        if (((target_item.Object.GetPortalFlags() & PortalFlag.LOCKED)) != 0 && (number_items >= Warp_Size_by_Item_Size(item_affected)))
                        {
                            target_item.Object.ClearPortalFlag(PortalFlag.LOCKED);
                            target_item.Object.FloatMesFileLine("mes/spell.mes", 30004);
                            if ((target_item.Object.GetPortalFlags() & PortalFlag.OPEN) == 0)
                            {
                                target_item.Object.TogglePortalOpen();
                                target_item.Object.FloatMesFileLine("mes/spell.mes", 30013);
                            }

                            number_items = number_items - Warp_Size_by_Item_Size(item_affected);
                        }
                    }
                    else
                    {
                        AttachParticles("Fizzle", target_item.Object);
                        target_item.Object.FloatMesFileLine("mes/spell.mes", 30003);
                    }
                }
                else
                {
                    AttachParticles("Fizzle", target_item.Object);
                    target_item.Object.FloatMesFileLine("mes/spell.mes", 30003);
                }
            }

            remove_list.Add(target_item.Object);
        }

        spell.RemoveTargets(remove_list);
        spell.EndSpell();
    }
Esempio n. 8
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Flaming Sphere OnSpellEffect");
        var dam = Dice.D4;

        spell.duration = 1 * spell.casterLevel;
        var weapon_proto     = 4143;
        var weapon_portrait  = 4320;
        var monster_proto_id = 14629;
        var npc = spell.caster;

        if (npc.GetNameId() == 8036 || npc.GetNameId() == 14425) // faction 7
        {
            monster_proto_id = 14621;
        }

        if (npc.GetNameId() == 14425 && npc.GetMap() == 5065) // faction 15
        {
            monster_proto_id = 14604;
        }

        // create monster
        spell.SummonMonsters(true, monster_proto_id);
        GameObject monster_obj = null;
        var        m_list      = ObjList.ListCone(spell.caster, ObjectListFilter.OLC_CRITTERS, 200, -180, 360);

        foreach (var m in m_list)
        {
            if (m.GetNameId() == monster_proto_id && m.ItemWornAt(EquipSlot.WeaponPrimary) == null && m.GetLeader() == spell.caster && Co8.are_spell_flags_null(m))
            {
                monster_obj = m;
                Co8.set_spell_flag(m, Co8SpellFlag.FlamingSphere);
                m.SetInt(obj_f.critter_description_unknown, 20356);
            }
        }

        m_list = ObjList.ListCone(monster_obj, ObjectListFilter.OLC_CRITTERS, 5, -180, 360);
        foreach (var m in m_list)
        {
            if (m != spell.caster && !Co8.is_spell_flag_set(m, Co8SpellFlag.FlamingSphere))
            {
                if (!m.SavingThrow(spell.dc, SavingThrowType.Reflex, D20SavingThrowFlag.NONE, monster_obj))
                {
                    m.Damage(monster_obj, DamageType.Fire, dam, D20AttackPower.NORMAL);
                }
                else
                {
                    m.FloatMesFileLine("mes/spell.mes", 30001);
                }
            }
        }

        monster_obj.AddCondition("Amulet of Mighty Fists", -20, -10);
        monster_obj.AddCondition("Monster Plant", 0, 0);
        monster_obj.SetInt(obj_f.critter_portrait, weapon_portrait);
        var hit_points = 10 * spell.casterLevel;

        hit_points = 25 + hit_points;
        monster_obj.SetBaseStat(Stat.hp_max, hit_points);
        monster_obj.ClearObjectFlag(ObjectFlag.CLICK_THROUGH);
        // monster_obj.npc_flag_set(ONF_NO_ATTACK)
        // add monster to follower list for spell_caster
        if (!spell.caster.HasMaxFollowers())
        {
            spell.caster.RemoveAIFollower(monster_obj);
            spell.caster.AddFollower(monster_obj);
            monster_obj.AddCondition("sp-Endurance", spell.spellId, spell.duration, 0);
        }

        // add monster to target list
        spell.ClearTargets();
        spell.AddTarget(
            monster_obj,
            AttachParticles("sp-Fireball-proj", monster_obj)
            );
        // add spell indicator to spell caster
        spell.caster.AddCondition("sp-Endurance", spell.spellId, spell.duration, 0);
        Logger.Info("{0}", spell.Targets[0].Object);
        spell.EndSpell();
    }
    public override void OnEndProjectile(SpellPacketBody spell, GameObject projectile, int index_of_target)
    {
        Logger.Info("Disintegrate OnEndProjectile");
        var damage_dice = Dice.D6;

        damage_dice    = damage_dice.WithCount(Math.Min(40, spell.casterLevel * 2));
        spell.duration = 0;
        var is_immune_to_crit = 0;
        var changed_con       = 0;
        var target_item       = spell.Targets[0];

        EndProjectileParticles(projectile);

        var return_val = spell.caster.PerformTouchAttack(target_item.Object);

        if ((return_val & D20CAF.HIT) != D20CAF.NONE)
        {
            AttachParticles("sp-Disintegrate-Hit", target_item.Object);
            if ((target_item.Object.GetNameId() == 14629 || target_item.Object.GetNameId() == 14621 || target_item.Object.GetNameId() == 14604) && !Co8.is_spell_flag_set(target_item.Object, Co8SpellFlag.FlamingSphere))
            {
                // check for Otiluke's Resilient Sphere
                if (target_item.Object.HasCondition(SpellEffects.SpellOtilukesResilientSphere))
                {
                    target_item.Object.AddCondition("sp-Break Enchantment", spell.spellId, spell.duration, 0);
                    SpawnParticles("sp-Otilukes Resilient Sphere-END", target_item.Object.GetLocation());
                }
                else
                {
                    SpawnParticles("sp-Stoneskin", target_item.Object.GetLocation());
                    target_item.Object.Destroy();
                }
            }
            else
            {
                // hit
                if (target_item.Object.IsMonsterCategory(MonsterCategory.construct) || target_item.Object.IsMonsterCategory(MonsterCategory.undead))
                {
                    if (target_item.Object.GetBaseStat(Stat.constitution) < 0)
                    {
                        target_item.Object.SetBaseStat(Stat.constitution, 10);
                        changed_con = 1;
                    }

                    is_immune_to_crit = 1;
                }
                else if (target_item.Object.IsMonsterCategory(MonsterCategory.plant) || target_item.Object.IsMonsterCategory(MonsterCategory.ooze) || target_item.Object.IsMonsterCategory(MonsterCategory.elemental))
                {
                    is_immune_to_crit = 1;
                }

                // elif return_val == 2:
                // damage_dice.num = damage_dice.num * 2 # handled internally now
                if (target_item.Object.SavingThrowSpell(spell.dc, SavingThrowType.Fortitude, D20SavingThrowFlag.NONE, spell.caster, spell.spellId))
                {
                    damage_dice = damage_dice.WithCount(5);
                    // if return_val == 2 and is_immune_to_crit == 0:
                    // damage_dice.num = 10
                    target_item.Object.FloatMesFileLine("mes/spell.mes", 30001);
                }

                target_item.Object.DealSpellDamage(spell.caster, DamageType.Force, damage_dice, D20AttackPower.UNSPECIFIED, 100, D20ActionType.CAST_SPELL, spell.spellId, return_val, index_of_target);
                if (target_item.Object.GetStat(Stat.hp_current) < 1)
                {
                    target_item.Object.KillWithDeathEffect();
                    target_item.Object.AddCondition("sp-Animate Dead", spell.spellId, spell.duration, 3);
                    AttachParticles("sp-Stoneskin", target_item.Object);
                }

                // check for Otiluke's Resilient Sphere
                if (target_item.Object.HasCondition(SpellEffects.SpellOtilukesResilientSphere))
                {
                    target_item.Object.AddCondition("sp-Break Enchantment", spell.spellId, spell.duration, 0);
                    AttachParticles("sp-Otilukes Resilient Sphere-END", target_item.Object);
                }
            }
        }
        else
        {
            // missed
            target_item.Object.FloatMesFileLine("mes/spell.mes", 30007);
            AttachParticles("Fizzle", target_item.Object);
        }

        if (changed_con == 1)
        {
            target_item.Object.SetBaseStat(Stat.constitution, -1);
        }


        spell.RemoveTarget(target_item.Object);
        spell.EndSpell();
    }