1
This commit is contained in:
parent
413e8b769e
commit
034f1f972e
@ -36,11 +36,6 @@
|
||||
|
||||
#include "buff/bufffactory.h"
|
||||
|
||||
static int GetTraceTargetId(Creature* c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Creature::Creature():MoveableEntity()
|
||||
{
|
||||
weak_ptr_chunk_.Set(this);
|
||||
@ -900,7 +895,7 @@ void Creature::UpdateSkill()
|
||||
if (curr_skill_phase < CurrentSkill()->meta->_phases.size()) {
|
||||
const mt::SkillPhase* phase = &CurrentSkill()->meta->_phases[curr_skill_phase];
|
||||
if (phase->time_offset <= CurrentSkill()->GetPassedTime()) {
|
||||
ProcSkillPhase(phase);
|
||||
CurrentSkill()->ProcSkillPhase(phase);
|
||||
++curr_skill_phase;
|
||||
}
|
||||
} else {
|
||||
@ -911,184 +906,6 @@ void Creature::UpdateSkill()
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::ProcSkillPhase(const mt::SkillPhase* phase)
|
||||
{
|
||||
switch (phase->func_id) {
|
||||
case kSkill_TurnOver:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case kSkill_JumpTo:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case kSkill_Shot:
|
||||
{
|
||||
const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt());
|
||||
if (weapon_meta) {
|
||||
const mt::Equip* bullet_meta =
|
||||
mt::Equip::GetById(weapon_meta->use_bullet());
|
||||
if (CurrentSkill()->meta->skill_target() == kST_SpecDir) {
|
||||
if (std::abs(skill_dir_.x) > FLT_EPSILON ||
|
||||
std::abs(skill_dir_.y) > FLT_EPSILON) {
|
||||
float target_distance = 5;
|
||||
if (CurrentSkill()->meta->GetMagicId() == MAGIC_FG) {
|
||||
target_distance = CurrentSkill()->meta->_number_meta->_float_range;
|
||||
}
|
||||
if (weapon_meta->equip_type() == EQUIP_TYPE_THROW &&
|
||||
weapon_meta->equip_subtype() == THROW_EQUIP_TYPE_ADD_BUFF) {
|
||||
target_distance = skill_distance_;
|
||||
auto context_pos_p = context_pos;
|
||||
room->xtimer.SetTimeoutEx
|
||||
(
|
||||
(target_distance / weapon_meta->bullet_speed() + 1.5) * 1000.0f / FRAME_RATE_MS,
|
||||
[this, context_pos_p, weapon_meta]
|
||||
(int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
Position new_context_pos;
|
||||
new_context_pos.x = context_pos_p.x;
|
||||
new_context_pos.y = context_pos_p.y;
|
||||
Position old_context_pos = context_pos;
|
||||
context_pos = new_context_pos;
|
||||
TryAddBuff(this, weapon_meta->_int_param1,
|
||||
CurrentSkill() ? CurrentSkill()->meta : nullptr);
|
||||
context_pos = old_context_pos;
|
||||
}
|
||||
},
|
||||
&xtimer_attacher);
|
||||
}
|
||||
if (CurrentSkill()->meta->GetMagicId() == MAGIC_YLZ) {
|
||||
target_distance = std::max(0.0001f, target_distance);
|
||||
}
|
||||
if (bullet_meta && target_distance > 0.00001f) {
|
||||
int target_id = 0;
|
||||
if (CurrentSkill()->meta->GetMagicId() == MAGIC_HJHX) {
|
||||
target_distance = 0;
|
||||
TryAddBuff(this, 202013);
|
||||
TryAddBuff(this, 202014);
|
||||
target_id = GetTraceTargetId(this);
|
||||
|
||||
}
|
||||
glm::vec3 old_attack_dir = GetAttackDir();
|
||||
glm::vec3 attack_dir = skill_dir_;
|
||||
GlmHelper::Normalize(attack_dir);
|
||||
SetAttackDir(attack_dir);
|
||||
InternalShot
|
||||
(
|
||||
this,
|
||||
weapon_meta,
|
||||
bullet_meta,
|
||||
CurrentSkill() ? CurrentSkill()->meta : nullptr,
|
||||
target_distance,
|
||||
0,
|
||||
0);
|
||||
SetAttackDir(old_attack_dir);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Entity* entity = room->GetEntityByUniId(skill_target_id_);
|
||||
if (entity) {
|
||||
float target_distance = entity->GetPos().Distance2D2(GetPos());
|
||||
if (bullet_meta && target_distance > 0.00001f) {
|
||||
if (CurrentSkill()->meta->GetMagicId() == MAGIC_HJHX) {
|
||||
TryAddBuff(this, 202013);
|
||||
TryAddBuff(this, 202014);
|
||||
}
|
||||
glm::vec3 old_attack_dir = GetAttackDir();
|
||||
glm::vec3 attack_dir = GetPos().CalcDir(entity->GetPos());
|
||||
GlmHelper::Normalize(attack_dir);
|
||||
SetAttackDir(attack_dir);
|
||||
InternalShot
|
||||
(
|
||||
this,
|
||||
weapon_meta,
|
||||
bullet_meta,
|
||||
CurrentSkill() ? CurrentSkill()->meta : nullptr,
|
||||
target_distance,
|
||||
0,
|
||||
0);
|
||||
SetAttackDir(old_attack_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kSkill_Pull:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case kSkill_HoldShield:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case kSkill_ForthBackJump:
|
||||
{
|
||||
glm::vec3 old_dir = GetMoveDir();
|
||||
Position old_pos = GetPos();
|
||||
if (CurrentSkill()->GetMinorType() == SMT_NONE) {
|
||||
int buff_id1 = phase->param3_ints.size() > 0 ? phase->param3_ints[0] : 0;
|
||||
int buff_id2 = phase->param3_ints.size() > 1 ? phase->param3_ints[1] : 0;
|
||||
int buff_id3 = phase->param3_ints.size() > 2 ? phase->param3_ints[2] : 0;
|
||||
const mt::Skill* skill_meta = CurrentSkill()->meta;
|
||||
TryAddBuff(this, buff_id1);
|
||||
int land_effect_buff_uniid = TryAddBuffAndSetTime
|
||||
(this,
|
||||
buff_id3,
|
||||
skill_meta->_number_meta->_float_time * 1000);
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("old_pos:%f,%f\n", {GetPos().x, GetPos().y});
|
||||
#endif
|
||||
ForwardMove(SkillHelper::GetSjydhxForthDistance(CurrentSkill()->meta));
|
||||
float recover_hp = SkillHelper::GetSjydhxRecoverHp(this, CurrentSkill()->meta);
|
||||
AddHp(recover_hp);
|
||||
glm::vec3 pre_dir = old_dir;
|
||||
Position pre_pos = old_pos;
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("new_pos:%f,%f", {GetPos().x, GetPos().y});
|
||||
#endif
|
||||
CurrentSkill()->AddMinorMode
|
||||
(
|
||||
SMT_BLINK,
|
||||
#if 1
|
||||
skill_meta->_number_meta->_float_time * 1000,
|
||||
#else
|
||||
phase->param2.GetInt() * 1000,
|
||||
#endif
|
||||
[this, pre_pos, pre_dir, buff_id1, buff_id2, buff_id3, land_effect_buff_uniid,
|
||||
skill_meta] () {
|
||||
glm::vec3 old_dir = GetMoveDir();
|
||||
Position old_pos = GetPos();
|
||||
float distance = GetPos().Distance2D2(pre_pos);
|
||||
RemoveBuffByUniId(land_effect_buff_uniid);
|
||||
if (distance > 0.0001f) {
|
||||
glm::vec3 new_dir = GetPos().CalcDir(pre_pos);
|
||||
GlmHelper::Normalize(new_dir);
|
||||
SetMoveDir(new_dir);
|
||||
TryAddBuff(this, buff_id2);
|
||||
ForwardMove(distance);
|
||||
}
|
||||
SetMoveDir(old_dir);
|
||||
TryAddBuffAndSetTime(this,
|
||||
skill_meta->_number_meta->buff_id(),
|
||||
skill_meta->_number_meta->buff_time() * 1000,
|
||||
skill_meta);
|
||||
}
|
||||
);
|
||||
}
|
||||
SetMoveDir(old_dir);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const mt::SkillPhase* Creature::GetCurrSkillPhase()
|
||||
{
|
||||
return curr_skill_phase < CurrentSkill()->meta->_phases.size() ?
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "skill.h"
|
||||
#include "creature.h"
|
||||
#include "room.h"
|
||||
@ -15,12 +17,18 @@
|
||||
#include "ability.h"
|
||||
#include "battledatacontext.h"
|
||||
#include "collision.h"
|
||||
#include "shot.h"
|
||||
|
||||
#include "mt/Buff.h"
|
||||
#include "mt/Skill.h"
|
||||
#include "mt/SkillNumber.h"
|
||||
#include "mt/Equip.h"
|
||||
|
||||
static int GetTraceTargetId(Creature* c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Skill::Initialzie()
|
||||
{
|
||||
curr_times_ = GetMaxTimes();
|
||||
@ -924,3 +932,181 @@ void Skill::ProcYSHF()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void Skill::ProcSkillPhase(const mt::SkillPhase* phase)
|
||||
{
|
||||
switch (phase->func_id) {
|
||||
case kSkill_TurnOver:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case kSkill_JumpTo:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case kSkill_Shot:
|
||||
{
|
||||
const mt::Equip* weapon_meta = mt::Equip::GetById(phase->param1.GetInt());
|
||||
if (weapon_meta) {
|
||||
const mt::Equip* bullet_meta =
|
||||
mt::Equip::GetById(weapon_meta->use_bullet());
|
||||
if (owner->CurrentSkill()->meta->skill_target() == kST_SpecDir) {
|
||||
if (std::abs(owner->skill_dir_.x) > FLT_EPSILON ||
|
||||
std::abs(owner->skill_dir_.y) > FLT_EPSILON) {
|
||||
float target_distance = 5;
|
||||
if (owner->CurrentSkill()->meta->GetMagicId() == MAGIC_FG) {
|
||||
target_distance = owner->CurrentSkill()->meta->_number_meta->_float_range;
|
||||
}
|
||||
if (weapon_meta->equip_type() == EQUIP_TYPE_THROW &&
|
||||
weapon_meta->equip_subtype() == THROW_EQUIP_TYPE_ADD_BUFF) {
|
||||
target_distance = owner->skill_distance_;
|
||||
auto context_pos_p = owner->context_pos;
|
||||
owner->room->xtimer.SetTimeoutEx
|
||||
(
|
||||
(target_distance / weapon_meta->bullet_speed() + 1.5) * 1000.0f / FRAME_RATE_MS,
|
||||
[this, context_pos_p, weapon_meta]
|
||||
(int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
Position new_context_pos;
|
||||
new_context_pos.x = context_pos_p.x;
|
||||
new_context_pos.y = context_pos_p.y;
|
||||
Position old_context_pos = owner->context_pos;
|
||||
owner->context_pos = new_context_pos;
|
||||
owner->TryAddBuff(owner, weapon_meta->_int_param1,
|
||||
owner->CurrentSkill() ? owner->CurrentSkill()->meta : nullptr);
|
||||
owner->context_pos = old_context_pos;
|
||||
}
|
||||
},
|
||||
&xtimer_attacher);
|
||||
}
|
||||
if (owner->CurrentSkill()->meta->GetMagicId() == MAGIC_YLZ) {
|
||||
target_distance = std::max(0.0001f, target_distance);
|
||||
}
|
||||
if (bullet_meta && target_distance > 0.00001f) {
|
||||
int target_id = 0;
|
||||
if (owner->CurrentSkill()->meta->GetMagicId() == MAGIC_HJHX) {
|
||||
target_distance = 0;
|
||||
owner->TryAddBuff(owner, 202013);
|
||||
owner->TryAddBuff(owner, 202014);
|
||||
target_id = GetTraceTargetId(owner);
|
||||
|
||||
}
|
||||
glm::vec3 old_attack_dir = owner->GetAttackDir();
|
||||
glm::vec3 attack_dir = owner->skill_dir_;
|
||||
GlmHelper::Normalize(attack_dir);
|
||||
owner->SetAttackDir(attack_dir);
|
||||
InternalShot
|
||||
(
|
||||
owner,
|
||||
weapon_meta,
|
||||
bullet_meta,
|
||||
owner->CurrentSkill() ? owner->CurrentSkill()->meta : nullptr,
|
||||
target_distance,
|
||||
0,
|
||||
0);
|
||||
owner->SetAttackDir(old_attack_dir);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Entity* entity = owner->room->GetEntityByUniId(owner->skill_target_id_);
|
||||
if (entity) {
|
||||
float target_distance = entity->GetPos().Distance2D2(owner->GetPos());
|
||||
if (bullet_meta && target_distance > 0.00001f) {
|
||||
if (owner->CurrentSkill()->meta->GetMagicId() == MAGIC_HJHX) {
|
||||
owner->TryAddBuff(owner, 202013);
|
||||
owner->TryAddBuff(owner, 202014);
|
||||
}
|
||||
glm::vec3 old_attack_dir = owner->GetAttackDir();
|
||||
glm::vec3 attack_dir = owner->GetPos().CalcDir(entity->GetPos());
|
||||
GlmHelper::Normalize(attack_dir);
|
||||
owner->SetAttackDir(attack_dir);
|
||||
InternalShot
|
||||
(
|
||||
owner,
|
||||
weapon_meta,
|
||||
bullet_meta,
|
||||
owner->CurrentSkill() ? owner->CurrentSkill()->meta : nullptr,
|
||||
target_distance,
|
||||
0,
|
||||
0);
|
||||
owner->SetAttackDir(old_attack_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kSkill_Pull:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case kSkill_HoldShield:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case kSkill_ForthBackJump:
|
||||
{
|
||||
glm::vec3 old_dir = owner->GetMoveDir();
|
||||
Position old_pos = owner->GetPos();
|
||||
if (owner->CurrentSkill()->GetMinorType() == SMT_NONE) {
|
||||
int buff_id1 = phase->param3_ints.size() > 0 ? phase->param3_ints[0] : 0;
|
||||
int buff_id2 = phase->param3_ints.size() > 1 ? phase->param3_ints[1] : 0;
|
||||
int buff_id3 = phase->param3_ints.size() > 2 ? phase->param3_ints[2] : 0;
|
||||
const mt::Skill* skill_meta = owner->CurrentSkill()->meta;
|
||||
owner->TryAddBuff(owner, buff_id1);
|
||||
int land_effect_buff_uniid = owner->TryAddBuffAndSetTime
|
||||
(owner,
|
||||
buff_id3,
|
||||
skill_meta->_number_meta->_float_time * 1000);
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("old_pos:%f,%f\n", {owner->GetPos().x, owner->GetPos().y});
|
||||
#endif
|
||||
owner->ForwardMove(SkillHelper::GetSjydhxForthDistance(owner->CurrentSkill()->meta));
|
||||
float recover_hp = SkillHelper::GetSjydhxRecoverHp(owner, owner->CurrentSkill()->meta);
|
||||
owner->AddHp(recover_hp);
|
||||
glm::vec3 pre_dir = old_dir;
|
||||
Position pre_pos = old_pos;
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("new_pos:%f,%f", {owner->GetPos().x, owner->GetPos().y});
|
||||
#endif
|
||||
owner->CurrentSkill()->AddMinorMode
|
||||
(
|
||||
SMT_BLINK,
|
||||
#if 1
|
||||
skill_meta->_number_meta->_float_time * 1000,
|
||||
#else
|
||||
phase->param2.GetInt() * 1000,
|
||||
#endif
|
||||
[this, pre_pos, pre_dir, buff_id1, buff_id2, buff_id3, land_effect_buff_uniid,
|
||||
skill_meta] () {
|
||||
glm::vec3 old_dir = owner->GetMoveDir();
|
||||
Position old_pos = owner->GetPos();
|
||||
float distance = owner->GetPos().Distance2D2(pre_pos);
|
||||
owner->RemoveBuffByUniId(land_effect_buff_uniid);
|
||||
if (distance > 0.0001f) {
|
||||
glm::vec3 new_dir = owner->GetPos().CalcDir(pre_pos);
|
||||
GlmHelper::Normalize(new_dir);
|
||||
owner->SetMoveDir(new_dir);
|
||||
owner->TryAddBuff(owner, buff_id2);
|
||||
owner->ForwardMove(distance);
|
||||
}
|
||||
owner->SetMoveDir(old_dir);
|
||||
owner->TryAddBuffAndSetTime(owner,
|
||||
skill_meta->_number_meta->buff_id(),
|
||||
skill_meta->_number_meta->buff_time() * 1000,
|
||||
skill_meta);
|
||||
}
|
||||
);
|
||||
}
|
||||
owner->SetMoveDir(old_dir);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ class Skill
|
||||
std::function<void()> cb
|
||||
);
|
||||
void DoMinorMode();
|
||||
void ProcSkillPhase(const mt::SkillPhase* phase);
|
||||
|
||||
private:
|
||||
void InitActiveSkill();
|
||||
|
Loading…
x
Reference in New Issue
Block a user