Compare commits

..

No commits in common. "5671adbd74377a69bdcb1b84575d297bc474f749" and "2249b5381bff12d14b56573fa8f075f6285dc24a" have entirely different histories.

3 changed files with 29 additions and 42 deletions

View File

@ -5,6 +5,8 @@
#include "Buffs.hpp" #include "Buffs.hpp"
#include "Nanos.hpp" #include "Nanos.hpp"
#include <assert.h>
using namespace Abilities; using namespace Abilities;
std::map<int32_t, SkillData> Abilities::SkillTable; std::map<int32_t, SkillData> Abilities::SkillTable;
@ -54,11 +56,6 @@ static SkillResult handleSkillDamageNDebuff(SkillData* skill, int power, ICombat
return SkillResult(sizeof(sSkillResult_Damage_N_Debuff), &result); return SkillResult(sizeof(sSkillResult_Damage_N_Debuff), &result);
} }
static SkillResult handleSkillLeech(SkillData* skill, int power, ICombatant* source, ICombatant* target) {
// TODO abilities
return SkillResult();
}
static SkillResult handleSkillBuff(SkillData* skill, int power, ICombatant* source, ICombatant* target) { static SkillResult handleSkillBuff(SkillData* skill, int power, ICombatant* source, ICombatant* target) {
BuffStack passiveBuff = { BuffStack passiveBuff = {
skill->drainType == SkillDrainType::PASSIVE ? 1 : skill->durationTime[power], // ticks skill->drainType == SkillDrainType::PASSIVE ? 1 : skill->durationTime[power], // ticks
@ -145,59 +142,54 @@ static SkillResult handleSkillResurrect(SkillData* skill, int power, ICombatant*
#pragma endregion #pragma endregion
static std::vector<SkillResult> handleSkill(SkillData* skill, int power, ICombatant* src, std::vector<ICombatant*> targets) { static std::vector<SkillResult> handleSkill(SkillData* skill, int power, ICombatant* src, std::vector<ICombatant*> targets) {
size_t resultSize = 0;
SkillResult (*skillHandler)(SkillData*, int, ICombatant*, ICombatant*) = nullptr; SkillResult (*skillHandler)(SkillData*, int, ICombatant*, ICombatant*) = nullptr;
std::vector<SkillResult> results; std::vector<SkillResult> results;
switch(skill->skillType) switch(skill->skillType)
{ {
case SkillType::DAMAGE: case SkillType::DAMAGE:
resultSize = sizeof(sSkillResult_Damage);
skillHandler = handleSkillDamage; skillHandler = handleSkillDamage;
break; break;
case SkillType::HEAL_HP: case SkillType::HEAL_HP:
case SkillType::RETURNHOMEHEAL: case SkillType::RETURNHOMEHEAL:
resultSize = sizeof(sSkillResult_Heal_HP);
skillHandler = handleSkillHealHP; skillHandler = handleSkillHealHP;
break; break;
case SkillType::KNOCKDOWN:
case SkillType::SLEEP:
case SkillType::SNARE:
case SkillType::STUN:
skillHandler = handleSkillDamageNDebuff;
break;
case SkillType::JUMP: case SkillType::JUMP:
case SkillType::RUN: case SkillType::RUN:
case SkillType::STEALTH: case SkillType::FREEDOM:
case SkillType::PHOENIX:
case SkillType::INVULNERABLE:
case SkillType::MINIMAPENEMY: case SkillType::MINIMAPENEMY:
case SkillType::MINIMAPTRESURE: case SkillType::MINIMAPTRESURE:
case SkillType::PHOENIX: case SkillType::NANOSTIMPAK:
case SkillType::PROTECTBATTERY: case SkillType::PROTECTBATTERY:
case SkillType::PROTECTINFECTION: case SkillType::PROTECTINFECTION:
case SkillType::REWARDBLOB: case SkillType::REWARDBLOB:
case SkillType::REWARDCASH: case SkillType::REWARDCASH:
// case SkillType::INFECTIONDAMAGE:
case SkillType::FREEDOM:
case SkillType::BOUNDINGBALL:
case SkillType::INVULNERABLE:
case SkillType::STAMINA_SELF: case SkillType::STAMINA_SELF:
case SkillType::NANOSTIMPAK: case SkillType::STEALTH:
case SkillType::BUFFHEAL: resultSize = sizeof(sSkillResult_Buff);
skillHandler = handleSkillBuff; skillHandler = handleSkillBuff;
break; break;
case SkillType::BLOODSUCKING: case SkillType::BATTERYDRAIN:
skillHandler = handleSkillLeech; resultSize = sizeof(sSkillResult_BatteryDrain);
skillHandler = handleSkillBatteryDrain;
break;
case SkillType::RECALL: // still soft lock
case SkillType::RECALL_GROUP: // works for player who uses it
resultSize = sizeof(sSkillResult_Move);
skillHandler = handleSkillMove;
break;
case SkillType::PHOENIX_GROUP: // broken
resultSize = sizeof(sSkillResult_Resurrect);
skillHandler = handleSkillResurrect;
break; break;
case SkillType::RETROROCKET_SELF: case SkillType::RETROROCKET_SELF:
// no-op // no-op
return results; return results;
case SkillType::PHOENIX_GROUP:
skillHandler = handleSkillResurrect;
break;
case SkillType::RECALL:
case SkillType::RECALL_GROUP:
skillHandler = handleSkillMove;
break;
case SkillType::BATTERYDRAIN:
skillHandler = handleSkillBatteryDrain;
break;
default: default:
std::cout << "[WARN] Unhandled skill type " << (int)skill->skillType << std::endl; std::cout << "[WARN] Unhandled skill type " << (int)skill->skillType << std::endl;
return results; return results;
@ -207,7 +199,7 @@ static std::vector<SkillResult> handleSkill(SkillData* skill, int power, ICombat
assert(target != nullptr); assert(target != nullptr);
SkillResult result = skillHandler(skill, power, src != nullptr ? src : target, target); SkillResult result = skillHandler(skill, power, src != nullptr ? src : target, target);
if(result.size == 0) continue; // skill not applicable if(result.size == 0) continue; // skill not applicable
if(result.size > MAX_SKILLRESULT_SIZE) { if(result.size != resultSize) {
std::cout << "[WARN] bad skill result size for " << (int)skill->skillType << " from " << (void*)handleSkillBuff << std::endl; std::cout << "[WARN] bad skill result size for " << (int)skill->skillType << " from " << (void*)handleSkillBuff << std::endl;
continue; continue;
} }
@ -240,7 +232,7 @@ void Abilities::useNanoSkill(CNSocket* sock, SkillData* skill, sNano& nano, std:
std::vector<SkillResult> results = handleSkill(skill, boost, plr, affected); std::vector<SkillResult> results = handleSkill(skill, boost, plr, affected);
if(results.empty()) return; // no effect; no need for confirmation packets if(results.empty()) return; // no effect; no need for confirmation packets
size_t resultSize = MAX_SKILLRESULT_SIZE; // lazy size_t resultSize = results.back().size; // guaranteed to be the same for every item
if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), results.size(), resultSize)) { if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), results.size(), resultSize)) {
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE_SUCC packet size\n"; std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE_SUCC packet size\n";
return; return;

View File

@ -7,19 +7,18 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <assert.h>
constexpr size_t MAX_SKILLRESULT_SIZE = sizeof(sSkillResult_BatteryDrain); constexpr size_t MAX_SKILLRESULT_SIZE = sizeof(sSkillResult_BatteryDrain);
enum class SkillType { enum class SkillType {
DAMAGE = 1, DAMAGE = 1,
HEAL_HP = 2, HEAL_HP = 2,
KNOCKDOWN = 3, // dnd KNOCKDOWN = 3,
SLEEP = 4, // dnd SLEEP = 4,
SNARE = 5, // dnd SNARE = 5,
HEAL_STAMINA = 6, HEAL_STAMINA = 6,
STAMINA_SELF = 7, STAMINA_SELF = 7,
STUN = 8, // dnd STUN = 8,
WEAPONSLOW = 9, WEAPONSLOW = 9,
JUMP = 10, JUMP = 10,
RUN = 11, RUN = 11,
@ -76,7 +75,6 @@ struct SkillResult {
size_t size; size_t size;
uint8_t payload[MAX_SKILLRESULT_SIZE]; uint8_t payload[MAX_SKILLRESULT_SIZE];
SkillResult(size_t len, void* dat) { SkillResult(size_t len, void* dat) {
assert(len <= MAX_SKILLRESULT_SIZE);
size = len; size = len;
memcpy(payload, dat, len); memcpy(payload, dat, len);
} }

View File

@ -21,9 +21,6 @@ std::map<int32_t, std::map<int8_t, Bullet>> Combat::Bullets;
#pragma region Player #pragma region Player
bool Player::addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) { bool Player::addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) {
if(!isAlive())
return false;
EntityRef self = PlayerManager::getSockFromID(iID); EntityRef self = PlayerManager::getSockFromID(iID);
if(!hasBuff(buffId)) { if(!hasBuff(buffId)) {