• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Help me to do this function please!!

Rebine

New Member
Joined
Feb 10, 2010
Messages
69
Reaction score
2
Location
Chile
Please someone know how to do this?

When a player have a summon the monster automatic attack the summon, not the player.
And when the player has no summons, monster attack the player.

Please please please :(

I tried but no works XDD
Code:
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;
    }

    Player* player = creature->getPlayer();
    if (player && !player->getSummonCount() != 0)
        return false;

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

    return setFollowCreature(creature, true);
}

Thanks.
 
Last edited:
You can accomplish what you're looking to accomplish in lua, my question is what have you done so far to do so?
 
Man, no. I want to do that in c++ because in lua is not good, can cause freezes or something else.

I did in lua adding function onThink but i dont want to use that.
Can u help me?
 
I tried for the monster attacking players when player has no summon and monsters attacking summon's player when player HAVE summon, i tried with the code i posted but DIDNT worked.

2) I can do that but just in LUA and it causes lag, with this function onThink:
Code:
-- attack config/others

function onThink(cid, interval)

if not isCreature(cid) then
return true
end

local sum = getCreatureSummons(cid)[1]
if #getCreatureSummons(cid) >= 1 then
if isWater(getTileInfo(getThingPos(sum)).itemid) then
doTeleportThing(sum, getThingPos(cid))
doPlayerSendTextMessage(cid, 27, "Tu pokemon no puede estar sobre el mar.")
end
end

if isWater(getTileInfo(getThingPos(cid)).itemid) then
if getPlayerGroupId(cid) == 1 then
setPlayerGroupId(cid, 8)
end
return true
end
if #getCreatureSummons(cid) >= 1 then
    if getPlayerGroupId(cid) == 1 then
    setPlayerGroupId(cid, 8)
    end
elseif #getCreatureSummons(cid) == 0 then
    if getPlayerGroupId(cid) == 8 then
    setPlayerGroupId(cid, 1)
    end
end

local mysum = getCreatureSummons(cid)[1]
if #getCreatureSummons(cid) >= 1 and not isCreature(getCreatureTarget(cid)) then
if math.abs((getThingPos(cid).x) - (getThingPos(mysum).x)) > 7+1 then
doTeleportThing(mysum, getThingPos(cid))
doSendMagicEffect(getThingPos(mysum), 21)
return true
end
if math.abs((getThingPos(cid).y) - (getThingPos(mysum).y)) > 7-1 then
doTeleportThing(mysum, getThingPos(cid))
doSendMagicEffect(getThingPos(mysum), 21)
return true
end
end

return true
end

Group 1: is attackable (by flag)
Group 8: is not attackable (by flag)

The idea is do that in c++ but i can't.

Sorry my english.
 
Man, no. I want to do that in c++ because in lua is not good, can cause freezes or something else.

I did in lua adding function onThink but i dont want to use that.
Can u help me?
Sure can cause freezes if you do something wrong.
I tried for the monster attacking players when player has no summon and monsters attacking summon's player when player HAVE summon, i tried with the code i posted but DIDNT worked.

2) I can do that but just in LUA and it causes lag, with this function onThink:
Code:
-- attack config/others

function onThink(cid, interval)

if not isCreature(cid) then
return true
end

local sum = getCreatureSummons(cid)[1]
if #getCreatureSummons(cid) >= 1 then
if isWater(getTileInfo(getThingPos(sum)).itemid) then
doTeleportThing(sum, getThingPos(cid))
doPlayerSendTextMessage(cid, 27, "Tu pokemon no puede estar sobre el mar.")
end
end

if isWater(getTileInfo(getThingPos(cid)).itemid) then
if getPlayerGroupId(cid) == 1 then
setPlayerGroupId(cid, 8)
end
return true
end
if #getCreatureSummons(cid) >= 1 then
    if getPlayerGroupId(cid) == 1 then
    setPlayerGroupId(cid, 8)
    end
elseif #getCreatureSummons(cid) == 0 then
    if getPlayerGroupId(cid) == 8 then
    setPlayerGroupId(cid, 1)
    end
end

local mysum = getCreatureSummons(cid)[1]
if #getCreatureSummons(cid) >= 1 and not isCreature(getCreatureTarget(cid)) then
if math.abs((getThingPos(cid).x) - (getThingPos(mysum).x)) > 7+1 then
doTeleportThing(mysum, getThingPos(cid))
doSendMagicEffect(getThingPos(mysum), 21)
return true
end
if math.abs((getThingPos(cid).y) - (getThingPos(mysum).y)) > 7-1 then
doTeleportThing(mysum, getThingPos(cid))
doSendMagicEffect(getThingPos(mysum), 21)
return true
end
end

return true
end

Group 1: is attackable (by flag)
Group 8: is not attackable (by flag)

The idea is do that in c++ but i can't.

Sorry my english.
I don't understand what this script has to do with anything in regards to your goals. You just posting a random script for me to see?

You can do this script with either an onTarget, or an onThink. Both pretty easy to do, onThink would accomplish your goal a little better due to the fact that if the player summons a monster after the monster targets the player, it'll still switch. But I would like to see you attempt something, because it doesn't look like you made any effort towards this except making multiple threads for the same thing. If you have nothing to work with, post something in requests, and wait for someone who's willing to do the script for you, but if you have no motive towards this idk why anyone else should.
 
Man do you not undestood what i need in C++ not in LUA?
In lua is too easy, just a script.
But i need to do it in my sources, if you know please help, thanks thats all.
 
Back
Top