Farcanox
New Member
Pls tell ur people to stop annoying realots.
i suggest you to go away,because noone here is carry about Realots
Pls tell ur people to stop annoying realots.
Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index,
uint32_t spriteId /*= 0*/, stackPosType_t type /*= STACKPOS_NORMAL*/)
{
if(pos.x != 0xFFFF){
Tile* tile = getTile(pos.x, pos.y, pos.z);
if(tile){
/*look at*/
if(type == STACKPOS_LOOK){
return tile->getTopThing();
}
Thing* thing = NULL;
/*for move operations*/
if(type == STACKPOS_MOVE){
Item* item = tile->getTopDownItem();
if(item && !item->isNotMoveable())
thing = item;
else
thing = tile->getTopCreature();
}
/*use item*/
else if(type == STACKPOS_USE){
thing = tile->getTopDownItem();
}
else if(type == STACKPOS_USEITEM){
//First check items with topOrder 2 (ladders, signs, splashes)
Item* item = tile->getItemByTopOrder(0);
if(item && g_actions->hasAction(item)){
thing = item;
}
else{
//then down items
thing = tile->getTopDownItem();
if(thing == NULL){
//then last we check items with topOrder 3 (doors etc)
thing = tile->getTopTopItem();
}
}
}
else{
thing = tile->__getThing(index);
}
if(player){
//do extra checks here if the thing is accessable
if(thing && thing->getItem()){
if(tile->hasProperty(ISVERTICAL)){
if(player->getPosition().x + 1 == tile->getPosition().x){
thing = NULL;
}
}
else if(tile->hasProperty(ISHORIZONTAL)){
if(player->getPosition().y + 1 == tile->getPosition().y){
thing = NULL;
}
}
}
}
return thing;
}
}
else{
//container
if(pos.y & 0x40){
uint8_t fromCid = pos.y & 0x0F;
uint8_t slot = pos.z;
Container* parentcontainer = player->getContainer(fromCid);
if(!parentcontainer)
return NULL;
return parentcontainer->getItem(slot);
}
else if(pos.y == 0 && pos.z == 0){
const ItemType& it = Item::items.getItemIdByClientId(spriteId);
if(it.id == 0){
return NULL;
}
int32_t subType = -1;
if(it.isFluidContainer()){
int32_t maxFluidType = sizeof(reverseFluidMap) / sizeof(uint32_t);
if(index < maxFluidType){
subType = reverseFluidMap[index];
}
}
return findItemOfType(player, it.id, true, subType);
}
//inventory
else{
slots_t slot = (slots_t)static_cast<unsigned char>(pos.y);
return player->getInventoryItem(slot);
}
}
return NULL;
}
ReturnValue Game::internalMoveCreature(Creature* creature, Direction direction, uint32_t flags /*= 0*/)
{
Cylinder* fromTile = creature->getTile();
Cylinder* toTile = NULL;
const Position& currentPos = creature->getPosition();
Position destPos = currentPos;
bool canChangeFloor = true;
switch(direction){
case NORTH:
destPos.y -= 1;
break;
case SOUTH:
destPos.y += 1;
break;
case WEST:
destPos.x -= 1;
break;
case EAST:
destPos.x += 1;
break;
case SOUTHWEST:
destPos.x -= 1;
destPos.y += 1;
canChangeFloor = false;
break;
case NORTHWEST:
destPos.x -= 1;
destPos.y -= 1;
canChangeFloor = false;
break;
case NORTHEAST:
destPos.x += 1;
destPos.y -= 1;
canChangeFloor = false;
break;
case SOUTHEAST:
destPos.x += 1;
destPos.y += 1;
canChangeFloor = false;
break;
}
if(creature->getPlayer() && canChangeFloor){
//try go up
if(currentPos.z != 8 && creature->getTile()->hasHeight(3)){
Tile* tmpTile = map->getTile(currentPos.x, currentPos.y, currentPos.z - 1);
if(tmpTile == NULL || (tmpTile->ground == NULL && !tmpTile->hasProperty(BLOCKSOLID))){
tmpTile = map->getTile(destPos.x, destPos.y, destPos.z - 1);
if(tmpTile && tmpTile->ground && !tmpTile->hasProperty(BLOCKSOLID)){
flags = flags | FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE;
destPos.z -= 1;
}
}
}
else{
//try go down
Tile* tmpTile = map->getTile(destPos);
if(currentPos.z != 7 && (tmpTile == NULL || (tmpTile->ground == NULL && !tmpTile->hasProperty(BLOCKSOLID)))){
tmpTile = map->getTile(destPos.x, destPos.y, destPos.z + 1);
if(tmpTile && tmpTile->hasHeight(3)){
flags = flags | FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE;
destPos.z += 1;
}
}
}
}
toTile = map->getTile(destPos);
Tile* toPos = getTile(destPos.x, destPos.y, destPos.z);
Tile* fromPos = getTile(currentPos.x, currentPos.y, currentPos.z);
ReturnValue ret = RET_NOTPOSSIBLE;
if(toTile != NULL){
if (currentPos.z > destPos.z && toPos->getHeight() > 1);
// not possible
else if ((((toPos->getHeight() - fromPos->getHeight()) < 2)) ||
(fromPos->hasHeight(3) && (currentPos.z == destPos.z)) ||
((currentPos.z < destPos.z) && (toPos->hasHeight(3) && (fromPos->getHeight() < 2))))
ret = internalMoveCreature(creature, fromTile, toTile, flags);
}
if(ret != RET_NOERROR){
if(Player* player = creature->getPlayer()){
player->sendCancelMessage(ret);
player->sendCancelWalk();
}
}
return ret;
}
uint32_t Tile::getHeight() const
int32_t Tile::getHeight() const
uint32_t getHeight() const;
int32_t getHeight() const;