I'd like to have a constant effect on an NPC, like how in Diablo 3, the Elite monsters have specific effects. Having a timed/constant effect is trivial, so that's not the problem. I can't find a solid solution to show
an effect on an NPC.
For a character, you can have a direct character effect, or you can do a tile effect.
For an npc, I see that you can do a spell effect directly on the npc, or you can also do a tile effect.
What I would like is an effect that behaves exactly like a character effect.
If I use a spell effect, the drawback is that it will show the HP bar and the damage on the NPC. Ontop of that, I am forced to create a spell in the pub file to do a specific effect.
Code:
void NPC::SpellEffect(int spellID)
{
PacketBuilder builder(PACKET_CAST, PACKET_REPLY, 14);
builder.AddShort(spellID);
builder.AddShort(0);
builder.AddChar(0);
builder.AddShort(this->index);
builder.AddThree(0);
builder.AddShort(util::clamp<int>(double(this->hp) / double(this->ENF().hp) * 100.0, 0, 100));
builder.AddShort(0);
UTIL_FOREACH(this->map->characters, character)
{
if (character->InRange(this))
{
character->Send(builder);
}
}
}
Result:
If I use a tile effect, there are other drawbacks:
- The effect behaves differently for some effects
- Some effects don't show, I assume because they are shown under the tile (like effect #6).
- Since they are tile based, they don't move with the NPC.
Code:
void NPC::TileEffect(int effect)
{
PacketBuilder builder(PACKET_EFFECT, PACKET_AGREE);
builder.AddChar(this->x);
builder.AddChar(this->y);
builder.AddShort(effect);
UTIL_FOREACH(this->map->characters, character)
{
if (character->InRange(this))
{
character->Send(builder);
}
}
}
Results:
Any clue what workaround I can do on server side or client side to achieve a more acceptable effect? If not, I will just use a tile effect.
---
Just your friendly neighborhood Programmer-Man!