PacketBuilder reply; PacketBuilder builder; if(this->Data()->type == ENF::Unknown4) { UTIL_PTR_LIST_FOREACH(this->map->characters, Character, character) { Character *target = *character; target->AddRef(); int distance = util::path_length(target->x, target->y, this->x, this->y); if(distance < 2 ) { target->poisoned = true; this->Attack(target); //add this for attacking return; // and this } } } if(this->Data()->type == ENF::Unknown3) { UTIL_PTR_LIST_FOREACH(this->map->characters, Character, character) { Character *target = *character; target->AddRef(); int spellid = this->Data()->spells; int amount = util::rand(this->Data()->mindam, this->Data()->maxdam); int distance = util::path_length(target->x, target->y, this->x, this->y); int limitamount = std::min(amount, int(character->hp)); if(distance > 3 && distance < 10 ) { int xdiff = this->x - target->x; int ydiff = this->y - target->y; int absxdiff = std::abs(xdiff); int absydiff = std::abs(ydiff); if ((absxdiff == 1 && absydiff == 0) || (absxdiff == 0 && absydiff == 1) || (absxdiff == 0 && absydiff == 0)) { return; } else if (absxdiff > absydiff) { if (xdiff < 0) { this->direction = DIRECTION_RIGHT; } else { this->direction = DIRECTION_LEFT; } } else { if (ydiff < 0) { this->direction = DIRECTION_DOWN; } else { this->direction = DIRECTION_UP; } } if (!this->Walk(this->direction)) { this->Walk(static_cast<Direction>(util::rand(0,3))); } //return; } else if(distance < 2) { this->Attack(target); //add this for attacking } else if (distance >=2 && distance <= 7) { if (this->map->world->config["LimitDamage"]) { amount = limitamount; } target->hp -= limitamount; builder.SetID(PACKET_CLOTHES, PACKET_ADMIN); builder.AddShort(0); builder.AddShort(target->player->id); builder.AddThree(amount); builder.AddChar(1); builder.AddChar(int(double(target->hp) / double(target->maxhp) * 100.0)); builder.AddChar(target->hp == 0); builder.AddShort(spellid); UTIL_PTR_LIST_FOREACH(this->map->characters, Character, character) { if (*character == target || !character->InRange(target)) { continue; } character->player->client->SendBuilder(builder); } target->player->client->SendBuilder(builder); if (target->hp == 0) { int sm = target->SpawnMap(); int sx = target->SpawnX(); int sy = target->SpawnY(); target->PetTransfer();//if you dont have a pet system remove this line target->Warp(sm, sx, sy, WARP_ANIMATION_ADMIN); target->PetTransfer();//if you dont have a pet system remove this line target->hp = target->maxhp; if(target->x == sx && target->y == sy) { builder.Reset(); builder.SetID(PACKET_RECOVER, PACKET_PLAYER); builder.AddShort(target->hp); builder.AddInt(target->exp); builder.AddShort(target->tp); target->player->client->SendBuilder(builder); } break; } builder.Reset(); builder.SetID(PACKET_RECOVER, PACKET_PLAYER); builder.AddShort(target->hp); builder.AddShort(target->tp); target->player->client->SendBuilder(builder); } } }