From 38a19d968b86dc6543e76f2f88887149190a1f56 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Jul 2019 16:15:25 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index c9dbd67..260acee 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -216,16 +216,23 @@ void Human::DirectShot(MetaData::Equip* bullet_meta, int skill_id) a8::XParams() .SetSender(this) .SetParam1(bullet_meta) - .SetParam2(skill_id) - .SetParam3(i), + .SetParam2(a8::MakeInt64(skill_id, i)) + .SetParam3(a8::MakeInt64(attack_dir.x * kTEN_W, attack_dir.y * kTEN_W)), [] (const a8::XParams& param) { Human* sender = (Human*)param.sender.GetUserData(); MetaData::Equip* bullet_meta = (MetaData::Equip*)param.param1.GetUserData(); if (sender) { + int skill_id = a8::Low32(param.param2.GetInt64()); + int offset_idx = a8::High32(param.param2.GetInt64()); + float attack_x = a8::Low32(param.param2.GetInt64()) / (float)kTEN_W; + float attack_y = a8::High32(param.param2.GetInt64()) / (float)kTEN_W; + a8::Vec2 old_attack_dir = sender->attack_dir; + sender->attack_dir = a8::Vec2(attack_x, attack_y); sender->InternalShot(bullet_meta, - param.param2, - param.param3); + skill_id, + offset_idx); + sender->attack_dir = old_attack_dir; } }, &xtimer_attacher.timer_list_); @@ -1830,7 +1837,16 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase) { MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt()); if (bullet_meta) { + a8::Vec2 old_attack_dir = attack_dir; + if (bullet_meta->i->equip_subtype() == kBulletType_Trace) { + Human* skill_target = room->GetHumanByUniId(skill_target_id); + if (skill_target) { + attack_dir = skill_target->pos - pos; + attack_dir.Normalize(); + } + } DirectShot(bullet_meta, skill_meta_->i->skill_id()); + attack_dir = old_attack_dir; if (bullet_meta->NeedTrace()) { room->xtimer.AddDeadLineTimerAndAttach(bullet_meta->i->time() * kSERVER_FRAME_RATE, a8::XParams()