Пример #1
0
        /// <summary>
        /// Song of sleep.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="spell"></param>
        /// <param name="level"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool SongSleep( CharData ch, Spell spell, int level, Target target )
        {
            foreach( CharData victim in ch.InRoom.People )
            {
                if (victim.IsAffected(Affect.AFFECT_SLEEP)
                        || Magic.SpellSavingThrow( level, victim, AttackType.DamageType.charm )
                        || victim.GetRace() == Race.RACE_VAMPIRE
                        || ch.IsSameGroup( victim ) )
                {
                    continue;
                }

                Affect af = new Affect(Affect.AffectType.song, spell.Name, level / 8, Affect.Apply.none, 0, Affect.AFFECT_SLEEP);
                victim.CombineAffect(af);

                if( victim.IsAwake() )
                {
                    victim.SendText( "You feel very sleepy... zzzzz.\r\n" );
                    if (ch.Fighting || victim.CurrentPosition == Position.fighting)
                    {
                        Combat.StopFighting(victim, false);
                    }
                    CommandType.Interpret( victim, "sleep" );
                }

            }

            return true;
        }
Пример #2
0
        /// <summary>
        /// Song of healing.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="spell"></param>
        /// <param name="level"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool SongHealing( CharData ch, Spell spell, int level, Target target )
        {
            foreach( CharData victim in ch.InRoom.People )
            {
                if( !ch.IsSameGroup( victim ) )
                    continue;

                int heal = MUDMath.Dice( 4, ( level / 3 ) ) + 1;

                if( victim.Hitpoints < victim.GetMaxHit() )
                    victim.Hitpoints = Math.Min( victim.Hitpoints + heal, victim.GetMaxHit() );
                victim.UpdatePosition();

                victim.SendText( "&+WYour wounds begin to heal.&n\r\n" );
            }
            return true;
        }
Пример #3
0
        public static void Group(CharData ch, string[] str)
        {
            if( ch == null ) return;

            // Group with no arguments should show group staus.
            if (str.Length == 0)
            {
                ch.ShowGroup();
                return;
            }

            if (!MUDString.IsPrefixOf(str[0], "all"))
            {
                int added = 0;
                foreach (CharData ivictim in ch.InRoom.People)
                {
                    if (ivictim == ch
                            || ivictim.FlightLevel != ch.FlightLevel
                            || ch.IsRacewar(ivictim))
                        continue;
                    if (((ivictim.IsNPC() && ivictim.HasActionBit(MobTemplate.ACT_PET))
                            || (!ivictim.IsNPC() && ivictim.IsConsenting(ch)))
                            && ivictim.Master == ch && !ivictim.GroupLeader)
                    {
                        ch.AddGroupMember(ivictim);
                        ++added;
                    }
                }
                if (added < 1)
                {
                    ch.SendText("No new group members.\r\n");
                }
                return;
            }

            CharData victim = ch.GetCharRoom(str[0]);
            if (!victim)
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }
            if (ch == victim)
            {
                ch.RemoveFromGroup(victim);
                return;
            }
            if (ch.IsRacewar(victim) && !victim.IsNPC())
            {
                ch.SendText("You can't group with such slime!\r\n");
                return;
            }
            if (ch.IsSameGroup(victim))
            {
                if (ch.GroupLeader == ch)
                {
                    ch.RemoveFromGroup(victim);
                }
                else
                {
                    ch.SendText("Only the leader of a group may kick someone out.\r\n");
                }
                return;
            }
            if (ch.GroupLeader == null || ch.GroupLeader == ch)
            {
                string buf;
                if (victim.GroupLeader == null)
                {
                    if ((!victim.IsNPC() && !victim.IsConsenting(ch)) || (victim.IsNPC() && victim.Master != ch))
                    {
                        buf = String.Format("{0} doesn't want to be in your group.\r\n", victim.ShowNameTo(ch, true));
                        ch.SendText(buf);
                    }
                    else
                    {
                        ch.GroupLeader = ch;
                        ch.AddGroupMember(victim);
                    }
                }
                else
                {
                    buf = String.Format("{0} is in another group.\r\n", victim.ShowNameTo(ch, true));
                    ch.SendText(buf);
                }
            }
            else
            {
                ch.SendText("You must be the head of the group to add someone.\r\n");
            }
            return;
        }
Пример #4
0
        /// <summary>
        /// Function for use with portal spells.  Can be reused for other spells if applicable.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        /// <returns></returns>
        public static bool HasSpellConsent( CharData ch, CharData victim )
        {
            if( victim.IsNPC() || ch.IsNPC() )
                return true;

            if( ch.IsSameGuild( victim ) )
                return true;

            if( ch.IsSameGroup( victim ) )
                return true;

            if( ch.IsImmortal() )
                return true;

            if( !victim.IsConsenting(ch) )
            {
                ch.SendText( "You do not have their consent.\r\n" );
                return false;
            }

            return true;
        }
Пример #5
0
        /// <summary>
        /// Inflict the damage from an area-effect spell.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="spell"></param>
        /// <param name="numTargets"></param>
        /// <param name="damage"></param>
        /// <param name="damtype"></param>
        public static void AreaSpellDamage( CharData ch, Spell spell, int numTargets, int damage, AttackType.DamageType damtype )
        {
            int count = 0;

            // TODO: Start with either a random or a targeted character instead of picking the first.
            foreach( CharData targetChar in ch.InRoom.People )
            {
                if (++count > numTargets)
                    break;

                if( !ch.IsSameGroup( targetChar ) && ch != targetChar && ch.FlightLevel == targetChar.FlightLevel )
                {
                    int tmpDam = damage;
                    /* handle special damage types (chain lightning, quake, etc) here */
                    /* by modifying tmpDam, or setting stuff on chars */
                    if (tmpDam > 0)
                    {
                        Combat.InflictSpellDamage(ch, targetChar, damage, spell, damtype);
                    }
                } //end if
            }
        }
Пример #6
0
 /// <summary>
 /// Checks whether someone is a valid target for an area-effect spell.
 /// </summary>
 /// <param name="ch"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 static bool IsValidAreaTarget( CharData ch, CharData target )
 {
     if (target.IsSameGroup(ch) || ch == target)
     {
         return false;
     }
     if (target.FlightLevel != ch.FlightLevel)
     {
         return false;
     }
     return true;
 }