This commit is contained in:
aozhiwei 2021-04-06 11:31:38 +08:00
parent 66862a31ce
commit bb636746ea
5 changed files with 54 additions and 22 deletions

View File

@ -158,6 +158,7 @@ enum BuffEffectType_e
kBET_CrazyMode = 33, //暴走模式 kBET_CrazyMode = 33, //暴走模式
kBET_ShockWave = 34, //冲击波 kBET_ShockWave = 34, //冲击波
kBET_Sprint = 35, //冲刺 kBET_Sprint = 35, //冲刺
kBET_SummonObstacle = 36, //召唤物件
kBET_ThroughWall = 50, //穿墙 kBET_ThroughWall = 50, //穿墙
kBET_Driver = 51, //驾驶中 kBET_Driver = 51, //驾驶中

View File

@ -19,6 +19,17 @@ void InternalShot(Creature* c,
float fly_distance, float fly_distance,
bool is_tank_skin) bool is_tank_skin)
{ {
if (weapon_meta->i->_inventory_slot() == IS_TRAP ||
weapon_meta->i->_inventory_slot() == IS_MINE) {
MetaData::Buff * buff_meta = MetaMgr::Instance()->GetBuff(bullet_meta->i->buffid());
if (buff_meta) {
c->AddBuff(c,
buff_meta,
1
);
}
return;
}
for (auto& tuple : weapon_meta->bullet_born_offset) { for (auto& tuple : weapon_meta->bullet_born_offset) {
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple)); a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
bullet_born_offset.Rotate(c->attack_dir.CalcAngle(a8::Vec2::UP)); bullet_born_offset.Rotate(c->attack_dir.CalcAngle(a8::Vec2::UP));
@ -444,7 +455,11 @@ bool Creature::CanUseSkill(int skill_id)
return skill->GetLeftTime() <= 0; return skill->GetLeftTime() <= 0;
} }
void Creature::DoSkill(int skill_id, int target_id, const a8::Vec2& skill_dir, const a8::Vec2& target_pos) void Creature::DoSkill(int skill_id,
int target_id,
const a8::Vec2& skill_dir,
float skill_distance,
const a8::Vec2& target_pos)
{ {
DoSkillPreProc(skill_id, target_id, target_pos); DoSkillPreProc(skill_id, target_id, target_pos);
Skill* skill = GetSkill(skill_id); Skill* skill = GetSkill(skill_id);
@ -453,6 +468,7 @@ void Creature::DoSkill(int skill_id, int target_id, const a8::Vec2& skill_dir, c
skill_target_id_ = target_id; skill_target_id_ = target_id;
skill_target_pos_ = target_pos; skill_target_pos_ = target_pos;
skill_dir_ = skill_dir; skill_dir_ = skill_dir;
skill_distance_ = skill_distance;
curr_skill_ = skill; curr_skill_ = skill;
playing_skill = true; playing_skill = true;
CurrentSkill()->last_use_frameno = room->GetFrameNo(); CurrentSkill()->last_use_frameno = room->GetFrameNo();
@ -671,12 +687,7 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
if (caster == this) { if (caster == this) {
abort(); abort();
} }
#if 1 if (caster->GetEntitySubType() == EST_Android) {
skill_dir_.Normalize();
target_pos = GetPos() + skill_dir_ * skill_distance_;
move_dir = target_pos - GetPos();
move_dir.Normalize();
#else
float target_distance = caster->GetPos().Distance(GetPos()); float target_distance = caster->GetPos().Distance(GetPos());
if (target_distance <= 0.000001f) { if (target_distance <= 0.000001f) {
SetPos(caster->GetPos()); SetPos(caster->GetPos());
@ -691,7 +702,12 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
target_pos = GetPos() + move_dir * (target_distance - buff->meta->param3); target_pos = GetPos() + move_dir * (target_distance - buff->meta->param3);
} }
} }
#endif } else {
caster->skill_dir_.Normalize();
target_pos = caster->GetPos() + caster->skill_dir_ * caster->skill_distance_;
move_dir = target_pos - GetPos();
move_dir.Normalize();
}
} }
break; break;
case kBET_JumpTo: case kBET_JumpTo:

View File

@ -75,7 +75,12 @@ class Creature : public MoveableEntity
const a8::Vec2& target_pos, const a8::Vec2& target_pos,
std::set<Creature*>& target_list); std::set<Creature*>& target_list);
virtual bool CanUseSkill(int skill_id); virtual bool CanUseSkill(int skill_id);
void DoSkill(int skill_id, int target_id, const a8::Vec2& skill_dir, const a8::Vec2& target_pos); void DoSkill(int skill_id,
int target_id,
const a8::Vec2& skill_dir,
float skill_distance,
const a8::Vec2& target_pos
);
void ResetSkill(); void ResetSkill();
Skill* CurrentSkill(); Skill* CurrentSkill();
MetaData::SkillPhase* GetCurrSkillPhase(); MetaData::SkillPhase* GetCurrSkillPhase();

View File

@ -393,7 +393,7 @@ void Player::UpdateUseSkill()
if (HasBuffEffect(kBET_Vertigo)) { if (HasBuffEffect(kBET_Vertigo)) {
return; return;
} }
DoSkill(use_skill_id, skill_target_id, skill_dir, a8::Vec2()); DoSkill(use_skill_id, skill_target_id, skill_dir, skill_distance, a8::Vec2());
use_skill = false; use_skill = false;
} }
@ -439,7 +439,7 @@ void Player::Shot()
int slot_id = curr_weapon->meta->i->_inventory_slot(); int slot_id = curr_weapon->meta->i->_inventory_slot();
//扔完手雷,如无手雷则优先换武器1>武器2 //扔完手雷,如无手雷则优先换武器1>武器2
switch (slot_id) { switch (slot_id) {
case 5: case IS_FRAG:
{ {
//手雷 //手雷
if (curr_weapon->ammo <= 0) { if (curr_weapon->ammo <= 0) {
@ -462,7 +462,7 @@ void Player::Shot()
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
break; break;
case 6: case IS_SMOKE:
{ {
//烟雾弹 //烟雾弹
if (curr_weapon->ammo <= 0) { if (curr_weapon->ammo <= 0) {

View File

@ -467,7 +467,17 @@ void ZombieModeAI::DoShot()
void ZombieModeAI::DoSkill(int skill_id) void ZombieModeAI::DoSkill(int skill_id)
{ {
Human* myself = (Human*)owner; Human* myself = (Human*)owner;
myself->DoSkill(skill_id, node_->target.Get()->GetEntityUniId(), a8::Vec2(), node_->target.Get()->GetPos()); a8::Vec2 skill_dir;
float skill_distance = node_->target.Get()->GetPos().Distance(myself->GetPos());
if (fabs(skill_distance) > 0.00001f) {
skill_dir = node_->target.Get()->GetPos() - myself->GetPos();
skill_dir.Normalize();
}
myself->DoSkill(skill_id,
node_->target.Get()->GetEntityUniId(),
a8::Vec2(),
skill_distance,
node_->target.Get()->GetPos());
} }
int ZombieModeAI::GetAttackTimes() int ZombieModeAI::GetAttackTimes()