mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Implemented the mob kill counter in missions and fixed a bug.
This commit is contained in:
parent
8887c6349b
commit
3172724596
@ -37,7 +37,7 @@ void CombatManager::pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
// initialize response struct
|
// initialize response struct
|
||||||
size_t resplen = sizeof(sP_FE2CL_PC_ATTACK_NPCs_SUCC) + pkt->iNPCCnt * sizeof(sAttackResult);
|
size_t resplen = sizeof(sP_FE2CL_PC_ATTACK_NPCs_SUCC) + pkt->iNPCCnt * sizeof(sAttackResult);
|
||||||
uint8_t respbuf[4096];
|
uint8_t respbuf[CN_PACKET_BUFFER_SIZE];
|
||||||
|
|
||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
|
|
||||||
@ -56,31 +56,33 @@ void CombatManager::pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
mob.appearanceData.iHP -= 100;
|
mob.appearanceData.iHP -= 100;
|
||||||
|
|
||||||
if (mob.appearanceData.iHP <= 0)
|
if (mob.appearanceData.iHP <= 0) {
|
||||||
giveReward(sock);
|
giveReward(sock);
|
||||||
// TODO: despawn mobs when they die
|
INITSTRUCT(sP_FE2CL_REP_PC_KILL_QUEST_NPCs_SUCC, kill);
|
||||||
|
|
||||||
|
kill.iNPCID = mob.appearanceData.iNPCType;
|
||||||
|
|
||||||
|
sock->sendPacket((void*)&kill, P_FE2CL_REP_PC_KILL_QUEST_NPCs_SUCC, sizeof(sP_FE2CL_REP_PC_KILL_QUEST_NPCs_SUCC));
|
||||||
|
// TODO: despawn mobs when they die
|
||||||
|
}
|
||||||
|
|
||||||
respdata[i].iID = mob.appearanceData.iNPC_ID;
|
respdata[i].iID = mob.appearanceData.iNPC_ID;
|
||||||
respdata[i].iDamage = 100;
|
respdata[i].iDamage = 100;
|
||||||
respdata[i].iHP = mob.appearanceData.iHP;
|
respdata[i].iHP = mob.appearanceData.iHP;
|
||||||
respdata[i].iHitFlag = 2;
|
respdata[i].iHitFlag = 2; // hitscan, not a rocket or a grenade
|
||||||
}
|
}
|
||||||
|
|
||||||
sock->sendPacket((void*)respbuf, P_FE2CL_PC_ATTACK_NPCs_SUCC, resplen);
|
sock->sendPacket((void*)respbuf, P_FE2CL_PC_ATTACK_NPCs_SUCC, resplen);
|
||||||
|
|
||||||
// a bit of a hack: these are the same size, so we can reuse the output packet
|
// a bit of a hack: these are the same size, so we can reuse the response packet
|
||||||
assert(sizeof(sP_FE2CL_PC_ATTACK_NPCs_SUCC) == sizeof(sP_FE2CL_PC_ATTACK_NPCs));
|
assert(sizeof(sP_FE2CL_PC_ATTACK_NPCs_SUCC) == sizeof(sP_FE2CL_PC_ATTACK_NPCs));
|
||||||
sP_FE2CL_PC_ATTACK_NPCs *resp1 = (sP_FE2CL_PC_ATTACK_NPCs*)respbuf;
|
sP_FE2CL_PC_ATTACK_NPCs *resp1 = (sP_FE2CL_PC_ATTACK_NPCs*)respbuf;
|
||||||
|
|
||||||
resp1->iPC_ID = plr->iID;
|
resp1->iPC_ID = plr->iID;
|
||||||
|
|
||||||
// send to other players
|
// send to other players
|
||||||
for (CNSocket *s : PlayerManager::players[sock].viewable) {
|
for (CNSocket *s : PlayerManager::players[sock].viewable)
|
||||||
if (s == sock)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
s->sendPacket((void*)respbuf, P_FE2CL_PC_ATTACK_NPCs, resplen);
|
s->sendPacket((void*)respbuf, P_FE2CL_PC_ATTACK_NPCs, resplen);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CombatManager::combatBegin(CNSocket *sock, CNPacketData *data) {} // stub
|
void CombatManager::combatBegin(CNSocket *sock, CNPacketData *data) {} // stub
|
||||||
@ -115,6 +117,7 @@ void CombatManager::giveReward(CNSocket *sock) {
|
|||||||
int slot = ItemManager::findFreeSlot(plr);
|
int slot = ItemManager::findFreeSlot(plr);
|
||||||
if (slot == -1) {
|
if (slot == -1) {
|
||||||
// no room for an item, but you still get FM and taros
|
// no room for an item, but you still get FM and taros
|
||||||
|
reward->iItemCnt = 0;
|
||||||
sock->sendPacket((void*)respbuf, P_FE2CL_REP_REWARD_ITEM, sizeof(sP_FE2CL_REP_REWARD_ITEM));
|
sock->sendPacket((void*)respbuf, P_FE2CL_REP_REWARD_ITEM, sizeof(sP_FE2CL_REP_REWARD_ITEM));
|
||||||
} else {
|
} else {
|
||||||
// item reward
|
// item reward
|
||||||
|
Loading…
Reference in New Issue
Block a user