KnightmareZ
New Member
Hello there! I have an event in a Arena where I spawn monsters with Game.createMonster(monster.name, monster.spawnPos ..). Now I would like to add friends(Players) to this monster so he wont target this person. It does add people to this list but still attacks them.
INVESTIGATION RESULT 1. Printer faced this problem where it still tried to steer to the player. Link: https://otland.net/threads/summon-auto-attacking-monster-1-0.211199/ with code examples.
INVESTIGATION RESULT 2. In monster.cpp at Monster::addTarget (Line 305~)
This process should be:
When addTarget is ran it will update monster friendList first (updateTargetList(I dont know?)).
then right before monster going to add target to his targetList, make it check if its in its friendlist. if it is, dont add it to target.
INVESTIGATION RESULT 3 - Tried to add the 4th line below but any monster never attacked any player
INVESTIGATION RESULT 4.
In LUA:
and player can be found in
and in monster.cpp:
and it still add target to player.
INVESTIGATION RESULT 1. Printer faced this problem where it still tried to steer to the player. Link: https://otland.net/threads/summon-auto-attacking-monster-1-0.211199/ with code examples.
INVESTIGATION RESULT 2. In monster.cpp at Monster::addTarget (Line 305~)
This process should be:
When addTarget is ran it will update monster friendList first (updateTargetList(I dont know?)).
then right before monster going to add target to his targetList, make it check if its in its friendlist. if it is, dont add it to target.
INVESTIGATION RESULT 3 - Tried to add the 4th line below but any monster never attacked any player
Code:
void Monster::addTarget(Creature* creature, bool pushFront/* = false*/)
{
assert(creature != this);
if (std::find(targetList.begin(), targetList.end(), creature) == targetList.end()) {
if (std::find(friendList.begin(), friendList.end(), creature) != friendList.end()) {
creature->incrementReferenceCounter();
if (pushFront) {
targetList.push_front(creature);
} else {
targetList.push_back(creature);
}
}
}
}
INVESTIGATION RESULT 4.
In LUA:
Code:
monster:addFriend(player)
Code:
monster:getFriendList().
Code:
if (isOpponent(creature) && isFriend(creature) == false) {[/I][/I][/I][/I][/I]
[I][I][I][I][I] addTarget(creature, pushFront);
}
Last edited: