AustinB posted: (29th Jan 2011 10:14 am)
Then you edited it wrong, because it works just fine. It attacks in a 4x4 square around me, so i don't know about you.
void Map::Attack(Character *from, Direction direction)
{
PacketBuilder builder;
from->direction = direction;
if (from->arena)
{
from->arena->Attack(from, direction);
}
if (this->pk || (this->world->config["GlobalPK"] && !this->world->PKExcept(this->id)))
{
if (this->AttackPK(from, direction))
{
return;
}
}
builder.SetID(PACKET_ATTACK, PACKET_PLAYER);
builder.AddShort(from->player->id);
builder.AddChar(direction);
UTIL_PTR_LIST_FOREACH(this->characters, Character, character)
{
if (*character == from || !from->InRange(*character))
{
continue;void Map::Attack(Character *from, Direction direction)
{
PacketBuilder builder;
from->direction = direction;
if (from->arena)
{
from->arena->Attack(from, direction);
}
if (this->pk || (this->world->config["GlobalPK"] && !this->world->PKExcept(this->id)))
{
if (this->AttackPK(from, direction))
{
return;
}
}
builder.SetID(PACKET_ATTACK, PACKET_PLAYER);
builder.AddShort(from->player->id);
builder.AddChar(direction);
UTIL_PTR_LIST_FOREACH(this->characters, Character, character)
{
if (*character == from || !from->InRange(*character))
{
continue;
}
character->player->client->SendBuilder(builder);
}
int target_x = from->x;
int target_y = from->y;
int range = 1;
if (this->world->eif->Get(from->paperdoll[Character::Weapon])->subtype == EIF::Ranged)
{
range = static_cast<int>(this->world->config["RangedDistance"]);
}
for (int i = 0; i < range; ++i)
{
switch (from->direction)
{
case DIRECTION_UP:
target_y -= 1;
break;
case DIRECTION_RIGHT:
target_x += 1;
break;
case DIRECTION_DOWN:
target_y += 1;
break;
case DIRECTION_LEFT:
target_x -= 1;
break;
}
if(from->paperdoll[Character::Weapon] == 486)
{
UTIL_PTR_VECTOR_FOREACH(this->npcs, NPC, closeby)
{
int distance = util::path_length(target_x, target_y, closeby->x, closeby->y);
int amount = util::rand(from->mindam + 0, from->maxdam + 0);
if (distance <=2 && closeby->alive)
{
closeby->Damage(from, amount);
}
}
}
Rite?