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 "Nanos.hpp"
#include <assert.h>
using namespace Abilities;
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);
}
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) {
BuffStack passiveBuff = {
skill->drainType == SkillDrainType::PASSIVE ? 1 : skill->durationTime[power], // ticks
@ -145,59 +142,54 @@ static SkillResult handleSkillResurrect(SkillData* skill, int power, ICombatant*
#pragma endregion
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;
std::vector<SkillResult> results;
switch(skill->skillType)
{
case SkillType::DAMAGE:
resultSize = sizeof(sSkillResult_Damage);
skillHandler = handleSkillDamage;
break;
case SkillType::HEAL_HP:
case SkillType::RETURNHOMEHEAL:
resultSize = sizeof(sSkillResult_Heal_HP);
skillHandler = handleSkillHealHP;
break;
case SkillType::KNOCKDOWN:
case SkillType::SLEEP:
case SkillType::SNARE:
case SkillType::STUN:
skillHandler = handleSkillDamageNDebuff;
break;
case SkillType::JUMP:
case SkillType::RUN:
case SkillType::STEALTH:
case SkillType::FREEDOM:
case SkillType::PHOENIX:
case SkillType::INVULNERABLE:
case SkillType::MINIMAPENEMY:
case SkillType::MINIMAPTRESURE:
case SkillType::PHOENIX:
case SkillType::NANOSTIMPAK:
case SkillType::PROTECTBATTERY:
case SkillType::PROTECTINFECTION:
case SkillType::REWARDBLOB:
case SkillType::REWARDCASH:
// case SkillType::INFECTIONDAMAGE:
case SkillType::FREEDOM:
case SkillType::BOUNDINGBALL:
case SkillType::INVULNERABLE:
case SkillType::STAMINA_SELF:
case SkillType::NANOSTIMPAK:
case SkillType::BUFFHEAL:
case SkillType::STEALTH:
resultSize = sizeof(sSkillResult_Buff);
skillHandler = handleSkillBuff;
break;
case SkillType::BLOODSUCKING:
skillHandler = handleSkillLeech;
case SkillType::BATTERYDRAIN:
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;
case SkillType::RETROROCKET_SELF:
// no-op
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:
std::cout << "[WARN] Unhandled skill type " << (int)skill->skillType << std::endl;
return results;
@ -207,7 +199,7 @@ static std::vector<SkillResult> handleSkill(SkillData* skill, int power, ICombat
assert(target != nullptr);
SkillResult result = skillHandler(skill, power, src != nullptr ? src : target, target);
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;
continue;
}
@ -240,7 +232,7 @@ void Abilities::useNanoSkill(CNSocket* sock, SkillData* skill, sNano& nano, std:
std::vector<SkillResult> results = handleSkill(skill, boost, plr, affected);
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)) {
std::cout << "[WARN] bad sP_FE2CL_NANO_SKILL_USE_SUCC packet size\n";
return;

View File

@ -7,19 +7,18 @@
#include <map>
#include <vector>
#include <assert.h>
constexpr size_t MAX_SKILLRESULT_SIZE = sizeof(sSkillResult_BatteryDrain);
enum class SkillType {
DAMAGE = 1,
HEAL_HP = 2,
KNOCKDOWN = 3, // dnd
SLEEP = 4, // dnd
SNARE = 5, // dnd
KNOCKDOWN = 3,
SLEEP = 4,
SNARE = 5,
HEAL_STAMINA = 6,
STAMINA_SELF = 7,
STUN = 8, // dnd
STUN = 8,
WEAPONSLOW = 9,
JUMP = 10,
RUN = 11,
@ -76,7 +75,6 @@ struct SkillResult {
size_t size;
uint8_t payload[MAX_SKILLRESULT_SIZE];
SkillResult(size_t len, void* dat) {
assert(len <= MAX_SKILLRESULT_SIZE);
size = 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
bool Player::addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) {
if(!isAlive())
return false;
EntityRef self = PlayerManager::getSockFromID(iID);
if(!hasBuff(buffId)) {