Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HeavenClient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ if(HEAVENCLIENT_BUILD_TESTS)
add_executable(movement_path_tests tests/movement_path.cpp Net/InPacket.cpp Net/Handlers/Helpers/MovementParser.cpp)
target_include_directories(movement_path_tests PRIVATE ${PROJECT_SOURCE_DIR}/libs/NoLifeNx)
add_test(NAME movement_path COMMAND movement_path_tests)
add_executable(buff_parser_tests tests/buff_parser.cpp Net/InPacket.cpp Net/Handlers/Helpers/BuffParser.cpp Character/Buff.cpp)
target_include_directories(buff_parser_tests PRIVATE ${PROJECT_SOURCE_DIR}/libs/NoLifeNx)
add_test(NAME buff_parser COMMAND buff_parser_tests)
add_executable(status_messages_tests tests/status_messages.cpp Net/InPacket.cpp)
target_include_directories(status_messages_tests PRIVATE ${PROJECT_SOURCE_DIR}/libs/NoLifeNx)
add_test(NAME status_messages COMMAND status_messages_tests)
Expand Down Expand Up @@ -567,6 +570,8 @@ add_executable(HeavenClient
Net/Handlers/Helpers/LoginParser.h
Net/Handlers/Helpers/MovementParser.cpp
Net/Handlers/Helpers/MovementParser.h
Net/Handlers/Helpers/BuffParser.cpp
Net/Handlers/Helpers/BuffParser.h
Net/Handlers/AttackHandlers.cpp
Net/Handlers/AttackHandlers.h
Net/Handlers/BuddyHandlers.cpp
Expand Down
2 changes: 2 additions & 0 deletions HeavenClient/Character/ActiveBuffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ namespace ms
buffs[Buffstat::Id::MDEF] = std::make_unique<SimpleStatBuff<EquipStat::Id::MDEF>>();
buffs[Buffstat::Id::SPEED] = std::make_unique<SimpleStatBuff<EquipStat::Id::SPEED>>();
buffs[Buffstat::Id::JUMP] = std::make_unique<SimpleStatBuff<EquipStat::Id::JUMP>>();
buffs[Buffstat::Id::ACC] = std::make_unique<SimpleStatBuff<EquipStat::Id::ACC>>();
buffs[Buffstat::Id::AVOID] = std::make_unique<SimpleStatBuff<EquipStat::Id::AVOID>>();
buffs[Buffstat::Id::HYPERBODYHP] = std::make_unique<PercentageStatBuff<EquipStat::Id::HP>>();
buffs[Buffstat::Id::HYPERBODYMP] = std::make_unique<PercentageStatBuff<EquipStat::Id::MP>>();
}
Expand Down
136 changes: 60 additions & 76 deletions HeavenClient/Character/Buff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,80 +21,64 @@ namespace ms
{
namespace Buffstat
{
const std::unordered_map<Id, uint64_t> first_codes =
{
{Id::DASH2, 0x8000000000000L},
{Id::DASH, 0x10000000000000L},
{Id::ELEMENTAL_RESET, 0x200000000L},
{Id::ARAN_COMBO, 0x1000000000L},
{Id::COMBO_DRAIN, 0x2000000000L},
{Id::COMBO_BARRIER, 0x4000000000L},
{Id::BODY_PRESSURE, 0x8000000000L},
{Id::SMART_KNOCKBACK, 0x10000000000L},
{Id::PYRAMID_PQ, 0x20000000000L},
{Id::ENERGY_CHARGE, 0x4000000000000L},
{Id::MONSTER_RIDING, 0x20000000000000L},
{Id::HOMING_BEACON, 0x80000000000000L},
{Id::SPEED_INFUSION, 0x100000000000000L}
};

const std::unordered_map<Id, uint64_t> second_codes =
{
{Id::NONE, 0x0},
{Id::MORPH, 0x2},
{Id::RECOVERY, 0x4},
{Id::MAPLE_WARRIOR, 0x8},
{Id::STANCE, 0x10},
{Id::SHARP_EYES, 0x20},
{Id::MANA_REFLECTION, 0x40},
{Id::SHADOW_CLAW, 0x100},
{Id::INFINITY_, 0x200},
{Id::HOLY_SHIELD, 0x400},
{Id::HAMSTRING, 0x800},
{Id::BLIND, 0x1000},
{Id::CONCENTRATE, 0x2000},
{Id::ECHO_OF_HERO, 0x8000},
{Id::GHOST_MORPH, 0x20000},
{Id::AURA, 0x40000},
{Id::CONFUSE, 0x80000},
{Id::BERSERK_FURY, 0x8000000},
{Id::DIVINE_BODY, 0x10000000},
{Id::SPARK, 0x20000000L},
{Id::FINALATTACK, 0x80000000L},
{Id::BATTLESHIP, 0xA00000040L},
{Id::WATK, 0x100000000L},
{Id::WDEF, 0x200000000L},
{Id::MATK, 0x400000000L},
{Id::MDEF, 0x800000000L},
{Id::ACC, 0x1000000000L},
{Id::AVOID, 0x2000000000L},
{Id::HANDS, 0x4000000000L},
{Id::SHOWDASH, 0x4000000000L},
{Id::SPEED, 0x8000000000L},
{Id::JUMP, 0x10000000000L},
{Id::MAGIC_GUARD, 0x20000000000L},
{Id::DARKSIGHT, 0x40000000000L},
{Id::BOOSTER, 0x80000000000L},
{Id::POWERGUARD, 0x100000000000L},
{Id::HYPERBODYHP, 0x200000000000L},
{Id::HYPERBODYMP, 0x400000000000L},
{Id::INVINCIBLE, 0x800000000000L},
{Id::SOULARROW, 0x1000000000000L},
{Id::STUN, 0x2000000000000L},
{Id::POISON, 0x4000000000000L},
{Id::SEAL, 0x8000000000000L},
{Id::DARKNESS, 0x10000000000000L},
{Id::COMBO, 0x20000000000000L},
{Id::SUMMON, 0x20000000000000L},
{Id::WK_CHARGE, 0x40000000000000L},
{Id::DRAGONBLOOD, 0x80000000000000L},
{Id::HOLY_SYMBOL, 0x100000000000000L},
{Id::MESOUP, 0x200000000000000L},
{Id::SHADOWPARTNER, 0x400000000000000L},
{Id::PICKPOCKET, 0x800000000000000L},
{Id::PUPPET, 0x800000000000000L},
{Id::MESOGUARD, 0x1000000000000000L},
{Id::WEAKEN, 0x4000000000000000L}
};
// The flag bits as v83 numbers them (1 << bit of a CFlag<128>). Bits
// 82 and up are the two-state stats.
Id by_bit(uint8_t bit)
{
switch (bit)
{
case 0: return WATK;
case 1: return WDEF;
case 2: return MATK;
case 3: return MDEF;
case 4: return ACC;
case 5: return AVOID;
case 6: return HANDS;
case 7: return SPEED;
case 8: return JUMP;
case 9: return MAGIC_GUARD;
case 10: return DARKSIGHT;
case 11: return BOOSTER;
case 12: return POWERGUARD;
case 13: return HYPERBODYHP;
case 14: return HYPERBODYMP;
case 15: return INVINCIBLE;
case 16: return SOULARROW;
case 17: return STUN;
case 18: return POISON;
case 19: return SEAL;
case 20: return DARKNESS;
case 21: return COMBO;
case 22: return WK_CHARGE;
case 23: return DRAGONBLOOD;
case 24: return HOLY_SYMBOL;
case 25: return MESOUP;
case 26: return SHADOWPARTNER;
case 27: return PICKPOCKET;
case 28: return MESOGUARD;
case 30: return WEAKEN;
case 33: return MORPH;
case 34: return RECOVERY;
case 35: return MAPLE_WARRIOR;
case 36: return STANCE;
case 37: return SHARP_EYES;
case 38: return MANA_REFLECTION;
case 40: return SHADOW_CLAW;
case 41: return INFINITY_;
case 42: return HOLY_SHIELD;
case 43: return HAMSTRING;
case 44: return BLIND;
case 45: return CONCENTRATE;
case 47: return ECHO_OF_HERO;
case 49: return GHOST_MORPH;
case 82: return ENERGY_CHARGE;
case 83: return DASH2;
case 84: return DASH;
case 85: return MONSTER_RIDING;
case 87: return HOMING_BEACON;
case 88: return SPEED_INFUSION;
default: return NONE;
}
}
}
}
}
6 changes: 3 additions & 3 deletions HeavenClient/Character/Buff.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#pragma once

#include <cstdint>
#include <unordered_map>

namespace ms
{
Expand Down Expand Up @@ -97,8 +96,9 @@ namespace ms
LENGTH
};

extern const std::unordered_map<Id, uint64_t> first_codes;
extern const std::unordered_map<Id, uint64_t> second_codes;
// The stat with flag bit `bit` of the 128 a buff packet carries
// (CFlag<128>), or NONE for one HeavenClient doesn't keep.
Id by_bit(uint8_t bit);
}

struct Buff
Expand Down
22 changes: 22 additions & 0 deletions HeavenClient/Character/OtherChar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ namespace ms
set_state(path.get_state().stance);
}

void OtherChar::show_buffs(const std::vector<std::pair<Buffstat::Id, int32_t>> &shown)
{
for (auto [stat, value] : shown)
buffs[stat] = value;
}

void OtherChar::hide_buffs(const std::vector<Buffstat::Id> &ended)
{
for (Buffstat::Id stat : ended)
buffs.erase(stat);
}

std::optional<int32_t> OtherChar::get_buff(Buffstat::Id stat) const
{
auto iter = buffs.find(stat);

if (iter == buffs.end())
return std::nullopt;

return iter->second;
}

int8_t OtherChar::get_integer_attackspeed() const
{
return attackspeed;
Expand Down
15 changes: 15 additions & 0 deletions HeavenClient/Character/OtherChar.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@

#include <cstdint>

#include "Buff.h"
#include "Char.h"

#include "Look/CharLook.h"

#include "../Gameplay/MovePath.h"

#include <map>
#include <optional>
#include <utility>
#include <vector>

namespace ms
Expand All @@ -53,6 +57,16 @@ namespace ms
// Update the character look.
void update_look(const LookEntry &look);

// Show these buffs, each with its value, as well as those shown
// already.
void show_buffs(const std::vector<std::pair<Buffstat::Id, int32_t>> &shown);

// Stop showing these buffs.
void hide_buffs(const std::vector<Buffstat::Id> &ended);

// The value of a buff the character shows.
std::optional<int32_t> get_buff(Buffstat::Id stat) const;

// Return the character's attacking speed.
int8_t get_integer_attackspeed() const override;

Expand All @@ -69,5 +83,6 @@ namespace ms

std::unordered_map<int32_t, uint8_t> skilllevels;
uint8_t attackspeed;
std::map<Buffstat::Id, int32_t> buffs;
};
}
4 changes: 4 additions & 0 deletions HeavenClient/Gameplay/Combat/Attack.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ namespace ms
int32_t healed = 0;

uint8_t hitcount = 0;
// Shadow Partner's second set of bullets makes 2.
uint8_t sets = 1;
uint8_t mobcount = 0;
uint8_t speed = 0;
uint8_t stance = 0;
Expand Down Expand Up @@ -130,6 +132,7 @@ namespace ms
{
type = attack.type;
hitcount = attack.hitcount;
sets = attack.sets;
skill = attack.skill;
charge = attack.charge;
speed = attack.speed;
Expand All @@ -146,6 +149,7 @@ namespace ms
int32_t attacker = 0;
uint8_t mobcount = 0;
uint8_t hitcount = 1;
uint8_t sets = 1;
int32_t skill = 0;
int32_t charge = 0;
int32_t bullet = 0;
Expand Down
Loading
Loading