Compare commits

..

1 Commits

Author SHA1 Message Date
Gent Semaj
e7e4667620
Merge d8b63a043e into c636c538eb 2023-09-02 20:50:38 -07:00
4 changed files with 7 additions and 12 deletions

View File

@ -120,7 +120,6 @@ 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) {
@ -132,11 +131,9 @@ 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);
}, },
[combatLifetime](EntityRef self, Buff* buff, time_t currTime) mutable { [](EntityRef self, Buff* buff, time_t currTime) {
if(buff->id == ECSB_BOUNDINGBALL && if(buff->id == ECSB_BOUNDINGBALL)
combatLifetime % COMBAT_TICKS_PER_DRAIN_PROC == 0) Buffs::tickDrain(self, buff); // drain
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

View File

@ -9,7 +9,6 @@
#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 {

View File

@ -169,13 +169,12 @@ 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, int mult) { void Buffs::tickDrain(EntityRef self, Buff* buff) {
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->getMaxHP() / 100 * mult; int damage = combatant->takeDamage(buff->getLastSource(), combatant->getMaxHP() / 100);
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);
@ -188,7 +187,7 @@ void Buffs::tickDrain(EntityRef self, Buff* buff, int mult) {
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 = dealt; drain->iDamage = damage;
drain->iHP = combatant->getCurrentHP(); drain->iHP = combatant->getCurrentHP();
drain->eCT = pkt->eCT; drain->eCT = pkt->eCT;
drain->iID = pkt->iID; drain->iID = pkt->iID;

View File

@ -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, int mult); void tickDrain(EntityRef self, Buff* buff);
} }