Ir para conteúdo

[c++] passive system


Posts Recomendados

 

2 hours ago, Ceetros said:

 

Cola a sua função

bool Monster::selectTarget(Creature* creature)

 

bool Monster::selectTarget(Creature* creature){#ifdef __DEBUG__	std::cout << "Selecting target... " << std::endl;#endif	if(!isTarget(creature))		return false;		if (isPassive() && !hasBeenAttacked(creature->getID())) {		return false;	}				if(!isHostile())        return false;             std::string value;     if(getStorage(505, value) && value != "-1") {       if(creature->isSummon()){          if(value != creature->getMaster()->getName())              return false;                            }else if(value != creature->getName()) //&& value != "0"){ -- se bugar             return false;         }   	CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);	if(it == targetList.end())	{		//Target not found in our target list.#ifdef __DEBUG__		std::cout << "Target not found in targetList." << std::endl;#endif		return false;	}	if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())		Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));	return setFollowCreature(creature, true);}

 

Editado por Josegvb
Link para o comentário
Compartilhar em outros sites

 

4 minutos atrás, Josegvb disse:

 

bool Monster::selectTarget(Creature* creature){#ifdef __DEBUG__	std::cout << "Selecting target... " << std::endl;#endif	if(!isTarget(creature))		return false;		if (isPassive() && !hasBeenAttacked(creature->getID())) {		return false;	}				if(!isHostile())        return false;             std::string value;     if(getStorage(505, value) && value != "-1") {       if(creature->isSummon()){          if(value != creature->getMaster()->getName())              return false;                            }else if(value != creature->getName()) //&& value != "0"){ -- se bugar             return false;         }   	CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);	if(it == targetList.end())	{		//Target not found in our target list.#ifdef __DEBUG__		std::cout << "Target not found in targetList." << std::endl;#endif		return false;	}	if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())		Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));	return setFollowCreature(creature, true);}

 

Apaga

if(!isHostile())        return false;

 

Link para o comentário
Compartilhar em outros sites

1 hour ago, Ceetros said:

 

Apaga

if(!isHostile())        return false;

 

 

pronto, deletei ficando assim: 

Quote

bool Monster::selectTarget(Creature* creature)

{

#ifdef __DEBUG__

    std::cout << "Selecting target... " << std::endl;

#endif

    if(!isTarget(creature))

        return false;

    

    if (isPassive() && !hasBeenAttacked(creature->getID())) {

        return false;

    }    

      

     std::string value;

     if(getStorage(505, value) && value != "-1") {

       if(creature->isSummon()){

          if(value != creature->getMaster()->getName())

              return false;                     

       }else if(value != creature->getName()) //&& value != "0"){ -- se bugar  

           return false;    

     }   

    CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);

    if(it == targetList.end())

    {

        //Target not found in our target list.

#ifdef __DEBUG__

        std::cout << "Target not found in targetList." << std::endl;

#endif

        return false;

    }

    if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())

        Dispatcher::getInstance().addTask(createTask(

            boost::bind(&Game::checkCreatureAttack, &g_game, getID())));

    return setFollowCreature(creature, true);

}

 

porem, mesmo resultado o poke é targetao e ate usando skills nele, ele fica andando sem atacar ninguem 

Link para o comentário
Compartilhar em outros sites

if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())        Dispatcher::getInstance().addTask(createTask(            boost::bind(&Game::checkCreatureAttack, &g_game, getID())));    return setFollowCreature(creature, true);}

Deixa:

if((isHostile() || isSummon()) && setAttackedCreature(creature) || !isSummon() && isPassive() || !isHostile())        Dispatcher::getInstance().addTask(createTask(            boost::bind(&Game::checkCreatureAttack, &g_game, getID())));    return setFollowCreature(creature, true);}

 

Link para o comentário
Compartilhar em outros sites

1 hour ago, Ceetros said:
if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())        Dispatcher::getInstance().addTask(createTask(            boost::bind(&Game::checkCreatureAttack, &g_game, getID())));    return setFollowCreature(creature, true);}

Deixa:

if((isHostile() || isSummon()) && setAttackedCreature(creature) || !isSummon() && isPassive() || !isHostile())        Dispatcher::getInstance().addTask(createTask(            boost::bind(&Game::checkCreatureAttack, &g_game, getID())));    return setFollowCreature(creature, true);}

 

 

pronto, resultado:

3f948decbafb569187d23b1542aaf813.gif

alias mesma coisa kk

Link para o comentário
Compartilhar em outros sites

Me manda o xml do monstro.

if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())        Dispatcher::getInstance().addTask(createTask(            boost::bind(&Game::checkCreatureAttack, &g_game, getID())));    return setFollowCreature(creature, true);}

 

 

O meu tá assim:

e tá funcionando

.-.

 

 

			if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth()) && setAttackedCreature(creature) && !isSummon() && isTarget(creature) && isPassive())			Dispatcher::getInstance().addTask(createTask(				boost::bind(&Game::checkCreatureAttack, &g_game, getID())));				return setFollowCreature(creature, true);        }

 

Link para o comentário
Compartilhar em outros sites

1 hour ago, Ceetros said:

Me manda o xml do monstro.

if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())        DispatchergetInstance().addTask(createTask(            boostbind(&GamecheckCreatureAttack, &g_game, getID())));    return setFollowCreature(creature, true);}

 

 

O meu tá assim:

e tá funcionando

.-.

 

 

			if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth()) && setAttackedCreature(creature) && !isSummon() && isTarget(creature) && isPassive())			DispatchergetInstance().addTask(createTask(				boostbind(&GamecheckCreatureAttack, &g_game, getID())));				return setFollowCreature(creature, true);        }

 

 

coloquei o seu, mesmo assim nem ta pegando x.x

Quote

<?xml version="1.0" encoding="UTF-8"?>

<monster name="Alakazam" nameDescription="a alakazam" race="psychic" experience="1100" speed="217" manacost="0">

    <health now="1200" max="1200"/>

    <look type="569" head="70" body="90" legs="95" feet="113" corpse="11840"/>

    <targetchange interval="2000" chance="0"/>

    <strategy attack="100" defense="0"/>

    <flags>

        <flag summonable="1"/>

        <flag attackable="1"/>

        <flag passive="1" />

        <flag hostile="1"/>

        <flag illusionable="1"/>

        <flag convinceable="1"/>

        <flag pushable="1"/>

        <flag canpushitems="0"/>

        <flag canpushcreatures="0"/>

        <flag targetdistance="2"/>

        <flag staticattack="100"/>

        <flag runonhealth="0"/>

       

    </flags>

    <attacks>

        <attack name="physical" interval="2000" chance="100" range="5" min="-50" max="-100">

            <attribute key="shootEffect" value="eartharrow"/>

        </attack>

        <attack name="Confusion" interval="2617" chance="30" range="6"/>

        <attack name="Restore" interval="4920" chance="20" range="6"/>

        <attack name="Psy Pulse" interval="2852" chance="29" range="6"/>

<!-- Magina nao pertence a esse pokemon         <attack name="Psywave" interval="3040" chance="28" range="5"/> -->

        <attack name="Psybeam" interval="3275" chance="26" range="6"/>

        <attack name="Calm Mind" interval="5625" chance="18" range="6"/>

        <attack name="Psychic" interval="3510" chance="25" range="6"/>

<!-- Magina nao pertence a esse pokemon         <attack name="Hypnosis" interval="5510" chance="25" range="3"/> -->

        <attack name="Psyusion" interval="5610" chance="25" range="4"/>

        <attack name="Reflect" interval="4510" chance="20" range="6"/>

    </attacks>

    <defenses armor="0" defense="0"/>

    <voices interval="5000" chance="10">

        <voice sentence="ALAKAZAM!"/>

    </voices>

    <loot>

        <item id="12194" chance="40" count="1" countmax="3"/> --future orb

        <item id="12193" chance="20" count="1"/> --twisted spoon

        <item id="13785" chance="100" countmax="80"/> --enchanted gem

        <item id="11452" chance="1" count="1"/> --enigma stone

        <item id="12338" chance="0.4" count="1"/> --bag box --bag box

    </loot>

    <script>

        <event name="Spawn"/>

    </script>

</monster>

 

 

Alakazam.xml

Alakazam.xml

Link para o comentário
Compartilhar em outros sites

1 hour ago, Ceetros said:

Tira o Hostile e tenta.

 

tirei mas mesma coisa, sempre fica pasivo achei q poderia ser por causa de ADM tentei em outro char mas mesma coisa :/

 

talves coloquei alguma coisa errada no momento de fazer oq diz o tutorial, irei rever isso porem duvido tiver errado, pois ja fiz varias veces 

 

edit: pro, td colocado no local certo, mas nao vai rs @Ceetros

Editado por Josegvb
Link para o comentário
Compartilhar em outros sites

Vou te enviar minha função:

 

bool Monster::selectTarget(Creature* creature){#ifdef __DEBUG__	std::cout << "Selecting target... " << std::endl;#endif	if(!isTarget(creature) && isPassive())		return false;	CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);	if(it == targetList.end())	{		//Target not found in our target list.#ifdef __DEBUG__		std::cout << "Target not found in targetList." << std::endl;#endif		return false;	}	if(!isHostile() && getHealth() ==  getMaxHealth() && !isSummon() && !isTarget(creature) && isPassive())    {		return false;	}	const std::list<Creature*>& summons = creature->getSummons();	CreatureList::const_iterator itt = summons.begin();	for(uint32_t i = 1; itt != summons.end(); ++itt, ++i)	{		if (i >= 1 && *itt){			if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth()) && setAttackedCreature(*itt) && !isSummon() || isTarget(creature) && isPassive())			Dispatcher::getInstance().addTask(createTask(				boost::bind(&Game::checkCreatureAttack, &g_game, getID())));				return setFollowCreature(*itt, true);        }			}	if (isTarget(creature) && !isHostile() && !isSummon() && isPassive())	{ Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));				return setFollowCreature(creature, true);                         }                         if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth() && isPassive() || !isHostile() && isTarget(creature)) && setAttackedCreature(creature) && !isSummon() && isPassive())		Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));	return setFollowCreature(creature, true);}

 

Link para o comentário
Compartilhar em outros sites

troquei a funçao por essa sua @Ceetros, porem agr a passividade nem funfa, nem tirando o hostile e deixando só passive no xlm, nem com os 2 juntos, o bixo sempre fica hostile

Link para o comentário
Compartilhar em outros sites

Agora, Josegvb disse:

troquei a funçao por essa sua @Ceetros, porem agr a passividade nem funfa, nem tirando o hostile e deixando só passive no xlm, nem com os 2 juntos, o bixo sempre fica hostile

 Retira isso que é de outro sistema:

 

const std::list<Creature*>& summons = creature->getSummons();
	CreatureList::const_iterator itt = summons.begin();
	for(uint32_t i = 1; itt != summons.end(); ++itt, ++i)
	{
		if (i >= 1 && *itt){
			if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth()) && setAttackedCreature(*itt) && !isSummon())
			Dispatcher::getInstance().addTask(createTask(
				boost::bind(&Game::checkCreatureAttack, &g_game, getID())));
		
		return setFollowCreature(*itt, true);
        }
		
	}

 

 

e onde tá itt poe creature

Link para o comentário
Compartilhar em outros sites

1 hour ago, Ceetros said:

 Retira isso que é de outro sistema:

 

const std::list<Creature*>& summons = creature->getSummons();	CreatureList::const_iterator itt = summons.begin();	for(uint32_t i = 1; itt != summons.end(); ++itt, ++i)	{		if (i >= 1 && *itt){			if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth()) && setAttackedCreature(*itt) && !isSummon())			Dispatcher::getInstance().addTask(createTask(				boost::bind(&Game::checkCreatureAttack, &g_game, getID())));				return setFollowCreature(*itt, true);        }			}

 

 

e onde tá itt poe creature

 

n entendi oq era pra retirar kk só troquei os itt pra creature

porem agr da erro ao compilar :/

8cbf27ff150097443895b1de4c1355db.png

Link para o comentário
Compartilhar em outros sites

bool Monster::selectTarget(Creature* creature){#ifdef __DEBUG__	std::cout << "Selecting target... " << std::endl;#endif	if(!isTarget(creature))		return false;	CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);	if(it == targetList.end())	{		//Target not found in our target list.#ifdef __DEBUG__		std::cout << "Target not found in targetList." << std::endl;#endif		return false;	}	if(!isHostile() && getHealth() ==  getMaxHealth() && !isSummon() && !isTarget(creature))    {		return false;	}			}	if (isTarget(creature) && !isHostile() && !isSummon())	{ Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));				return setFollowCreature(creature, true);                         }                         if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth() || !isHostile() && isTarget(creature)) && setAttackedCreature(creature) && !isSummon())		Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));	return setFollowCreature(creature, true);}

 

 

deixa assim

Link para o comentário
Compartilhar em outros sites

1 hour ago, Ceetros said:
bool Monster::selectTarget(Creature* creature){#ifdef __DEBUG__	std::cout << "Selecting target... " << std::endl;#endif	if(!isTarget(creature))		return false;	CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);	if(it == targetList.end())	{		//Target not found in our target list.#ifdef __DEBUG__		std::cout << "Target not found in targetList." << std::endl;#endif		return false;	}	if(!isHostile() && getHealth() ==  getMaxHealth() && !isSummon() && !isTarget(creature))    {		return false;	}			}	if (isTarget(creature) && !isHostile() && !isSummon())	{ Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));				return setFollowCreature(creature, true);                         }                         if((isHostile() || isSummon() || !isHostile() && getHealth() !=  getMaxHealth() || !isHostile() && isTarget(creature)) && setAttackedCreature(creature) && !isSummon())		Dispatcher::getInstance().addTask(createTask(			boost::bind(&Game::checkCreatureAttack, &g_game, getID())));	return setFollowCreature(creature, true);}

 

 

deixa assim

 

tinha uma chave demais encima do if (isTarget(creature) && !isHostile() && !isSummon())

 

retirei e compilou sem erro, porem mesmo problema, o pokemon nunca fica + passivo :/ 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...