Ir para conteúdo
  • Cadastre-se

C++ Monster Level TFS e OTX


Posts Recomendados

@.HuRRiKaNe o bug do primeiro spawn dos monstros nascer tudo level 1 ta fixado?

Compre seus Scripts Agora totalmente seguro e de forma rápida, aceitamos também encomendas.

discord.gg/phJZeHa2k4

 

Projeto ATS (Naruto)

Informações Abaixo

Facebook

Youtube
Discord

 

Tutoriais / Conteúdos

Clique Aqui

Link para o post
Compartilhar em outros sites
58 minutos atrás, .HuRRiKaNe disse:

Testado em tfs 0.4!


Em monsters.h procure por:

  Mostrar conteúdo oculto

 

 



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

 

E substitua por:



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

 

Busque por:



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

 

Substitua por:



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

 

 


Em monsters.cpp procure por:

  Mostrar conteúdo oculto

 



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

 

Substitua por:



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

 

Busque por:



baseSpeed = 200;

 

Adicione abaixo:



levelMin = levelMax = 1;

 

Busque por:



bool Monsters::loadMonster

 

Você encontrara está função:



for(xmlNodePtr p = root->children; p; p = p->next)
   {
      if(p->type != XML_ELEMENT_NODE)
         continue;

      if(!xmlStrcmp(p->name, (const xmlChar*)"health"))
      {
         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;
      } 

 

Adicione abaixo:



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;
        }

 

Busque por:



if(readXMLString(tmpNode, "emblem", strValue))
   mType->guildEmblem = getEmblems(strValue);

 

Adicione abaixo:



if(readXMLString(tmpNode, "hidelevel", strValue))
        mType->hideLevel = booleanString(strValue);

 

 

 

 


Em monster.h procure por:

  Mostrar conteúdo oculto

 



class Monster : public Creature
{

 

E logo abaixo disto:



public:
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
      static uint32_t monsterCount;
#endif
      virtual ~Monster();

 

Adicione:



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

 

Busque por:



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 + ".";}

 

Substitua 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 procure por:

  Mostrar conteúdo oculto

 



Monster::Monster(MonsterType* _mType):

 

E abaixo de:



isIdle = true;

 

Adicione:



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

 

Busque por:



Monster::onCreatureAppear

 

Substitua toda a função 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));
}

 

Busque por:

 



g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE)

 

Substitua por:



g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE) * bonusDefense

 

Busque por:



g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK)

 

Substitua por:



g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK) * bonusAttack

 


Em map.cpp procure por:

  Mostrar conteúdo oculto

 



#include "game.h"

 

Adicione abaixo:



#include "configmanager.h" 

 

Busque por:



extern Game g_game;

 

Adicione abaixo:



extern ConfigManager g_config;

 

Busque por:



bool Map::placeCreature
{

 

Adicione abaixo:



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 configmanager.h busque por;

  Mostrar conteúdo oculto

 



MONSTER_SPAWN_WALKBACK,

 

Adicione abaixo:



MONSTER_HAS_LEVEL,

 

 


Em configmanager.cpp busque por:

  Mostrar conteúdo oculto

 



m_loaded = true;

 

Adicione abaixo:



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

 

 

 

 

Agora no config.lua adicione:


monsterHasLevel = true

Como está programado, a cada nível, monstros ganham 10% de HP, 1% de dano e 0.5% de defesa.
Para configurar o level minimo e máximo do monstro basta adicionar no XML do monstro a tag:


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


 

Oque esse sistema faz? não tem nada explicando sobre poderia dizer?

Link para o post
Compartilhar em outros sites
1 hora atrás, luanluciano93 disse:

serve para todas a versões do TFS e OTX? Se você só testou em TFS 0.4 coloque no título TFS 0.4.

 

Pronto!

 

42 minutos atrás, LeoTK disse:

@.HuRRiKaNe o bug do primeiro spawn dos monstros nascer tudo level 1 ta fixado?

 

Para fixar isso basta ir em spawn.cpp e procurar pela função:

bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup /*= false*/)

 

Acima de:

spawnedMap.insert(SpawnedPair(spawnId, monster));

 

Adicionar:

monster->onCreatureAppear(monster);

 

41 minutos atrás, OinomedRellik disse:

Oque esse sistema faz? não tem nada explicando sobre poderia dizer?

É um sistema de level para os monstros que a cada nível, ps monstros ganham 10% de HP, 1% de dano e 0.5% de defesa.

x1fCxnI.png

Link para o post
Compartilhar em outros sites
1 hora atrás, .HuRRiKaNe disse:

Pronto!

 

 

Para fixar isso basta ir em spawn.cpp e procurar pela função:


bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup /*= false*/)

 

Acima de:


spawnedMap.insert(SpawnedPair(spawnId, monster));

 

Adicionar:


monster->onCreatureAppear(monster);

 

É um sistema de level para os monstros que a cada nível, ps monstros ganham 10% de HP, 1% de dano e 0.5% de defesa.

então os monstros que nasce vão ter niveis e quanto maior o nivel do monstro que deu spawn mais forte ele será?

Link para o post
Compartilhar em outros sites
3 minutos atrás, OinomedRellik disse:

então os monstros que nasce vão ter niveis e quanto maior o nivel do monstro que deu spawn mais forte ele será?

Isso!

x1fCxnI.png

Link para o post
Compartilhar em outros sites

Boa noite, na hora de compilar deu esse erro.

 

map.cpp: In member function bool Map::placeCreature(const Position&, Creature*, bool, bool)’:
map.cpp:210:79: error: itoa was not declared in this scope
      monster->name = monster->getName() + " [" + itoa(level, buffer, 10) + "]";
                                                                        ^
Makefile:40: recipe for target 'obj/map.o' failed
make: *** [obj/map.o] Error 1


Acabei de perceber que esta escrito errado em vez de "itoa" é "atoi"
vou apagar a pasta obj, e recompilar ?
Obrigado pelo sistema!

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

       112674.gif

 

 

 

Link para o post
Compartilhar em outros sites

@.HuRRiKaNe pra uma atualização boa ou mais futura seria legal trazer também quanto maior o nivel da criatura mais exp em porcentagem daria exemplo 10% ou 20% a mais de exp por level, assim valeria a pena caçar criaturas de nível mais forte porém da mesma raça saca

Compre seus Scripts Agora totalmente seguro e de forma rápida, aceitamos também encomendas.

discord.gg/phJZeHa2k4

 

Projeto ATS (Naruto)

Informações Abaixo

Facebook

Youtube
Discord

 

Tutoriais / Conteúdos

Clique Aqui

Link para o post
Compartilhar em outros sites
Spoiler

map.cpp:210:79: note:   mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ and ‘int’
             monster->name = monster->getName() + " [" + atoi(level, buffer, 10) + "]";
                                                                               ^
cc1plus: all warnings being treated as errors
make: *** [obj/map.o] Error 1


 

meu dá esse error

Link para o post
Compartilhar em outros sites
9 minutos atrás, OinomedRellik disse:
  Mostrar conteúdo oculto

map.cpp:210:79: note:   mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ and ‘int’
             monster->name = monster->getName() + " [" + atoi(level, buffer, 10) + "]";
                                                                               ^
cc1plus: all warnings being treated as errors
make: *** [obj/map.o] Error 1


 

meu dá esse error

Arrumado no tópico, tinha uma linha errada.

x1fCxnI.png

Link para o post
Compartilhar em outros sites
12 minutos atrás, .HuRRiKaNe disse:

Arrumado no tópico, tinha uma linha errada.

eu tenho uma duvida, essa parte do map.cpp é pra substituir né? porque se por abaixo de todo o codigo citado ele não vai funcionar eu acho

 

 

mesmo error 

Spoiler

map.cpp:210:79: note:   mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ and ‘int’
             monster->name = monster->getName() + " [" + atoi(level, buffer, 10) + "]";
                                                                               ^
cc1plus: all warnings being treated as errors
make: *** [obj/map.o] Error 1
 

 

Editado por OinomedRellik (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
2 horas atrás, OinomedRellik disse:

eu tenho uma duvida, essa parte do map.cpp é pra substituir né? porque se por abaixo de todo o codigo citado ele não vai funcionar eu acho

 

 

mesmo error 

  Ocultar conteúdo

map.cpp:210:79: note:   mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ and ‘int’
             monster->name = monster->getName() + " [" + atoi(level, buffer, 10) + "]";
                                                                               ^
cc1plus: all warnings being treated as errors
make: *** [obj/map.o] Error 1
 

 

Usa essa e delete a pasta obj:

Spoiler

 


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((uint32_t)"1996", value);                  
    monster->getMaster()->getStorage((uint32_t)"1996", 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() + " [" + atoi(level, buffer, 10) + "]";        }    }



	bool foundTile = false, placeInPz = false;
	Tile* tile = getTile(centerPos);
	if(tile)
	{
		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;
				}
			}
		}
	}

 

 

 

 

x1fCxnI.png

Link para o post
Compartilhar em outros sites
1 hora atrás, .HuRRiKaNe disse:

Usa essa e delete a pasta obj:

  Mostrar conteúdo oculto

 



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((uint32_t)"1996", value);                  
    monster->getMaster()->getStorage((uint32_t)"1996", 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() + " [" + atoi(level, buffer, 10) + "]";        }    }



	bool foundTile = false, placeInPz = false;
	Tile* tile = getTile(centerPos);
	if(tile)
	{
		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;
				}
			}
		}
	}

 

 

 

 

deu mais um error, percebi que faltava >>>   }   <<< e ocorreu esse error depois de compilar novamente.

Spoiler


map.cpp:206:71: note:   mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ and ‘int’
     monster->name = monster->getName() + " [" + atoi(level, buffer, 10) + "]";        }    }
                                                                       ^
map.cpp:276:1: error: no return statement in function returning non-void [-Werror=return-type]
 }
 ^
cc1plus: all warnings being treated as errors
make: *** [obj/map.o] Error 1
 

 

Link para o post
Compartilhar em outros sites
  • 2 years later...
  • 1 month later...

nie działa, nie mogę skompilować :( , jak to naprawić?
map.cpp: W funkcji składowej „bool Map::placeCreature(const Position&, Creature*, bool, bool)”:
map.cpp:212:80: błąd: „itoa” nie została zadeklarowana w tym zakresie
             monster- >nazwa = potwór->getName() + " [" + itoa (poziom, bufor, 10) + "]";
 done.

Editado por Elo1989 (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por Doria Louro
      Olá senhores.
       
      Gostaria de uma ajuda com um script de summon que venho trabalhando no momento, gostaria que o summon andasse do lado do jogador, entretanto o mesmo sempre fica para trás ou a frente do jogador.
      Efetuei a alteração na source creature.cpp:
       
      void Creature::getPathSearchParams(const Creature* creature, FindPathParams& fpp) const { fpp.fullPathSearch = !hasFollowPath; fpp.clearSight = true; if(creature->isPlayerSummon()) { if(creature->getName() == "Summon Name") fpp.clearSight = false; } fpp.maxSearchDist = 12; fpp.minTargetDist = fpp.maxTargetDist = 1; }  
      fpp.maxTargetDist = 1;
      Porém ele sempre mantem 1 de distancia do jogador, alterando para zero o "Zero" summon nem segue o jogador.
      Resultado:

       
      Agradeço desde já.
    • Por Imperius
      O propósito é criar uma nova função em creaturescripts que será acionada toda vez que um novo report (CTRL + R) for aberto.
       
      Eu implementei para enviar uma notificação no grupo do Telegram, contendo os dados do report.
       
      Isso garantirá que os GMs tenham acesso aos reports dos jogadores mesmo quando não estiverem logados, e também evitará que algum report seja perdido caso o jogador saia do servidor.
      A parte do Telegram é apenas um exemplo. Você pode ajustar o script para executar outras ações desejadas.
       
      creatureevent.cpp:
      Dentro deste arquivo, localize a função:
       
      uint32_t CreatureEvent::executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap)  
      abaixo dela, adicione:
       
      uint32_t CreatureEvent::executeOpenRuleViolation(Player* player, std::string message) { if (!m_interface->reserveEnv()) { std::clog << "[Error - CreatureEvent::executeOpenRuleViolation] Call stack overflow." << std::endl; return 0; } ScriptEnviroment* env = m_interface->getEnv(); env->setScriptId(m_scriptId, m_interface); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushstring(L, message.c_str()); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; }  
      Após, procure por:
       
      std::string CreatureEvent::getScriptEventName() const  
      abaixo de:
       
      case CREATURE_EVENT_CHANNEL_LEAVE: return "onLeaveChannel";  
      adicione:
       
      case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "onOpenRuleViolation";  
      Agora, procure por:
       
      std::string CreatureEvent::getScriptEventParams() const  
      abaixo de:
       
      case CREATURE_EVENT_CHANNEL_LEAVE: return "cid, channel, users";  
      adicione:
       
      case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "cid, message";  
      Procure por:
       
      bool CreatureEvent::configureEvent(xmlNodePtr p)  
      abaixo de:
       
      else if(tmpStr == "leavechannel") m_type = CREATURE_EVENT_CHANNEL_LEAVE;  
      adicione:
       
      else if(tmpStr == "openruleviolation") m_type = CREATURE_EVENT_OPEN_RULE_VIOLATION;  
       
      creatureevent.h:
      Dentro deste arquivo, localize:
       
      enum CreatureEventType_t  
      adicione "CREATURE_EVENT_OPEN_RULE_VIOLATION" como o último item de enum CreatureEventType_t
       
      Exemplo:
       
      enum CreatureEventType_t { // ... CREATURE_EVENT_OPEN_RULE_VIOLATION };  
      Agora, procure por:
       
      uint32_t executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap);  
      abaixo dela, adicione:
       
      uint32_t executeOpenRuleViolation(Player* player, std::string message);  
      game.cpp:
      Dentro deste arquivo, localize:
       
      bool Game::playerReportRuleViolation(Player* player, const std::string& text)  
      e substitua por:
       
      bool Game::playerReportRuleViolation(Player* player, const std::string& text) { //Do not allow reports on multiclones worlds since reports are name-based if(g_config.getNumber(ConfigManager::ALLOW_CLONES)) { player->sendTextMessage(MSG_INFO_DESCR, "Rule violation reports are disabled."); return false; } cancelRuleViolation(player); boost::shared_ptr<RuleViolation> rvr(new RuleViolation(player, text, time(NULL))); ruleViolations[player->getID()] = rvr; ChatChannel* channel = g_chat.getChannelById(CHANNEL_RVR); if(!channel) return false; for(UsersMap::const_iterator it = channel->getUsers().begin(); it != channel->getUsers().end(); ++it) it->second->sendToChannel(player, SPEAK_RVR_CHANNEL, text, CHANNEL_RVR, rvr->time); CreatureEventList joinEvents = player->getCreatureEvents(CREATURE_EVENT_OPEN_RULE_VIOLATION); for(CreatureEventList::iterator it = joinEvents.begin(); it != joinEvents.end(); ++it) (*it)->executeOpenRuleViolation(player, text); return true; }  
      Agora é só compilar a source.
       
      depois em "data > creaturescripts > creaturescripts.xml", adicione:
       
      <event type="login" name="loginNotifyRuleViolation" script="notifyRuleViolation.lua"/> <event type="openruleviolation" name="openNotifyRuleViolation" script="notifyRuleViolation.lua"/>  
      em "data > creaturescripts > scripts", crie um arquivo notifyRuleViolation.lua e adicione:
       
      function onOpenRuleViolation(cid, message) local config = { token = "", -- Token do seu BOT no Telegram chatId = "" -- ID do chat do Telegram que será enviado a notificação. } local message = "Player: "..getCreatureName(cid).."\n\nReport:\n"..message.."" message = string.gsub(message, "\n", "%%0A") local url = "https://api.telegram.org/bot"..config.token.."/sendMessage" local data = "chat_id="..config.chatId.."&text="..message.."" local curl = io.popen('curl -d "'..data..'" "'..url..'"'):read("*a") return true end function onLogin(cid) registerCreatureEvent(cid, "openNotifyRuleViolation") return true end  
       
      Demonstração:
      1. Jogador abre um novo report (CTRL + R)

      2. notifyRuleViolation.lua, definido em creaturescripts.xml, é acionado para enviar uma notificação ao grupo do Telegram.
       

       
    • Por FeeTads
      SALVE rapaziada do TK, esses dias vim pensando em novos scripts pro meu OT, e em um deles eu precisava que determinada area não contasse frag pro player que matasse outros, PORÉM eu precisava que os players que morressem nessa area ainda assim tivessem as penalidades da sua morte, procurei por ai, achei alguns scripts que apenas tiravam o SKULL e não realmente o FRAG do player.

      **script atualizado 22/10/2023** - melhorado e otimizado, levei o script pra puxar as infos por .lua / creatureScripts

      vou disponibilizar o code aqui, e o que fazer pra determinada area não contar frag.

      SOURCE OTX 2 / TFS 0.x, Funciona em TFS 1.x mudando as tags e ajeitando as sintaxes.

      vá em creatureevent.cpp

      procure por:
      else if(type == "preparedeath") _type = CREATURE_EVENT_PREPAREDEATH;
      Adiciona abaixo:
      else if(type == "nocountfrag") _type = CREATURE_EVENT_NOCOUNTFRAG;

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath";  
      Adicione abaixo: 
      case CREATURE_EVENT_NOCOUNTFRAG: return "noCountFragArea";

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList";
      Adicione abaixo:
      case CREATURE_EVENT_NOCOUNTFRAG: return "cid, target";

      agora no mesmo arquivo, vá até o final do arquivo e adicione essa função:
      uint32_t CreatureEvent::executeNoCountFragArea(Creature* creature, Creature* target) { //noCountFragArea(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::ostringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; if(m_scriptData) scriptstream << *m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::ostringstream desc; desc << creature->getName(); env->setEvent(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::noCountFragArea] Call stack overflow." << std::endl; return 0; } }

      agora vá em creatureevent.h

      procure por:
      CREATURE_EVENT_PREPAREDEATH
      adicione abaixo:
      CREATURE_EVENT_NOCOUNTFRAG

      procure por:
      uint32_t executePrepareDeath(Creature* creature, DeathList deathList);
      Adicione abaixo:
      uint32_t executeNoCountFragArea(Creature* creature, Creature* target);

      agora vá em player.cpp

      procure por:
      bool Player::onKilledCreature(Creature* target, DeathEntry& entry)
      abaixo de:
      War_t enemy; if(targetPlayer->getEnemy(this, enemy)) { if(entry.isLast()) IOGuild::getInstance()->updateWar(enemy); entry.setWar(enemy); }
      Adicione o seguinte código:
      if (targetPlayer){ CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_NOCOUNTFRAG); for (const auto &event : killEvents) { if (!event->executeNoCountFragArea(this, target)) { return true; } } }

      //

      Feito isso, tudo completo na sua source, agora é necessário adicionar o creaturescript dentro do servidor

      vá até creaturescripts/scripts
      crie um arquivo chamado, "noCountFragInArea.lua"
      e dentro dele cole o código:
       
      --[[ script feito por feetads / TibiaKing ]]-- --[[ discord: feetads / FeeTads#0246 ]]-- -- Add positions here for which you do not want to count frags local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, -- from = area superior esquerda / to = area inferior direita (formando um quadrado) } local onlyKillerInArea = false -- only killer need to be in area? function noCountFragArea(cid, target) if not isCreature(cid) or not isCreature(target) then return true end local posKiller = getPlayerPosition(cid) local posTarget = getPlayerPosition(target) for i = 1, #areas do local area = areas[i] if isInArea(posKiller, area.from, area.to) then if onlyKillerInArea then return false elseif isInArea(posTarget, area.from, area.to) then return false end end end return true end
      agora em creaturescripts.xml
      <event type="nocountfrag" name="fragarea" event="script" value="noCountFragInArea.lua"/>
      agora em creaturescripts/scripts/login.lua
       procure por OU semelhante a esse:
      registerCreatureEvent(cid, "AdvanceSave")
      e abaixo adicione:
      registerCreatureEvent(cid, "fragarea")

      //


      Agora tudo certo, quando quiser adiciona uma area que não pega frag, vá até o script e apenas coloque a area, igual o demonstrado no script

      Exemplo:
      local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, [2] = {from = {x = 1000, y = 1000, z = 7}, to = {x = 1100, y = 1100, z = 7}}, }
      assim somente colocando a area no script e abrindo o server ou dando /reload, já funcionará a area como não pegar frag.
      Esse sistema pode ser bom pra areas de pvp ativo, onde você ainda quer que o player que morrer perca os atributos, como se fosse uma morte normal, porém não conta frag pra quem matar.
      Bom pra sistemas tipo castle 48h (guild war), onde há diversas mortes e risco de pegar red, atrapalhando a war.

      Façam bom proveito dos scripts, e deixem os créditos no script rsrs

      **Eu fiz as alterações e o simples código por isso vim disponibilizar, créditos meus**
    • Por Mateus Robeerto
      Para quem deseja utilizar o 'IncreaseMagicPercent' no arquivo items.xml, que aumenta o dano mágico em porcentagem
       
       
      No arquivo game.cpp
      depois.
      Player* attackerPlayer; if (attacker) { attackerPlayer = attacker->getPlayer(); } else { attackerPlayer = nullptr; } Player* targetPlayer = target->getPlayer(); if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) { return false; } damage.primary.value = std::abs(damage.primary.value); damage.secondary.value = std::abs(damage.secondary.value); int32_t healthChange = damage.primary.value + damage.secondary.value; if (healthChange == 0) { return true; } adicionar
      // Inc Magic by lursky auto originList = { ORIGIN_RANGED, ORIGIN_MELEE, ORIGIN_CONDITION }; auto it = std::find(originList.begin(), originList.end(), damage.origin); if (attackerPlayer && it == originList.end()) { int32_t magicPercentBonus = 0; for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { Item* item = attackerPlayer->inventory[slot]; if (item) { const ItemType& iiType = Item::items[item->getID()]; const int32_t& slotPosition = item->getSlotPosition(); if (iiType.increaseMagicPercent && (iiType.slotPosition & slotPosition)) { magicPercentBonus += iiType.increaseMagicPercent; } } } if (magicPercentBonus > 0) { damage.primary.value += damage.primary.value * (magicPercentBonus / 100.0f); } } No arquivo item.cpp
       
      post edit: Deve ter colocado duas vezes, ok? É só procurar no item.cpp essa linha e adicionar. Repita a busca pela mesma linha e adicione para exibir 'inc magic'. Pronto 

      depois.
      if (it.abilities) { for (uint8_t i = SKILL_FIRST; i <= SKILL_LAST; i++) { if (!it.abilities->skills[i]) { continue; } if (begin) { begin = false; s << " ("; } else { s << ", "; } s << getSkillName(i) << ' ' << std::showpos << it.abilities->skills[i] << std::noshowpos; } adicionar.
      if (it.increaseMagicPercent) { if (begin) { begin = false; s << " ("; } else { s << ", "; } s << "Inc.Magic " << std::showpos << it.increaseMagicPercent << '%' << std::noshowpos; } No arquivo items.cpp
      depois.
      {"worth", ITEM_PARSE_WORTH}, adicionar:
      { "increasemagicpercent", ITEM_PARSE_INCREASEMAGICPERCENT }, Novamente, no arquivo items.cpp:
      depois.
      case ITEM_PARSE_SUPPRESSCURSE: { if (valueAttribute.as_bool()) { abilities.conditionSuppressions |= CONDITION_CURSED; } break; } adicionar.
      case ITEM_PARSE_INCREASEMAGICPERCENT: { it.increaseMagicPercent = pugi::cast<int32_t>(valueAttribute.value()); break; } No arquivo items.h
      depois.
      uint64_t worth = 0; adicionar.
      int32_t increaseMagicPercent = 0; Novamente, no arquivo items.h:
      after.
      ITEM_PARSE_WORTH, adicionar:
      ITEM_PARSE_INCREASEMAGICPERCENT, FIM
      É só recompilar e testar
      Como funciona usar esses atributos? Veja aqui um exemplo
      item id="xxx" name="teste robe"> <attribute key="weight" value="7100"/> <attribute key="armor" value="18"/> <attribute key="slotType" value="body"/> <attribute key="increaseMagicPercent" value="50"/> </item>  
      Obs: Esses adições na source foram feitas por Mateus Roberto, e Lurskcy fez uma correção de erro que estava causando um .crash no arquivo games.cpp. Está funcionando bem.
       
      Espero que gostem
    • Por L3K0T
      Olá pessoal! Vamos resolver esse problema dos monstros não passarem por cima de outros corpse para te atacarem... Trata-se de uma pequena modificação no rev3777 tfs 0.4, um bug comum nesse TFS. Aqui está a alteração que fiz para que funcione!
       
      Tile.cpp:
       
      if(!creature->canWalkthrough(*cit))
      return NOTPOSSIBLE; //NOTPOSSIBLE
       
      Mude para:
       
      if (!creature->canWalkthrough(*cit) && (!cit->isCreature() || cit->isCorpse()))
          return NOTPOSSIBLE; // NOTPOSSIBLE
       
      Após isso, exclua todo o conteúdo da pasta "obj" e compile novamente. Pronto, o problema estará resolvido!
      Créditos para mim, @L3K0T
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo