예제 #1
0
    public static void Handle(ReceivablePacket packet)
    {
        switch (packet.ReadShort())
        {
        case 1:
            AccountAuthenticationResult.Process(packet);
            break;

        case 2:
            CharacterSelectionInfoResult.Process(packet);
            break;

        case 3:
            CharacterCreationResult.Process(packet);
            break;

        case 4:
            CharacterDeletionResult.Process(packet);
            break;

        case 5:
            PlayerOptionsInformation.Process(packet);
            break;

        case 6:
            PlayerInformation.Process(packet);
            break;

        case 7:
            NpcInformation.Process(packet);
            break;

        case 8:
            DeleteObject.Process(packet);
            break;

        case 9:
            Logout.Process(packet);
            break;

        case 10:
            LocationUpdate.Process(packet);
            break;

        case 11:
            AnimatorUpdate.Process(packet);
            break;

        case 12:
            ChatResult.Process(packet);
            break;

        case 13:
            PlayerInventoryUpdate.Process(packet);
            break;
        }
    }
    public static void Handle(Player player, string command)
    {
        // Gather information from parameters.
        string[] commandSplit = command.Split(' ');
        int      npcId;

        if (commandSplit.Length > 1)
        {
            npcId = int.Parse(commandSplit[1]);
        }
        else
        {
            ChatManager.SendSystemMessage(player, "Proper syntax is /spawn npcId delaySeconds(optional).");
            return;
        }
        int respawnDelay = 60;

        if (commandSplit.Length > 2)
        {
            respawnDelay = int.Parse(commandSplit[2]);
        }

        // Log admin activity.
        LocationHolder playerLocation = player.GetLocation();
        LocationHolder npcLocation    = new LocationHolder(playerLocation.GetX(), playerLocation.GetY(), playerLocation.GetZ(), playerLocation.GetHeading());

        if (Config.LOG_ADMIN)
        {
            LogManager.LogAdmin(player.GetName() + " used command /spawn " + npcId + " " + respawnDelay + " at " + npcLocation);
        }

        // Spawn NPC.
        Npc npc = SpawnData.SpawnNpc(npcId, npcLocation, respawnDelay);

        // Broadcast NPC information.
        NpcInformation info = new NpcInformation(npc);

        player.ChannelSend(info);
        foreach (Player nearby in WorldManager.GetVisiblePlayers(player))
        {
            nearby.ChannelSend(info);
        }

        // Send player success message.
        ChatManager.SendSystemMessage(player, "You have spawned " + npcId + " at " + npcLocation);

        // Store in database.
        try
        {
            MySqlConnection con = DatabaseManager.GetConnection();
            MySqlCommand    cmd = new MySqlCommand(SPAWN_SAVE_QUERY, con);
            cmd.Parameters.AddWithValue("npc_id", npcId);
            cmd.Parameters.AddWithValue("x", npcLocation.GetX());
            cmd.Parameters.AddWithValue("y", npcLocation.GetY());
            cmd.Parameters.AddWithValue("z", npcLocation.GetZ());
            cmd.Parameters.AddWithValue("heading", npcLocation.GetHeading());
            cmd.Parameters.AddWithValue("respawn_delay", respawnDelay);
            cmd.ExecuteNonQuery();
            con.Close();
        }
        catch (Exception e)
        {
            LogManager.Log(e.ToString());
        }
    }
예제 #3
0
 public NPC(NpcInformation information, Vector2 position)
     : base(new AnimatedSprite(information.Texture, 0, Game1.tileSize / 4, Game1.tileSize * 2 / 4), position, information.DefaultMap, (int)information.DefaultFacingDirection, information.Name, information.IsDatable, null, information.Portrait)
 {
     Information = information;
 }