Fixed HitInfo on Mover, which was actually a structure
This commit is contained in:
parent
cff2af6a0d
commit
1c9001f582
|
|
@ -11,14 +11,10 @@ namespace flyff {
|
||||||
enum class ItemKind2 : uint32_t {
|
enum class ItemKind2 : uint32_t {
|
||||||
// from https://api.flyff.com/#tag/item
|
// from https://api.flyff.com/#tag/item
|
||||||
// Remove those which are identified.
|
// Remove those which are identified.
|
||||||
// "weapon"
|
|
||||||
// "armor"
|
|
||||||
// "fashion"
|
// "fashion"
|
||||||
// "flying"
|
// "flying"
|
||||||
// "collector"
|
|
||||||
// "trans"
|
// "trans"
|
||||||
// "fuel"
|
// "fuel"
|
||||||
// "booty"
|
|
||||||
// "charm"
|
// "charm"
|
||||||
// "firework"
|
// "firework"
|
||||||
// "pickuppet"
|
// "pickuppet"
|
||||||
|
|
@ -30,7 +26,12 @@ namespace flyff {
|
||||||
// "scroll"
|
// "scroll"
|
||||||
// "vendorskin"
|
// "vendorskin"
|
||||||
// "raisedpet"
|
// "raisedpet"
|
||||||
|
Weapon = 2,
|
||||||
|
Armor = 3,
|
||||||
Jewelry = 5,
|
Jewelry = 5,
|
||||||
|
Flying = 6,
|
||||||
|
Collector = 7,
|
||||||
|
Booty = 11,
|
||||||
Arrow = 12,
|
Arrow = 12,
|
||||||
Recovery = 14,
|
Recovery = 14,
|
||||||
Blinkwing = 15,
|
Blinkwing = 15,
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,16 @@ namespace flyff {
|
||||||
uint64_t get_time_remaining() const;
|
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 {
|
union {
|
||||||
DEFINE_MEMBER(0x0, const Pointer<const Vtable>, vtable);
|
DEFINE_MEMBER(0x0, const Pointer<const Vtable>, vtable);
|
||||||
|
|
||||||
|
|
@ -150,7 +160,7 @@ namespace flyff {
|
||||||
|
|
||||||
DEFINE_MEMBER(1576, Vector<Pointer<Buff>>, buffs);
|
DEFINE_MEMBER(1576, Vector<Pointer<Buff>>, buffs);
|
||||||
|
|
||||||
DEFINE_MEMBER(1616, const Vector<flyff::MoverID>, enemies);
|
DEFINE_MEMBER(1616, const Vector<const HitInfo>, enemies);
|
||||||
DEFINE_MEMBER(1628, Vector3, move_target);
|
DEFINE_MEMBER(1628, Vector3, move_target);
|
||||||
|
|
||||||
DEFINE_MEMBER(1652, Vector3, delta_velocity);
|
DEFINE_MEMBER(1652, Vector3, delta_velocity);
|
||||||
|
|
|
||||||
|
|
@ -493,7 +493,7 @@ flyff::MoverID find_closest_target() {
|
||||||
const auto &mover = current->mover;
|
const auto &mover = current->mover;
|
||||||
|
|
||||||
auto dx = std::abs(mover->position.x - neuz.player->position.x);
|
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 dz = std::abs(mover->position.z - neuz.player->position.z);
|
||||||
|
|
||||||
auto squared = (dx * dx) + (dy * dy) + (dz * dz);
|
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) {
|
// if (client.player->selected_target != id) {
|
||||||
// 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);
|
client.send_interact_target(action);
|
||||||
|
|
@ -700,7 +700,9 @@ void attacker_script() {
|
||||||
auto monster = neuz.get_mover(current_target);
|
auto monster = neuz.get_mover(current_target);
|
||||||
if (monster && !monster->enemies->empty()) {
|
if (monster && !monster->enemies->empty()) {
|
||||||
auto is_player_monster_enemy =
|
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 the player is not in the list of enemies, we can not attack the monster.
|
||||||
if (!is_player_monster_enemy) {
|
if (!is_player_monster_enemy) {
|
||||||
client.show_message("Uh oh, you are being killstealed.", {0xFF, 0, 0});
|
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;
|
std::cout << "No item, no target. Searching..." << std::endl;
|
||||||
|
|
||||||
// First check all mobs if they attacked me (aggro ones).
|
// First check all mobs if they attacked me (aggro ones).
|
||||||
for (const auto &id: client.player->enemies) {
|
for (const auto &hit: client.player->enemies) {
|
||||||
const auto &mover = client.get_mover(id);
|
const auto &mover = client.get_mover(hit.object_id);
|
||||||
|
|
||||||
if (mover) {
|
if (mover) {
|
||||||
std::string str = "Attacking ";
|
std::string str = "Attacking ";
|
||||||
str.append(mover->name);
|
str.append(mover->name);
|
||||||
str.append(" because it is my enemy.");
|
str.append(" because it is my enemy.");
|
||||||
|
|
||||||
current_target = id;
|
current_target = hit.object_id;
|
||||||
attack_target(id);
|
attack_target(hit.object_id);
|
||||||
|
|
||||||
neuz.show_message(str);
|
neuz.show_message(str);
|
||||||
return;
|
return;
|
||||||
|
|
@ -987,14 +989,6 @@ void after_main_loop() {
|
||||||
// std::cout << "Speed: " << client.player->get_speed() << std::endl;
|
// 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) {
|
switch (script) {
|
||||||
case ScriptType::Attacker:
|
case ScriptType::Attacker:
|
||||||
attacker_script();
|
attacker_script();
|
||||||
|
|
|
||||||
Reference in New Issue