diff --git a/src/Abilities.cpp b/src/Abilities.cpp index efcbab7..54f8c91 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -38,7 +38,7 @@ std::vector Abilities::matchTargets(SkillData* skill, int count, int3 return targets; } -void Abilities::useAbility(SkillData* skill, EntityRef src, std::vector targets) { +void Abilities::applyAbility(SkillData* skill, EntityRef src, std::vector targets) { for (EntityRef target : targets) { Entity* entity = target.getEntity(); if (entity->kind != PLAYER && entity->kind != COMBAT_NPC && entity->kind != MOB) diff --git a/src/Abilities.hpp b/src/Abilities.hpp index 3179cc1..27c376b 100644 --- a/src/Abilities.hpp +++ b/src/Abilities.hpp @@ -18,12 +18,17 @@ enum class SkillTargetType { GROUP = 3 }; +enum class SkillDrainType { + ACTIVE = 1, + PASSIVE = 2 +}; + struct SkillData { int skillType; SkillEffectTarget effectTarget; int effectType; // always 1? SkillTargetType targetType; - int batteryDrainType; + SkillDrainType drainType; int effectArea; int batteryUse[4]; diff --git a/src/Combat.cpp b/src/Combat.cpp index 31fe980..479951f 100644 --- a/src/Combat.cpp +++ b/src/Combat.cpp @@ -686,15 +686,37 @@ static void playerTick(CNServer *serv, time_t currTime) { plr->healCooldown -= 4000; } + // nanos for (int i = 0; i < 3; i++) { - if (plr->activeNano != 0 && plr->equippedNanos[i] == plr->activeNano) { // spend stamina - plr->Nanos[plr->activeNano].iStamina -= 1 + plr->nanoDrainRate / 5; + if (plr->activeNano != 0 && plr->equippedNanos[i] == plr->activeNano) { // tick active nano + sNano& nano = plr->Nanos[plr->activeNano]; + int drainRate = 0; - if (plr->Nanos[plr->activeNano].iStamina <= 0) + if (Abilities::SkillTable.find(nano.iSkillID) != Abilities::SkillTable.end()) { + // nano has skill data + SkillData* skill = &Abilities::SkillTable[nano.iSkillID]; + int boost = Nanos::getNanoBoost(plr); + drainRate = skill->batteryUse[boost * 3]; + + if (skill->drainType == SkillDrainType::PASSIVE) { + // passive buff + std::vector targets; + if (skill->targetType == SkillTargetType::GROUP && plr->group != nullptr) + targets = plr->group->members; // group + else if(skill->targetType == SkillTargetType::SELF) + targets.push_back(sock); // self + + std::cout << "[SKILL] id " << nano.iSkillID << ", type " << skill->skillType << ", target " << (int)skill->targetType << std::endl; + } + } + + nano.iStamina -= 1 + drainRate / 5; + + if (nano.iStamina <= 0) Nanos::summonNano(sock, -1, true); // unsummon nano silently transmit = true; - } else if (plr->Nanos[plr->equippedNanos[i]].iStamina < 150) { // regain stamina + } else if (plr->Nanos[plr->equippedNanos[i]].iStamina < 150) { // tick resting nano sNano& nano = plr->Nanos[plr->equippedNanos[i]]; nano.iStamina += 1; diff --git a/src/Eggs.cpp b/src/Eggs.cpp index 5a5c903..ca82b54 100644 --- a/src/Eggs.cpp +++ b/src/Eggs.cpp @@ -18,7 +18,7 @@ int Eggs::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int duration) { Player* plr = PlayerManager::getPlayer(sock); // TODO ABILITIES - int bitFlag = plr->group->conditionBitFlag; + //int bitFlag = plr->group->conditionBitFlag; int CBFlag = 0;// Abilities::applyBuff(sock, skillId, 1, 3, bitFlag); size_t resplen; @@ -98,7 +98,7 @@ static void eggStep(CNServer* serv, time_t currTime) { int32_t CBFlag = it->first.second; Player* plr = PlayerManager::getPlayer(sock); - int groupFlags = plr->group->conditionBitFlag; + //int groupFlags = plr->group->conditionBitFlag; // TODO ABILITIES //for (auto& pwr : Abilities::Powers) { // if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff diff --git a/src/Groups.cpp b/src/Groups.cpp index 57418b8..f3bf7d8 100644 --- a/src/Groups.cpp +++ b/src/Groups.cpp @@ -153,7 +153,7 @@ static void joinGroup(CNSocket* sock, CNPacketData* data) { resp->iID_NewMember = plr->iID; resp->iMemberPCCnt = players.size(); - int bitFlag = otherPlr->group->conditionBitFlag; + //int bitFlag = otherPlr->group->conditionBitFlag; for (int i = 0; i < players.size(); i++) { Player* varPlr = PlayerManager::getPlayer(players[i].sock); diff --git a/src/Groups.hpp b/src/Groups.hpp index ac6ad57..c694597 100644 --- a/src/Groups.hpp +++ b/src/Groups.hpp @@ -12,7 +12,6 @@ enum EntityKind; struct Group { std::vector members; - int8_t conditionCounters[32]; std::vector filter(EntityKind kind) { std::vector filtered; diff --git a/src/Nanos.cpp b/src/Nanos.cpp index c37b7ea..34e200d 100644 --- a/src/Nanos.cpp +++ b/src/Nanos.cpp @@ -82,49 +82,14 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) { if (slot != -1 && plr->Nanos[nanoID].iSkillID == 0) return; // prevent powerless nanos from summoning - plr->nanoDrainRate = 0; - int16_t skillID = plr->Nanos[plr->activeNano].iSkillID; - SkillData* skillData = &Abilities::SkillTable[skillID]; - std::vector targetData; - - // passive nano unbuffing - if (skillData->batteryDrainType == 2) { - targetData.push_back(sock); // self - if (skillData->targetType == SkillTargetType::GROUP && plr->group != nullptr) - targetData = plr->group->members; // whole group - - /* TODO ABILITIES */ - targetData.clear(); - } - if (nanoID >= NANO_COUNT || nanoID < 0) return; // sanity check plr->activeNano = nanoID; - skillID = plr->Nanos[nanoID].iSkillID; - skillData = &Abilities::SkillTable[skillID]; - // passive nano buffing - if (skillData->batteryDrainType == 2) { - int boost = 0; - if (getNanoBoost(plr)) - boost = 1; - - targetData.push_back(sock); // self - if (skillData->targetType == SkillTargetType::GROUP && plr->group != nullptr) - targetData = plr->group->members; // whole group - - // TODO ABILITIES - //std::vector targetData = Abilities::findTargets(plr, skillID); - //for (auto& pwr : Abilities::Powers) { - // if (pwr.skillType == Abilities::SkillTable[skillID].skillType) { - // resp.eCSTB___Add = 1; // the part that makes nano go ZOOMAZOOM - // plr->nanoDrainRate = Abilities::SkillTable[skillID].batteryUse[boost*3]; - - // pwr.handle(sock, targetData, nanoID, skillID, 0, Abilities::SkillTable[skillID].powerIntensity[boost]); - // } - //} - } + int16_t skillID = plr->Nanos[nanoID].iSkillID; + if (Abilities::SkillTable.count(skillID) > 0 && Abilities::SkillTable[skillID].drainType == SkillDrainType::PASSIVE) + resp.eCSTB___Add = 1; // passive buff effect if (!silent) // silent nano death but only for the summoning player sock->sendPacket(resp, P_FE2CL_REP_NANO_ACTIVE_SUCC); diff --git a/src/Player.hpp b/src/Player.hpp index 84513b8..3b9a40c 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -50,7 +50,6 @@ struct Player : public Entity, public ICombatant { bool inCombat = false; bool onMonkey = false; - int nanoDrainRate = 0; int healCooldown = 0; int pointDamage = 0; diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 61e11cc..1cff647 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -474,8 +474,9 @@ static void revivePlayer(CNSocket* sock, CNPacketData* data) { resp2.PCRegenDataForOtherPC.iAngle = plr->angle; if (plr->group != nullptr) { - int bitFlag = plr->group->conditionBitFlag; - resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->iConditionBitFlag = plr->iSelfConditionBitFlag | bitFlag; + // TODO ABILITIES + //int bitFlag = plr->group->conditionBitFlag; + //resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->iConditionBitFlag = plr->iSelfConditionBitFlag | bitFlag; resp2.PCRegenDataForOtherPC.iPCState = plr->iPCState; resp2.PCRegenDataForOtherPC.iSpecialState = plr->iSpecialState;