From 67e2b62ab170c0a9a678eff288575a1d4602ed0e Mon Sep 17 00:00:00 2001 From: Knaapchen Date: Tue, 1 Nov 2022 18:59:25 +0100 Subject: [PATCH] Added MoverProperty Added Element and Rank enums Discovered Speed property --- flyff-api/CMakeLists.txt | 2 +- flyff-api/src/object/Object.h | 11 ++-- flyff-api/src/object/mover/Element.h | 50 +++++++++++++++++ flyff-api/src/object/mover/Mover.h | 50 ++++++++++++----- flyff-api/src/object/mover/MoverProperty.h | 27 +++++++++ flyff-api/src/object/mover/ParamID.h | 7 ++- flyff-api/src/object/mover/Rank.h | 65 ++++++++++++++++++++++ fugg-client/src/Client.cpp | 61 ++++++++++++-------- 8 files changed, 229 insertions(+), 44 deletions(-) create mode 100644 flyff-api/src/object/mover/Element.h create mode 100644 flyff-api/src/object/mover/MoverProperty.h create mode 100644 flyff-api/src/object/mover/Rank.h diff --git a/flyff-api/CMakeLists.txt b/flyff-api/CMakeLists.txt index 73a870e..994c35b 100644 --- a/flyff-api/CMakeLists.txt +++ b/flyff-api/CMakeLists.txt @@ -8,7 +8,7 @@ add_library( "include/flyff.h" src/core.h src/skill/SkillProperty.h - src/object/ObjectProperty.h src/item/ItemKind2.h src/item/ItemKind3.h src/item/Part.h src/item/InventoryItem.h src/object/mover/JobProperty.h src/object/mover/ParamID.h) + src/object/ObjectProperty.h src/item/ItemKind2.h src/item/ItemKind3.h src/item/Part.h src/item/InventoryItem.h src/object/mover/JobProperty.h src/object/mover/ParamID.h src/object/mover/MoverProperty.h src/object/mover/Rank.h src/object/mover/Element.h) target_include_directories(flyff-api PUBLIC "include") target_link_libraries(flyff-api PUBLIC flyff-client fugg-api) \ No newline at end of file diff --git a/flyff-api/src/object/Object.h b/flyff-api/src/object/Object.h index 69503ed..62cef1e 100644 --- a/flyff-api/src/object/Object.h +++ b/flyff-api/src/object/Object.h @@ -51,17 +51,18 @@ namespace flyff { Attack3, // ... Attack4, - + // OBJSTA_ATK_MAGIC1 Unknown1, - Unknown2, + // Shoot arrow (OBJSTA_ATK_RANGE1) + Ranged, Unknown3, Unknown4, - // Magic Casting #1 (Start) + // Magic Casting #1 (Start) (OBJSTA_ATK_CASTING1) Casting1, - // Magic Casting 2 times (repeat.) + // Magic Casting 2 times (repeat.) (OBJSTA_ATK_CASTING2) Casting2, - // Magic firing action. + // Magic firing action. (OBJSTA_ATK_MAGICSKILL) MagicSkill, // wand attack in action diff --git a/flyff-api/src/object/mover/Element.h b/flyff-api/src/object/mover/Element.h new file mode 100644 index 0000000..b82d1fe --- /dev/null +++ b/flyff-api/src/object/mover/Element.h @@ -0,0 +1,50 @@ +// +// Created by main on 31-10-22. +// + +#ifndef FUGG_ELEMENT_H +#define FUGG_ELEMENT_H + +#include +#include + +namespace flyff { + enum class Element : uint32_t { + None, + Fire, + Water, + Electricity, + Air, + Earth + }; + + static std::ostream &operator<<(std::ostream &os, const Element &element) { + switch(element) { + case Element::None: + os << "None"; + break; + case Element::Fire: + os << "Fire"; + break; + case Element::Water: + os << "Water"; + break; + case Element::Electricity: + os << "Electricity"; + break; + case Element::Air: + os << "Air"; + break; + case Element::Earth: + os << "Earth"; + break; + default: + os << "Element(" << static_cast(element) << ")"; + break; + } + return os; + } +}; + + +#endif //FUGG_ELEMENT_H diff --git a/flyff-api/src/object/mover/Mover.h b/flyff-api/src/object/mover/Mover.h index e9c8347..071b68d 100644 --- a/flyff-api/src/object/mover/Mover.h +++ b/flyff-api/src/object/mover/Mover.h @@ -21,6 +21,7 @@ #include "../../item/Part.h" #include "JobProperty.h" #include "ParamID.h" +#include "MoverProperty.h" namespace flyff { namespace raw { @@ -116,19 +117,27 @@ namespace flyff { DEFINE_MEMBER(164, const Vector3, rotation); DEFINE_MEMBER(188, const Pointer, property); + DEFINE_MEMBER(192, uintptr_t, world); + + DEFINE_MEMBER(204, const ObjectType, type); DEFINE_MEMBER(212, const int, property_id); DEFINE_MEMBER(216, const bool, is_despawned); DEFINE_MEMBER(352, const MoverID, object_id); + DEFINE_MEMBER(860, Vector, inventory); + // If the index of the InventoryItem is below this, it's in the inventory. Otherwise it's equipped. + DEFINE_MEMBER(872, const uint32_t, max_inventory_slots); + DEFINE_MEMBER(880, const uint32_t, locked_inventory_slots); + + DEFINE_MEMBER(904, uint32_t, if_not_null_needsattackitem); + DEFINE_MEMBER(920, Parameter, adjusted_parameters[MAX_PARAM]); DEFINE_MEMBER(1248, Parameter, changed_parameters[MAX_PARAM]); DEFINE_MEMBER(1576, Vector>, buffs); - DEFINE_MEMBER(2020, const String, name); - DEFINE_MEMBER(1616, const Vector, enemies); DEFINE_MEMBER(1628, Vector3, move_target); @@ -146,28 +155,20 @@ namespace flyff { DEFINE_MEMBER(1768, MoverID, current_attack_target); DEFINE_MEMBER(1776, MoverID, platform_standing_on); + DEFINE_MEMBER(1792, int, current_animation); + DEFINE_MEMBER(1816, int, adj_param); DEFINE_MEMBER(1820, uint32_t, server_tick); DEFINE_MEMBER(1840, int, hitpoints); DEFINE_MEMBER(1848, int, is_grounded); - - DEFINE_MEMBER(1792, int, current_animation); - - DEFINE_MEMBER(204, const ObjectType, type); + DEFINE_MEMBER(1888, const float, speed_factor); DEFINE_MEMBER(1804, uint32_t, object_state); DEFINE_MEMBER(1808, uint32_t, object_state_flags); - DEFINE_MEMBER(904, uint32_t, if_not_null_needsattackitem); - - DEFINE_MEMBER(192, uintptr_t, world); - - DEFINE_MEMBER(860, Vector, inventory); - // If the index of the InventoryItem is below this, it's in the inventory. Otherwise it's equipped. - DEFINE_MEMBER(872, const uint32_t, max_inventory_slots); - DEFINE_MEMBER(880, const uint32_t, locked_inventory_slots); + DEFINE_MEMBER(2020, const String, name); DEFINE_MEMBER(2432, const flyff::Pointer, job_property); @@ -239,6 +240,20 @@ namespace flyff { return flyff::Pointer(ptr); } + float get_speed() const { + auto *mover_property = reinterpret_cast( + static_cast(property) + ); + + auto src_speed = mover_property->speed * speed_factor; + auto adj_value = get_adjust_param(flyff::ParamID::Speed); + if (adj_value != 0) { + src_speed = src_speed + (src_speed * (static_cast(adj_value) / 100.0f)); + } + + return src_speed <= 0. ? 0. : src_speed; + } + uint32_t get_max_hp() const { float factor = 1.0f; auto result = get_param(ParamID::MaxHitPoint, get_max_origin_hp()); @@ -286,6 +301,11 @@ namespace flyff { return (object_state & ObjectState::LookAll); } + void set_jump_state(Object::JumpState state) { + uint32_t new_state = (static_cast(state) & 0xF) << 12; + object_state = (object_state & ~(1UL << 12)) | new_state; + } + Object::JumpState get_jump_state() const { // 0x0000F000 return static_cast((object_state >> 12) & 0xF); @@ -342,7 +362,7 @@ namespace flyff { bool is_jumping() const { return get_jump_state() != Object::JumpState::None && - get_jump_state() != Object::JumpState::Ready; + get_jump_state() != Object::JumpState::Ready; } bool is_attacking() const { diff --git a/flyff-api/src/object/mover/MoverProperty.h b/flyff-api/src/object/mover/MoverProperty.h new file mode 100644 index 0000000..5a2df5e --- /dev/null +++ b/flyff-api/src/object/mover/MoverProperty.h @@ -0,0 +1,27 @@ +// +// Created by main on 31-10-22. +// + +#ifndef FUGG_MOVERPROPERTY_H +#define FUGG_MOVERPROPERTY_H + +#include "../../core.h" + +#include "Rank.h" +#include "Element.h" + +namespace flyff { + struct MoverProperty { + union { + DEFINE_MEMBER(40, const flyff::String, name); + DEFINE_MEMBER(56, const Rank, rank); + DEFINE_MEMBER(60, const Element, element); + + DEFINE_MEMBER(120, const float, speed); + + const MinimumSize<176> _size; + }; + }; +}; + +#endif //FUGG_MOVERPROPERTY_H diff --git a/flyff-api/src/object/mover/ParamID.h b/flyff-api/src/object/mover/ParamID.h index 6fb7e16..69f3901 100644 --- a/flyff-api/src/object/mover/ParamID.h +++ b/flyff-api/src/object/mover/ParamID.h @@ -9,10 +9,15 @@ namespace flyff { enum class ParamID : uint32_t { + Strength = 0, + Dexterity, + Intelligence, + Stamina, + Speed = 4, // UnknownSpeed = 9, - + AdditionalDamage = 35, // DST_HP_MAX MaxHitPoint = 44, // DST_HP_MAX_RATE diff --git a/flyff-api/src/object/mover/Rank.h b/flyff-api/src/object/mover/Rank.h new file mode 100644 index 0000000..6219578 --- /dev/null +++ b/flyff-api/src/object/mover/Rank.h @@ -0,0 +1,65 @@ +// +// Created by main on 31-10-22. +// + +#ifndef FUGG_RANK_H +#define FUGG_RANK_H + +#include +#include + +namespace flyff { + enum class Rank : uint32_t { + None, + Low, + Normal, + Captain, + Boss, + MidBoss, + Material, + Super, + Guard, + Citizen + }; + + static std::ostream &operator<<(std::ostream &os, const Rank &rank) { + switch(rank) { + case Rank::None: + os << "None"; + break; + case Rank::Low: + os << "Low"; + break; + case Rank::Normal: + os << "Normal"; + break; + case Rank::Captain: + os << "Captain"; + break; + case Rank::Boss: + os << "Boss"; + break; + case Rank::MidBoss: + os << "MidBoss"; + break; + case Rank::Material: + os << "Material"; + break; + case Rank::Super: + os << "Super"; + break; + case Rank::Guard: + os << "Guard"; + break; + case Rank::Citizen: + os << "Citizen"; + break; + default: + os << "Rank(" << static_cast(rank) << ")"; + break; + } + return os; + } +}; + +#endif //FUGG_RANK_H diff --git a/fugg-client/src/Client.cpp b/fugg-client/src/Client.cpp index 3ccc981..e249ea4 100644 --- a/fugg-client/src/Client.cpp +++ b/fugg-client/src/Client.cpp @@ -661,30 +661,30 @@ void attacker_script() { // } // // if (buffs.empty()) { - if (!main_hand || main_hand->item_kind3 != flyff::ItemKind3::KnuckleHammer) { - const auto &knuckle = find_first_equippable_item(flyff::ItemKind3::KnuckleHammer); + if (!main_hand || main_hand->item_kind3 != flyff::ItemKind3::KnuckleHammer) { + const auto &knuckle = find_first_equippable_item(flyff::ItemKind3::KnuckleHammer); - if (knuckle) { - client.send_use_item_in_inventory(knuckle->index); - } else { - neuz.show_message("Unable to find a knuckle", {0xFF, 0, 0}); - } + if (knuckle) { + client.send_use_item_in_inventory(knuckle->index); + } else { + neuz.show_message("Unable to find a knuckle", {0xFF, 0, 0}); } + } - if (!off_hand || off_hand->item_kind3 != flyff::ItemKind3::Shield) { - const auto &shield = find_first_equippable_item(flyff::ItemKind3::Shield); + if (!off_hand || off_hand->item_kind3 != flyff::ItemKind3::Shield) { + const auto &shield = find_first_equippable_item(flyff::ItemKind3::Shield); - if (shield) { - client.send_use_item_in_inventory(shield->index); - } else { - neuz.show_message("Unable to find a shield", {0xFF, 0, 0}); - } + if (shield) { + client.send_use_item_in_inventory(shield->index); + } else { + neuz.show_message("Unable to find a shield", {0xFF, 0, 0}); } + } - if(!check_rebuff(neuz.player, neuz.player, { flyff::SkillID::Asmodeus }).empty()) { - client.send_use_skill(flyff::SkillID::Asmodeus); - return; - } + if (!check_rebuff(neuz.player, neuz.player, {flyff::SkillID::Asmodeus}).empty()) { + client.send_use_skill(flyff::SkillID::Asmodeus); + return; + } // } } @@ -861,12 +861,29 @@ void before_main_loop() { void after_main_loop() { const auto &client = fugg::Client::instance(); - if (client.player && client.player->is_moving() && !client.player->is_jumping()) { + // TODO: Fix player getting stuck. + // - Detect player stuck behind tree. + // - Try one of the following methods: + // - See if you can glitch through objects by moving the player forward by ~15% of the speed. + // - Jump + // TODO: Fix player trying to pick up items that are someone elses. + +// if (client.player && client.player->is_moving() && !client.player->is_jumping()) { // std::cout << "Sending jump packet!" << std::endl; // -// double rotation_y = client.player->rotation.y; -// client.send_motion_packet(0x2, *reinterpret_cast(&rotation_y)); - } +// client.send_motion_packet(0x2, *reinterpret_cast(&client.player->rotation.y)); +// client.player->set_jump_state(flyff::Object::JumpState::Jump); +// +// std::cout << "New state: " << reinterpret_cast(client.player->object_state) << std::endl; +// } + + +// if (client.player && client.player->is_moving()) { +//// std::cout << "Player is " << client.player->is_grounded << std::endl; +//// std::cout << client.player->get_attack_state() << std::endl; +// std::cout << "Speed: " << client.player->get_speed() << std::endl; +// } + switch (script) {