void Map::Poisoned()
{
PacketBuilder builder;
UTIL_PTR_LIST_FOREACH(this->characters, Character, character)
{
Character *from = *character;
from->AddRef();
if(from->poisoned == true)
{
int amount = util::rand(2, 10);
int limitamount = std::min(amount, int(from->hp));
if(this->world->config["LimitDamage"])
{
amount = limitamount;
}
from->hp -= limitamount;
builder.SetID(PACKET_CLOTHES, PACKET_REPLY);
builder.AddShort(0);
builder.AddShort(from->player->id);
builder.AddThree(amount);
builder.AddChar(from->direction);
builder.AddChar(int(double(from->hp) / double(from->maxhp) * 100.0));
builder.AddChar(from->hp == 0);
UTIL_PTR_LIST_FOREACH(this->characters, Character, checkchar)
{
if (from->InRange(*checkchar))
{
checkchar->player->client->SendBuilder(builder);
}
}
if(from->hp == 0)
{
int sm = from->SpawnMap();
int sx = from->SpawnX();
int sy = from->SpawnY();
from->PetTransfer();//if you dont have a pet system remove this line
from->Warp(sm, sx, sy, WARP_ANIMATION_ADMIN);
from->PetTransfer();//if you dont have a pet system remove this line
from->hp = from->maxhp;
from->poisoned = false;
if(from->x == sx && from->y == sy)
{
builder.Reset();
builder.SetID(PACKET_RECOVER, PACKET_PLAYER);
builder.AddShort(from->hp);
builder.AddInt(from->exp);
builder.AddShort(from->tp);
from->player->client->SendBuilder(builder);
}
break;
}
builder.Reset();
builder.SetID(PACKET_RECOVER, PACKET_PLAYER);
builder.AddShort(from->hp);
builder.AddInt(from->exp);
builder.AddShort(from->tp);
from->player->client->SendBuilder(builder);
}
}
}