Ir para conteúdo

Featured Replies

Postado

ola =)
estava aqui mexendo nas sources q tenho aqui

e achei um sistema de level nos monstros q tinha em um forum q agora esta morto(kkk)

 

Source de Teste: otxserver2(FINAL) Baseada na versão: tfs 0.3.7

 

entao vamos la =)

 

em configmanager.h

 

embaixo de:

MONSTER_SPAWN_WALKBACK,

coloque:

MONSTER_HAS_LEVEL,

em configmanager.cpp

embaixo de:

m_confBool[MONSTER_SPAWN_WALKBACK] = getGlobalBool("monsterSpawnWalkback", true);

coloque:

m_confBool[MONSTER_HAS_LEVEL] = getGlobalBool("monsterHasLevel", true);

em luascript.cpp

embaixo de:

setField(L, "guildEmblem", mType->guildEmblem);

coloque:

	setField(L, "levelMin", mType->levelMin);
	setField(L, "levelMax", mType->levelMax);

em map.cpp

embaixo de:

#include "game.h"

coloque:

#include "configmanager.h" 

troque inteiro:

bool Map::placeCreature(const Position& centerPos, Creature* creature, bool extendedPos /*= false*/, bool forced /*= false*/)

por:

bool Map::placeCreature(const Position& centerPos, Creature* creature, bool extendedPos /*= false*/, bool forced /*= false*/)
{
	Monster* monster = creature->getMonster();
	if (monster && g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL))
	{
		uint8_t level;
		if (!monster->getMonsterType()->hideLevel)
		{
			if (monster->isSummon())
			{
				std::string value;
				monster->getMaster()->getStorage((std::string)"monster_level", value);

				uint8_t intValue = atoi(value.c_str());
				if (intValue || value == "0")
					level = intValue;
				else
					level = 1;
			}
			else
				level = monster->level;

			char buffer[10];
			monster->name = monster->getName() + " [" + itoa(level, buffer, 10) + "]";
		}
	}

	bool foundTile = false, placeInPz = false;
	Tile* tile = getTile(centerPos);
	if (tile && !extendedPos)
	{
		placeInPz = tile->hasFlag(TILESTATE_PROTECTIONZONE);
		uint32_t flags = FLAG_IGNOREBLOCKITEM;
		if (creature->isAccountManager())
			flags |= FLAG_IGNOREBLOCKCREATURE;

		ReturnValue ret = tile->__queryAdd(0, creature, 1, flags);
		if (forced || ret == RET_NOERROR || ret == RET_PLAYERISNOTINVITED)
			foundTile = true;
	}

	size_t shufflePos = 0;
	PairVector relList;
	if (extendedPos)
	{
		shufflePos = 8;
		relList.push_back(PositionPair(-2, 0));
		relList.push_back(PositionPair(0, -2));
		relList.push_back(PositionPair(0, 2));
		relList.push_back(PositionPair(2, 0));
		std::random_shuffle(relList.begin(), relList.end());
	}

	relList.push_back(PositionPair(-1, -1));
	relList.push_back(PositionPair(-1, 0));
	relList.push_back(PositionPair(-1, 1));
	relList.push_back(PositionPair(0, -1));
	relList.push_back(PositionPair(0, 1));
	relList.push_back(PositionPair(1, -1));
	relList.push_back(PositionPair(1, 0));
	relList.push_back(PositionPair(1, 1));
	std::random_shuffle(relList.begin() + shufflePos, relList.end());

	uint32_t radius = 1;
	Position tryPos;
	for (uint32_t n = 1; n <= radius && !foundTile; ++n)
	{
		for (PairVector::iterator it = relList.begin(); it != relList.end() && !foundTile; ++it)
		{
			int32_t dx = it->first * n, dy = it->second * n;
			tryPos = centerPos;

			tryPos.x = tryPos.x + dx;
			tryPos.y = tryPos.y + dy;
			if (!(tile = getTile(tryPos)) || (placeInPz && !tile->hasFlag(TILESTATE_PROTECTIONZONE)))
				continue;

			if (tile->__queryAdd(0, creature, 1, 0) == RET_NOERROR)
			{
				if (!extendedPos)
				{
					foundTile = true;
					break;
				}

				if (isSightClear(centerPos, tryPos, false))
				{
					foundTile = true;
					break;
				}
			}
		}
	}

	if (!foundTile)
		return false;

	int32_t index = 0;
	uint32_t flags = 0;

	Item* toItem = NULL;
	if (Cylinder* toCylinder = tile->__queryDestination(index, creature, &toItem, flags))
	{
		toCylinder->__internalAddThing(creature);
		if (Tile* toTile = toCylinder->getTile())
			toTile->qt_node->addCreature(creature);
	}

	return true;
}

em monster.h

embaixo de:

virtual ~Monster();

coloque:

		std::string name, nameDescription;
		int32_t level;
		double bonusAttack, bonusDefense;

troque:

		virtual const std::string& getName() const {return mType->name;}
		virtual const std::string& getNameDescription() const {return mType->nameDescription;}
		virtual std::string getDescription(int32_t) const {return mType->nameDescription + ".";}

por:

		virtual const std::string& getName() const { return name; }
		virtual const std::string& getNameDescription() const { return nameDescription; }
		virtual std::string getDescription(int32_t) const { return nameDescription + "."; }

em monster.cpp

embaixo de:

raid = NULL;

coloque:

	name = _mType->name;
	nameDescription = _mType->nameDescription;
	level = (int32_t)random_range(_mType->levelMin, _mType->levelMax, DISTRO_NORMAL);
	bonusAttack = 1.0;
	bonusDefense = 1.0;

troque inteiro:

void Monster::onCreatureAppear(const Creature* creature)

por:

void Monster::onCreatureAppear(const Creature* creature)
{
	Creature::onCreatureAppear(creature);
	if (creature == this)
	{
		//We just spawned lets look around to see who is there.
		if (isSummon())
		{
			std::string value;
			this->master->getStorage((std::string)"monster_level", value);

			uint8_t intValue = atoi(value.c_str());
			if (intValue || value == "0")
				level = intValue;
			else
				level = 1;
			isMasterInRange = canSee(master->getPosition());
		}

		if (g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL))
		{
			this->healthMax = std::floor(this->getMaxHealth() * (1 + (0.1 * (level - 1))));
			this->health = this->healthMax;

			this->bonusAttack += (0.01 * (level - 1));
			this->bonusDefense += (0.005 * (level - 1));
		}



		updateTargetList();
		updateIdleStatus();
	}
	else
		onCreatureEnter(const_cast<Creature*>(creature));
}

em :

void Monster::doAttacking(uint32_t interval)

procure por:

				if(maxCombatValue > 0) //defense
					multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE);
				else //attack
					multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK);

e troque por:

				if(maxCombatValue > 0) //defense
					multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE) * bonusDefense;
				else //attack
					multiplier = g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK) * bonusAttack;

em monsters.h

troque:

		bool isSummonable, isIllusionable, isConvinceable, isAttackable, isHostile, isLureable,
			isWalkable, canPushItems, canPushCreatures, pushable, hideName, hideHealth, eliminable;

por:

		bool isSummonable, isIllusionable, isConvinceable, isAttackable, isHostile, isLureable,
			isWalkable, canPushItems, canPushCreatures, pushable, hideName, hideHealth, eliminable, hideLevel;

troque:

		int32_t defense, armor, health, healthMin, healthMax, baseSpeed, lookCorpse, corpseUnique, corpseAction,
			maxSummons, targetDistance, runAwayHealth, conditionImmunities, damageImmunities,
			lightLevel, lightColor, changeTargetSpeed, changeTargetChance;

por:

		int32_t defense, armor, health, healthMin, healthMax, baseSpeed, lookCorpse, corpseUnique, corpseAction,
			maxSummons, targetDistance, runAwayHealth, conditionImmunities, damageImmunities,
			lightLevel, lightColor, changeTargetSpeed, changeTargetChance, levelMin, levelMax;

em monsters.cpp

troque:

	canPushItems = canPushCreatures = isSummonable = isIllusionable = isConvinceable = isLureable = isWalkable = hideName = hideHealth = eliminable = false;

por:

	canPushItems = canPushCreatures = isSummonable = isIllusionable = isConvinceable = isLureable = isWalkable = hideName = hideHealth = eliminable = hideLevel = false;

embaixo de:

baseSpeed = 200;

coloque:

	levelMin = levelMax = 1;

procure por:

		if(!xmlStrcmp(p->name, (const xmlChar*)"health"))
		{
			if(readXMLInteger(p, "min", intValue))
				mType->healthMin = intValue;

			if(!readXMLInteger(p, "max", intValue))
			{
				SHOW_XML_ERROR("Missing health.max");
				monsterLoad = false;
				break;
			}

			mType->healthMax = intValue;
			if(!readXMLInteger(p, "now", intValue))
				mType->health = mType->healthMax;
			else
				mType->health = intValue;
		}

embaixo dele coloque:

		else if (!xmlStrcmp(p->name, (const xmlChar*)"level"))
		{
			if (!readXMLInteger(p, "max", intValue))
				mType->levelMax = 1;
			else
				mType->levelMax = intValue;

			if (!readXMLInteger(p, "min", intValue))
				mType->levelMin = mType->levelMax;
			else
				mType->levelMin = intValue;
		}

agora nos arquivos dos monstros vc pode colocar

<level min="1" max="6"/> 

min = level minimo q pode vir no monstro

max = level maximo q pode vir no monstro

 

obs: se vc colocar essa tag nos monstros sempre vai vir Monstro Level 1

 

 

obs²: getMonsterInfo(name) n funcionar para achar o nome do monstro

pq ele pega o nome real q esta no arquivo do monstro q n vai ter o [1](q é o level)

estou tentando arrumar isso mas ainda n consegui

se alguem conseguir arrumar isso avisa ai =)

 

acho q é so isso

 

Creditos: 100% OneShot/Garou

Editado por rohfagundes (veja o histórico de edições)

  • Respostas 32
  • Visualizações 9.7k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo