Exemplo n.º 1
0
 /// <summary>
 /// Handle a message from a creature.
 /// </summary>
 /// <param name="creature">The creature sending the message.</param>
 /// <param name="msg">The message sent.</param>
 public void HandleChat(Creature creature, string msg)
 {
     ThingSet tSet = new ThingSet();
     if (msg.StartsWith(PRIVATE_MSG_INDICATOR)) {
         HandlePrivateMessage(creature, msg);
     } else if (msg.StartsWith(MSG_QUANTIFIER)) {
         HandleQuantifiedMessage(creature, msg, tSet);
     } else {
         tSet = gameMap.GetThingsInVicinity(creature.CurrentPosition, true);
         HandleLocalChat(creature.GetChatType(), tSet, msg, creature);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// A quantified message is a message that starts with a special character. For example,
        /// in tibia 6.4, # is a quantifier, so #y is used to yell, #w is used to whisper etc.
        /// </summary>
        /// <param name="sender">Sender of the quantified message.</param>
        /// <param name="msg">The message itself.</param>
        private void HandleQuantifiedMessage(Creature sender, string msg, ThingSet tSet)
        {
            if (!msg.StartsWith(MSG_QUANTIFIER)) {
                throw new Exception("Invalid call to HandleQuantifiedMessage()");
            }
            msg = msg.Substring(1); //Remove first quanitifer
            char quantifierType = char.ToLower(msg[0]);
            switch (quantifierType) {
                case BROADCAST_TYPE:
                    HandleBroadcast(sender, msg);
                    break;
                case WHISPER_TYPE:
                     gameMap.GetThingsInWhisperVicinity(sender.CurrentPosition, tSet);
                    //msg.Substring(2) is called in order to remove quantifier type and a space
                     HandleLocalChat(ChatLocal.WHISPER, tSet, msg.Substring(2), sender);

                    break;
                case YELL_TYPE:
                    gameMap.GetThingsInYellVacinity(sender.CurrentPosition, tSet);
                    //msg.Substring(2) is called in order to remove quantifier type and a space
                    HandleLocalChat(ChatLocal.YELLS, tSet, msg.Substring(2).ToUpper(), sender);
                    break;
                default:
            #if DEBUG
                    Log.WriteDebug("Invalid quantifier type");
            #endif
                    break;
            }
        }
Exemplo n.º 3
0
 public void GetThings(ThingSet tSet)
 {
     foreach (Thing thing in tileThings) {
         tSet.AddThing(thing);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Handles sending a chat message in a player's local vicinity.
 /// </summary>
 /// <param name="type">The type of chat to send.</param>
 /// <param name="set">The set of things in the player's local vicinity.</param>
 /// <param name="msg">The message to send.</param>
 /// <param name="sender">The sender of the message.</param>
 private void HandleLocalChat(ChatLocal type, ThingSet set, 
     string msg, Creature sender)
 {
     foreach (Thing thing in set.GetThings()) {
         thing.AddLocalChat(type, msg, sender.CurrentPosition, sender);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Gets a set of things that are in the vacinity of a whipser.
 /// </summary>
 /// <param name="center">The center of the vacinity.</param>
 public void GetThingsInWhisperVicinity(Position center, ThingSet tSet)
 {
     GetThingsInVicinity(center, tSet, -8, -7, -6, -5, true);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets a set of things are are in the vacinity of a yell.
 /// </summary>
 /// <param name="center">The center of the vacinity.</param>
 /// <returns>A set of things in the yell vacinity.</returns>
 public void GetThingsInYellVacinity(Position center, ThingSet tSet)
 {
     GetThingsInVicinity(center, tSet, 8, 7, 6, 5, false);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gets things in the vicinity.
 /// </summary>
 /// <param name="position">The position of the vicinity.</param>
 /// <param name="tSet">The ThingSet to add to.</param>
 public void GetThingsInVicinity(Position position, ThingSet tSet)
 {
     GetThingsInVicinity(position, tSet, 0, 0, 0, 0, false);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Gets things in the vicinity.
 /// </summary>
 /// <param name="position">The position of the vicinity.</param>
 /// <param name="noZChange">True if only to get things on the same z level or false
 /// in order to get things on all z levels defined in the general Vicinity.</param>
 /// <returns>All the things in the Vicinity.</returns>
 public ThingSet GetThingsInVicinity(Position position, bool noZChange)
 {
     ThingSet tSet = new ThingSet();
     GetThingsInVicinity(position, tSet, 0, 0, 0, 0, noZChange);
     return tSet;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Gets all the things in the vicinity (as specified in the parameters)
        /// and adds them to the ThingSet specified in the parameters.
        /// Note: general vicinity is specified as an 18x14 box w/ the Position
        /// in the center at x == 6 && y == 7.
        /// </summary>
        /// <param name="position">The position for which to get the things
        /// in Vicinity.</param>
        /// <param name="tSet">The ThingSet to add all the things gotten in 
        /// the vacanity.</param>
        /// <param name="leftXOffset">The left offset from the general Vicinity.</param>
        /// <param name="rightXOffset">The right offset from the general Vicinity.</param>
        /// <param name="leftYOffset">The left offset from the general Vicinity.</param>
        /// <param name="rightYOffset">The right offset from the gernal Vicinity</param>
        /// <param name="noZChange">True if only get things on the same z level or false
        /// in order to get things on all z levels defined in the general Vicinity.</param>
        public void GetThingsInVicinity(Position position, ThingSet tSet, int leftXOffset,
            int rightXOffset, int leftYOffset, int rightYOffset, bool noZChange)
        {
            short startZ = 0;
            short endZ = 0;
            short zStep = 1;
            if (noZChange) {
                startZ = endZ = position.z;
            } else {
                GetZIter(ref startZ, ref endZ, ref zStep, position.z);
            }
            //Original x: -9, +8, y: -7, +6
            for (int x = position.x - 9 - leftXOffset; x <= position.x + 9 + rightXOffset; x++) {
                for (int y = position.y - 7 - leftYOffset; y <= position.y + 6 + rightYOffset; y++) {
                    for (short z = startZ; z != endZ + zStep; z += zStep) {
                        short offset = (short)(position.z - z);
                        Tile mapTile = GetTile((ushort)(x + offset), (ushort)(y + offset), (byte)(z));
                        if (mapTile == null)
                            continue;

                        mapTile.GetThings(tSet);
                    }
                }
            }
        }
Exemplo n.º 10
0
 private void AddShootEffect(DistanceType type, Position origin,
     Position destination, ThingSet tSet)
 {
     gameMap.GetThingsInVicinity(origin, tSet);
     gameMap.GetThingsInVicinity(destination, tSet);
     foreach (Thing thing in tSet.GetThings()) {
         thing.AddShootEffect((byte)type, origin, destination);
     }
 }
Exemplo n.º 11
0
 public void HandleSpellCheck(Creature caster)
 {
     lock (lockThis) {
         Spell spell = caster.GetSpell();
         if (spell != null) {
             ThingSet tSet = new ThingSet();
             spellSystem.CastSpell(spell.Name, caster, spell, this);
             SendProtocolMessages();
         }
     }
 }