void Being::setSubtype(Uint16 subtype) { if (subtype == mSubType) return; mSubType = subtype; if (getType() == MONSTER) { mInfo = MonsterDB::get(mSubType); setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay()); } else if (getType() == NPC) { mInfo = NPCDB::get(mSubType); setupSpriteDisplay(mInfo->getDisplay(), false); } else if (getType() == PLAYER) { int id = -100 - subtype; // Prevent showing errors when sprite doesn't exist if (!itemDb->exists(id)) id = -100; setSprite(Net::getCharHandler()->baseSprite(), id); } }
void FloorItem::postInit(Map *const map, int subX, int subY) { setMap(map); const ItemInfo &info = ItemDB::get(mItemId); if (map) { const int max = info.getMaxFloorOffset(); if (subX > max) subX = max; else if (subX < -max) subX = -max; if (subY > max) subY = max; else if (subY < -max) subY = -max; mPos.x = static_cast<float>(mX * map->getTileWidth() + subX + mapTileSize / 2 - 8); mPos.y = static_cast<float>(mY * map->getTileHeight() + subY + mapTileSize - 8); } else { mPos.x = 0; mPos.y = 0; } mCursor = info.getPickupCursor(); setupSpriteDisplay(info.getDisplay(), true, 1, info.getDyeColorsString(mColor)); mYDiff = 31; }
void FloorItem::postInit(Map *const map, int subX, int subY) { setMap(map); const ItemInfo &info = ItemDB::get(mItemId); if (map) { const int maxX = info.getMaxFloorOffsetX(); const int maxY = info.getMaxFloorOffsetY(); if (!serverFeatures->haveExtendedDropsPosition()) { if (subX > maxX) subX = maxX; else if (subX < -maxX) subX = -maxX; if (subY > maxY) subY = maxY; else if (subY < -maxY) subY = -maxY; subX -= 8; subY -= 8; } mHeightPosDiff = map->getHeightOffset(mX, mY) * 16; mPixelX = mX * map->getTileWidth() + subX + mapTileSize / 2; mPixelY = mY * map->getTileHeight() + subY + mapTileSize - mHeightPosDiff; mPos.x = static_cast<float>(mPixelX); mPos.y = static_cast<float>(mPixelY); mYDiff = 31 - mHeightPosDiff; } else { mPixelX = 0; mPixelY = 0; mPos.x = 0; mPos.y = 0; mYDiff = 31; } mCursor = info.getPickupCursor(); setupSpriteDisplay(info.getDisplay(), ForceDisplay_true, 1, info.getDyeIconColorsString(mColor)); }
FloorItem::FloorItem(int id, int itemId, const Vector &position, Map *map): ActorSprite(id), mItemId(itemId), mX(0), mY(0) { mPos = position; setMap(map); mX = (int)position.x / map->getTileWidth(); mY = (int)position.y / map->getTileHeight(); setupSpriteDisplay(itemDb->get(itemId).getDisplay()); }
void NPC::setSubtype(Uint16 subtype) { Being::setSubtype(subtype); setupSpriteDisplay(NPCDB::get(subtype), false); }