Não recomendo usar isso para mapas grandes(acima de 30mb), recomando usar programas. porque dependendo o tamanho do mapa demora + para abrir o servidor, porque irá randomizar todos os tiles, mais como tem pessoas que gostam de randomizar pelo servidor aqui vai o code:
Em game.cpp adicione no final
short Game::checkItemGroundType(uint16_t itemid)
{
if(itemid >= 4608 && itemid <= 4625 || itemid >= 4664 && itemid <= 4666 || itemid == 4820)
return GROUND_WATER;
else if(itemid >= 708 && itemid <= 711)
return GROUND_TAR;
else if(itemid >= 4691 && itemid <= 4712 || itemid >= 4749 && itemid <= 4755 || itemid == 4758)
return GROUND_SWAMP;
else if(itemid >= 598 && itemid <= 601)
return GROUND_LAVA;
else
return 0;
}
short Game::checkItemGroundTypeRandomizer(uint16_t itemid)
{
if(itemid >= 4608 && itemid <= 4625 || itemid >= 4664 && itemid <= 4666)
return GROUND_WATER;
else if(itemid >= 708 && itemid <= 711)
return GROUND_TAR;
else if(itemid >= 4691 && itemid <= 4712 || itemid >= 4749 && itemid <= 4755 || itemid == 4758)
return GROUND_SWAMP;
else if(itemid >= 598 && itemid <= 601)
return GROUND_LAVA;
else if(itemid >= 4405 && itemid <= 4438)
return GROUND_MOUNTAIN1;
else if(itemid >= 4439 && itemid <= 4455)
return GROUND_MOUNTAIN2;
else if(itemid == 4566 || itemid >= 4570 && itemid <= 4579 || itemid == 4595)
return GROUND_ROCKS;
else if(itemid >= 4526 && itemid <= 4541 || itemid >= 4567 && itemid <= 4569 || itemid == 4756)
return GROUND_GRASS;
else if(itemid >= 5405 && itemid <= 5410)
return GROUND_UNDERWATER;
else
return 0;
}
Em game.h abaixo de:
void changeLight(const Creature* creature);
Adicione:
short checkItemGroundType(uint16_t itemid); short checkItemGroundTypeRandomizer(uint16_t itemid);
Vá para const79.h, abaixo de:
enum SquareColor_t {
SQ_COLOR_NONE = 256,
SQ_COLOR_BLACK = 0,
};
Adicione:
enum GroundType_t {
GROUND_WATER = 1,
GROUND_LAVA = 2,
GROUND_SWAMP = 3,
GROUND_TAR = 4,
GROUND_MOUNTAIN1 = 5,
GROUND_MOUNTAIN2 = 6,
GROUND_ROCKS = 7,
GROUND_GRASS = 8,
GROUND_UNDERWATER = 9,
};
Agora em iomapotbm.cpp abaixo de:
case OTBM_ATTR_ITEM:
{
Item* item = Item::CreateItem(propStream);
if(!item){
map->setLastError(LOADMAPERROR_FAILEDTOCREATEITEM, nodeTile);
return false;
}
Adicione:
if(g_config.getString(ConfigManager::RANDOMIZE_GROUND) == "yes" && g_game.checkItemGroundTypeRandomizer(item->getID()) != 0 && item->getActionId() == 0 && item->getUniqueId() == 0){
randomizeGround(item);
}
No final de iomapotbm.cpp adicione:
void IOMapOTBM::randomizeGround(Item* item)
{
uint16_t percent = 1;
GroundType_t type;
switch(g_game.checkItemGroundTypeRandomizer(item->getID())){
case GROUND_WATER:
if(g_config.getNumber(ConfigManager::WATER_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::WATER_PERCENT);
else
percent = 0;
type = GROUND_WATER;
break;
case GROUND_LAVA:
if(g_config.getNumber(ConfigManager::LAVA_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::LAVA_PERCENT);
else
percent = 0;
type = GROUND_LAVA;
break;
case GROUND_SWAMP:
if(g_config.getNumber(ConfigManager::SWAMP_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::SWAMP_PERCENT);
else
percent = 0;
type = GROUND_SWAMP;
break;
case GROUND_TAR:
if(g_config.getNumber(ConfigManager::TAR_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::TAR_PERCENT);
else
percent = 0;
type = GROUND_TAR;
break;
case GROUND_MOUNTAIN1:
if(g_config.getNumber(ConfigManager::MOUNTAIN_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::MOUNTAIN_PERCENT);
else
percent = 0;
type = GROUND_MOUNTAIN1;
break;
case GROUND_MOUNTAIN2:
if(g_config.getNumber(ConfigManager::MOUNTAIN_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::MOUNTAIN_PERCENT);
else
percent = 0;
type = GROUND_MOUNTAIN2;
break;
case GROUND_ROCKS:
if(g_config.getNumber(ConfigManager::ROCKS_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::ROCKS_PERCENT);
else
percent = 0;
type = GROUND_ROCKS;
break;
case GROUND_GRASS:
if(g_config.getNumber(ConfigManager::GRASS_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::GRASS_PERCENT);
else
percent = 0;
type = GROUND_GRASS;
break;
case GROUND_UNDERWATER:
if(g_config.getNumber(ConfigManager::UNDERWATER_PERCENT) > 0)
percent = 100/g_config.getNumber(ConfigManager::UNDERWATER_PERCENT);
else
percent = 0;
type = GROUND_UNDERWATER;
break;
}
if(percent == 0)
return;
int x = random_range(1,percent);
short y = 0;
int toID = 0;
if(x == 1){
if(type == GROUND_WATER){
y = random_range(1,21);
if(y >= 1 && y <= 18)
toID = 4607+y;
else if(y >= 19 && y <= 21)
toID = 4645+y;
}
else if(type == GROUND_LAVA){
y = random_range(1,4);
toID = 597+y;
}
else if(type == GROUND_SWAMP){
y = random_range(1,30);
if(y >= 1 && y <= 22)
toID = 4690+y;
else if(y >= 23 && y <= 29)
toID = 4726+y;
else if(y == 30)
toID = 4758;
}
else if(type == GROUND_TAR){
y = random_range(1,4);
toID = 707+y;
}
else if(type == GROUND_MOUNTAIN1){
y = random_range(1,34);
toID = 4404+y;
}
else if(type == GROUND_MOUNTAIN2){
y = random_range(1,17);
toID = 4438+y;
}
else if(type == GROUND_ROCKS){
y = random_range(1,12);
if(y == 1)
toID = 4566;
else if(y >= 2 && y <= 11)
toID = 4568+y;
else if(y == 12)
toID = 4595;
}
else if(type == GROUND_GRASS){
y = random_range(1,20);
if(y >= 1 && y <= 16)
toID = 4525+y;
else if(y >= 17 && y <= 19)
toID = 4550+y;
else if(y == 20)
toID = 4756;
}
else if(type == GROUND_UNDERWATER){
y = random_range(1,6);
toID = 5404+y;
}
item->setID(toID);
}
}
Em iomapotbm.h, abaixo de:
virtual bool loadHouses(Map* map);
Adicione:
void randomizeGround(Item* item);
Agora em item.cpp abaixo de:
else if(_type == ITEM_DUSTBIN){
newItem = new TrashHolder(_type /*, NM_ME_PUFF*/);
}
Adicione:
else if(g_game.checkItemGroundType(_type) != 0){
MagicEffectClasses effect_type;
switch(g_game.checkItemGroundType(_type)){
case GROUND_TAR:
effect_type = NM_ME_PUFF;
break;
case GROUND_WATER:
effect_type = NM_ME_LOSE_ENERGY;
break;
case GROUND_SWAMP:
effect_type = NM_ME_POISON_RINGS;
break;
case GROUND_LAVA:
effect_type = NM_ME_HITBY_FIRE;
break;
}
newItem = new TrashHolder(_type, effect_type);
}
Agora em tile.cpp abaixo de:
else if(iiType.isTar()) continue;
Adicione:
else if(g_game.checkItemGroundType(iitem->getID()) != 0) continue;
Agora em configmanager.cpp adicione
m_confString[RANDOMIZE_GROUND] = getGlobalString(L, "randomize_ground", "no"); m_confInteger[WATER_PERCENT] = getGlobalNumber(L, "water_percent", 10); m_confInteger[LAVA_PERCENT] = getGlobalNumber(L, "lava_percent", 10); m_confInteger[SWAMP_PERCENT] = getGlobalNumber(L, "swamp_percent", 10); m_confInteger[TAR_PERCENT] = getGlobalNumber(L, "tar_percent", 10); m_confInteger[MOUNTAIN_PERCENT] = getGlobalNumber(L, "mountain_percent", 10); m_confInteger[ROCKS_PERCENT] = getGlobalNumber(L, "rocks_percent", 10); m_confInteger[GRASS_PERCENT] = getGlobalNumber(L, "grass_percent", 10);
Em configmanager.h adicione nos strings
RANDOMIZE_GROUND,
Agora nos integer adicione
WATER_PERCENT, LAVA_PERCENT, SWAMP_PERCENT, TAR_PERCENT, MOUNTAIN_PERCENT, ROCKS_PERCENT, GRASS_PERCENT, UNDERWATER_PERCENT,
Pronto de rebuild all, ctrl+f11 e adicione isso no config.lua:
-------------------------------------------------------------------- ---------- Randomize Ground Configs ------------ -------------------------------------------------------------------- -- Randomize Ground? (yes/no) randomize_ground = "no" -- Water Percent water_percent = 70 -- Lava Percent lava_percent = 10 -- Swamp Percent swamp_percent = 50 -- Tar Percent tar_percent = 10 -- Mountain Percent mountain_percent = 50 -- Rocks Percent rocks_percent = 60 -- Grass Percent grass_percent = 80 -- Underwater Ground Percent underwater_percent = 70
Espero ter ajudado, qualquer dúvida só perguntar.
Code desenvolvido pelo nosso amigo Zorzin.
Abraços.











