Net: show damage numbers through the actor damage queue
Port CInstanceBase::AddDamageEffect/ProcessDamage: damage packets queue per actor and show one digit-effect burst per update, dodge/block show the miss effect. Add CEffectManager::SetEffectTextures and CFlyingManager::CreateIndexedFly for the indexed fly types, and reset the damage target on GC_PHASE loading. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
f6dfcfc337
commit
31c5b3dd9b
@@ -51,6 +51,14 @@ static std::string NormalizePath(std::string path) {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EffectData::ChangeTexture(size_t particleIndex, const std::string& fileName) {
|
||||||
|
if (particleIndex >= m_particles.size()) return false;
|
||||||
|
auto& textures = m_particles[particleIndex].particle.texture_files;
|
||||||
|
if (textures.size() > 1) return false;
|
||||||
|
textures.assign(1, NormalizePath(fileName));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<std::string> TokenizeScript(const std::string& content) {
|
static std::vector<std::string> TokenizeScript(const std::string& content) {
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ public:
|
|||||||
const float* GetBoundingSpherePosition() const { return m_bounding_sphere_position; }
|
const float* GetBoundingSpherePosition() const { return m_bounding_sphere_position; }
|
||||||
const std::vector<ParticleElement>& GetParticles() const { return m_particles; }
|
const std::vector<ParticleElement>& GetParticles() const { return m_particles; }
|
||||||
const std::string& GetSoundFileName() const { return m_sound_filename; }
|
const std::string& GetSoundFileName() const { return m_sound_filename; }
|
||||||
|
// CParticleSystemData::ChangeTexture -> CParticleProperty::SetTexture: replaces a single-texture
|
||||||
|
// particle's image (false for animated multi-texture particles or a missing particle).
|
||||||
|
bool ChangeTexture(size_t particleIndex, const std::string& fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ EffectInstance::EffectInstance(std::shared_ptr<EffectData> data)
|
|||||||
: m_data(std::move(data)) {
|
: m_data(std::move(data)) {
|
||||||
if (m_data) {
|
if (m_data) {
|
||||||
m_emitters.resize(m_data->GetParticles().size());
|
m_emitters.resize(m_data->GetParticles().size());
|
||||||
|
for (const auto& pe : m_data->GetParticles()) m_textures.push_back(pe.particle.texture_files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,8 +205,8 @@ void EffectInstance::Update(float dt) {
|
|||||||
it->scale[1] = InterpolateTimeEvent(pe.particle.time_scale_y, t, 1.0f);
|
it->scale[1] = InterpolateTimeEvent(pe.particle.time_scale_y, t, 1.0f);
|
||||||
|
|
||||||
// Texture animation
|
// Texture animation
|
||||||
if (pe.particle.texture_files.size() > 1 && pe.particle.tex_ani_delay > 0.001f) {
|
if (m_textures[i].size() > 1 && pe.particle.tex_ani_delay > 0.001f) {
|
||||||
it->frame_index = static_cast<uint8_t>(std::fmod(it->life / pe.particle.tex_ani_delay, pe.particle.texture_files.size()));
|
it->frame_index = static_cast<uint8_t>(std::fmod(it->life / pe.particle.tex_ani_delay, m_textures[i].size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
++it;
|
++it;
|
||||||
@@ -250,9 +251,10 @@ void EffectInstance::BuildDrawCommands(const float* viewMatrix, const float* pro
|
|||||||
for (size_t pIdx = 0; pIdx < inst.particles.size(); ++pIdx) {
|
for (size_t pIdx = 0; pIdx < inst.particles.size(); ++pIdx) {
|
||||||
const auto& p = inst.particles[pIdx];
|
const auto& p = inst.particles[pIdx];
|
||||||
std::string tex = "";
|
std::string tex = "";
|
||||||
if (!pe.particle.texture_files.empty()) {
|
const auto& textures = m_textures[i];
|
||||||
size_t frame = p.frame_index % pe.particle.texture_files.size();
|
if (!textures.empty()) {
|
||||||
tex = pe.particle.texture_files[frame];
|
size_t frame = p.frame_index % textures.size();
|
||||||
|
tex = textures[frame];
|
||||||
}
|
}
|
||||||
texGroups[tex].push_back(pIdx);
|
texGroups[tex].push_back(pIdx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ private:
|
|||||||
bool m_hasCustomMatrix = false;
|
bool m_hasCustomMatrix = false;
|
||||||
|
|
||||||
std::vector<EmitterInstance> m_emitters;
|
std::vector<EmitterInstance> m_emitters;
|
||||||
|
// CParticleSystemInstance m_kVct_pkImgInst: the texture list is taken when the instance is created,
|
||||||
|
// so CEffectManager::SetEffectTextures only affects instances created after it.
|
||||||
|
std::vector<std::vector<std::string>> m_textures;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ava2
|
} // namespace ava2
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ uint32_t EffectManager::CreateEffect(uint32_t effectId, float x, float y, float
|
|||||||
return instId;
|
return instId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EffectManager::SetEffectTextures(uint32_t effectId, const std::vector<std::string>& textures) {
|
||||||
|
auto it = m_dataCache.find(effectId);
|
||||||
|
if (it == m_dataCache.end() || !it->second) return; // Tracef("... - NO DATA")
|
||||||
|
for (size_t i = 0; i < textures.size(); ++i) it->second->ChangeTexture(i, textures[i]);
|
||||||
|
}
|
||||||
|
|
||||||
bool EffectManager::DestroyEffectInstance(uint32_t instanceId) {
|
bool EffectManager::DestroyEffectInstance(uint32_t instanceId) {
|
||||||
auto it = m_instances.find(instanceId);
|
auto it = m_instances.find(instanceId);
|
||||||
if (it != m_instances.end()) {
|
if (it != m_instances.end()) {
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public:
|
|||||||
uint32_t CreateEffect(const std::string& filename, float x = 0.0f, float y = 0.0f, float z = 0.0f, float yaw = 0.0f);
|
uint32_t CreateEffect(const std::string& filename, float x = 0.0f, float y = 0.0f, float z = 0.0f, float yaw = 0.0f);
|
||||||
uint32_t CreateEffect(uint32_t effectId, float x = 0.0f, float y = 0.0f, float z = 0.0f, float yaw = 0.0f);
|
uint32_t CreateEffect(uint32_t effectId, float x = 0.0f, float y = 0.0f, float z = 0.0f, float yaw = 0.0f);
|
||||||
|
|
||||||
|
// CEffectManager::SetEffectTextures: texture i replaces particle i's image in the shared data.
|
||||||
|
void SetEffectTextures(uint32_t effectId, const std::vector<std::string>& textures);
|
||||||
|
|
||||||
bool DestroyEffectInstance(uint32_t instanceId);
|
bool DestroyEffectInstance(uint32_t instanceId);
|
||||||
void DeleteAllInstances();
|
void DeleteAllInstances();
|
||||||
bool IsAliveEffect(uint32_t instanceId) const;
|
bool IsAliveEffect(uint32_t instanceId) const;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "FlyingManager.h"
|
#include "FlyingManager.h"
|
||||||
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -335,6 +337,38 @@ uint32_t FlyingManager::CreateFlyingInstance(uint32_t flyId, const float* startP
|
|||||||
return static_cast<uint32_t>(m_instances.size());
|
return static_cast<uint32_t>(m_instances.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlyingManager::CreateIndexedFly(uint32_t index, const float* startPos, float startRotation, const float* endTargetPos) {
|
||||||
|
auto it = m_indexedFlyData.find(index);
|
||||||
|
if (it == m_indexedFlyData.end()) {
|
||||||
|
std::cerr << "[AVA2 TraceError] CFlyingManager::CreateIndexedFly(dwIndex=" << index << ") - Not registered index" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto frandom = [](float lo, float hi) { return lo + (hi - lo) * (static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)); };
|
||||||
|
switch (it->second.type) {
|
||||||
|
case INDEX_FLY_TYPE_NORMAL:
|
||||||
|
CreateFlyingInstance(it->second.flyId, startPos, endTargetPos);
|
||||||
|
break;
|
||||||
|
case INDEX_FLY_TYPE_FIRE_CRACKER: {
|
||||||
|
constexpr float DEG = 3.14159265358979323846f / 180.0f;
|
||||||
|
const float fRot = std::fmod(startRotation - 90.0f + 360.0f, 360.0f) + frandom(-30.0f, 30.0f);
|
||||||
|
const float fDistance = frandom(2000.0f, 5000.0f);
|
||||||
|
const float fxRand = fDistance * std::cos(fRot * DEG);
|
||||||
|
const float fyRand = fDistance * std::sin(fRot * DEG);
|
||||||
|
const float fzRand = frandom(1000.0f, 2500.0f);
|
||||||
|
// Native (x, y, z) = engine (x, -z, height).
|
||||||
|
const float start[3] = {startPos[0], startPos[1] + 200.0f, startPos[2]};
|
||||||
|
const float end[3] = {startPos[0] + fxRand, startPos[1] + fzRand, startPos[2] - fyRand};
|
||||||
|
CreateFlyingInstance(it->second.flyId, start, end);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case INDEX_FLY_TYPE_AUTO_FIRE: {
|
||||||
|
const float start[3] = {startPos[0], startPos[1] + 100.0f, startPos[2]};
|
||||||
|
CreateFlyingInstance(it->second.flyId, start, endTargetPos);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FlyingManager::Update(float dt, float currentTime) {
|
void FlyingManager::Update(float dt, float currentTime) {
|
||||||
for (auto it = m_instances.begin(); it != m_instances.end();) {
|
for (auto it = m_instances.begin(); it != m_instances.end();) {
|
||||||
if (!(*it)->Update(dt, currentTime)) {
|
if (!(*it)->Update(dt, currentTime)) {
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ public:
|
|||||||
uint32_t CreateFlyingInstance(uint32_t flyId, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr);
|
uint32_t CreateFlyingInstance(uint32_t flyId, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr);
|
||||||
uint32_t CreateFlyingInstance(const std::string& filename, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr);
|
uint32_t CreateFlyingInstance(const std::string& filename, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr);
|
||||||
|
|
||||||
|
// CFlyingManager::CreateIndexedFly: start = the start actor's position (engine x, height, z) and
|
||||||
|
// rotation (native degrees), end = the end actor's fly-target position.
|
||||||
|
void CreateIndexedFly(uint32_t index, const float* startPos, float startRotation, const float* endTargetPos);
|
||||||
|
|
||||||
void Update(float dt, float currentTime);
|
void Update(float dt, float currentTime);
|
||||||
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws);
|
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws);
|
||||||
void DeleteAllInstances();
|
void DeleteAllInstances();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "eter_effect/EffectManager.h"
|
#include "eter_effect/EffectManager.h"
|
||||||
#include "nonplayer_data.h"
|
#include "nonplayer_data.h"
|
||||||
#include "eter_render/RaceData.h"
|
#include "eter_render/RaceData.h"
|
||||||
|
#include "eter_render/Gr2ModelRenderer.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -241,6 +242,82 @@ void NetworkActorManager::CreateSpecialEffect(uint32_t vid, unsigned type) {
|
|||||||
EffectManager::Instance().CreateEffect(GetEffectCRC(type), x, y, z, yaw);
|
EffectManager::Instance().CreateEffect(GetEffectCRC(type), x, y, z, yaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkActorManager::AddDamageEffect(uint32_t vid, uint32_t damage, uint8_t flag, bool bSelf, bool bTarget) {
|
||||||
|
auto* actor = GetActorData(vid);
|
||||||
|
if (!actor) return; // the caller checks CPythonSystem::IsShowDamage (eter_render has no scripting)
|
||||||
|
actor->m_DamageQueue.push_back({damage, flag, bSelf, bTarget});
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// CInstanceBase::ProcessDamage. The camera comes from the current scene renderer: its view matrix
|
||||||
|
// rows are the camera axes in engine space (x right, z forward); native (x, y) = engine (x, -z).
|
||||||
|
void ProcessDamage(SNetworkActorData& actor) {
|
||||||
|
if (actor.m_DamageQueue.empty() || !actor.m_pActorInstance) return;
|
||||||
|
const auto sDamage = actor.m_DamageQueue.front();
|
||||||
|
actor.m_DamageQueue.pop_front();
|
||||||
|
|
||||||
|
uint32_t damage = sDamage.damage;
|
||||||
|
const uint8_t flag = sDamage.flag;
|
||||||
|
|
||||||
|
float rightX = 1.0f, rightY = 0.0f, rightZ = 0.0f, cameraAngle = 0.0f;
|
||||||
|
if (const auto* renderer = TextTailManager::Instance().GetCurrentSceneRenderer()) {
|
||||||
|
const float* view = renderer->GetViewMatrix();
|
||||||
|
rightX = view[0]; rightY = view[4]; rightZ = view[8];
|
||||||
|
// GetDegreeFromPosition2(target, eye): the native direction from the camera target to the eye.
|
||||||
|
const float dirX = -view[2], dirY = view[10];
|
||||||
|
const float len = std::sqrt(dirX * dirX + dirY * dirY);
|
||||||
|
if (len > 0.0f) {
|
||||||
|
cameraAngle = std::acos(std::clamp(-dirY / len, -1.0f, 1.0f)) * 180.0f / 3.14159265358979323846f;
|
||||||
|
if (dirX < 0.0f) cameraAngle = 360.0f - cameraAngle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr float FONT_WIDTH = 30.0f;
|
||||||
|
auto& rkEftMgr = EffectManager::Instance();
|
||||||
|
float x, y, z;
|
||||||
|
actor.m_pActorInstance->GetHeadPosition(x, y, z); // GetPosition() + GetHeight()
|
||||||
|
|
||||||
|
if ((flag & NetworkActorManager::DAMAGE_DODGE) || (flag & NetworkActorManager::DAMAGE_BLOCK)) {
|
||||||
|
rkEftMgr.CreateEffect(NetworkActorManager::GetEffectCRC(sDamage.bSelf ? NetworkActorManager::EFFECT_DAMAGE_MISS
|
||||||
|
: NetworkActorManager::EFFECT_DAMAGE_TARGETMISS),
|
||||||
|
x, y, z, cameraAngle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// DAMAGE_CRITICAL: the critical effect is commented out upstream; the number is still shown.
|
||||||
|
|
||||||
|
std::string strDamageType;
|
||||||
|
unsigned rdwCRCEft = 0;
|
||||||
|
if (sDamage.bSelf) {
|
||||||
|
strDamageType = "damage_";
|
||||||
|
rdwCRCEft = actor.m_bDamageEffectType ? NetworkActorManager::EFFECT_DAMAGE_SELFDAMAGE2 : NetworkActorManager::EFFECT_DAMAGE_SELFDAMAGE;
|
||||||
|
actor.m_bDamageEffectType = !actor.m_bDamageEffectType;
|
||||||
|
} else if (!sDamage.bTarget) {
|
||||||
|
return; // "nontarget_" / EFFECT_DAMAGE_NOT_TARGET: not applied upstream.
|
||||||
|
} else {
|
||||||
|
strDamageType = "target_";
|
||||||
|
rdwCRCEft = NetworkActorManager::EFFECT_DAMAGE_TARGET;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t effectId = NetworkActorManager::GetEffectCRC(rdwCRCEft);
|
||||||
|
uint32_t index = 0;
|
||||||
|
while (damage > 0) {
|
||||||
|
if (index > 7) {
|
||||||
|
std::cerr << "[AVA2 TraceError] ProcessDamage Possibility of endless loop" << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const uint32_t num = damage % 10;
|
||||||
|
damage /= 10;
|
||||||
|
rkEftMgr.SetEffectTextures(effectId, {"d:/ymir work/effect/affect/damagevalue/" + strDamageType + std::to_string(num) + ".dds"});
|
||||||
|
// Translation by (-FONT_WIDTH * index, 0, 0) in view space.
|
||||||
|
const float offset = -FONT_WIDTH * static_cast<float>(index);
|
||||||
|
rkEftMgr.CreateEffect(effectId, x + rightX * offset, y + rightY * offset, z + rightZ * offset, cameraAngle);
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
bool NetworkActorManager::IsPossibleEmoticon(uint32_t vid) const {
|
bool NetworkActorManager::IsPossibleEmoticon(uint32_t vid) const {
|
||||||
const auto* actor = GetActorData(vid);
|
const auto* actor = GetActorData(vid);
|
||||||
if (!actor) return false;
|
if (!actor) return false;
|
||||||
@@ -855,6 +932,7 @@ void NetworkActorManager::Update(float dt, const TerrainHeightSource* terrain) {
|
|||||||
eftMgr.SetEffectInstanceRotation(e->instanceId, inst.GetYaw(), 0.0f, 0.0f);
|
eftMgr.SetEffectInstanceRotation(e->instanceId, inst.GetYaw(), 0.0f, 0.0f);
|
||||||
++e;
|
++e;
|
||||||
}
|
}
|
||||||
|
ProcessDamage(actorData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <deque>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace ava2 {
|
namespace ava2 {
|
||||||
@@ -80,6 +81,10 @@ struct SNetworkActorData {
|
|||||||
// packet copies above (SetHair/SetSash/SetWeapon may refuse a value the packet carried).
|
// packet copies above (SetHair/SetSash/SetWeapon may refuse a value the packet carried).
|
||||||
uint32_t m_awPart[7] = {};
|
uint32_t m_awPart[7] = {};
|
||||||
std::vector<SAttachedEffect> m_attachedEffects;
|
std::vector<SAttachedEffect> m_attachedEffects;
|
||||||
|
// CInstanceBase::SEffectDamage / m_DamageQueue / m_bDamageEffectType (AddDamageEffect, ProcessDamage).
|
||||||
|
struct SEffectDamage { uint32_t damage = 0; uint8_t flag = 0; bool bSelf = false; bool bTarget = false; };
|
||||||
|
std::deque<SEffectDamage> m_DamageQueue;
|
||||||
|
bool m_bDamageEffectType = false;
|
||||||
// CInstanceBase::m_adwCRCAffectEffect[AFFECT_NUM]: the effect instance __SetAffect attached.
|
// CInstanceBase::m_adwCRCAffectEffect[AFFECT_NUM]: the effect instance __SetAffect attached.
|
||||||
uint32_t m_adwAffectEffect[64] = {};
|
uint32_t m_adwAffectEffect[64] = {};
|
||||||
// CGraphicThingInstance::Hide/Show (chr.Hide/chr.Show); hidden instances are not drawn.
|
// CGraphicThingInstance::Hide/Show (chr.Hide/chr.Show); hidden instances are not drawn.
|
||||||
@@ -189,6 +194,14 @@ public:
|
|||||||
void CreateSpecialEffect(uint32_t vid, unsigned type); // effect at the actor transform
|
void CreateSpecialEffect(uint32_t vid, unsigned type); // effect at the actor transform
|
||||||
bool IsPossibleEmoticon(uint32_t vid) const;
|
bool IsPossibleEmoticon(uint32_t vid) const;
|
||||||
void SetEmoticon(uint32_t vid, unsigned emoticon);
|
void SetEmoticon(uint32_t vid, unsigned emoticon);
|
||||||
|
// CInstanceBase::AddDamageEffect (the caller checks CPythonSystem::IsShowDamage) and ProcessDamage,
|
||||||
|
// which shows one queued entry per update as damagevalue digit effects.
|
||||||
|
enum { DAMAGE_DODGE = 1 << 2, DAMAGE_BLOCK = 1 << 3, DAMAGE_CRITICAL = 1 << 5 };
|
||||||
|
enum {
|
||||||
|
EFFECT_DAMAGE_TARGET = 254, EFFECT_DAMAGE_NOT_TARGET, EFFECT_DAMAGE_SELFDAMAGE, EFFECT_DAMAGE_SELFDAMAGE2,
|
||||||
|
EFFECT_DAMAGE_POISON, EFFECT_DAMAGE_MISS, EFFECT_DAMAGE_TARGETMISS, EFFECT_DAMAGE_CRITICAL,
|
||||||
|
};
|
||||||
|
void AddDamageEffect(uint32_t vid, uint32_t damage, uint8_t flag, bool bSelf, bool bTarget);
|
||||||
void SetTimeSourceForTest(uint32_t (*now)()) { m_now = now; }
|
void SetTimeSourceForTest(uint32_t (*now)()) { m_now = now; }
|
||||||
|
|
||||||
// CInstanceBase name/title colour tables (InstanceBaseEffect.cpp g_akD3DXClrName/Title,
|
// CInstanceBase name/title colour tables (InstanceBaseEffect.cpp g_akD3DXClrName/Title,
|
||||||
|
|||||||
@@ -9,14 +9,13 @@
|
|||||||
#include "shared/common/PythonUtils.h"
|
#include "shared/common/PythonUtils.h"
|
||||||
#include "nonplayer_data.h"
|
#include "nonplayer_data.h"
|
||||||
#include "python_app.h"
|
#include "python_app.h"
|
||||||
|
#include "python_system.h"
|
||||||
#include "python_gameplay_modules.h"
|
#include "python_gameplay_modules.h"
|
||||||
#include "python_chat.h"
|
#include "python_chat.h"
|
||||||
#include "python_native_modules.h"
|
#include "python_native_modules.h"
|
||||||
#include "PythonExchange.h"
|
#include "PythonExchange.h"
|
||||||
#include "PythonSafeBox.h"
|
#include "PythonSafeBox.h"
|
||||||
#include "eter_render/FloatingTextManager.h"
|
|
||||||
#include "eter_render/TextTailManager.h"
|
#include "eter_render/TextTailManager.h"
|
||||||
#include "eter_sound/SoundManager.h"
|
|
||||||
#include "eter_effect/EffectManager.h"
|
#include "eter_effect/EffectManager.h"
|
||||||
#include "eter_effect/FlyingManager.h"
|
#include "eter_effect/FlyingManager.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -465,6 +464,7 @@ bool PythonNetworkStream::RecvPhasePacket() {
|
|||||||
break;
|
break;
|
||||||
case PHASE_LOADING: // SetLoadingPhase: CPythonPlayer::Clear
|
case PHASE_LOADING: // SetLoadingPhase: CPythonPlayer::Clear
|
||||||
ResetPlayerState();
|
ResetPlayerState();
|
||||||
|
m_dwInstTargetVID=0; // the instances it named are gone (CPythonCharacterManager::DeleteAllInstances)
|
||||||
SetPhase(PHASE_LOADING);
|
SetPhase(PHASE_LOADING);
|
||||||
break;
|
break;
|
||||||
case PHASE_GAME: // SetGamePhase: __RefreshStatus
|
case PHASE_GAME: // SetGamePhase: __RefreshStatus
|
||||||
@@ -875,27 +875,15 @@ bool PythonNetworkStream::RecvDamageInfoPacket() {
|
|||||||
TPacketGCDamageInfo p;
|
TPacketGCDamageInfo p;
|
||||||
if (!Read(sizeof(p), &p)) return false;
|
if (!Read(sizeof(p), &p)) return false;
|
||||||
|
|
||||||
auto actor = NetworkActorManager::Instance().GetActorInstance(p.dwVID);
|
auto& chrMgr = NetworkActorManager::Instance();
|
||||||
float ax = 0.0f, ay = 0.0f, az = 0.0f;
|
const bool bSelf = p.dwVID == chrMgr.GetMainActorVID();
|
||||||
if (actor) {
|
const bool bTarget = p.dwVID == m_dwInstTargetVID;
|
||||||
ax = actor->GetX();
|
if (chrMgr.GetActorData(p.dwVID)) {
|
||||||
ay = actor->GetY();
|
if (p.damage >= 0) {
|
||||||
az = actor->GetZ();
|
if (CPythonSystem::Instance().IsShowDamage()) // CInstanceBase::AddDamageEffect
|
||||||
actor->TakeDamage(p.damage);
|
chrMgr.AddDamageEffect(p.dwVID, uint32_t(p.damage), p.flag, bSelf, bTarget);
|
||||||
}
|
} else
|
||||||
|
std::cerr << "[AVA2 TraceError] Damage is equal or below 0." << std::endl;
|
||||||
// Spawn 3D floating damage number above target head
|
|
||||||
bool isCritical = (p.flag & 1) != 0;
|
|
||||||
FloatingTextManager::Instance().AddDamage(p.damage, ax, ay + 140.0f, az, isCritical, true);
|
|
||||||
|
|
||||||
// Hit particle sparks
|
|
||||||
EffectManager::Instance().CreateEffect("ymir work/pc/warrior/effect/gihyeol_spark.mse", ax, ay + 70.0f, az);
|
|
||||||
|
|
||||||
// SFX
|
|
||||||
SoundManager::Instance().PlaySound2D("sound/ui/punch.wav");
|
|
||||||
|
|
||||||
if (m_damageCallback) {
|
|
||||||
m_damageCallback(p.dwVID, p.damage, p.flag);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1058,28 +1046,12 @@ bool PythonNetworkStream::RecvCreateFlyPacket() {
|
|||||||
|
|
||||||
auto startActor = NetworkActorManager::Instance().GetActorInstance(p.dwStartVID);
|
auto startActor = NetworkActorManager::Instance().GetActorInstance(p.dwStartVID);
|
||||||
auto endActor = NetworkActorManager::Instance().GetActorInstance(p.dwEndVID);
|
auto endActor = NetworkActorManager::Instance().GetActorInstance(p.dwEndVID);
|
||||||
|
if (!startActor || !endActor) return true;
|
||||||
|
|
||||||
float startPos[3] = {0.0f, 100.0f, 0.0f};
|
const float startPos[3] = {startActor->GetX(), startActor->GetY(), startActor->GetZ()};
|
||||||
float endPos[3] = {200.0f, 100.0f, 0.0f};
|
float endPos[3];
|
||||||
|
endActor->GetFlyTargetCenter(endPos);
|
||||||
if (startActor) {
|
FlyingManager::Instance().CreateIndexedFly(p.bType, startPos, startActor->GetYaw(), endPos);
|
||||||
startPos[0] = startActor->GetX();
|
|
||||||
startPos[1] = startActor->GetY() + 60.0f;
|
|
||||||
startPos[2] = startActor->GetZ();
|
|
||||||
}
|
|
||||||
if (endActor) {
|
|
||||||
endPos[0] = endActor->GetX();
|
|
||||||
endPos[1] = endActor->GetY() + 60.0f;
|
|
||||||
endPos[2] = endActor->GetZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
FlyingManager::Instance().CreateFlyingInstance(p.bType, startPos, endPos, [endVID = p.dwEndVID](const float* hitPos) {
|
|
||||||
EffectManager::Instance().CreateEffect("ymir work/pc/warrior/effect/gihyeol_spark.mse", hitPos[0], hitPos[1], hitPos[2]);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (m_flyCallback) {
|
|
||||||
m_flyCallback(p.bType, p.dwStartVID, p.dwEndVID);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,8 +177,6 @@ public:
|
|||||||
std::pair<int32_t,int32_t> GetDungeonDestination() const { return m_dungeonDestination; }
|
std::pair<int32_t,int32_t> GetDungeonDestination() const { return m_dungeonDestination; }
|
||||||
|
|
||||||
// Callback when damage occurs
|
// Callback when damage occurs
|
||||||
using DamageCallback = std::function<void(uint32_t vid, int damage, uint8_t flag)>;
|
|
||||||
void SetDamageCallback(DamageCallback cb) { m_damageCallback = cb; }
|
|
||||||
|
|
||||||
// Callback when chat is received
|
// Callback when chat is received
|
||||||
|
|
||||||
@@ -213,8 +211,6 @@ public:
|
|||||||
void SetGroundItemCallback(GroundItemCallback cb) { m_groundItemCallback = cb; }
|
void SetGroundItemCallback(GroundItemCallback cb) { m_groundItemCallback = cb; }
|
||||||
|
|
||||||
// Callback when fly projectile is created
|
// Callback when fly projectile is created
|
||||||
using FlyCallback = std::function<void(uint8_t flyType, uint32_t startVID, uint32_t endVID)>;
|
|
||||||
void SetFlyCallback(FlyCallback cb) { m_flyCallback = cb; }
|
|
||||||
|
|
||||||
// GC_WARP: the transport (LoginClient::warp) performs CNetworkStream::Connect(lAddr, wPort).
|
// GC_WARP: the transport (LoginClient::warp) performs CNetworkStream::Connect(lAddr, wPort).
|
||||||
bool TakeWarpRequest(uint32_t& address,uint16_t& port) {
|
bool TakeWarpRequest(uint32_t& address,uint16_t& port) {
|
||||||
@@ -425,10 +421,10 @@ private:
|
|||||||
// Temporary pending actor data when CharacterAdd arrives before CharacterAdditionalInfo
|
// Temporary pending actor data when CharacterAdd arrives before CharacterAdditionalInfo
|
||||||
SNetworkActorData m_pendingActorData;
|
SNetworkActorData m_pendingActorData;
|
||||||
|
|
||||||
DamageCallback m_damageCallback;
|
// m_pInstTarget (RecvTargetPacket): RecvDamageInfoPacket shows "target_" numbers only for it.
|
||||||
|
uint32_t m_dwInstTargetVID = 0;
|
||||||
WhisperCallback m_whisperCallback;
|
WhisperCallback m_whisperCallback;
|
||||||
GroundItemCallback m_groundItemCallback;
|
GroundItemCallback m_groundItemCallback;
|
||||||
FlyCallback m_flyCallback;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ava2
|
} // namespace ava2
|
||||||
|
|||||||
@@ -598,6 +598,7 @@ bool PythonNetworkStream::RecvTargetInfoPacket() {
|
|||||||
PyCallClassMemberFunc(game,"BINARY_AddTargetMonsterDropInfo",Py_BuildValue("(iii)",int(p.race),int(p.dwVnum),int(p.count)));
|
PyCallClassMemberFunc(game,"BINARY_AddTargetMonsterDropInfo",Py_BuildValue("(iii)",int(p.race),int(p.dwVnum),int(p.count)));
|
||||||
PyCallClassMemberFunc(game,"BINARY_RefreshTargetMonsterDropInfo",Py_BuildValue("(i)",int(p.race)));
|
PyCallClassMemberFunc(game,"BINARY_RefreshTargetMonsterDropInfo",Py_BuildValue("(i)",int(p.race)));
|
||||||
} else PyCallClassMemberFunc(game,"CloseTargetBoard",Py_BuildValue("()"));
|
} else PyCallClassMemberFunc(game,"CloseTargetBoard",Py_BuildValue("()"));
|
||||||
|
m_dwInstTargetVID=p.dwVID;
|
||||||
}
|
}
|
||||||
} else PyCallClassMemberFunc(game,"CloseTargetBoard",Py_BuildValue("()"));
|
} else PyCallClassMemberFunc(game,"CloseTargetBoard",Py_BuildValue("()"));
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user