• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Request: C++: When i shoot attack with my summon! Rep++

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
Request: When i shoot attack with my summon, the monster doesnt attack back i have to click on the monster as a target then its attack me. The attacks is based on talkactions i dont think the scripts are wrong i think i have to change on c++!

If you dont understand here is a movie:

[video=youtube;j8II600S598]http://www.youtube.com/watch?v=j8II600S598[/video]

Please Help!


Rep++
 
monster.cpp before "void Monster::onCreatureFound(Creature* creature, bool pushFront /*= false*/)" add:
[cpp]void Monster::addTarget(Creature* creature, bool pushFront /*= false*/)
{
if(isOpponent(creature))
{
assert(creature != this);
if(std::find(targetList.begin(), targetList.end(), creature) == targetList.end())
{
creature->addRef();
if(pushFront)
targetList.push_front(creature);
else
targetList.push_back(creature);
}
}

updateIdleStatus();
}[/cpp]

In function "void Monster::onCreatureFound(Creature* creature, bool pushFront /*= false*/)" remove this:
[cpp]if(isOpponent(creature))
{
assert(creature != this);
if(std::find(targetList.begin(), targetList.end(), creature) == targetList.end())
{
creature->addRef();
if(pushFront)
targetList.push_front(creature);
else
targetList.push_back(creature);
}
}[/cpp]

In monster.h after "bool isFleeing() const {return getHealth() <= mType->runAwayHealth;}" add:
[cpp]void addTarget(Creature* creature, bool pushFront = false);[/cpp]

combat.cpp:
In function "bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)", "bool Combat::CombatNullFunc(Creature* caster, Creature* target, const CombatParams& params, void*)" and "bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)" add:
[cpp] if(Monster* attackedMonster = target->getMonster())
if(!attackedMonster->isSummon())
{
attackedMonster->addTarget(caster, true);
if(Creature* master = caster->getMaster())
attackedMonster->addTarget(master, false);
}[/cpp]
before "return true;"
 
Last edited:
Summ does it mean if someone shoot like !attack the monster will attack you because its m1,m2,m3
 
If I am right you need to have a target to cast those spells and when you target the creature it will start attacking you.
 
Not all the spells need target they are like exevo gran mas vis, when i shoot with out target the monster, the monster doesnt attack back.
 
i tried your code, it's nice, but it has a bug, when i attack normally a monster this it doesn't attack me, it attacks me only when i throw it a spell, can you fix that?
thanks in advance :)
 
i tried your code, it's nice, but it has a bug, when i attack normally a monster this it doesn't attack me, it attacks me only when i throw it a spell, can you fix that?
thanks in advance :)

Have you fix what joe rod said?
 
Back
Top