diff --git a/flyff-api/src/item/ItemKind2.h b/flyff-api/src/item/ItemKind2.h index 558095d..6cec169 100644 --- a/flyff-api/src/item/ItemKind2.h +++ b/flyff-api/src/item/ItemKind2.h @@ -11,14 +11,10 @@ namespace flyff { enum class ItemKind2 : uint32_t { // from https://api.flyff.com/#tag/item // Remove those which are identified. - // "weapon" - // "armor" // "fashion" // "flying" - // "collector" // "trans" // "fuel" - // "booty" // "charm" // "firework" // "pickuppet" @@ -30,7 +26,12 @@ namespace flyff { // "scroll" // "vendorskin" // "raisedpet" + Weapon = 2, + Armor = 3, Jewelry = 5, + Flying = 6, + Collector = 7, + Booty = 11, Arrow = 12, Recovery = 14, Blinkwing = 15, diff --git a/flyff-api/src/object/mover/Mover.h b/flyff-api/src/object/mover/Mover.h index 6cf6f80..c80fd5d 100644 --- a/flyff-api/src/object/mover/Mover.h +++ b/flyff-api/src/object/mover/Mover.h @@ -119,6 +119,16 @@ namespace flyff { uint64_t get_time_remaining() const; }; + struct __attribute__((packed)) HitInfo { + union { + DEFINE_MEMBER(0, const MoverID, object_id); + DEFINE_MEMBER(16, const MoverID, first_hit); + DEFINE_MEMBER(24, const MoverID, last_hit); + + const MinimumSize<32> size; + }; + }; + union { DEFINE_MEMBER(0x0, const Pointer, vtable); @@ -150,7 +160,7 @@ namespace flyff { DEFINE_MEMBER(1576, Vector>, buffs); - DEFINE_MEMBER(1616, const Vector, enemies); + DEFINE_MEMBER(1616, const Vector, enemies); DEFINE_MEMBER(1628, Vector3, move_target); DEFINE_MEMBER(1652, Vector3, delta_velocity); diff --git a/fugg-client/src/Client.cpp b/fugg-client/src/Client.cpp index ef61c53..8c241da 100644 --- a/fugg-client/src/Client.cpp +++ b/fugg-client/src/Client.cpp @@ -493,7 +493,7 @@ flyff::MoverID find_closest_target() { const auto &mover = current->mover; auto dx = std::abs(mover->position.x - neuz.player->position.x); - auto dy = std::abs(mover->position.y - neuz.player->position.y) * 5; + auto dy = std::abs(mover->position.y - neuz.player->position.y); auto dz = std::abs(mover->position.z - neuz.player->position.z); auto squared = (dx * dx) + (dy * dy) + (dz * dz); @@ -577,7 +577,7 @@ void pickup_target(flyff::MoverID id, uint32_t action) { // if (client.player->selected_target != id) { // client.player->selected_target = id; - client.send_set_target(id); + client.send_set_target(id); // } client.send_interact_target(action); @@ -700,7 +700,9 @@ void attacker_script() { auto monster = neuz.get_mover(current_target); if (monster && !monster->enemies->empty()) { auto is_player_monster_enemy = - std::find(monster->enemies.begin(), monster->enemies.end(), client.player->object_id) != nullptr; + std::find_if(monster->enemies.begin(), monster->enemies.end(), + [&client](const flyff::Mover::HitInfo &x) { return x.object_id == client.player->object_id; }) != + monster->enemies.end(); // If the player is not in the list of enemies, we can not attack the monster. if (!is_player_monster_enemy) { client.show_message("Uh oh, you are being killstealed.", {0xFF, 0, 0}); @@ -800,16 +802,16 @@ void attacker_script() { std::cout << "No item, no target. Searching..." << std::endl; // First check all mobs if they attacked me (aggro ones). - for (const auto &id: client.player->enemies) { - const auto &mover = client.get_mover(id); + for (const auto &hit: client.player->enemies) { + const auto &mover = client.get_mover(hit.object_id); if (mover) { std::string str = "Attacking "; str.append(mover->name); str.append(" because it is my enemy."); - current_target = id; - attack_target(id); + current_target = hit.object_id; + attack_target(hit.object_id); neuz.show_message(str); return; @@ -987,14 +989,6 @@ void after_main_loop() { // std::cout << "Speed: " << client.player->get_speed() << std::endl; // } - if (client.player) { - auto monster = client.get_mover(client.player->selected_target); - - if (monster) { - - } - } - switch (script) { case ScriptType::Attacker: attacker_script();