mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-24 22:11:04 +00:00
Compare commits
6 Commits
57eb692226
...
e124bc0645
Author | SHA1 | Date | |
---|---|---|---|
|
e124bc0645 | ||
|
5671adbd74 | ||
|
550b26db39 | ||
|
68be9cc381 | ||
|
ef33a182d1 | ||
|
9bd8eabed7 |
@ -5,8 +5,6 @@
|
||||
#include "Buffs.hpp"
|
||||
#include "Nanos.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Abilities;
|
||||
|
||||
std::map<int32_t, SkillData> Abilities::SkillTable;
|
||||
@ -56,6 +54,11 @@ 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
|
||||
@ -142,54 +145,59 @@ 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::FREEDOM:
|
||||
case SkillType::PHOENIX:
|
||||
case SkillType::INVULNERABLE:
|
||||
case SkillType::STEALTH:
|
||||
case SkillType::MINIMAPENEMY:
|
||||
case SkillType::MINIMAPTRESURE:
|
||||
case SkillType::NANOSTIMPAK:
|
||||
case SkillType::PHOENIX:
|
||||
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::STEALTH:
|
||||
resultSize = sizeof(sSkillResult_Buff);
|
||||
case SkillType::NANOSTIMPAK:
|
||||
case SkillType::BUFFHEAL:
|
||||
skillHandler = handleSkillBuff;
|
||||
break;
|
||||
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;
|
||||
case SkillType::BLOODSUCKING:
|
||||
skillHandler = handleSkillLeech;
|
||||
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;
|
||||
@ -199,7 +207,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 != resultSize) {
|
||||
if(result.size > MAX_SKILLRESULT_SIZE) {
|
||||
std::cout << "[WARN] bad skill result size for " << (int)skill->skillType << " from " << (void*)handleSkillBuff << std::endl;
|
||||
continue;
|
||||
}
|
||||
@ -232,7 +240,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 = results.back().size; // guaranteed to be the same for every item
|
||||
size_t resultSize = MAX_SKILLRESULT_SIZE; // lazy
|
||||
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;
|
||||
|
@ -7,18 +7,19 @@
|
||||
|
||||
#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,
|
||||
SLEEP = 4,
|
||||
SNARE = 5,
|
||||
KNOCKDOWN = 3, // dnd
|
||||
SLEEP = 4, // dnd
|
||||
SNARE = 5, // dnd
|
||||
HEAL_STAMINA = 6,
|
||||
STAMINA_SELF = 7,
|
||||
STUN = 8,
|
||||
STUN = 8, // dnd
|
||||
WEAPONSLOW = 9,
|
||||
JUMP = 10,
|
||||
RUN = 11,
|
||||
@ -75,6 +76,7 @@ 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);
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ 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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user