mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Start moving passive power processing to playerTick
This commit is contained in:
parent
398e9fddf8
commit
9982d9bdda
@ -38,7 +38,7 @@ std::vector<EntityRef> Abilities::matchTargets(SkillData* skill, int count, int3
|
||||
return targets;
|
||||
}
|
||||
|
||||
void Abilities::useAbility(SkillData* skill, EntityRef src, std::vector<EntityRef> targets) {
|
||||
void Abilities::applyAbility(SkillData* skill, EntityRef src, std::vector<EntityRef> targets) {
|
||||
for (EntityRef target : targets) {
|
||||
Entity* entity = target.getEntity();
|
||||
if (entity->kind != PLAYER && entity->kind != COMBAT_NPC && entity->kind != MOB)
|
||||
|
@ -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];
|
||||
|
@ -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<EntityRef> 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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -12,7 +12,6 @@ enum EntityKind;
|
||||
|
||||
struct Group {
|
||||
std::vector<EntityRef> members;
|
||||
int8_t conditionCounters[32];
|
||||
|
||||
std::vector<EntityRef> filter(EntityKind kind) {
|
||||
std::vector<EntityRef> filtered;
|
||||
|
@ -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<EntityRef> 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<int> 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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user