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();
    }
    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();
    }
Esempio n. 3
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();
    }