Exemplo n.º 1
0
        static bool SpecWpBonethunder(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (keeper == null || keeper.Fighting == null || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                Spell spell = StringLookup.SpellLookup("bonethunder");
                if (!spell)
                {
                    Log.Error("SpecWpBonethunder: 'bonethunder' spell not found. Check the spells file.");
                    return(false);
                }
                SocketConnection.Act("&+w$n's&n $p&n &+wemits a horrible &+WCRACKING&n &+wnoise and&n $N&n &+wshreaks in agony!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+wYour&n $p&n &+wmakes a horrible&n &+WCRACKING&n &+wnoise and&n $N&n &+wshreaks in pain!", keeper,
                                     (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+w$n's&n $p&n &+wmakes a horrible&n &+WCRACKING&n &+wnoise and you feel your bones breaking!&N", keeper,
                                     (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        static bool SpecWindsabre(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 + keeper.Level / 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                SocketConnection.Act("&+c$n's&n $p&n &+csummons forth a &+Cgust&n&+c of &+Wstrong winds!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+cYour&n $p&n &+csummons forth a &+Cgust&n&+c of &+Wstrong winds&N&+c, cutting into &n$N&n&+c!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+c$n's&n $p&n &+csummons forth a &+Cgust&n&+c of &+Wstrong winds&N&+c, cutting into you!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                Spell spell = Spell.SpellList["chill touch"];
                if (spell != null)
                {
                    spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        static bool SpecCelestial(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                SocketConnection.Act("&+b$n's&n $p&n &+bs&+Bp&+ca&+Wr&n&+Ck&n&+cl&N&+Be&n&+bs with a &+csoft &+Bblue &n&+wg&+Wl&n&+wi&+Wtt&N&+we&+Wr&n&+b...&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+bYour&n $p&n &+bs&+Bp&N&+ca&+Cr&+Wk&+Cl&+Be&n&+bs at &n$N&n&+b, &+Bglowing&N&+b with a&+c soft &+Bblue &N&+wg&+Wl&n&+wi&+Wtt&n&+we&+Wr&n&+b!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+b$n's&n $p&n &+bs&+Bp&N&+ca&+Cr&+Wk&+Cl&+Be&n&+bs at you, &+Bglowing&N&+b with a&+c soft &+Bblue &N&+wg&+Wl&n&+wi&+Wtt&n&+we&+Wr&n&+b!&N ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                Spell spl = Spell.SpellList["magic missile"];
                if (spl != null)
                {
                    spl.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        static bool SpecAutumndecay(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9) &&
                !keeper.Fighting.IsAffected(Affect.AFFECT_WITHER))
            {
                SocketConnection.Act("&+y$n's&n $p&n &+ydives into &n$N&n&+y, and a &+Lblack m&N&+wis&+Lt&n&+y flows into the &+rwound!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.everyone_but_victim);
                SocketConnection.Act("&+yYour&n $p&n &+ydives into &n$N&n&+y, and a &+Lblack m&N&+wis&+Lt&n&+y flows into the &+rwound!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.character);
                SocketConnection.Act("&+y$n's&n $p&n &+ydives into you, and a &+Lblack m&N&+wis&+Lt&n&+y flows into the &+rwound!&N",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.victim);
                Spell spl = Spell.SpellList["wither"];
                if (spl != null)
                {
                    spl.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        static bool SpecHaste(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (hit)
            {
                return(false);
            }
            if (!keeper.IsAffected(Affect.AFFECT_HASTE))
            {
                Spell spl = Spell.SpellList["haste"];
                if (spl != null)
                {
                    spl.Invoke(keeper, 30, keeper);
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        static bool SpecWpMagicMissile(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            if (MUDMath.NumberPercent() < 10 && (keeper.Fighting.Hitpoints >= -9))
            {
                Spell spl = Spell.SpellList["magic missile"];
                if (spl != null)
                {
                    spl.Invoke(keeper, keeper.Level, keeper.Fighting);
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        static bool SpecTrident(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            // Hum
            if (MUDMath.NumberPercent() < 10)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            // Weapon proc
            if (keeper.Fighting && MUDMath.NumberPercent() < 15)
            {
                Spell spell = StringLookup.SpellLookup("lightanddark");
                if (!spell)
                {
                    Log.Error("SpecTrident: 'lightanddark' spell not found. Check the spells file.");
                    return(false);
                }
                SocketConnection.Act("&n$n&+c's &n&+Ctr&n&+cident &n&+bglows &+Bblue&n&+c as &n&+Csur&n&+crea&n&+Cl &n&+Bwat&n&+bers " +
                                     "&n&+Bbeg&n&+bin &n&+cto &n&+Cg&n&+cath&n&+Cer &n&+bat i&n&+Bt&n&+bs &n&+Cti&n&+cp.&n",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.room);
                spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        static bool SpecLightanddark(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;

            if (!keeper || !keeper.Fighting || !hit)
            {
                return(false);
            }

            //Hum
            if (MUDMath.NumberPercent() < 10)
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                return(true);
            }

            // Weapon proc
            if (keeper.Fighting && MUDMath.NumberPercent() < 15)
            {
                Spell spell = StringLookup.SpellLookup("lightanddark");
                if (!spell)
                {
                    Log.Error("SpecLightanddark: 'lightanddark' spell not found. Check the spells file.");
                    return(false);
                }
                SocketConnection.Act("&n$n&+L's sword fulgurates fiercely as a &+Csearing &+clight &+Lcollects at the blade's end. ",
                                     keeper, (Object)obj, keeper.Fighting, SocketConnection.MessageTarget.room);
                spell.Invoke(keeper, keeper.Level, keeper.Fighting);
                return(true);
            }

            return(false);
        }
Exemplo n.º 9
0
        /// <summary>
        /// When a spell event terminates, we need something to happen.
        /// 
        /// By this point we should have terminated the spell/song event data
        /// and should only need the info about the character and the spell
        /// and the argument(s).
        /// 
        /// Passing of the correct function parameters should be handled by the
        /// event system.
        /// </summary>
        /// <param name="ch">The caster</param>
        /// <param name="spell">The spell number</param>
        /// <param name="target">The _targetType</param>
        public static void FinishSpell( CharData ch, Spell spell, Target target )
        {
            Object obj;
            int chance = 0;
            bool found = false;

            string lbuf = String.Format("Magic.FinishSpell: {0} by {1}", spell.Name, ch.Name);
            Log.Trace( lbuf );

            for( int i = Database.CastList.Count - 1; i >= 0; i--)
            {
                if (Database.CastList[i].Who && Database.CastList[i].Who == ch)
                {
                    Database.CastList.RemoveAt( i );
                }
            }

            // If they're not casting at the end of the song or spell
            // they certainly can't finish it.
            if( ch.IsAffected( Affect.AFFECT_CASTING ) )
                ch.RemoveAffect( Affect.AFFECT_CASTING );
            else
            {
                return;
            }

            if( !ch.CheckConcentration(spell) )
                return;

            if( ( ch.IsAffected( Affect.AFFECT_MUTE ) || ch.HasInnate( Race.RACE_MUTE ) )
                    && !ch.IsClass( CharClass.Names.psionicist ) )
            {
                ch.SendText( "Your lips move but no sound comes out.\r\n" );
                return;
            }

            // Make sure the room is still castable.
            if( !ch.InRoom.CheckCastable( ch, false, false ) )
                return;

            if( ch.InRoom.CheckStarshell( ch ) )
                return;

            MemorizeData memorized = null;
            if (!ch.IsNPC() && !ch.IsImmortal() && !ch.IsClass(CharClass.Names.psionicist))
            {
                foreach( MemorizeData mem in ((PC)ch).Memorized )
                {
                    if( !mem.Memmed )
                        continue;
                    if( mem.Name == spell.Name )
                    {
                        found = true;
                        memorized = mem;
                        break;
                    }
                }

                if (!found && !ch.IsNPC() && !ch.IsClass(CharClass.Names.psionicist))
                {
                    ch.SendText( "You do not have that spell memorized!\r\n" );
                    if( spell.ValidTargets == TargetType.objectOrCharacter )
                        target = null;
                    else if( spell.ValidTargets == TargetType.none )
                        target = null;
                    return;
                }
            }

            if( ch.IsAffected( Affect.AFFECT_FEEBLEMIND ) )
            {
                ch.SendText( "You are just too stupid to cast that spell!\r\n" );
                SocketConnection.Act( "$n&n screws up $s face in concentration.", ch, null, null, SocketConnection.MessageTarget.room );
                SocketConnection.Act( "$n&n tries really, really hard to complete a spell, but fails.", ch, null, null, SocketConnection.MessageTarget.room );
                return;
            }

            // Locate targets.
            CharData victim = null;
            switch( spell.ValidTargets )
            {
                default:
                    Log.Trace( "FinishSpell: bad TargetType for spell {1}.", spell );
                    return;
                case TargetType.objectOrCharacter:
                    if( ch.IsAffected( Affect.AFFECT_BLIND ) )
                    {
                        ch.SendText( "You cannot see to cast that spell.\r\n" );
                        return;
                    }
                    break;
                case TargetType.none:
                    break;
                case TargetType.trap:
                    ch.SendText( "You cannot cast a trap!\r\n" );
                    return;
                case TargetType.singleCharacterOffensive:
                    victim = (CharData)target;

                    if( ch.IsAffected( Affect.AFFECT_BLIND ) )
                    {
                        //allow casting if in combat and no _targetType specified
                        if( !( ch.Fighting && victim == ch.Fighting ) )
                        {
                            ch.SendText( "You cannot see to cast that spell.\r\n" );
                            return;
                        }
                    }
                    if( !victim )
                    {
                        ch.SendText( "They aren't here.\r\n" );
                        return;
                    }
                    if( !victim.InRoom || victim.InRoom != ch.InRoom )
                    {
                        ch.SendText( "They are not here.\r\n" );
                        return;
                    }
                    if( Combat.IsSafe( ch, victim ) )
                        return;
                    // Command.is_safe could wipe out victim, as it calls procs if a boss
                    // check and see that victim is still valid
                    if( !victim )
                        return;

                    Crime.CheckAttemptedMurder( ch, victim );

                    /* Check for globes.  This will stop any spells of type TargetType.singleCharacterOffensive
                    * but area effect spells with type TargetType.none will get through, since we
                    * don't know whether they will be offensive or not.  The only thing we can
                    * really do is add this same thing in the Command.SpellDamage function to prevent
                    * those from getting through.  However, we must treat cases of things like
                    * an area effect sleep spell as a special case within the SpellWhatever
                    * function in Spells.cs.  However, by the nature of the spell, anything
                    * that is not either offensive and not direct damage, it should get through
                    * just so that these spells have some weaknesses for the strategic to get
                    * around.
                    */
                    /*
                    *  TODO: Find out why this globe code was commented out and either uncomment or delete.
                    if( CharData.IsAffected( victim, Affect.AFFECT_MAJOR_GLOBE ) && Spell.Table[spell].spell_circle[ch.cclass] <= 6 )
                    {
                    Descriptor._actFlags( "&+RThe globe around $N&n's body bears the brunt of your assault!&n", ch, null, victim, Descriptor.MessageTarget.character );
                    Descriptor._actFlags( "&+RYour globe deflects $n&+R's attack!&n", ch, null, victim, Descriptor.MessageTarget.victim );
                    Descriptor._actFlags( "&+R$N&+R's globe deflects $n&+R's attack!&n", ch, null, victim, Descriptor.MessageTarget.room );
                    return;
                    }
                    if( CharData.IsAffected( victim, Affect.AFFECT_GREATER_SPIRIT_WARD ) && Spell.Table[spell].spell_circle[ch.cclass] <= 5 )
                    {
                    Descriptor._actFlags( "&+WThe aura around $N&n's body bears the brunt of your assault!&n", ch, null, victim, Descriptor.MessageTarget.character );
                    Descriptor._actFlags( "&+WYour globe absorbs $n&+W's attack!&n", ch, null, victim, Descriptor.MessageTarget.victim );
                    Descriptor._actFlags( "&+W$N&+W's aura absorbs $n&+W's attack!&n", ch, null, victim, Descriptor.MessageTarget.room );
                    return;
                    }
                    if( CharData.IsAffected( victim, Affect.AFFECT_MINOR_GLOBE ) && Spell.Table[spell].spell_circle[ch.cclass] <= 4 )
                    {
                    Descriptor._actFlags( "&+RThe globe around $N&n's body bears the brunt of your assault!&n", ch, null, victim, Descriptor.MessageTarget.character );
                    Descriptor._actFlags( "&+RYour globe deflects $n&+R's attack!&n", ch, null, victim, Descriptor.MessageTarget.victim );
                    Descriptor._actFlags( "&+R$N&+R's globe deflects $n&+R's attack!&n", ch, null, victim, Descriptor.MessageTarget.room );
                    return;
                    }
                    if( CharData.IsAffected( victim, Affect.AFFECT_SPIRIT_WARD ) && Spell.Table[spell].spell_circle[ch.cclass] <= 3 )
                    {
                    Descriptor._actFlags( "&+WThe aura around $N&n's body bears the brunt of your assault!&n", ch, null, victim, Descriptor.MessageTarget.character );
                    Descriptor._actFlags( "&+WYour globe absorbs $n&+W's attack!&n", ch, null, victim, Descriptor.MessageTarget.victim );
                    Descriptor._actFlags( "&+W$N&+W's aura absorbs $n&+W's attack!&n", ch, null, victim, Descriptor.MessageTarget.room );
                    return;
                    }
                    */
                    break;
                case TargetType.singleCharacterWorld:
                    victim = (CharData)target;

                    if( ch.IsAffected( Affect.AFFECT_BLIND ) && victim != ch )
                    {
                        ch.SendText( "You cannot see to cast that spell.\r\n" );
                        return;
                    }
                    break;
                case TargetType.singleCharacterDefensive:
                    victim = (CharData)target;

                    if( ch.IsAffected( Affect.AFFECT_BLIND ) && victim != ch )
                    {
                        ch.SendText( "You cannot see to cast that spell.\r\n" );
                        return;
                    }
                    if( !victim || victim.InRoom != ch.InRoom )
                    {
                        ch.SendText( "They aren't here.\r\n" );
                        return;
                    }
                    break;
                case TargetType.self:
                    break;
                case TargetType.objectInInventory:
                    obj = (Object)target;

                    if( ch.IsAffected( Affect.AFFECT_BLIND ) )
                    {
                        ch.SendText( "You cannot see to cast that spell.\r\n" );
                        return;
                    }
                    if( !obj || obj.CarriedBy != ch )
                    {
                        ch.SendText( "You are not carrying that.\r\n" );
                        return;
                    }
                    break;
                case TargetType.objectInRoom:
                    obj = (Object)target;

                    if( ch.IsAffected( Affect.AFFECT_BLIND ) )
                    {
                        ch.SendText( "You cannot see to cast that spell.\r\n" );
                        return;
                    }
                    if( !obj || ( obj.CarriedBy != ch && obj.InRoom != ch.InRoom ) )
                    {
                        ch.SendText( "You do not see that here.\r\n" );
                        return;
                    }
                    break;
                case TargetType.objectCorpse:
                    break;
                case TargetType.singleCharacterRanged:
                    victim = (CharData)target;
                    if( ch.IsAffected( Affect.AFFECT_BLIND ) )
                    {
                        ch.SendText( "You cannot see to cast that spell.\r\n" );
                        return;
                    }
                    if( !victim
                            || victim.FlightLevel != ch.FlightLevel
                            || !CharData.CanSee( ch, victim ) )
                    {
                        ch.SendText( "Your prey has disappeared.\r\n" );
                        return;
                    }
                    //check that _targetType is still within the spell range
                    if( ch.InRoom == victim.InRoom )
                    {
                        break;
                    }
                    bool targetInRange = false;
                    int dir;
                    for( dir = 0; dir < Limits.MAX_DIRECTION; dir++ )
                    {
                        if( !ch.InRoom.ExitData[ dir ]
                                || ch.InRoom.ExitData[ dir ].HasFlag( Exit.ExitFlag.secret )
                                || ch.InRoom.ExitData[ dir ].HasFlag( Exit.ExitFlag.closed )
                                || ch.InRoom.ExitData[ dir ].HasFlag( Exit.ExitFlag.blocked )
                                || ch.InRoom.ExitData[dir].HasFlag(Exit.ExitFlag.walled))
                            continue;
                        if( ch.InRoom.ExitData[ dir ].TargetRoom == victim.InRoom )
                        {
                            targetInRange = true;
                            break;
                        }
                        // for fireball we check two rooms away
                        if( ch.InRoom.ExitData[ dir ].TargetRoom &&
                                ch.InRoom.ExitData[ dir ].TargetRoom.ExitData[ dir ]
                                && ch.InRoom.ExitData[ dir ].TargetRoom.ExitData[ dir ].TargetRoom == victim.InRoom )
                        {
                            targetInRange = true;
                            break;
                        }
                    }
                    if( !targetInRange )
                    {
                        ch.SendText( "They are no longer in range!\r\n" );
                        return;
                    }
                    break;
                }

            // No wait state - we already made them wait.
            ch.PracticeSpell( spell );

            if (ch.IsNPC())
            {
                chance = 85;
            }
            else if (ch.HasSpell(spell.Name))
            {
                chance = ((PC)ch).SpellAptitude[spell.Name];
            }

            if( !ch.IsImmortal() && ( MUDMath.NumberPercent() > chance ) )
            {
                ch.SendText( "You lost your concentration.\r\n" );
                SocketConnection.Act( "&+r$n&n&+r stops chanting abruptly.&n", ch, null, null, SocketConnection.MessageTarget.room );
            }
            else
            {
                // TODO: Figure out whether this should be re-enabled.
                //if( song )
                //{
                //    ch.SendText( "You complete a verse of the song...\r\n" );
                //    ch.GainExperience( 1 );
                //    SaySong( ch, spell );
                //}
                //else
                {
                    if (!ch.IsClass(CharClass.Names.psionicist))
                    {
                        ch.SendText( "You complete your spell...\r\n" );
                        if( MUDString.StringsNotEqual( spell.Name, "ventriloquate" ) )
                            SaySpell( ch, spell );
                    }
                    ch.GainExperience( 1 );
                }
                if( !ch.IsNPC() )
                {
                    string buf = String.Format( "Spell ({0}) being cast by {1}", spell.Name, ch.Name );
                    Log.Trace( buf );
                }

                int level = Macros.Range(1, ch.Level, Limits.LEVEL_HERO);
                spell.Invoke(ch, level, target);

                if( memorized && !ch.IsNPC() && !ch.IsImmortal() )
                {
                    memorized.Memmed = false;
                    memorized.Memtime = memorized.FullMemtime;
                }
            }

            if( ( spell.ValidTargets == TargetType.singleCharacterOffensive
                    || spell.ValidTargets == TargetType.singleCharacterRanged )
                    && victim && victim.Master != ch && victim != ch && victim.IsAwake() )
            {
                if( ch.InRoom == victim.InRoom )
                {
                    if( !victim.Fighting && CharData.CanSee( victim, ch ) )
                        victim.AttackCharacter( ch );
                }
                else
                {
                    // Range spell presumably, since different rooms
                    Combat.StartGrudge( victim, ch, true );
                    foreach( CharData roomChar in ch.InRoom.People )
                    {
                        if( roomChar == victim )
                            continue;
                        if( roomChar.FlightLevel != ch.FlightLevel )
                            continue;
                        //protectors will be aggro'd
                        if (roomChar.HasActionBit(MobTemplate.ACT_PROTECTOR) && (roomChar.GetRace() == victim.GetRace()))
                        {
                            Combat.StartGrudge( roomChar, ch, true );
                        }
                        // all aggro mobs will hunt down caster
                        if (roomChar.HasActionBit(MobTemplate.ACT_AGGRESSIVE))
                        {
                            Combat.StartGrudge(roomChar, ch, true);
                        }
                    }
                }
            }
            return;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Casts a spell using a magical object.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="spell"></param>
        /// <param name="level"></param>
        /// <param name="victim"></param>
        /// <param name="obj"></param>
        public static void ObjectCastSpell( CharData ch, Spell spell, int level, CharData victim, Object obj )
        {
            Target target;

            if( spell == null || obj == null )
            {
                return;
            }

            switch( spell.ValidTargets )
            {
                default:
                    Log.Error( "ObjectCastSpell: bad TargetType for spell {0}.", spell.Name );
                    return;

                case TargetType.none:
                    target = null;
                    break;

                case TargetType.trap:
                    return;

                case TargetType.singleCharacterOffensive:
                    if( !victim )
                        victim = ch.Fighting;
                    if( !victim )
                    {
                        ch.SendText( "You can't do that.\r\n" );
                        return;
                    }

                    if( Combat.IsSafe( ch, victim ) )
                        return;
                    // Combat.IsSafe could wipe out victim, as it calls procs if a boss
                    // check and see that victim is still valid
                    if(  !victim )
                        return;

                    Crime.CheckAttemptedMurder( ch, victim );

                    target = new Target( victim );
                    break;

                case TargetType.singleCharacterDefensive:
                    if( !victim )
                        victim = ch;
                    target = new Target( victim );
                    break;

                case TargetType.self:
                    target = new Target( ch );
                    break;

                case TargetType.objectInInventory:
                    if( !obj )
                    {
                        ch.SendText( "You can't do that.\r\n" );
                        return;
                    }
                    target = new Target( obj );
                    break;

                case TargetType.objectInRoom:
                    if( !obj )
                    {
                        ch.SendText( "You can't do that.\r\n" );
                        return;
                    }
                    target = new Target( obj );
                    break;

                case TargetType.objectCorpse:
                    target = new Target( obj );
                    break;
            }

            spell.Invoke(ch, level, target);

            if( spell.ValidTargets == TargetType.singleCharacterOffensive
                    && victim.Master != ch && ch != victim )
            {
                foreach( CharData roomChar in ch.InRoom.People )
                {
                    if( victim == roomChar && !victim.Fighting )
                    {
                        victim.AttackCharacter( ch );
                        break;
                    }
                }
            }

            return;
        }
Exemplo n.º 11
0
        static bool SpecHammer(System.Object obj, System.Object owner, bool hit)
        {
            CharData keeper = (CharData)owner;
            bool     retval = false;

            if (!keeper)
            {
                return(false);
            }

            //Hum
            if ((!keeper.Fighting && MUDMath.NumberPercent() < 10) ||
                (keeper.Fighting && MUDMath.NumberPercent() < 2))
            {
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lcarried by&n $n&n.",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("&+LA faint hum can be heard from&n $p&n &+Lyou are carrying.&n",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.character);
                if (!keeper.IsAffected(Affect.AFFECT_STONESKIN) && MUDMath.NumberPercent() < 30)
                {
                    Spell spl = Spell.SpellList["stoneskin"];
                    if (spl != null)
                    {
                        spl.Invoke(keeper, 60, keeper);
                    }
                }
                retval = true;
            }

            if (!keeper.Fighting)
            {
                return(retval);
            }

            // it fires off 1 in 12 times
            if (MUDMath.NumberPercent() > 8)
            {
                return(false);
            }

            // if not wielded as primary, do nothing
            if (Object.GetEquipmentOnCharacter(keeper, ObjTemplate.WearLocation.hand_one) != obj)
            {
                return(false);
            }

            // grumbar's hammer needs to be grounded to work
            if (keeper.FlightLevel != 0)
            {
                return(false);
            }

            // need to have some earthly elements around
            //    if ( keeper.in_room.sector == RoomIndex.TerrainType.plane_of_air ||
            //         keeper.in_room.sector == RoomIndex.TerrainType.plane_of_water ||
            //         keeper.in_room.sector == RoomIndex.TerrainType.plane_of_fire )
            //        return false;

            CharData vict = keeper.Fighting;

            switch (MUDMath.NumberRange(1, 3))
            {
            case 1:
                //throw a wall
                int dir = MUDMath.NumberRange(0, Limits.MAX_DIRECTION - 1);
                if (keeper.InRoom.ExitData[dir])
                {
                    Spell spl = Spell.SpellList["wall of stone"];
                    if (spl != null)
                    {
                        spl.Invoke(keeper, 50, dir.ToString());
                    }
                }
                retval = true;
                break;

            case 2:
                // earthen rain
                if (!keeper.IsOutside())
                {
                    retval = false;
                    break;
                }
                SocketConnection.Act("Your $p crushes $N in a rain of &+yearth&N and &+Lstone&N!", keeper,
                                     (Object)obj, vict, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n's $p crushes you under a rain of &+yearth&N and &+Lstone&N!", keeper,
                                     (Object)obj, vict, SocketConnection.MessageTarget.victim);
                SocketConnection.Act("$n's $p crushes $N under a rain of &+yearth&N and &+Lstone&N!.", keeper,
                                     (Object)obj, vict, SocketConnection.MessageTarget.everyone_but_victim);
                // same damage as earthen rain at level 50
                int dam = MUDMath.Dice(150, 3) + 100;
                Combat.InflictSpellDamage(keeper, vict, dam, "earthen rain", AttackType.DamageType.crushing);
                retval = true;
                break;

            case 3:
                // cause an earthquake
                SocketConnection.Act("Your $p causes the ground to rise up!",
                                     keeper, (Object)obj, vict, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n's $p blasts the ground with a &+yshockwave&N!",
                                     keeper, (Object)obj, null, SocketConnection.MessageTarget.room);
                foreach (CharData targetChar in keeper.InRoom.People)
                {
                    if ((targetChar == keeper) || targetChar.IsImmortal())
                    {
                        continue;
                    }
                    if (keeper.IsSameGroup(targetChar))
                    {
                        continue;
                    }
                    if (targetChar.IsAffected(Affect.AFFECT_FLYING))
                    {
                        continue;
                    }
                    if (keeper.IsNPC() && targetChar.IsNPC() && !vict.IsSameGroup(targetChar))
                    {
                        continue;
                    }
                    if (Magic.SpellSavingThrow(60, targetChar, AttackType.DamageType.earth))
                    {
                        SocketConnection.Act("You wobble precipitously, but keep your feet.",
                                             keeper, null, targetChar, SocketConnection.MessageTarget.victim);
                        SocketConnection.Act("$n&n stumbles slightly but keeps $s balance.", targetChar, null, null, SocketConnection.MessageTarget.room);
                    }
                    else
                    {
                        SocketConnection.Act("You are knocked to the ground!",
                                             keeper, null, targetChar, SocketConnection.MessageTarget.victim);
                        SocketConnection.Act("$n&n is knocked to the ground!", targetChar, null, null, SocketConnection.MessageTarget.room);
                        targetChar.CurrentPosition = Position.kneeling;
                        targetChar.WaitState(Event.TICK_COMBAT);
                    }
                }     // end for
                retval = true;
                break;

            default:
                break;
            } //end switch
            return(retval);
        }