This is far and away the proudest thing I have been apart of in the Zelda community. Thank you to everyone who either directly or indirectly contributed to this effort. If I forgot to co-author you and you were involved, know that I simply forgot but still appreciated your help! Also thank you to the literal tens of thousands of people who have played Anchor, providing feedback and bug reports. Super thrilled to finally have this merged into the main Ship of Harkinian experience. Co-authored-by: mattman107 <65982675+mattman107@users.noreply.github.com> Co-authored-by: David Chavez <david@dcvz.io> Co-authored-by: MelonSpeedruns <melonspeedruns@outlook.com> Co-authored-by: aMannus <mannusmenting@gmail.com> Co-authored-by: Malkierian <malkierian@gmail.com> Co-authored-by: Caladius <Caladius@users.noreply.github.com> Co-authored-by: Patrick12115 <115201185+Patrick12115@users.noreply.github.com> Co-authored-by: PurpleHato <47987542+PurpleHato@users.noreply.github.com> Co-authored-by: balloondude2 <55861555+balloondude2@users.noreply.github.com> Co-authored-by: lilacLunatic <8488221+lilacLunatic@users.noreply.github.com> Co-authored-by: Felix Lee <flee135@users.noreply.github.com> Co-authored-by: Sirius902 <10891979+Sirius902@users.noreply.github.com>
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
#include "soh/Network/Anchor/Anchor.h"
|
|
#include <nlohmann/json.hpp>
|
|
#include <libultraship/libultraship.h>
|
|
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
|
|
|
extern "C" {
|
|
#include "macros.h"
|
|
#include "functions.h"
|
|
extern PlayState* gPlayState;
|
|
void func_80838280(Player* player);
|
|
}
|
|
|
|
/**
|
|
* DAMAGE_PLAYER
|
|
*/
|
|
|
|
void Anchor::SendPacket_DamagePlayer(u32 clientId, u8 damageEffect, u8 damage) {
|
|
if (!IsSaveLoaded()) {
|
|
return;
|
|
}
|
|
|
|
nlohmann::json payload;
|
|
payload["type"] = DAMAGE_PLAYER;
|
|
payload["targetClientId"] = clientId;
|
|
payload["damageEffect"] = damageEffect;
|
|
payload["damage"] = damage;
|
|
|
|
SendJsonToRemote(payload);
|
|
}
|
|
|
|
void Anchor::HandlePacket_DamagePlayer(nlohmann::json payload) {
|
|
uint32_t clientId = payload["clientId"].get<uint32_t>();
|
|
if (!clients.contains(clientId) || clients[clientId].player == nullptr) {
|
|
return;
|
|
}
|
|
|
|
AnchorClient& anchorClient = clients[clientId];
|
|
Player* otherPlayer = anchorClient.player;
|
|
Player* self = GET_PLAYER(gPlayState);
|
|
|
|
// Prevent incoming damage during cutscenes or item get sequences
|
|
if (Player_InBlockingCsMode(gPlayState, self) || self->stateFlags1 & PLAYER_STATE1_IN_ITEM_CS ||
|
|
self->stateFlags1 & PLAYER_STATE1_GETTING_ITEM) {
|
|
return;
|
|
}
|
|
|
|
u8 damageEffect = payload["damageEffect"].get<u8>();
|
|
u8 damage = payload["damage"].get<u8>();
|
|
|
|
self->actor.colChkInfo.damage = damage * 8; // Arbitrary number currently, need to fine tune
|
|
|
|
if (damageEffect == DUMMY_PLAYER_HIT_RESPONSE_FIRE) {
|
|
for (int i = 0; i < ARRAY_COUNT(self->bodyFlameTimers); i++) {
|
|
self->bodyFlameTimers[i] = Rand_S16Offset(0, 200);
|
|
}
|
|
self->bodyIsBurning = true;
|
|
} else if (damageEffect == DUMMY_PLAYER_HIT_RESPONSE_STUN) {
|
|
self->actor.freezeTimer = 20;
|
|
Actor_SetColorFilter(&self->actor, 0, 0xFF, 0, 24);
|
|
return;
|
|
}
|
|
|
|
func_80837C0C(gPlayState, self, damageEffect, 4.0f, 5.0f,
|
|
Actor_WorldYawTowardActor(&otherPlayer->actor, &self->actor), 20);
|
|
}
|