public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Summon Fire Elemental OnSpellEffect");
        spell.duration = 10;
        // get the proto_id for this monster
        var monster_proto_id = 14298;

        // create monster
        spell.SummonMonsters(true, monster_proto_id);
        // Gets handle on monster, and sets a flag so that it won't be mistaken for a new summoned monster
        var monster_obj = Co8.GetCritterHandle(spell, monster_proto_id);

        AttachParticles("Orb-Summon-Fire-Elemental", monster_obj);
        // add monster to follower list for spell_caster
        spell.caster.AddAIFollower(monster_obj);
        // add monster_obj to d20initiative, and set initiative to spell_caster's
        var caster_init_value = spell.caster.GetInitiative();

        monster_obj.AddToInitiative();
        monster_obj.SetInitiative(caster_init_value);
        UiSystems.Combat.Initiative.UpdateIfNeeded();
        // monster should disappear when duration is over, apply "TIMED_DISAPPEAR" condition
        monster_obj.AddCondition("sp-Summoned", spell.spellId, spell.duration, 0);
        // add monster to target list
        spell.ClearTargets();
        spell.AddTarget(monster_obj);
        spell.EndSpell();
    }
Beispiel #2
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Holy Sword OnSpellEffect");
        // game.particles("sp-Raise Dead", spell.caster)
        spell.duration = spell.casterLevel;
        var y = spell.caster.FindItemByProto(4999);

        if (spell.spellKnownSlotLevel > 3 && y == null)
        {
            AttachParticles("sp-Shillelagh", spell.caster);
            Utilities.create_item_in_inventory(4999, spell.caster);
            spell.ClearTargets();
            spell.AddTarget(spell.caster);
            spell.caster.AddCondition("sp-Magic Circle Outward", spell.spellId, spell.duration, 2);
        }
        else
        {
            if (spell.spellKnownSlotLevel < 4)
            {
                spell.caster.FloatMesFileLine("mes/spell.mes", 16008);
            }

            if (y != null)
            {
                spell.caster.FloatMesFileLine("mes/spell.mes", 16007);
            }

            spell.EndSpell();
        }
    }
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Mordenkainen's Faithful Hound OnSpellEffect");
        spell.duration = 600 * spell.casterLevel;
        // get the proto_id for this monster (from radial menu)
        var monster_proto_id = 14278;

        // create monster
        // game.particles( 'sp-Mordenkainens Faithful Hound', spell.target_loc )
        spell.SummonMonsters(true, monster_proto_id);
        var monster_obj = Co8.GetCritterHandle(spell, 14278);
        var hit_points  = 6 * spell.casterLevel;

        hit_points = 25 + hit_points;
        monster_obj.SetBaseStat(Stat.hp_max, hit_points);
        // add monster to follower list for spell_caster
        spell.caster.AddAIFollower(monster_obj);
        // add monster_obj to d20initiative, and set initiative to spell_caster's
        var caster_init_value = spell.caster.GetInitiative();

        monster_obj.AddToInitiative();
        monster_obj.SetInitiative(caster_init_value);
        UiSystems.Combat.Initiative.UpdateIfNeeded();
        // add monster to target list
        spell.ClearTargets();
        spell.AddTarget(monster_obj, AttachParticles("sp-Mordenkainens Faithful Hound", spell.Targets[0].Object));
        spell.Targets[0].Object = monster_obj;
        // add condition
        monster_obj.AddCondition("sp-Mordenkainens Faithful Hound", spell.spellId, spell.duration, 0);
        spell.EndSpell();
    }
    public static void SummonMonsters(this SpellPacketBody activeSpell, bool aiFollower, int protoId = 17000)
    {
        var summon = GameSystems.MapObject.CreateObject(protoId, activeSpell.aoeCenter);

        GameSystems.AI.ForceSpreadOut(summon);

        if (!GameSystems.Critter.AddFollower(summon, activeSpell.caster, true, aiFollower))
        {
            Logger.Error("Unable to add new critter as a follower");
            GameSystems.MapObject.RemoveMapObj(summon);
            return;
        }

        GameSystems.D20.Initiative.AddToInitiative(summon);
        var casterIni = GameSystems.D20.Initiative.GetInitiative(activeSpell.caster);

        GameSystems.D20.Initiative.SetInitiative(summon, casterIni);

        UiSystems.Combat.Initiative.Update();
        UiSystems.Party.Update();

        summon.AddCondition(SpellEffects.SpellSummoned, activeSpell.spellId, activeSpell.duration, 0);
        summon.AddCondition(StatusEffects.TimedDisappear, activeSpell.spellId, activeSpell.duration, 0);

        // Add to the target list
        activeSpell.AddTarget(summon);

        // Make NPC summoned monsters attack the party
        if (activeSpell.caster.IsNPC() && !GameSystems.Party.IsInParty(activeSpell.caster))
        {
            // add the summoner's faction
            var factionArr  = activeSpell.caster.GetInt32Array(obj_f.npc_faction);
            int numFactions = factionArr.Count;

            for (var i = 0; i < numFactions; i++)
            {
                var newFac = factionArr[i];
                if (newFac == 0)
                {
                    continue;
                }
                if (!GameSystems.Critter.HasFaction(summon, newFac))
                {
                    GameSystems.Critter.AddFaction(summon, newFac);
                }
            }

            foreach (var partyMember in GameSystems.Party.PartyMembers)
            {
                GameSystems.AI.ProvokeHostility(partyMember, summon, 1, 2);
            }
        }

        GameSystems.Anim.Interrupt(summon, AnimGoalPriority.AGP_HIGHEST);
    }
Beispiel #5
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Analyze Dweomer OnSpellEffect");
        var remove_list = new List <GameObject>();

        spell.duration = spell.casterLevel * 10;
        if (spell.Targets.Length == 1 && spell.Targets[0].Object == spell.caster)
        {
        }
        else
        {
            if (spell.caster.GetMoney() >= 150000)
            {
                foreach (var t in spell.Targets)
                {
                    AttachParticles("sp-Identify", t.Object);
                    t.Object.IdentifyAll();
                }
            }
            else
            {
                spell.caster.FloatMesFileLine("mes/spell.mes", 16009);
            }
        }

        foreach (var target_item in spell.Targets)
        {
            remove_list.Add(target_item.Object);
        }

        spell.RemoveTargets(remove_list);
        if (Co8.find_spell_obj_with_flag(spell.caster, 6400, Co8SpellFlag.AnalyzeDweomer) == null)
        {
            var spell_obj = GameSystems.MapObject.CreateObject(6400, spell.caster.GetLocation());
            Co8.set_spell_flag(spell_obj, Co8SpellFlag.AnalyzeDweomer);
            spell_obj.AddConditionToItem("Skill Circumstance Bonus", (int)SkillId.spellcraft, 20);
            spell.caster.GetItem(spell_obj);
            spell.ClearTargets();
            spell.AddTarget(spell.caster);
            spell.caster.AddCondition("sp-Endurance", spell.spellId, spell.duration, 0);
        }
        else
        {
            spell.caster.FloatMesFileLine("mes/spell.mes", 16007);
            spell.EndSpell();
        }
    }
Beispiel #6
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Acid Fog OnSpellEffect");
        spell.duration = 10 * spell.casterLevel;
        // spawn one spell_object object
        var spell_obj = GameSystems.MapObject.CreateObject(OBJECT_SPELL_GENERIC, spell.aoeCenter);
        // add to d20initiative
        var caster_init_value = spell.caster.GetInitiative();

        spell_obj.InitD20Status();
        spell_obj.SetInitiative(caster_init_value);
        // put sp-Solid Fog condition on obj
        var spell_obj_partsys_id = AttachParticles("sp-Solid Fog", spell_obj);

        spell_obj.AddCondition("sp-Solid Fog", spell.spellId, spell.duration, 0, spell_obj_partsys_id);
        // spell_obj.condition_add_arg_x( 3, spell_obj_partsys_id )
        // objectevent_id = spell_obj.condition_get_arg_x( 2 )
        // add monster to target list
        spell.ClearTargets();
        spell.AddTarget(spell_obj);
    }
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Antidote OnSpellEffect");
        spell.duration = 600;
        if (Co8.find_spell_obj_with_flag(spell.caster, 12706, Co8SpellFlag.AnalyzeDweomer) == null)
        {
            var spell_obj = GameSystems.MapObject.CreateObject(12706, spell.caster.GetLocation());
            Co8.set_spell_flag(spell_obj, Co8SpellFlag.AnalyzeDweomer);
            spell_obj.AddConditionToItem("Luck Poison Save Bonus", 5, 0);
            spell.caster.GetItem(spell_obj);
            spell.ClearTargets();
            spell.AddTarget(spell.caster);
            spell.caster.AddCondition("sp-Endurance", spell.spellId, spell.duration, 0);
        }
        else
        {
            spell.caster.FloatMesFileLine("mes/spell.mes", 16007);
        }

        spell.EndSpell();
    }
Beispiel #8
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Summon Earth Elemental OnSpellEffect");
        spell.duration = 10;

        var monster_proto_id = 14296;

        var monster_obj = GameSystems.MapObject.CreateObject(monster_proto_id, spell.aoeCenter);

        AttachParticles("Orb-Summon-Earth-Elemental", monster_obj);
        spell.caster.AddAIFollower(monster_obj);
        var caster_init_value = spell.caster.GetInitiative();

        monster_obj.AddToInitiative();
        monster_obj.SetInitiative(caster_init_value);
        UiSystems.Combat.Initiative.UpdateIfNeeded();
        monster_obj.AddCondition("sp-Summoned", spell.spellId, spell.duration, 0);
        spell.ClearTargets();
        spell.AddTarget(monster_obj);
        spell.EndSpell();
    }
Beispiel #9
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Mordenkainen's Faithful Hound OnSpellEffect");
        spell.duration = 600 * spell.casterLevel;

        var monster_proto_id = 14278;

        var monster_obj = GameSystems.MapObject.CreateObject(monster_proto_id, spell.aoeCenter);

        spell.caster.AddAIFollower(monster_obj);
        var caster_init_value = spell.caster.GetInitiative();

        monster_obj.AddToInitiative();
        monster_obj.SetInitiative(caster_init_value);
        UiSystems.Combat.Initiative.UpdateIfNeeded();
        spell.ClearTargets();

        monster_obj.AddCondition("sp-Mordenkainens Faithful Hound", spell.spellId, spell.duration, 0);
        var particles = AttachParticles("sp-Mordenkainens Faithful Hound", monster_obj);

        spell.AddTarget(monster_obj, particles);

        spell.EndSpell();
    }
Beispiel #10
0
    // game.particles( "sp-conjuration-conjure", spell.caster )

    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Summon Familiar OnSpellEffect");
        spell.duration = 2147483647;
        var master = spell.caster;
        // get familiar inventory object handle
        var inv_proto = FindFamiliarProto(spell.caster, false);
        var familiar  = spell.caster.FindItemByProto(inv_proto);

        if ((get_ID(familiar) != 0))
        {
            return;
        }

        // get the proto_id for this familiar
        var familiar_proto_id = FindFamiliarProto(spell.caster, true);

        if ((familiar_proto_id == 0)) // not a recognized familiar type
        {
            return;
        }

        // creates random ID number
        var ID_number = RandomRange(1, 2147483647);

        ID_number = ID_number ^ RandomRange(1,
                                            2147483647); // xor with next "random" number in line, should be more random
        // create familiar
        spell.SummonMonsters(true, familiar_proto_id);
        // get familiar's handle
        var familiar_obj = Co8.GetCritterHandle(spell, familiar_proto_id);

        if ((familiar_obj == null)) // no new familiar present
        {
            return;
        }

        // summoning effect
        // game.particles( 'Orb-Summon-Air-Elemental', familiar_obj )
        // assigns familiar ownership
        set_ID(familiar_obj, ID_number);
        set_ID(familiar, ID_number);
        // game.particles( "sp-summon monster II", game.party[0] )
        // sets familiar's stat's and bonuses depending on it's masters level
        var master_level = GetLevel(spell.caster);
        var f_level      = ((master_level + 1) / 2);
        var f_hp         = ((spell.caster.GetStat(Stat.hp_max)) / 2); // familiar's hp = i/2 masters hp
        var base_hp      = familiar_obj.GetStat(Stat.hp_max);         // familiar's base hp from proto
        var prev_max_hp  =
            familiar.GetInt(obj_f
                            .item_pad_i_1); // familiar's max hp from last time summoned ( 0 if never summoned before)
        var prev_curr_hp =
            familiar.GetInt(obj_f
                            .item_pad_i_2); // familiar's current xp from last time stowed ( 0 if never summoed before)
        int new_hp;

        if ((base_hp <= f_hp)) // if 1/2 master's hp is greater than base hp from proto, will use 1/2 masters hp
        {
            new_hp = familiar_obj.SetBaseStat(Stat.hp_max, f_hp);
        }

        var curr_max_hp = familiar_obj.GetStat(Stat.hp_max); // familiar's max hp from current summons
        var hp_diff     =
            (curr_max_hp -
             prev_max_hp);      // difference between max hp from last time summoned and max hp now ( 0 if master has not gained a level since)

        if ((prev_max_hp != 0)) // has been summoned before
        {
            int hp_now;
            if ((hp_diff >= 1)) // adds gained hp if master has gained hp since last time summoned
            {
                hp_now = prev_curr_hp + hp_diff;
            }
            else
            {
                hp_now = prev_curr_hp;
            }

            var dam = Dice.Parse("1d1");
            dam = dam.WithCount(curr_max_hp - hp_now);
            if ((dam.Count >= 1))
            {
                familiar_obj.Damage(null, DamageType.Force, dam, D20AttackPower.NORMAL);
            }
        }

        // This next bit gives the familiar it's masters BAB.  The familiar should have a BAB (without the masters BAB) of zero, but since
        // the game engine doesn't allow for Weapon Finesse with natural attacks( which would let the familiar use their dexterity modifier
        // instead of the strength modifier), I fiddled with the  "to hit" in the protos to counteract the negative attack modifier do to
        // low strength and add the dexterity modifier. - Ceruleran the Blue ##
        var f_to_hit   = spell.caster.GetBaseStat(Stat.attack_bonus);
        var new_to_hit = familiar_obj.AddCondition("To Hit Bonus", f_to_hit, 0);
        var new_int    = familiar_obj.SetBaseStat(Stat.intelligence, (5 + f_level)); // familiar INT bonus

        familiar_obj.SetInt(obj_f.npc_ac_bonus, (f_level));                          // Natrual Armor bonus
        if ((master_level >= 11))
        {
            var spell_resistance =
                familiar_obj.AddCondition("Monster Spell Resistance", (5 + master_level), 0); // spell resistance
        }

        // familiar uses masters saving throw bonuses if they are higher than it's own.
        var fortitude_bonus = Fortitude(spell.caster);

        if ((fortitude_bonus >= 3))
        {
            familiar_obj.SetInt(obj_f.npc_save_fortitude_bonus, fortitude_bonus);
        }

        var reflex_bonus = Reflex(spell.caster);

        if ((reflex_bonus >= 3))
        {
            familiar_obj.SetInt(obj_f.npc_save_reflexes_bonus, reflex_bonus);
        }

        var will_bonus = Will(spell.caster);

        if ((will_bonus >= 1))
        {
            familiar_obj.SetInt(obj_f.npc_save_willpower_bonus, will_bonus);
        }

        // add familiar to follower list for spell_caster
        if (!(spell.caster.HasMaxFollowers()))
        {
            spell.caster.AddFollower(familiar_obj);
        }
        else
        {
            spell.caster.AddAIFollower(familiar_obj);
        }

        // add familiar_obj to d20initiative, and set initiative to spell_caster's
        var caster_init_value = spell.caster.GetInitiative();

        familiar_obj.AddToInitiative();
        familiar_obj.SetInitiative(caster_init_value);
        UiSystems.Combat.Initiative.UpdateIfNeeded();
        // familiar should disappear when duration is over, apply "TIMED_DISAPPEAR" condition
        // familiar_obj.condition_add_with_args( 'sp-Summoned', spell.id, spell.duration, 0 )
        // add familiar to target list
        spell.ClearTargets();
        spell.AddTarget(familiar_obj);
        spell.EndSpell();
    }
Beispiel #11
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 OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Spiritual Weapon OnSpellEffect");
        spell.duration = 1 * spell.casterLevel;
        // get the caster's deity
        var deity = spell.caster.GetDeity();
        // find the deity's preferred weapon, default is dagger
        var weapon_proto    = 4142;
        var weapon_portrait = 0;

        if ((deity == DeityId.BOCCOB))
        {
            // staff
            weapon_proto    = 4152;
            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.CORELLON_LARETHIAN))
        {
            // longsword
            weapon_proto    = 4146;
            weapon_portrait = 8010;
        }
        else if ((deity == DeityId.EHLONNA))
        {
            // staff
            weapon_proto    = 4152;
            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.ERYTHNUL))
        {
            // morningstar
            weapon_proto    = 4147;
            weapon_portrait = 8040;
        }
        else if ((deity == DeityId.FHARLANGHN))
        {
            // staff
            weapon_proto    = 4152;
            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.GARL_GLITTERGOLD))
        {
            // battleaxe blue
            weapon_proto    = 4140;
            weapon_portrait = 7950;
        }
        else if ((deity == DeityId.GRUUMSH))
        {
            // spear
            weapon_proto    = 4151;
            weapon_portrait = 8050;
        }
        else if ((deity == DeityId.HEIRONEOUS))
        {
            // longsword
            weapon_proto    = 4146;
            weapon_portrait = 8010;
        }
        else if ((deity == DeityId.HEXTOR))
        {
            // morningstar
            weapon_proto    = 4147;
            weapon_portrait = 8040;
        }
        else if ((deity == DeityId.KORD))
        {
            // greatsword
            weapon_proto    = 4143;
            weapon_portrait = 7980;
        }
        else if ((deity == DeityId.MORADIN))
        {
            // warhammer
            weapon_proto    = 4153;
            weapon_portrait = 8070;
        }
        else if ((deity == DeityId.NERULL))
        {
            // scythe
            weapon_proto    = 4149;
            weapon_portrait = 8030;
        }
        else if ((deity == DeityId.OBAD_HAI))
        {
            // staff
            weapon_proto    = 4152;
            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.OLIDAMMARA))
        {
            // rapier
            weapon_proto    = 4148;
            weapon_portrait = 8020;
        }
        else if ((deity == DeityId.PELOR))
        {
            // heavymace
            weapon_proto    = 4144;
            weapon_portrait = 7970;
        }
        else if ((deity == DeityId.ST_CUTHBERT))
        {
            // heavymace
            weapon_proto    = 4144;
            weapon_portrait = 7970;
        }
        else if ((deity == DeityId.VECNA))
        {
            // dagger
            weapon_proto    = 4142;
            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.WEE_JAS))
        {
            // dagger
            weapon_proto    = 4142;
            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.YONDALLA))
        {
            // shortsword
            weapon_proto    = 4150;
            weapon_portrait = 8000;
        }
        else if ((deity == DeityId.OLD_FAITH))
        {
            // heavymace
            weapon_proto    = 4144;
            weapon_portrait = 7970;
        }
        else if ((deity == DeityId.ZUGGTMOY))
        {
            // warhammer
            weapon_proto    = 4153;
            weapon_portrait = 8070;
        }
        else if ((deity == DeityId.IUZ))
        {
            // greatsword
            weapon_proto    = 4143;
            weapon_portrait = 7980;
        }
        else if ((deity == DeityId.LOLTH))
        {
            // dagger
            weapon_proto    = 4142;
            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.PROCAN))
        {
            // spear
            weapon_proto    = 4151;
            weapon_portrait = 8050;
        }
        else if ((deity == DeityId.NOREBO))
        {
            // dagger
            weapon_proto    = 4142;
            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.PYREMIUS))
        {
            // longsword
            weapon_proto    = 4146;
            weapon_portrait = 8010;
        }
        else if ((deity == DeityId.RALISHAZ))
        {
            // staff
            weapon_proto    = 4152;
            weapon_portrait = 8060;
        }
        else
        {
            // staff
            weapon_proto    = 4152;
            weapon_portrait = 8060;

            Logger.Info("SPIRITUAL WEAPON WARNING: deity={0} not found!", deity);
        }

        // figure out the proto_id from the deity
        // monster_proto_id = 14370
        var monster_proto_id = 14629;
        var npc = spell.caster;

        if (npc.GetNameId() == 8036 || npc.GetNameId() == 14425 || npc.GetNameId() == 14212 || npc.GetNameId() == 14211) // faction 7, 3,4,5,6 added -SA
        {
            monster_proto_id = 14621;
        }

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

        // create monster
        var monster_obj = GameSystems.MapObject.CreateObject(monster_proto_id, spell.aoeCenter);

        monster_obj.SetInt(obj_f.critter_portrait, weapon_portrait);
        var hit_points = 6 * spell.casterLevel;

        hit_points = 25 + hit_points;
        monster_obj.SetBaseStat(Stat.hp_max, hit_points);
        // equip the tempman with the appropriate weapon
        var weapon_obj = GameSystems.MapObject.CreateObject(weapon_proto, monster_obj.GetLocation());

        monster_obj.GetItem(weapon_obj);
        monster_obj.WieldBestInAllSlots();
        Logger.Info("SPIRITUAL WEAPON: equipped obj=( {0} ) with weapon=( {1} )!", monster_obj, weapon_obj);
        // add monster to follower list for spell_caster
        spell.caster.AddAIFollower(monster_obj);
        Logger.Info("added as follower");
        // add monster_obj to d20initiative, and set initiative to spell_caster's
        var caster_init_value = spell.caster.GetInitiative();

        Logger.Info("got the caster's initiative");
        monster_obj.AddToInitiative();
        Logger.Info("added to initiative");
        var initt = -999;

        if (!((PartyLeader.GetPartyMembers()).Contains(spell.caster)))
        {
            var highest = -999;
            foreach (var dude in GameSystems.Party.PartyMembers)
            {
                if (dude.GetInitiative() > highest && !Utilities.critter_is_unconscious(dude))
                {
                    highest = dude.GetInitiative();
                }

                if (dude.GetInitiative() > initt && dude.GetInitiative() < caster_init_value && !Utilities.critter_is_unconscious(dude))
                {
                    initt = Math.Max(dude.GetInitiative() - 1, 1);
                }
            }

            if (initt == -999)
            {
                initt = Math.Max(highest, 1);
            }
        }
        else
        {
            initt = caster_init_value;
        }

        monster_obj.SetInitiative(initt); // changed by S.A. - in case you have the same faction as the summoned weapon, it needs to see you fighting other members of its faction otherwise it won't act
        // monster_obj.set_initiative( caster_init_value ) # removed by S.A. - in case you have the same faction as the summoned weapon, it needs to see you fighting other members of its faction otherwise it won't act and lose a turn
        UiSystems.Combat.Initiative.UpdateIfNeeded();
        Logger.Info("update cmbat ui");
        // monster should disappear when duration is over, apply "TIMED_DISAPPEAR" condition
        monster_obj.AddCondition("sp-Summoned", spell.spellId, spell.duration, 0);
        monster_obj.AddCondition("sp-Spiritual Weapon", spell.spellId, spell.duration, weapon_proto);
        Logger.Info("condition have been added to Spiritual Weapon");
        // add monster to target list
        spell.ClearTargets();
        spell.AddTarget(monster_obj, AttachParticles("sp-spell resistance", monster_obj));
        Logger.Info("particles");
        spell.EndSpell();
        Logger.Info("spell ended, end of OnSpellEffect script");
    }
Beispiel #13
0
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Spiritual Weapon OnSpellEffect");
        spell.duration = 1 * spell.casterLevel;

        var deity = spell.caster.GetDeity();

        var weapon_proto = 4142;

        var weapon_portrait = 0;


        if ((deity == DeityId.BOCCOB))
        {
            weapon_proto = 4152;

            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.CORELLON_LARETHIAN))
        {
            weapon_proto = 4146;

            weapon_portrait = 8010;
        }
        else if ((deity == DeityId.EHLONNA))
        {
            weapon_proto = 4152;

            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.ERYTHNUL))
        {
            weapon_proto = 4147;

            weapon_portrait = 8040;
        }
        else if ((deity == DeityId.FHARLANGHN))
        {
            weapon_proto = 4152;

            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.GARL_GLITTERGOLD))
        {
            weapon_proto = 4140;

            weapon_portrait = 7950;
        }
        else if ((deity == DeityId.GRUUMSH))
        {
            weapon_proto = 4151;

            weapon_portrait = 8050;
        }
        else if ((deity == DeityId.HEIRONEOUS))
        {
            weapon_proto = 4146;

            weapon_portrait = 8010;
        }
        else if ((deity == DeityId.HEXTOR))
        {
            weapon_proto = 4147;

            weapon_portrait = 8040;
        }
        else if ((deity == DeityId.KORD))
        {
            weapon_proto = 4143;

            weapon_portrait = 7980;
        }
        else if ((deity == DeityId.MORADIN))
        {
            weapon_proto = 4153;

            weapon_portrait = 8070;
        }
        else if ((deity == DeityId.NERULL))
        {
            weapon_proto = 4149;

            weapon_portrait = 8030;
        }
        else if ((deity == DeityId.OBAD_HAI))
        {
            weapon_proto = 4152;

            weapon_portrait = 8060;
        }
        else if ((deity == DeityId.OLIDAMMARA))
        {
            weapon_proto = 4148;

            weapon_portrait = 8020;
        }
        else if ((deity == DeityId.PELOR))
        {
            weapon_proto = 4144;

            weapon_portrait = 7970;
        }
        else if ((deity == DeityId.ST_CUTHBERT))
        {
            weapon_proto = 4144;

            weapon_portrait = 7970;
        }
        else if ((deity == DeityId.VECNA))
        {
            weapon_proto = 4142;

            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.WEE_JAS))
        {
            weapon_proto = 4142;

            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.YONDALLA))
        {
            weapon_proto = 4150;

            weapon_portrait = 8000;
        }
        else if ((deity == DeityId.OLD_FAITH))
        {
            weapon_proto = 4144;

            weapon_portrait = 7970;
        }
        else if ((deity == DeityId.ZUGGTMOY))
        {
            weapon_proto = 4153;

            weapon_portrait = 8070;
        }
        else if ((deity == DeityId.IUZ))
        {
            weapon_proto = 4143;

            weapon_portrait = 7980;
        }
        else if ((deity == DeityId.LOLTH))
        {
            weapon_proto = 4142;

            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.PROCAN))
        {
            weapon_proto = 4151;

            weapon_portrait = 8050;
        }
        else if ((deity == DeityId.NOREBO))
        {
            weapon_proto = 4142;

            weapon_portrait = 7960;
        }
        else if ((deity == DeityId.PYREMIUS))
        {
            weapon_proto = 4146;

            weapon_portrait = 8010;
        }
        else if ((deity == DeityId.RALISHAZ))
        {
            weapon_proto = 4152;

            weapon_portrait = 8060;
        }
        else
        {
            weapon_proto = 4152;

            weapon_portrait = 8060;


            Logger.Info("SPIRITUAL WEAPON WARNING: deity={0} not found!", deity);
        }

        var monster_proto_id = 14370;

        var monster_obj = GameSystems.MapObject.CreateObject(monster_proto_id, spell.aoeCenter);

        monster_obj.SetInt(obj_f.critter_portrait, weapon_portrait);
        var weapon_obj = GameSystems.MapObject.CreateObject(weapon_proto, monster_obj.GetLocation());

        monster_obj.GetItem(weapon_obj);
        monster_obj.WieldBestInAllSlots();
        Logger.Info("SPIRITUAL WEAPON: equipped obj=( {0} ) with weapon=( {1} )!", monster_obj, weapon_obj);
        spell.caster.AddAIFollower(monster_obj);
        var caster_init_value = spell.caster.GetInitiative();

        monster_obj.AddToInitiative();
        monster_obj.SetInitiative(caster_init_value);
        UiSystems.Combat.Initiative.UpdateIfNeeded();
        monster_obj.AddCondition("sp-Summoned", spell.spellId, spell.duration, 0);
        monster_obj.AddCondition("sp-Spiritual Weapon", spell.spellId, spell.duration, weapon_proto);

        spell.ClearTargets();
        spell.AddTarget(monster_obj, AttachParticles("sp-spell resistance", monster_obj));

        spell.EndSpell();
    }
    public override void OnSpellEffect(SpellPacketBody spell)
    {
        Logger.Info("Mordenkainens Sword OnSpellEffect");
        spell.duration = 1 * spell.casterLevel;
        var hp_bonus         = 25;
        var weapon_proto     = 4143;
        var weapon_portrait  = 7980;
        var monster_proto_id = 14629;
        var npc = spell.caster;

        if (npc.GetNameId() == 8036 || npc.GetNameId() == 14425) // faction 7
        {
            monster_proto_id = 14621;
            spell.duration   = 10;
            hp_bonus         = 1000;
        }

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

        // 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() >= 25000)
            {
                focus = 1;
            }
        }

        // check for focus
        if (focus == 1)
        {
            // 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.MordenkainensSword);
                    m.SetInt(obj_f.critter_description_unknown, 20355);
                    monster_obj.ClearObjectFlag(ObjectFlag.CLICK_THROUGH);
                }
            }

            if (!Co8.is_in_party(spell.caster))
            {
                monster_obj.ClearObjectFlag(ObjectFlag.INVULNERABLE);
                monster_obj.AddCondition("Monster Energy Immunity", "Force", 0);
            }

            monster_obj.AddCondition("Monster Plant", 0, 0);
            monster_obj.SetInt(obj_f.critter_portrait, weapon_portrait);
            var hit_points = 10 * spell.casterLevel;
            hit_points = hp_bonus + hit_points;
            monster_obj.SetBaseStat(Stat.hp_max, hit_points);
            // equip the tempman with the appropriate weapon
            var weapon_obj = GameSystems.MapObject.CreateObject(weapon_proto, monster_obj.GetLocation());
            weapon_obj.SetInt(obj_f.weapon_damage_dice, 772);
            weapon_obj.SetInt(obj_f.weapon_attacktype, (int)DamageType.Force);
            weapon_obj.AddConditionToItem("Armor Bonus", -7, 0);
            var to_hit = spell.casterLevel + 3 - monster_obj.GetBaseStat(Stat.attack_bonus);
            if ((Stat)spell.spellClass == Stat.level_wizard)
            {
                to_hit = to_hit + spell.caster.GetStat(Stat.int_mod);
            }
            else
            {
                to_hit = to_hit + spell.caster.GetStat(Stat.cha_mod);
            }

            weapon_obj.AddConditionToItem("To Hit Bonus", to_hit, 0);
            weapon_obj.AddConditionToItem("Damage Bonus", 3, 0);
            monster_obj.GetItem(weapon_obj);
            weapon_obj.SetItemFlag(ItemFlag.NO_TRANSFER);
            monster_obj.WieldBestInAllSlots();
            // add monster to follower list for spell_caster
            if (Co8.is_in_party(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-Spell Resistance", monster_obj));
            // add spell indicator to spell caster
            spell.caster.AddCondition("sp-Endurance", spell.spellId, spell.duration, 0);
        }
        else
        {
            // no focus
            spell.caster.FloatMesFileLine("mes/spell.mes", 16009);
        }

        spell.EndSpell();
    }