Added MoverProperty

Added Element and Rank enums
Discovered Speed property
This commit is contained in:
Knaapchen 2022-11-01 18:59:25 +01:00
parent 51743e3ba2
commit 67e2b62ab1
8 changed files with 229 additions and 44 deletions

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,50 @@
//
// Created by main on 31-10-22.
//
#ifndef FUGG_ELEMENT_H
#define FUGG_ELEMENT_H
#include <cstdint>
#include <ostream>
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<unsigned>(element) << ")";
break;
}
return os;
}
};
#endif //FUGG_ELEMENT_H

View File

@ -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<const ObjectProperty>, 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<InventoryItem>, 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<Pointer<Buff>>, buffs);
DEFINE_MEMBER(2020, const String, name);
DEFINE_MEMBER(1616, const Vector<flyff::MoverID>, 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<InventoryItem>, 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<const JobProperty>, job_property);
@ -239,6 +240,20 @@ namespace flyff {
return flyff::Pointer<flyff::ItemProperty>(ptr);
}
float get_speed() const {
auto *mover_property = reinterpret_cast<const flyff::MoverProperty *>(
static_cast<const flyff::ObjectProperty *>(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<float>(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<uint32_t>(state) & 0xF) << 12;
object_state = (object_state & ~(1UL << 12)) | new_state;
}
Object::JumpState get_jump_state() const {
// 0x0000F000
return static_cast<Object::JumpState>((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 {

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,65 @@
//
// Created by main on 31-10-22.
//
#ifndef FUGG_RANK_H
#define FUGG_RANK_H
#include <cstdint>
#include <ostream>
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<unsigned>(rank) << ")";
break;
}
return os;
}
};
#endif //FUGG_RANK_H

View File

@ -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<unsigned long long*>(&rotation_y));
}
// client.send_motion_packet(0x2, *reinterpret_cast<const uint32_t*>(&client.player->rotation.y));
// client.player->set_jump_state(flyff::Object::JumpState::Jump);
//
// std::cout << "New state: " << reinterpret_cast<void*>(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) {