mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 15:00:06 +00:00
reduce drain tickrate
This commit is contained in:
parent
0b73cef187
commit
eb88fa05cb
@ -120,6 +120,7 @@ static SkillResult handleSkillBuff(SkillData* skill, int power, ICombatant* sour
|
|||||||
|
|
||||||
int timeBuffId = Abilities::getCSTBFromST(skill->skillType);
|
int timeBuffId = Abilities::getCSTBFromST(skill->skillType);
|
||||||
SkillDrainType drainType = skill->drainType;
|
SkillDrainType drainType = skill->drainType;
|
||||||
|
int combatLifetime = 0;
|
||||||
if(!target->addBuff(timeBuffId,
|
if(!target->addBuff(timeBuffId,
|
||||||
[drainType](EntityRef self, Buff* buff, int status, BuffStack* stack) {
|
[drainType](EntityRef self, Buff* buff, int status, BuffStack* stack) {
|
||||||
if(buff->id == ECSB_BOUNDINGBALL) {
|
if(buff->id == ECSB_BOUNDINGBALL) {
|
||||||
@ -131,9 +132,11 @@ static SkillResult handleSkillBuff(SkillData* skill, int power, ICombatant* sour
|
|||||||
if(drainType == SkillDrainType::ACTIVE && status == ETBU_DEL)
|
if(drainType == SkillDrainType::ACTIVE && status == ETBU_DEL)
|
||||||
Buffs::timeBuffTimeout(self);
|
Buffs::timeBuffTimeout(self);
|
||||||
},
|
},
|
||||||
[](EntityRef self, Buff* buff, time_t currTime) {
|
[combatLifetime](EntityRef self, Buff* buff, time_t currTime) mutable {
|
||||||
if(buff->id == ECSB_BOUNDINGBALL)
|
if(buff->id == ECSB_BOUNDINGBALL &&
|
||||||
Buffs::tickDrain(self, buff); // drain
|
combatLifetime % COMBAT_TICKS_PER_DRAIN_PROC == 0)
|
||||||
|
Buffs::tickDrain(self, buff, COMBAT_TICKS_PER_DRAIN_PROC); // drain
|
||||||
|
combatLifetime++;
|
||||||
},
|
},
|
||||||
&passiveBuff)) return SkillResult(); // no result if already buffed
|
&passiveBuff)) return SkillResult(); // no result if already buffed
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
const int COMBAT_TICKS_PER_DRAIN_PROC = 2;
|
||||||
constexpr size_t MAX_SKILLRESULT_SIZE = sizeof(sSkillResult_BatteryDrain);
|
constexpr size_t MAX_SKILLRESULT_SIZE = sizeof(sSkillResult_BatteryDrain);
|
||||||
|
|
||||||
enum class SkillType {
|
enum class SkillType {
|
||||||
|
@ -169,12 +169,13 @@ void Buffs::timeBuffTimeout(EntityRef self) {
|
|||||||
NPCManager::sendToViewable(entity, &pkt, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT, sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT));
|
NPCManager::sendToViewable(entity, &pkt, P_FE2CL_CHAR_TIME_BUFF_TIME_OUT, sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_OUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffs::tickDrain(EntityRef self, Buff* buff) {
|
void Buffs::tickDrain(EntityRef self, Buff* buff, int mult) {
|
||||||
if(self.kind != EntityKind::COMBAT_NPC && self.kind != EntityKind::MOB)
|
if(self.kind != EntityKind::COMBAT_NPC && self.kind != EntityKind::MOB)
|
||||||
return; // not implemented
|
return; // not implemented
|
||||||
Entity* entity = self.getEntity();
|
Entity* entity = self.getEntity();
|
||||||
ICombatant* combatant = dynamic_cast<ICombatant*>(entity);
|
ICombatant* combatant = dynamic_cast<ICombatant*>(entity);
|
||||||
int damage = combatant->takeDamage(buff->getLastSource(), combatant->getMaxHP() / 100);
|
int damage = combatant->getMaxHP() / 100 * mult;
|
||||||
|
int dealt = combatant->takeDamage(buff->getLastSource(), damage);
|
||||||
|
|
||||||
size_t resplen = sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK) + sizeof(sSkillResult_Damage);
|
size_t resplen = sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK) + sizeof(sSkillResult_Damage);
|
||||||
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
||||||
@ -187,7 +188,7 @@ void Buffs::tickDrain(EntityRef self, Buff* buff) {
|
|||||||
pkt->iTB_ID = ECSB_BOUNDINGBALL;
|
pkt->iTB_ID = ECSB_BOUNDINGBALL;
|
||||||
|
|
||||||
sSkillResult_Damage *drain = (sSkillResult_Damage*)(respbuf + sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK));
|
sSkillResult_Damage *drain = (sSkillResult_Damage*)(respbuf + sizeof(sP_FE2CL_CHAR_TIME_BUFF_TIME_TICK));
|
||||||
drain->iDamage = damage;
|
drain->iDamage = dealt;
|
||||||
drain->iHP = combatant->getCurrentHP();
|
drain->iHP = combatant->getCurrentHP();
|
||||||
drain->eCT = pkt->eCT;
|
drain->eCT = pkt->eCT;
|
||||||
drain->iID = pkt->iID;
|
drain->iID = pkt->iID;
|
||||||
|
@ -89,5 +89,5 @@ namespace Buffs {
|
|||||||
void timeBuffUpdate(EntityRef self, Buff* buff, int status, BuffStack* stack);
|
void timeBuffUpdate(EntityRef self, Buff* buff, int status, BuffStack* stack);
|
||||||
void timeBuffTick(EntityRef self, Buff* buff);
|
void timeBuffTick(EntityRef self, Buff* buff);
|
||||||
void timeBuffTimeout(EntityRef self);
|
void timeBuffTimeout(EntityRef self);
|
||||||
void tickDrain(EntityRef self, Buff* buff);
|
void tickDrain(EntityRef self, Buff* buff, int mult);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user