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 {
|
||||
// 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,
|
||||
|
|
|
|||
|
|
@ -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<const Vtable>, vtable);
|
||||
|
||||
|
|
@ -150,7 +160,7 @@ namespace flyff {
|
|||
|
||||
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(1652, Vector3, delta_velocity);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Reference in New Issue