Passive nano powers pt 1

This commit is contained in:
gsemaj 2022-07-21 09:22:19 -07:00 committed by gsemaj
parent 36f329c302
commit 2901f5f285
No known key found for this signature in database
GPG Key ID: 24B96BAA40497929
6 changed files with 57 additions and 42 deletions

View File

@ -40,71 +40,71 @@ std::vector<EntityRef> Abilities::matchTargets(SkillData* skill, int count, int3
return targets; return targets;
} }
/* ripped from client */ /* ripped from client (enums emplaced) */
int Abilities::getCSTBFromST(int eSkillType) { int Abilities::getCSTBFromST(int eSkillType) {
int result = 0; int result = 0;
switch (eSkillType) switch (eSkillType)
{ {
case 11: case EST_RUN:
result = 1; result = ECSB_UP_MOVE_SPEED;
break; break;
case 10: case EST_JUMP:
result = 3; result = ECSB_UP_JUMP_HEIGHT;
break; break;
case 12: case EST_STEALTH:
result = 4; result = ECSB_UP_STEALTH;
break; break;
case 16: case EST_PHOENIX:
result = 5; result = ECSB_PHOENIX;
break; break;
case 17: case EST_PROTECTBATTERY:
result = 6; result = ECSB_PROTECT_BATTERY;
break; break;
case 18: case EST_PROTECTINFECTION:
result = 7; result = ECSB_PROTECT_INFECTION;
break; break;
case 5: case EST_SNARE:
result = 8; result = ECSB_DN_MOVE_SPEED;
break; break;
case 4: case EST_SLEEP:
result = 11; result = ECSB_MEZ;
break; break;
case 14: case EST_MINIMAPENEMY:
result = 13; result = ECSB_MINIMAP_ENEMY;
break; break;
case 15: case EST_MINIMAPTRESURE:
result = 14; result = ECSB_MINIMAP_TRESURE;
break; break;
case 19: case EST_REWARDBLOB:
result = 15; result = ECSB_REWARD_BLOB;
break; break;
case 20: case EST_REWARDCASH:
result = 16; result = ECSB_REWARD_CASH;
break; break;
case 23: case EST_INFECTIONDAMAGE:
result = 17; result = ECSB_INFECTION;
break; break;
case 25: case EST_FREEDOM:
result = 18; result = ECSB_FREEDOM;
break; break;
case 31: case EST_BOUNDINGBALL:
result = 19; result = ECSB_BOUNDINGBALL;
break; break;
case 32: case EST_INVULNERABLE:
result = 20; result = ECSB_INVULNERABLE;
break; break;
case 35: case EST_BUFFHEAL:
result = 24; result = ECSB_HEAL;
break; break;
case 33: case EST_NANOSTIMPAK:
result = 21; result = ECSB_STIMPAKSLOT1;
break; break;
} }
return result; return result;
} }
#pragma region Skill Handlers #pragma region Skill Handlers
void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr) { void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr, int boost) {
assert(skill->drainType == SkillDrainType::PASSIVE); assert(skill->drainType == SkillDrainType::PASSIVE);
EntityRef self = PlayerManager::getSockFromID(plr->iID); EntityRef self = PlayerManager::getSockFromID(plr->iID);
@ -118,12 +118,17 @@ void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr) {
std::cout << "[WARN] Passive skill with type " << skill->skillType << " has target type MOB" << std::endl; std::cout << "[WARN] Passive skill with type " << skill->skillType << " has target type MOB" << std::endl;
} }
int timeBuffId = getCSTBFromST(skill->skillType);
int value = skill->values[0][boost];
BuffStack passiveBuff = { BuffStack passiveBuff = {
1, // passive nano buffs refreshed every tick 1, // passive nano buffs refreshed every tick
value,
self, self,
BuffClass::NONE, // overwritten per target BuffClass::NONE, // overwritten per target
[](EntityRef host, BuffStack* stack) { [](EntityRef host, BuffStack* stack) {
Buffs::timeBuffUpdate(host, stack, ETBU_ADD); Buffs::timeBuffUpdate(host, stack, ETBU_ADD);
// TODO SKILLUSE/SKILLUSESUCC, sSkillResult_Buff
}, },
nullptr, nullptr,
[](EntityRef host, BuffStack* stack) { [](EntityRef host, BuffStack* stack) {
@ -138,7 +143,7 @@ void Abilities::usePassiveNanoSkill(SkillData* skill, Player* plr) {
passiveBuff.buffStackClass = target == self ? BuffClass::NANO : BuffClass::GROUP_NANO; passiveBuff.buffStackClass = target == self ? BuffClass::NANO : BuffClass::GROUP_NANO;
ICombatant* combatant = dynamic_cast<ICombatant*>(entity); ICombatant* combatant = dynamic_cast<ICombatant*>(entity);
combatant->addBuff(getCSTBFromST(skill->skillType), &passiveBuff); combatant->addBuff(timeBuffId, &passiveBuff);
} }
} }
#pragma endregion #pragma endregion

View File

@ -47,7 +47,7 @@ namespace Abilities {
std::vector<EntityRef> matchTargets(SkillData*, int, int32_t*); std::vector<EntityRef> matchTargets(SkillData*, int, int32_t*);
int getCSTBFromST(int eSkillType); int getCSTBFromST(int eSkillType);
void usePassiveNanoSkill(SkillData*, Player*); void usePassiveNanoSkill(SkillData*, Player*, int);
void init(); void init();
} }

View File

@ -73,14 +73,21 @@ void Buffs::timeBuffUpdate(EntityRef self, BuffStack* stack, int status) {
if(status == ETBU_DEL && plr->hasBuff(stack->buff->id)) if(status == ETBU_DEL && plr->hasBuff(stack->buff->id))
return; // no premature status removal! return; // no premature status removal!
sTimeBuff payload{};
int cbf = plr->getCompositeCondition(); int cbf = plr->getCompositeCondition();
if(status == ETBU_ADD && stack->buff->id > 0) cbf |= CSB_FROM_ECSB(stack->buff->id); if(status == ETBU_ADD) {
if(stack->buff->id > 0) cbf |= CSB_FROM_ECSB(stack->buff->id);
payload.iValue = stack->value;
//payload.iTimeLimit = stack->durationTicks * MS_PER_PLAYER_TICK;
}
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt); INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, pkt);
pkt.eCSTB = stack->buff->id; // eCharStatusTimeBuffID pkt.eCSTB = stack->buff->id; // eCharStatusTimeBuffID
pkt.eTBU = status; // eTimeBuffUpdate pkt.eTBU = status; // eTimeBuffUpdate
pkt.eTBT = (int)stack->buffStackClass; pkt.eTBT = (int)stack->buffStackClass;
pkt.iConditionBitFlag = cbf; pkt.iConditionBitFlag = cbf;
pkt.TimeBuff = payload;
self.sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE)); self.sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
} }

View File

@ -26,6 +26,7 @@ typedef std::function<void(EntityRef, BuffStack*)> BuffCallback;
struct BuffStack { struct BuffStack {
int durationTicks; int durationTicks;
int value;
EntityRef source; EntityRef source;
BuffClass buffStackClass; BuffClass buffStackClass;

View File

@ -380,6 +380,7 @@ static void dotDamageOnOff(CNSocket *sock, CNPacketData *data) {
if (pkt->iFlag && !plr->hasBuff(ECSB_INFECTION)) { if (pkt->iFlag && !plr->hasBuff(ECSB_INFECTION)) {
BuffStack infection = { BuffStack infection = {
-1, // infinite -1, // infinite
NULL,
sock, // self-inflicted sock, // self-inflicted
BuffClass::ENVIRONMENT, BuffClass::ENVIRONMENT,
[](EntityRef host, BuffStack* stack) { [](EntityRef host, BuffStack* stack) {
@ -775,7 +776,7 @@ static void playerTick(CNServer *serv, time_t currTime) {
if (skill->drainType == SkillDrainType::PASSIVE) { if (skill->drainType == SkillDrainType::PASSIVE) {
// apply passive buff // apply passive buff
drainRate = skill->batteryUse[boost * 3]; drainRate = skill->batteryUse[boost * 3];
Abilities::usePassiveNanoSkill(skill, plr); Abilities::usePassiveNanoSkill(skill, plr, boost * 3);
} }
} }

View File

@ -494,6 +494,7 @@ static void itemUseHandler(CNSocket* sock, CNPacketData* data) {
int durationMilliseconds = Abilities::SkillTable[144].durationTime[0] * 100; int durationMilliseconds = Abilities::SkillTable[144].durationTime[0] * 100;
BuffStack gumballBuff = { BuffStack gumballBuff = {
durationMilliseconds / MS_PER_PLAYER_TICK, durationMilliseconds / MS_PER_PLAYER_TICK,
NULL,
sock, sock,
BuffClass::CASH_ITEM, // or BuffClass::ITEM? BuffClass::CASH_ITEM, // or BuffClass::ITEM?
[](EntityRef host, BuffStack* stack) { [](EntityRef host, BuffStack* stack) {