示例#1
0
        public override void AddTileCreature(Creature creature, bool knowsCreature)
        {
            if (knowsCreature)
            {
                netmsg.AddByte(0x62);
                netmsg.AddByte(0x00);
                netmsg.AddU32(creature.GetID());
            }
            else
            {
                netmsg.AddByte(0x61);
                netmsg.AddByte(0x00);

                netmsg.AddU32(0); //TODO: Login stuff?
                netmsg.AddU32(creature.GetID());
                netmsg.AddStringL(creature.Name);
            }

            netmsg.AddByte(creature.GetHealthPercentage());  //HP percent
            netmsg.AddByte((byte)creature.CurrentDirection); //Direction

            /*if (creature.isInvisible) {
             *  AddCreatureInvisible();
             * } else if (creature.isUsingChameleon) {
             *  AddByte(0x00);
             *  AddU16((ushort)creature.chameleonItem);
             * } else {*/
            netmsg.AddByte(0x7F); //lookhead
            netmsg.AddByte(0x00);
            netmsg.AddByte(0x00);
            netmsg.AddByte(0x00);
            netmsg.AddByte(0x00);

            //netmsg.AddByte(creature.CharType);

            /*
             * netmsg.AddByte(creature.colorHead);
             * netmsg.AddByte(creature.colorBody);
             * netmsg.AddByte(creature.colorLegs);
             * netmsg.AddByte(creature.colorFeet);
             *///TODO: FINISH THIS
            // }

            netmsg.AddByte(creature.SpellLightLevel);   //light levels
            netmsg.AddByte(0xD7);                       // light color, yellow light = 0xD7

            netmsg.AddU16((ushort)creature.GetSpeed()); //speed
        }
示例#2
0
 public override void UpdateCreatureLight(Creature creature, byte light)
 {
     netmsg.AddByte(0x8D);
     netmsg.AddU32(creature.GetID());
     netmsg.AddByte(creature.SpellLightLevel);
     netmsg.AddByte(0xD7); //Light color
 }
示例#3
0
        /// <summary>
        /// Have a creature set its target that it will be attacking.
        /// </summary>
        /// <param name="creature">The creature attacking.</param>
        /// <param name="target">The creature who is being attacked.</param>
        public virtual void HandleCreatureTarget(Creature creature, Creature target)
        {
            if (target == null)
            {
                throw new Exception("Target is null in HandleCreatureTarget()");
            }

            HandleCreatureTarget(creature, target.GetID());
        }
示例#4
0
        /// <summary>
        /// Adds the protocol information for moving a creature.
        /// </summary>
        /// <param name="direction">The new direction of the creature.</param>
        /// <param name="creature">The creature to move.</param>
        /// <param name="oldPos">Creature's old position.</param>
        /// <param name="newPos">Creature's new position.</param>
        /// <param name="oldStackpos">Creature's old stack position.</param>
        /// <param name="newStackpos">Creature's new stack position.</param>
        public override void AddCreatureMove(Direction direction, Creature creature,
                                             Position oldPos, Position newPos, byte oldStackpos, byte newStackpos)
        {
            RemoveThing(oldPos, oldStackpos);

            UpdateThingHeaders(newPos, UpdateThing.ADD, newStackpos);

            AddCreatureDirection(direction, creature.GetID());
        }
示例#5
0
        /// <summary>
        /// Add a creature to the player's client on the map.
        /// </summary>
        /// <param name="creature">The creature to add.</param>
        /// <param name="knowsCreature">Whether the player knows the creature.</param>
        public override void AddTileCreature(Creature creature, bool knowsCreature)
        {
            netmsg.AddByte(0xFB);
            if (knowsCreature)
            {
                netmsg.AddU32(creature.GetID());
            }
            else
            {
                netmsg.AddU32(0);
            }

            netmsg.AddU32(creature.GetID());
            netmsg.AddStringZ(creature.Name, 30);
            netmsg.AddByte((byte)creature.CurrentHealthStatus);
            netmsg.AddByte((byte)creature.CurrentDirection);
            AddOutfit(creature);
            netmsg.AddByte(creature.GetLightLevel());
        }
示例#6
0
 /// <summary>
 /// Adds a creature to a single tile with only the 
 /// most basic information. Note: Used for speeding up
 /// loading spawns.
 /// </summary>
 /// <param name="creature">Creature to add.</param>
 /// <param name="position">Position to add creature.</param>
 public void AddCachedCreature(Creature creature, Position position)
 {
     lock (lockThis) {
         creature.World = this;
         creaturesOnline.Add(creature.GetID(), creature);
         creature.Finder = pathFinder;
         creature.LogedIn = true;
         gameMap.AddThing(creature, position);
     }
 }
示例#7
0
 /// <summary>
 /// Adds a creature to a single tile with only the
 /// most basic information. Note: Used for speeding up
 /// loading spawns.
 /// </summary>
 /// <param name="creature">Creature to add.</param>
 /// <param name="position">Position to add creature.</param>
 public void AddCachedCreature(Creature creature, Position position)
 {
     lock (lockThis) {
         creature.World = this;
         creaturesOnline.Add(creature.GetID(), creature);
         creature.Finder  = pathFinder;
         creature.LogedIn = true;
         gameMap.AddThing(creature, position);
     }
 }
示例#8
0
        /// <summary>
        /// Removes the creature from the game world and only
        /// appends the data to the ThingSet without reseting or sending it.
        /// </summary>
        /// <param name="creature">The creature to remove.</param>
        /// <param name="tSet">A reference for which things to notify of the
        /// creature's removal.</param>
        private void AppendRemoveCreature(Creature creature)
        {
            creaturesOnline.Remove(creature.GetID());
            creature.LogedIn = false;
            byte     stackpos = gameMap.GetStackPosition(creature, creature.CurrentPosition);
            ThingSet tSet     = gameMap.GetThingsInVicinity(creature.CurrentPosition);

            foreach (Monster summon in creature.GetSummons())
            {
                summon.SetMaster(null);
            }
            foreach (Thing thing in tSet.GetThings())
            {
                thing.RemoveThing(creature.CurrentPosition, stackpos);
            }
            gameMap.RemoveThing(creature, creature.CurrentPosition);
        }
示例#9
0
 public override void UpdateCreatureLight(Creature creature, byte light)
 {
     netmsg.AddByte(0x8D);
     netmsg.AddU32(creature.GetID());
     netmsg.AddByte(creature.SpellLightLevel);
     netmsg.AddByte(0xD7); //Light color
 }
示例#10
0
 public override void UpdateCreatureHealth(Creature creature)
 {
     netmsg.AddByte(0x8C);
     netmsg.AddU32(creature.GetID());
     netmsg.AddByte(creature.GetHealthPercentage());
 }
示例#11
0
        public override void AddTileCreature(Creature creature, bool knowsCreature)
        {
            if (knowsCreature) {
                netmsg.AddByte(0x62);
                netmsg.AddByte(0x00);
                netmsg.AddU32(creature.GetID());
            } else {
                netmsg.AddByte(0x61);
                netmsg.AddByte(0x00);

                netmsg.AddU32(0); //TODO: Login stuff?
                netmsg.AddU32(creature.GetID());
                netmsg.AddStringL(creature.Name);
            }

            netmsg.AddByte(creature.GetHealthPercentage()); //HP percent
            netmsg.AddByte((byte)creature.CurrentDirection); //Direction

            /*if (creature.isInvisible) {
                AddCreatureInvisible();
            } else if (creature.isUsingChameleon) {
                AddByte(0x00);
                AddU16((ushort)creature.chameleonItem);
            } else {*/
            netmsg.AddByte(0x7F); //lookhead
            netmsg.AddByte(0x00);
            netmsg.AddByte(0x00);
            netmsg.AddByte(0x00);
            netmsg.AddByte(0x00);

            //netmsg.AddByte(creature.CharType);
            /*
            netmsg.AddByte(creature.colorHead);
            netmsg.AddByte(creature.colorBody);
            netmsg.AddByte(creature.colorLegs);
            netmsg.AddByte(creature.colorFeet);
             */ //TODO: FINISH THIS
               // }

            netmsg.AddByte(creature.SpellLightLevel); //light levels
            netmsg.AddByte(0xD7); // light color, yellow light = 0xD7

            netmsg.AddU16((ushort)creature.GetSpeed());  //speed
        }
示例#12
0
 /// <summary>
 /// Adds the headers for updating a creature.
 /// </summary>
 /// <param name="c">The creature to update.</param>
 /// <param name="type">The type of update being done.</param>
 private void UpdateCreatureHeaders(Creature creature, UpdateCreature type)
 {
     netmsg.AddU16(0x32); //Update header
     netmsg.AddU32(creature.GetID());
     netmsg.AddByte((byte)type);
 }
示例#13
0
 /// <summary>
 /// Update the creature's direction.
 /// </summary>
 /// <param name="creature">The creature whose direction to update.</param>
 /// <param name="direction">The new direction.</param>
 /// <param name="stackpos">The creature's stack position.</param>
 /// <param name="position">The creature's position.</param>
 public override void UpdateCreatureDirection(Creature creature,
     Direction direction, byte stackpos, Position position)
 {
     UpdateThingHeaders(position, UpdateThing.UPDATE, stackpos);
     AddCreatureDirection(direction, creature.GetID());
 }
示例#14
0
        /// <summary>
        /// Add a creature to the player's client on the map.
        /// </summary>
        /// <param name="creature">The creature to add.</param>
        /// <param name="knowsCreature">Whether the player knows the creature.</param>
        public override void AddTileCreature(Creature creature, bool knowsCreature)
        {
            netmsg.AddByte(0xFB);
            if (knowsCreature) {
                netmsg.AddU32(creature.GetID());
            } else {
                netmsg.AddU32(0);
            }

            netmsg.AddU32(creature.GetID());
            netmsg.AddStringZ(creature.Name, 30);
            netmsg.AddByte((byte)creature.CurrentHealthStatus);
            netmsg.AddByte((byte)creature.CurrentDirection);
            AddOutfit(creature);
            netmsg.AddByte(creature.GetLightLevel());
        }
示例#15
0
        /// <summary>
        /// Adds the protocol information for moving a creature.
        /// </summary>
        /// <param name="direction">The new direction of the creature.</param>
        /// <param name="creature">The creature to move.</param>
        /// <param name="oldPos">Creature's old position.</param>
        /// <param name="newPos">Creature's new position.</param>
        /// <param name="oldStackpos">Creature's old stack position.</param>
        /// <param name="newStackpos">Creature's new stack position.</param>
        public override void AddCreatureMove(Direction direction, Creature creature,
            Position oldPos, Position newPos, byte oldStackpos, byte newStackpos)
        {
            RemoveThing(oldPos, oldStackpos);

            UpdateThingHeaders(newPos, UpdateThing.ADD, newStackpos);

            AddCreatureDirection(direction, creature.GetID());
        }
示例#16
0
 public override void UpdateCreatureHealth(Creature creature)
 {
     netmsg.AddByte(0x8C);
     netmsg.AddU32(creature.GetID());
     netmsg.AddByte(creature.GetHealthPercentage());
 }
示例#17
0
        /// <summary>
        /// Have a creature set its target that it will be attacking.
        /// </summary>
        /// <param name="creature">The creature attacking.</param>
        /// <param name="target">The creature who is being attacked.</param>
        public virtual void HandleCreatureTarget(Creature creature, Creature target)
        {
            if (target == null) {
                throw new Exception("Target is null in HandleCreatureTarget()");
            }

            HandleCreatureTarget(creature, target.GetID());
        }
示例#18
0
 /// <summary>
 /// Adds the headers for updating a creature.
 /// </summary>
 /// <param name="c">The creature to update.</param>
 /// <param name="type">The type of update being done.</param>
 private void UpdateCreatureHeaders(Creature creature, UpdateCreature type)
 {
     netmsg.AddU16(0x32); //Update header
     netmsg.AddU32(creature.GetID());
     netmsg.AddByte((byte)type);
 }
示例#19
0
 /// <summary>
 /// Removes the creature from the game world and only
 /// appends the data to the ThingSet without reseting or sending it.
 /// </summary>
 /// <param name="creature">The creature to remove.</param>
 /// <param name="tSet">A reference for which things to notify of the
 /// creature's removal.</param>
 private void AppendRemoveCreature(Creature creature)
 {
     creaturesOnline.Remove(creature.GetID());
     creature.LogedIn = false;
     byte stackpos = gameMap.GetStackPosition(creature, creature.CurrentPosition);
     ThingSet tSet = gameMap.GetThingsInVicinity(creature.CurrentPosition);
     foreach (Monster summon in creature.GetSummons()) {
         summon.SetMaster(null);
     }
     foreach (Thing thing in tSet.GetThings()) {
         thing.RemoveThing(creature.CurrentPosition, stackpos);
     }
     gameMap.RemoveThing(creature, creature.CurrentPosition);
 }
示例#20
0
 /// <summary>
 /// Update the creature's direction.
 /// </summary>
 /// <param name="creature">The creature whose direction to update.</param>
 /// <param name="direction">The new direction.</param>
 /// <param name="stackpos">The creature's stack position.</param>
 /// <param name="position">The creature's position.</param>
 public override void UpdateCreatureDirection(Creature creature,
                                              Direction direction, byte stackpos, Position position)
 {
     UpdateThingHeaders(position, UpdateThing.UPDATE, stackpos);
     AddCreatureDirection(direction, creature.GetID());
 }
示例#21
0
        /// <summary>
        /// Returns true if the specified creature is known, otherwise
        /// false and adds it to the known creatures queue.
        /// </summary>
        /// <param name="creature">Creature to test</param>
        /// <returns>True if known, false otherwise.</returns>
        public bool KnowsCreature(Creature creature)
        {
            if (knownCreatures.Contains(creature.GetID()))
                return true;

            if (knownCreatures.Count >= 128)
                knownCreatures.Dequeue();

            knownCreatures.Enqueue(creature.GetID());
            return false;
        }