Pastebin

New Paste · Browse · Stats

Latest Pastes

walk


/* $Id: Walk.cpp 182 2010-01-08 10:35:27Z sausage $
 * EOSERV is released under the zlib license.
 * See LICENSE.txt for more info.
 */

#include "handlers.h"
#include "map.hpp"
#include "npc.hpp"

CLIENT_F_FUNC(Walk)
{
    PacketBuilder reply;

    switch (action)
    {
        case PACKET_ADMIN: // Player walking (admin)
        {
            if (this->state < EOClient::Playing) return false;

            if (this->player->character->admin < ADMIN_GUARDIAN)
            {
                return false;
            }
        }
        // no break

        case PACKET_PLAYER: // Player walking (normal)
        case PACKET_SPEC: // Player walking (ghost)
        {
            if (this->state < EOClient::Playing) return false;
            //CLIENT_QUEUE_ACTION(0.46)

            Direction direction = static_cast<Direction>(reader.GetChar());
            /*int timestamp = */reader.GetThree();
            unsigned char x = reader.GetChar();
            unsigned char y = reader.GetChar();

            if (this->player->character->sitting != SIT_STAND)
            {
                return true;
            }

            if (direction >= 0 && direction <= 3)
            {

                if (action == PACKET_ADMIN)
                {
                    this->player->character->AdminWalk(direction);
                    this->player->character->AdminWalk(direction);//remove this for non speed
                    this->player->character->AdminWalk(direction);//remove this for non speed
                }
                else
                {
                    this->player->character->npc = 0;
                    this->player->character->npc_type = ENF::NPC;
                    this->player->character->board = 0;
                    this->player->character->jukebox_open = false;
                    if (!this->player->character->Walk(direction))
                    {
                        return true;
                    }
                }
            }

            if (this->player->character)
	      {
           int target_x = this->player->character->x;
           int target_y = this->player->character->y;

	       switch (this->player->character->direction)
	        {
		     case DIRECTION_UP:
			 target_y -= 1;
			 break;

		    case DIRECTION_RIGHT:
			target_x += 1;
			break;

		    case DIRECTION_DOWN:
			target_y += 1;
			break;

		    case DIRECTION_LEFT:
			target_x -= 1;
			break;
	    }
            if (this->player->character->map->GetSpec(target_x, target_y) == Map_Tile::Unknown6 || (this->player->character->x == target_x && this->player->character->y == target_y))
         {
              this->player->character->deal = true;
              this->player->character->map->Msg(this->player->character," Would you like to play 21 if so type #deal cards If you want to try your luck at roulette type #bet red, black, even, or odd", true);
         }
      }


            if (this->player->character->x != x || this->player->character->y != y)
            {
                this->player->character->Refresh();
            }

        }
        break;

        default:
            return false;
    }

    return true;
}