Exemple #1
0
 public Entity(Map.Nod start, Map.Spawn pSpawn, byte type, int id)
 {
     this.mySpawn    = pSpawn;
     this.myNode     = start;
     this.entityType = type;
     this.uniqueID   = id;
 }
Exemple #2
0
 //skill but on place
 public Action(ActiveSkill actSkill, Skill skill, Database.Entity attacker, Map.Nod pos)
 {
     this.skill    = skill;
     this.actSkill = actSkill;
     this.attacker = attacker;
     this.position = pos;
 }
Exemple #3
0
 public Entity(Map.Nod start, Map.Spawn pSpawn, byte type)
 {
     this.mySpawn    = pSpawn;
     this.myNode     = start;
     this.entityType = type;
     this.uniqueID   = Interlocked.Increment(ref nextID);
 }
Exemple #4
0
 public Mob(Map.Nod start, Map.Spawn pSpawn, byte type) : base(start, pSpawn, type)
 {
     Map.Nod nod = GameServer.world.GetPositionAtTile(start.X, start.Y);
     PosX      = (int)nod.X;
     PosY      = (int)nod.Y;
     cSM       = new CoreStateMachine();
     ActHealth = 1000;
 }
Exemple #5
0
 public GameEntity(Map.Nod start, Map.Spawn spawn)
     : base(start, spawn)
 {
     //this.uniqueID = World.GetID();
     this.charPosition    = new Map.Nod();
     this.charStats       = new Stats();
     this.charResistances = new Resistances();
 }
Exemple #6
0
 //skill
 public Action(ActiveSkill actSkill, Skill skill, Database.Entity attacker, int target)
 {
     this.skill    = skill;
     this.actSkill = actSkill;
     this.attacker = attacker;
     this.targetID = target;
     this.position = new Map.Nod();
 }
Exemple #7
0
 public Entity(Map.Nod start, Map.Spawn pSpawn, byte type)
 {
     this.mySpawn = pSpawn;
     this.myNode  = start;
     if (myNode != null)
     {
         this.oldNode = new Map.Nod(myNode.X, myNode.Y);
     }
     else
     {
         this.oldNode = new Map.Nod(0, 0);
     }
     this.entityType = type;
     this.uniqueID   = Interlocked.Increment(ref nextID);
 }
Exemple #8
0
 public Entity(Map.Nod start, Map.Spawn pSpawn, byte type, int id)
 {
     this.mySpawn = pSpawn;
     this.myNode  = start;
     if (myNode != null)
     {
         this.oldNode = new Map.Nod(myNode.X, myNode.Y);
     }
     else
     {
         this.oldNode = new Map.Nod(0, 0);
     }
     this.entityType = type;
     this.uniqueID   = id;
 }
Exemple #9
0
 public void StopMove()
 {
     moving = false;
     state  = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MoveStop(PlayerPID, PosX, PosY));
     newX   = newY = 0;
     Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
     if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
     {
         MapPosition.X = curNod.X;
         MapPosition.Y = curNod.Y;
         GameServer.world.MovePlayerOnMap(this, OldMapPosition, MapPosition);
         OldMapPosition.X = curNod.X;
         OldMapPosition.Y = curNod.Y;
     }
     sw.Stop();
 }
Exemple #10
0
        public static void MoveStart(Connection pConn, byte[] data)
        {
            int id = BitConverter.ToInt32(data, Program.receivePrefixLength);
            int x  = BitConverter.ToInt32(data, Program.receivePrefixLength + 4);
            int y  = BitConverter.ToInt32(data, Program.receivePrefixLength + 4 + 4);

            if (Program.DEBUG_recv)
            {
                Output.WriteLine("RecvPacketHandlers::MoveStart");
            }
            pConn.client.GetPlayer().newX           = x;
            pConn.client.GetPlayer().newY           = y;
            pConn.client.GetPlayer().isCastingSkill = false;
            if (Program.DEBUG_recv)
            {
                Map.Nod myNod = GameServer.world.GetTileAddress((uint)x, (uint)y);
                Output.WriteLine("Recv player start move to [" + x.ToString() + "," + y.ToString() + "] MAP [" + myNod.X.ToString() + "," + myNod.Y.ToString() + "]");
            }
            GameServerMainLoop.noSleep = true;
        }
Exemple #11
0
        private void Goto()
        {
            float elapsed = sw.ElapsedMilliseconds / 1000f;

            sw.Restart();
            if (Con != null && newX != 0 && newY != 0)
            {
                if ((newX != PosX) || (newY != PosY))
                {
                    if (moveTarget.X != newX || moveTarget.Y != newY)
                    {
                        moveTarget.X = newX;
                        moveTarget.Y = newY;
                        // On starting movement
                        //Output.WriteLine("MOVING TO : [" + newX.ToString() + "," + newY.ToString() + ",0]");
                        distance = (float)(Math.Sqrt(Math.Pow(newX - PosX, 2) + Math.Pow(newY - PosY, 2)));
                        //Output.WriteLine("Distance: " + distance.ToString());
                        directionX = (float)(newX - PosX) / distance;
                        directionY = (float)(newY - PosY) / distance;
                        mX         = PosX;
                        mY         = PosY;
                        startX     = mX;
                        startY     = mY;
                        tstartX    = mX;
                        tstartY    = mY;
                        moving     = true;
                        //pl.Con.Send(new Packet.SendPacketHandlers.MoveStart(pl.PlayerPID, pl.newX, pl.newY));// send to client info that server start moving avatar
                        //con.Player.StartMove(con.newX, con.newY, 0);// -> send to all info about move start...
                        //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MoveStart(PlayerPID, newX, newY));
                        state = new AI.EntityState.StartMove(PosX, PosY, new Packet.SendPacketHandlers.MoveStart(PlayerPID, newX, newY));
                        sw.Restart();
                        elapsed = 0;
                        return;
                    }
                    // On update
                    if (moving)
                    {
                        mX       = directionX * speed * elapsed;
                        mY       = directionY * speed * elapsed;
                        tstartX += mX;
                        tstartY += mY;
                        tmX      = (int)(tstartX * 1000);
                        tmY      = (int)(tstartY * 1000);
                        //Output.WriteLine("speed " + speed.ToString() + " elapsed " + elapsed.ToString());
                        //Output.WriteLine("mx,my [" + mX.ToString() + ":" + mY.ToString() + "] tstart [" + tstartX.ToString() + ":" + tstartY.ToString() + "]");
                        float tmpDistance = (float)(Math.Sqrt(Math.Pow(tstartX - startX, 2) + Math.Pow(tstartY - startY, 2)));
                        //Output.WriteLine("tmpDistance: " + tmpDistance.ToString());
                        if (tmpDistance >= distance)
                        {
                            PosX   = newX;
                            PosY   = newY;
                            moving = false;
                            //pl.Con.Send(new Packet.SendPacketHandlers.MoveStop(pl.PlayerPID, pl.tmX, pl.tmY));//send stop packet to user
                            //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MoveStop(PlayerPID, tmX, tmY));
                            state = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MoveStop(PlayerPID, PosX, PosY));
                            newX  = newY = 0;
                            //Output.WriteLine(":1 MOV STOP [" + PosX.ToString() + "," + PosY.ToString() + "]");
                            Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                            if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                            {
                                //player moved to new map tile
                                MapPosition.X = curNod.X;
                                MapPosition.Y = curNod.Y;
                                GameServer.world.MovePlayerOnMap(this, OldMapPosition, MapPosition);
                                OldMapPosition.X = curNod.X;
                                OldMapPosition.Y = curNod.Y;
                            }
                            sw.Stop();
                        }
                        else
                        {
                            if (PosX == newX && PosY == newY)
                            {
                                moving = false;
                                //pl.Con.Send(new Packet.SendPacketHandlers.MoveStop(pl.PlayerPID, pl.tmX, pl.tmY));
                                //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MoveStop(PlayerPID, tmX, tmY));
                                state = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MoveStop(PlayerPID, PosX, PosY));
                                newX  = newY = 0;
                                //Output.WriteLine(":2 MOV STOP : [" + PosX.ToString() + "," + PosY.ToString() + "]");
                                Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                                if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                                {
                                    //player moved to new map tile
                                    MapPosition.X = curNod.X;
                                    MapPosition.Y = curNod.Y;
                                    GameServer.world.MovePlayerOnMap(this, OldMapPosition, MapPosition);
                                    OldMapPosition.X = curNod.X;
                                    OldMapPosition.Y = curNod.Y;
                                }
                                sw.Stop();
                                return;
                            }
                            //Output.WriteLine("[" + mX.ToString() +"," + mY.ToString() + "] to [" + tstartX.ToString() + "," + tstartY.ToString() + "]");
                            //Con.Send(new Packet.SendPacketHandlers.Move(PlayerPID, tmX, tmY));
                            //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.Move(PlayerPID, tmX, tmY));
                            //state = new AI.EntityState.Move(PosX, PosY, new Packet.SendPacketHandlers.Move(PlayerPID, tmX, tmY));
                            //Output.WriteLine("MOV [" + tmX.ToString() + "," + tmY.ToString() + "]");
                            int bX = (int)tstartX - PosX;
                            int bY = (int)tstartY - PosY;
                            if (bX != 0 || bY != 0)
                            {
                                //con.Player.Move(bX, bY, 0);//update player position in sever
                                //for test we do it here....
                                // update the own position
                                PosX += bX;
                                PosY += bY;
                                PosZ += 0;
                                Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                                if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                                {
                                    //player moved to new map tile
                                    MapPosition.X = curNod.X;
                                    MapPosition.Y = curNod.Y;
                                    GameServer.world.MovePlayerOnMap(this, OldMapPosition, MapPosition);
                                    OldMapPosition.X = curNod.X;
                                    OldMapPosition.Y = curNod.Y;
                                }
                            }
                        }
                    }
                }
                else
                {
                    moving = false;
                    //pl.Con.Send(new Packet.SendPacketHandlers.MoveStop(pl.PlayerPID, pl.tmX, pl.tmY));
                    //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MoveStop(PlayerPID, tmX, tmY));
                    state = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MoveStop(PlayerPID, PosX, PosY));
                    newX  = newY = 0;
                    //Output.WriteLine(":2 MOV STOP : [" + PosX.ToString() + "," + PosY.ToString() + "]");
                    Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                    if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                    {
                        //player moved to new map tile
                        MapPosition.X = curNod.X;
                        MapPosition.Y = curNod.Y;
                        GameServer.world.MovePlayerOnMap(this, OldMapPosition, MapPosition);
                        OldMapPosition.X = curNod.X;
                        OldMapPosition.Y = curNod.Y;
                    }
                    sw.Stop();
                    return;
                }
            }
        }
Exemple #12
0
 public Player(Connection connection, Map.Nod startNod) : base(startNod, null, 0, connection.client.PlayerID)
 {
     con        = connection;
     PlayerPID  = con.client.PlayerID;
     moveTarget = new GameServerMainLoop.Vector3();
 }
Exemple #13
0
        public static void SkillExecute(int skillID, Database.Player.RACE race, Database.Player pAttacker, int targetID = 0, Map.Nod position = null)
        {
            if (!pAttacker.isCastingSkill || pAttacker.currentCastingSkillID != skillID)
            {
                Output.WriteLine("SkillHandler::SkillExecute " + " Try to cast skill but isCastingSkill is FALSE or skill ID missmatch");
                return; // if no Skillrequest executed or player break the skill execute then return
            }
            Skill skill = null;
            Dictionary <int, Skill> dict = null;
            ActiveSkill             activeSkill;

            if (!pAttacker.activeSkillList.TryGetValue(skillID, out activeSkill))
            {
                throw new KeyNotFoundException();
            }
            try
            {
                switch (race)
                {
                case Database.Player.RACE.KNIGHT:
                    dict = knightSkillList;
                    break;

                case Database.Player.RACE.MAGE:
                    dict = mageSkillList;
                    break;

                case Database.Player.RACE.ARCHER:
                    dict = archerSkillList;
                    break;

                default:
                    throw new NullReferenceException();
                    break;
                }
                skill = dict[skillID];
            }
            catch (KeyNotFoundException e)
            {
                Output.WriteLine("SkillHandler::SkillExecute " + "Someone tried to execute a skill for that no handler exists. " + e.Source.ToString() + " : " + e.TargetSite.ToString());
            }
            catch (NullReferenceException)
            {
                // Should never ever happen -.-
                Output.WriteLine("SkillHandler::SkillExecute " + "Someone tried to request a skill for an unknown race!");
            }
            if (activeSkill.ElapsedCast() > 0 && activeSkill.ElapsedCast() < skill.castTime)
            {
                Output.WriteLine(ConsoleColor.Red, "SkillHandler::SkillExecute - can't cast skill (still in cast time)");
                Output.WriteLine(ConsoleColor.Red, "SkillHandler::SkillExecute cast time: " + activeSkill.ElapsedCast().ToString());
                return;
            }
            Output.WriteLine(ConsoleColor.DarkGreen, "SkillHandler::SkillExecute cast time: " + activeSkill.ElapsedCast().ToString());
            //this is place where we do actions for execution the skill
            Output.WriteLine("SkillExecute: " + skill.name);
            Output.WriteLine("cast time: " + skill.castTime);
            Output.WriteLine("cool down: " + skill.coolDown);
            Output.WriteLine("info: " + skill.info);
            Output.WriteLine("lvl: " + skill.lvl);
            Output.WriteLine("mana cost: " + skill.manaCost);
            Output.WriteLine("race: " + skill.race);
            Output.WriteLine("range: " + skill.range);
            activeSkill.StartCoolDown();
            activeSkill.startCast           = DateTime.UtcNow;
            pAttacker.isCastingSkill        = false;
            pAttacker.currentCastingSkillID = -1;
            //BroadcastPacket bPacket = new BroadcastPacket((uint)pAttacker.PosX, (uint)pAttacker.PosY, (int)World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.AttackMag(pAttacker.PlayerPID, targetID, activeSkill.skillID, activeSkill.skillLvl));
            //GameServer.world.broadcastQueue.Enqueue(bPacket);
            switch (skill.demageFlag)
            {
            //skills that need to give target entity
            case SKILL_DEMAGE_FLAG.SINGLE_TARGET_FLAG:
            case SKILL_DEMAGE_FLAG.MULTI_TARGET_FLAG:
            {
                Action act = new Action(activeSkill, skill, pAttacker, targetID);
                GameServer.world.actions.Enqueue(act);
                Output.WriteLine("Skill enqueue as target skill");
            }
            break;

            //skills that are place related not target entity
            case SKILL_DEMAGE_FLAG.POSITION_TARGET_FLAG:
            case SKILL_DEMAGE_FLAG.CON_45_FLAG:
            case SKILL_DEMAGE_FLAG.CON_90_FLAG:
            case SKILL_DEMAGE_FLAG.AOE_TARGET_FLAG:
            {
                Action act = new Action(activeSkill, skill, pAttacker, position);
                GameServer.world.actions.Enqueue(act);
                Output.WriteLine("Skill enqueue as position skill");
            }
            break;

            default:
                Output.WriteLine("Skill has inncorrect DEMAGE FLAG SET");
                break;
            }
        }
Exemple #14
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         *
         * Here we go. Let's define the functions that get called whenever a skill is executed.
         * This is the place where you wanna start to create your own custom skills. Perhaps some
         * kind of scripting support will be added in the far future.
         *
         */
        public static void SkillRequest(int skillID, Database.Player.RACE race, Database.Player pAttacker, int targetID = 0, Map.Nod position = null)
        {
            Skill skill = null;
            Dictionary <int, Skill> dict = null;
            ActiveSkill             activeSkill;

            if (!pAttacker.activeSkillList.TryGetValue(skillID, out activeSkill))
            {
                throw new KeyNotFoundException();
            }
            try
            {
                switch (race)
                {
                case Database.Player.RACE.KNIGHT:
                    dict = knightSkillList;
                    break;

                case Database.Player.RACE.MAGE:
                    dict = mageSkillList;
                    break;

                case Database.Player.RACE.ARCHER:
                    dict = archerSkillList;
                    break;

                default:
                    throw new NullReferenceException();
                    break;
                }
                skill = dict[skillID];
            }
            catch (KeyNotFoundException e)
            {
                Output.WriteLine("SkillHandler::GetSkillExecuteHandler " + "Someone tried to execute a skill for that no handler exists. " + e.Source.ToString() + " : " + e.TargetSite.ToString());
            }
            catch (NullReferenceException)
            {
                // Should never ever happen -.-
                Output.WriteLine("SkillHandler::GetSkillExecuteHandler " + "Someone tried to request a skill for an unknown race!");
            }
            //This is place where we do actions for requested skill
            Output.WriteLine("SkillRequest: " + skill.name);
            if (activeSkill.ElapsedCoolDown() > 0 && activeSkill.ElapsedCoolDown() < skill.coolDown)
            {
                Output.WriteLine(ConsoleColor.Red, "SkillHandler::SkillRequest - can't cast skill (still on CoolDown)");
                Output.WriteLine(ConsoleColor.Red, "SkillHandler::SkillRequest CoolDown: " + activeSkill.ElapsedCoolDown().ToString());
                return;
            }
            Output.WriteLine(ConsoleColor.DarkGreen, "SkillHandler::SkillRequest CoolDown: " + activeSkill.ElapsedCoolDown().ToString());
            pAttacker.isCastingSkill        = true;
            pAttacker.currentCastingSkillID = skillID;
            activeSkill.StartCast();
            BroadcastPacket bPacket = new BroadcastPacket((uint)pAttacker.PosX, (uint)pAttacker.PosY, (int)World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.SkillAnim(pAttacker.PlayerPID, targetID, activeSkill.skillID, activeSkill.skillLvl));

            GameServer.world.broadcastQueue.Enqueue(bPacket);
        }
Exemple #15
0
        private void Goto()
        {
            if (Program.DEBUG_MOB_STOP)
            {
                if (currentState == EntityState.STATE.START_MOVE || currentState == EntityState.STATE.MOVE)
                {
                    state = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MobMoveStop(InternalID, PosX, PosY));
                }
                currentState = EntityState.STATE.STOP_MOVE;
                cSM.SetState = AI.CoreStateMachine.State.STAND;
                sw.Stop();
                return;
            }
            float elapsed = sw.ElapsedMilliseconds / 1000f;

            sw.Restart();
            if (newX != 0 && newY != 0)
            {
                if ((newX != PosX) || (newY != PosY))
                {
                    if (moveTarget.X != newX || moveTarget.Y != newY)
                    {
                        moveTarget.X = newX;
                        moveTarget.Y = newY;
                        // On starting movement
                        //Output.WriteLine("MOVING TO : [" + newX.ToString() + "," + newY.ToString() + ",0]");
                        distance = (float)(Math.Sqrt(Math.Pow(newX - PosX, 2) + Math.Pow(newY - PosY, 2)));
                        //Output.WriteLine("Distance: " + distance.ToString());
                        directionX = (float)(newX - PosX) / distance;
                        directionY = (float)(newY - PosY) / distance;
                        mX         = PosX;
                        mY         = PosY;
                        startX     = mX;
                        startY     = mY;
                        tstartX    = mX;
                        tstartY    = mY;
                        moving     = true;
                        //pl.Con.Send(new Packet.SendPacketHandlers.MoveStart(pl.PlayerPID, pl.newX, pl.newY));// send to client info that server start moving avatar
                        //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MobMoveStart(uniqueID, newX, newY));
                        currentState = EntityState.STATE.START_MOVE;
                        state        = new AI.EntityState.StartMove(PosX, PosY, new Packet.SendPacketHandlers.MobMoveStart(InternalID, newX, newY));
                        sw.Restart();
                        elapsed = 0;
                        return;
                    }
                    // On update
                    if (moving)
                    {
                        mX       = directionX * speed * elapsed;
                        mY       = directionY * speed * elapsed;
                        tstartX += mX;
                        tstartY += mY;
                        tmX      = (int)(tstartX * 1000);
                        tmY      = (int)(tstartY * 1000);
                        if (Math.Sqrt(Math.Pow(tstartX - startX, 2) + Math.Pow(tstartY - startY, 2)) >= distance)
                        {
                            PosX   = newX;
                            PosY   = newY;
                            moving = false;
                            //pl.Con.Send(new Packet.SendPacketHandlers.MoveStop(pl.PlayerPID, pl.tmX, pl.tmY));//send stop packet to user
                            //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MobMoveStop(uniqueID, tmX, tmY));
                            currentState = EntityState.STATE.STOP_MOVE;
                            state        = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MobMoveStop(InternalID, PosX, PosY));
                            newX         = newY = 0;
                            Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                            if (curNod == null)
                            {
                                curNod = GameServer.world.GetPositionAtTile(MapPosition.X, MapPosition.Y);
                                if (curNod == null)
                                {
                                    Output.WriteLine(ConsoleColor.Red, "Mob::Goto Nod null!");
                                    Despawn(null);
                                    return;
                                }
                                PosX = (int)curNod.X;
                                PosY = (int)curNod.Y;
                                Despawn(null);
                                return;
                            }
                            if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                            {
                                //player moved to new map tile
                                if (PosX > GameServer.world.WorldMaxX || PosX < GameServer.world.WorldMinX || PosY > GameServer.world.WorldMaxY || PosY < GameServer.world.WorldMinY)
                                {
                                    Despawn(null);
                                    return;
                                }
                                MapPosition.X = curNod.X;
                                MapPosition.Y = curNod.Y;
                                GameServer.world.MoveMobOnMap(this, OldMapPosition, MapPosition);
                                OldMapPosition.X = curNod.X;
                                OldMapPosition.Y = curNod.Y;
                            }
                            cSM.SetState = AI.CoreStateMachine.State.STAND;
                            sw.Stop();
                        }
                        else
                        {
                            if (PosX == newX && PosY == newY)
                            {
                                moving = false;
                                //pl.Con.Send(new Packet.SendPacketHandlers.MoveStop(pl.PlayerPID, pl.tmX, pl.tmY));
                                //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MobMoveStop(uniqueID, tmX, tmY));
                                currentState = EntityState.STATE.STOP_MOVE;
                                state        = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MobMoveStop(InternalID, PosX, PosY));
                                Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                                newX = newY = 0;
                                if (curNod == null)
                                {
                                    curNod = GameServer.world.GetPositionAtTile(MapPosition.X, MapPosition.Y);
                                    if (curNod == null)
                                    {
                                        Output.WriteLine(ConsoleColor.Red, "Mob::Goto Nod null!");
                                        Despawn(null);
                                        return;
                                    }
                                    Despawn(null);
                                    return;
                                }
                                if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                                {
                                    //player moved to new map tile
                                    if (PosX > GameServer.world.WorldMaxX || PosX < GameServer.world.WorldMinX || PosY > GameServer.world.WorldMaxY || PosY < GameServer.world.WorldMinY)
                                    {
                                        Despawn(null);
                                        return;
                                    }
                                    MapPosition.X = curNod.X;
                                    MapPosition.Y = curNod.Y;
                                    GameServer.world.MoveMobOnMap(this, OldMapPosition, MapPosition);
                                    OldMapPosition.X = curNod.X;
                                    OldMapPosition.Y = curNod.Y;
                                }
                                cSM.SetState = AI.CoreStateMachine.State.STAND;
                                sw.Stop();
                                return;
                            }
                            //Output.WriteLine("[" + mX.ToString() +"," + mY.ToString() + "] to [" + tstartX.ToString() + "," + tstartY.ToString() + "]");
                            //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MobMove(uniqueID, tmX, tmY));
                            currentState = EntityState.STATE.MOVE;
                            state        = new AI.EntityState.Move(PosX, PosY, null);//new AI.EntityState.Move(PosX, PosY, new Packet.SendPacketHandlers.MobMove(InternalID, tmX, tmY));
                            int bX = (int)tstartX - PosX;
                            int bY = (int)tstartY - PosY;
                            if (bX != 0 || bY != 0)
                            {
                                // update the own position
                                PosX += bX;
                                PosY += bY;
                                PosZ += 0;
                                Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                                if (curNod == null)
                                {
                                    curNod = GameServer.world.GetPositionAtTile(MapPosition.X, MapPosition.Y);
                                    if (curNod == null)
                                    {
                                        Output.WriteLine(ConsoleColor.Red, "Mob::Goto Nod null!");
                                        Despawn(null);
                                        return;
                                    }
                                    Despawn(null);
                                    return;
                                }
                                if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                                {
                                    //player moved to new map tile
                                    if (PosX > GameServer.world.WorldMaxX || PosX < GameServer.world.WorldMinX || PosY > GameServer.world.WorldMaxY || PosY < GameServer.world.WorldMinY)
                                    {
                                        Despawn(null);
                                        return;
                                    }
                                    MapPosition.X = curNod.X;
                                    MapPosition.Y = curNod.Y;
                                    GameServer.world.MoveMobOnMap(this, OldMapPosition, MapPosition);
                                    OldMapPosition.X = curNod.X;
                                    OldMapPosition.Y = curNod.Y;
                                }
                            }
                        }
                    }
                }
                else
                {
                    moving = false;
                    //pl.Con.Send(new Packet.SendPacketHandlers.MoveStop(pl.PlayerPID, pl.tmX, pl.tmY));
                    //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MobMoveStop(uniqueID, tmX, tmY));
                    currentState = EntityState.STATE.STOP_MOVE;
                    state        = new AI.EntityState.StopMove(PosX, PosY, new Packet.SendPacketHandlers.MobMoveStop(InternalID, PosX, PosY));
                    Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                    newX = newY = 0;
                    if (curNod == null)
                    {
                        curNod = GameServer.world.GetPositionAtTile(MapPosition.X, MapPosition.Y);
                        if (curNod == null)
                        {
                            Output.WriteLine(ConsoleColor.Red, "Mob::Goto Nod null!");
                            Despawn(null);
                            return;
                        }
                        Despawn(null);
                        return;
                    }
                    if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                    {
                        //player moved to new map tile
                        if (PosX > GameServer.world.WorldMaxX || PosX < GameServer.world.WorldMinX || PosY > GameServer.world.WorldMaxY || PosY < GameServer.world.WorldMinY)
                        {
                            Despawn(null);
                            return;
                        }
                        MapPosition.X = curNod.X;
                        MapPosition.Y = curNod.Y;
                        GameServer.world.MoveMobOnMap(this, OldMapPosition, MapPosition);
                        OldMapPosition.X = curNod.X;
                        OldMapPosition.Y = curNod.Y;
                    }
                    cSM.SetState = AI.CoreStateMachine.State.STAND;
                    sw.Stop();
                    return;
                }
            }
        }
Exemple #16
0
 //physicall attack
 public Action(Database.Entity attacker, int target)
 {
     this.attacker = attacker;
     this.targetID = target;
     this.position = new Map.Nod();
 }
Exemple #17
0
 public Player(Connection connection, Map.Nod start) : base(start, null, 0, connection.client.PlayerID)
 {
     this.con = connection;
 }
Exemple #18
0
 public Entity(Map.Nod start, Map.Spawn spawn)
 {
     this.start    = start;
     this.spawn    = spawn;
     this.uniqueID = Interlocked.Increment(ref nextID);
 }