AD
pedido

Apenas X vocation id pode atacar X monstro

Por AdilsonHacker, 18 de jun. de 2015 em Scripts

resolvido
script
48
5.9k
AdilsonHackerA
19 de junho de 2015 às 00:36

Eu não manjo em c++ mais sem bem como compilar e aplicar as alterações, se alguém tiver disposto a me ajudar serei grato.

Obrigado a todos que estão tentando me ajudar.

RigByR
19 de junho de 2015 às 11:40

Dei uma pesquisada achei um que funciona com storage feito pelo Doggynub.

procure por:

void Monster::doAttacking(uint32_t interval)
{
    if(!attackedCreature || (isSummon() && attackedCreature == this))
        return;

logo abaixo adicione:

Player* player = attackedCreature->getPlayer();
    std::string value;
    std::string check = "15";
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
    {
        setFollowCreature(NULL);
        setAttackedCreature(NULL);
        searchTarget(TARGETSEARCH_NEAREST);
        
    }

procure por:

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

logo abaixo adicione:

 Player* player = creature->getPlayer();
    std::string value;
    std::string check = "15";  
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
        return false;

onde tam "Rat" é o nome do Mob que você que.

em 8000 é o id da storage

em 15 é o valor da storage

 

Agora so basta fazer um onLogin para que quando o player logue é for de tal vocação ele ganhe a storage

local voc = 1 
function onLogin(cid)
if getPlayerVocation(cid) == voc then
setPlayerStorageValue(cid, 8000, 15)
end
return true
end
hi.gif

 

 

Editado Junho 19 por RigBy

AdilsonHackerA
20 de junho de 2015 às 01:17

Dei uma pesquisada achei um que funciona com storage feito pelo Doggynub.

procure por:

void Monster::doAttacking(uint32_t interval)
{
    if(!attackedCreature || (isSummon() && attackedCreature == this))
        return;

logo abaixo adicione:

Player* player = attackedCreature->getPlayer();
    std::string value;
    std::string check = "15";
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
    {
        setFollowCreature(NULL);
        setAttackedCreature(NULL);
        searchTarget(TARGETSEARCH_NEAREST);
        
    }

procure por:

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

logo abaixo adicione:

 Player* player = creature->getPlayer();
    std::string value;
    std::string check = "15";  
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
        return false;

onde tam "Rat" é o nome do Mob que você que.

em 8000 é o id da storage

em 15 é o valor da storage

 

Agora so basta fazer um onLogin para que quando o player logue é for de tal vocação ele ganhe a storage

local voc = 1 
function onLogin(cid)
if getPlayerVocation(cid) == voc then
setPlayerStorageValue(cid, 8000, 15)
end
return true
end
hi.gif

 

 

Obrigado por tentar ajudar mais infelizmente ocorreu este erro, uso uma rev 3884 TFS 0.4 8.6

nalwo.jpg

zipter98Z
20 de junho de 2015 às 02:01

Use:

    Player* player = attackedCreature->getPlayer();
    std::string value;
    std::string check = "15";
    uint32_t storage = 8000;
    if (getName() == "Rat" && player && ( !(player->getStorage(storage, value)) || check != value ) )
    {
        setFollowCreature(NULL);
        setAttackedCreature(NULL);
        searchTarget(TARGETSEARCH_NEAREST);
    }
e:
    Player* player = creature->getPlayer();
    std::string value;
    std::string check = "15";  
    uint32_t storage = 8000;
    if (getName() == "Rat" && player && ( !(player->getStorage(storage, value)) || check != value ) )
        return false;

 

Editado Junho 20 por zipter98

AdilsonHackerA
20 de junho de 2015 às 02:23

Não deu Zipter

2uh1n2t.png

RigByR
20 de junho de 2015 às 10:59

muda todos 8000 para "8000"

XtudomuitoX
20 de junho de 2015 às 14:58

Mas tipo, como faço pra add mas monster. Tipo

rat 8000, 15

dog 8000, 16

dragon 8000, 17

 

quero fazer missão de saga. Fiz o pedido mas eu acho que é osso.

http://www.xtibia.com/forum/topic/234460-saga-system-wodbo/

Editado Junho 20 por Xtudomuito

AdilsonHackerA
20 de junho de 2015 às 17:52

muda todos 8000 para "8000"

 

Ainda continua o mesmo erro amigo.

zipter98Z
20 de junho de 2015 às 18:19

Hm, neste caso, vamos fazer em C++ e Lua:

Troque:

    Player* player = creature->getPlayer();
    std::string value;
    std::string check = "15";  
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
        return false;
por:
    CreatureEventList targetEvents = getCreatureEvents(CREATURE_EVENT_TARGET);
    for(CreatureEventList::iterator it = targetEvents.begin(); it != targetEvents.end(); ++it)
    {
        if(!(*it)->executeTarget(this, creature))
            return false;
    }
Depois, troque:
    Player* player = attackedCreature->getPlayer();
    std::string value;
    std::string check = "15";
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
    {
        setFollowCreature(NULL);
        setAttackedCreature(NULL);
        searchTarget(TARGETSEARCH_NEAREST);
        
    }
por:
    Creature* creature = attackedCreature->getCreature();
    if(creature)
    {
        CreatureEventList targetEvents = getCreatureEvents(CREATURE_EVENT_TARGET);
        for(CreatureEventList::iterator it = targetEvents.begin(); it != targetEvents.end(); ++it)
        {
            if(!(*it)->executeTarget(this, creature))
            {
                setFollowCreature(NULL);
                setAttackedCreature(NULL);
                searchTarget(TARGETSEARCH_NEAREST);
                break;
            }
        }
    }
Aí, em data/creaturescripts/scripts:
local config = {
    name = "xxx",    --nome do monstro
    vocId = xxx,     --vocation id
}
function onTarget(cid, target)
    local player = isMonster(cid) and isPlayer(target) and target or isPlayer(cid) and isMonster(target) and getCreatureName(target) == config.name and cid or false
    if player then
        if getPlayerVocation(player) ~= config.vocId then
            if isPlayer(cid) then
                doPlayerSendCancel(cid, "você não pode atacar esta criatura.")
            end
            return false
        end
    end
    return true
end
function onStatsChange(cid, attacker, type, combat, value)
    local player = isMonster(attacker) and isPlayer(cid) and cid or isPlayer(attacker) and isMonster(cid) and getCreatureName(cid) == config.name and attacker or false
    if player then
        return getPlayerVocation(player) == config.vocId
    end
    return true
end
Registre o evento tanto em login.lua quanto no arquivo XML do monstro.

Editado Junho 22 por zipter98

ManoTobiraM
21 de junho de 2015 às 00:07

o sistema original do dbko usa monsters.xml creaturescript e sources qero sabe se alguem consegue faze

 

a funçao da sources nao verifica o nome do monster e sim o valor da storage q é colocado na .xml dele tipo assim:

 

<monster name="Haku" nameDescription="a haku" race="blood" saga="6" experience="1100" speed="295" manacost="0">

 

cada monster tem seu arquivo creaturescript q é feito assim:

 

function onSaga(cid, target)
local bomb = {x=20, y=20, z=7, stackpos=253}
if isPlayer(target) then
doPlayerAddExp(target,200000)
setPlayerStorageValue(target, 8000, 7)
doTeleportThing(cid, bomb)
end
return true
end
essa parte eu nao entendi muito da script só sei q dps q mata o bixo ele muda o valor da sua storage e te da experiencia
e depois registra em creatureevent.xml com essa tag:
<event type="saga" name="haku" event="script" value="haku.lua" />
a unica coisa q falta pro sistema fica completo é a funçao da sources espero q alguem ajude criando ela pois a unica coisa q eu consegui foi descobri como funciona o sistema a partir dessas scripts
o sistema nao usa vocation pra ataca o bixo e sim storage

Editado Junho 21 por ptdg

AdilsonHackerA
21 de junho de 2015 às 01:13

 

Hm, neste caso, vamos fazer em C++ e Lua:

Troque:

    Player* player = creature->getPlayer();
    std::string value;
    std::string check = "15";  
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
        return false;
por:
    CreatureEventList targetEvents = getCreatureEvents(CREATURE_EVENT_TARGET);
    for(CreatureEventList::iterator it = targetEvents.begin(); it != targetEvents.end(); ++it)
    {
        if(!(*it)->executeTarget(this, creature))
            return false;
    }
Depois, troque:
    Player* player = attackedCreature->getPlayer();
    std::string value;
    std::string check = "15";
    if (getName() == "Rat" && player && ( !(player->getStorage(8000,value)) || check != value ) )
    {
        setFollowCreature(NULL);
        setAttackedCreature(NULL);
        searchTarget(TARGETSEARCH_NEAREST);
        
    }
por:
    Creature* creature = attackedCreature->getCreature()
    if(creature)
    {
        CreatureEventList targetEvents = getCreatureEvents(CREATURE_EVENT_TARGET);
        for(CreatureEventList::iterator it = targetEvents.begin(); it != targetEvents.end(); ++it)
        {
            if(!(*it)->executeTarget(this, creature))
                return false;
        }
    }
Aí, em data/creaturescripts/scripts:
local config = {
    name = "xxx",    --nome do monstro
    vocId = xxx,     --vocation id
}
function onTarget(cid, target)
    local player = isMonster(cid) and isPlayer(target) and target or isPlayer(cid) and isMonster(target) and getCreatureName(target) == config.name and cid or false
    if player then
        return getPlayerVocation(player) == config.vocId
    end
    return true
end
Registre o evento tanto em login.lua quanto no arquivo XML do monstro.

 

 

Quase amigo, dessa vez o erro foi menor:

2h4yxaq.png

 

Obrigado por esta tentando me ajudar.

zipter98Z
21 de junho de 2015 às 01:31

Ops, corrigido.

AdilsonHackerA
21 de junho de 2015 às 01:57

Affz, agora outro.

2m6o8sj.png

BrunoB
21 de junho de 2015 às 02:05

Troca esse return false por apenas return e testa.

Funções do tipo void não retorna valores.

AdilsonHackerA
21 de junho de 2015 às 02:17

Funcionou, obrigado.

Mas enquanto em lua, nenhum resultado o monster ainda ataca o jogador com vocation id diferente da adicionada no script.