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_ShockWave = 34, //冲击波
kBET_Sprint = 35, //冲刺
kBET_SummonObstacle = 36, //召唤物件
kBET_ThroughWall = 50, //穿墙
kBET_Driver = 51, //驾驶中

View File

@ -19,6 +19,17 @@ void InternalShot(Creature* c,
float fly_distance,
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) {
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));
@ -444,7 +455,11 @@ bool Creature::CanUseSkill(int skill_id)
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);
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_pos_ = target_pos;
skill_dir_ = skill_dir;
skill_distance_ = skill_distance;
curr_skill_ = skill;
playing_skill = true;
CurrentSkill()->last_use_frameno = room->GetFrameNo();
@ -671,27 +687,27 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
if (caster == this) {
abort();
}
#if 1
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());
if (target_distance <= 0.000001f) {
SetPos(caster->GetPos());
target_pos = caster->GetPos();
} else {
if (target_distance <= buff->meta->param3) {
if (caster->GetEntitySubType() == EST_Android) {
float target_distance = caster->GetPos().Distance(GetPos());
if (target_distance <= 0.000001f) {
SetPos(caster->GetPos());
target_pos = caster->GetPos();
} else {
move_dir = caster->GetPos() - GetPos();
move_dir.Normalize();
target_pos = GetPos() + move_dir * (target_distance - buff->meta->param3);
if (target_distance <= buff->meta->param3) {
SetPos(caster->GetPos());
target_pos = caster->GetPos();
} else {
move_dir = caster->GetPos() - GetPos();
move_dir.Normalize();
target_pos = GetPos() + move_dir * (target_distance - buff->meta->param3);
}
}
} else {
caster->skill_dir_.Normalize();
target_pos = caster->GetPos() + caster->skill_dir_ * caster->skill_distance_;
move_dir = target_pos - GetPos();
move_dir.Normalize();
}
#endif
}
break;
case kBET_JumpTo:

View File

@ -75,7 +75,12 @@ class Creature : public MoveableEntity
const a8::Vec2& target_pos,
std::set<Creature*>& target_list);
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();
Skill* CurrentSkill();
MetaData::SkillPhase* GetCurrSkillPhase();

View File

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

View File

@ -467,7 +467,17 @@ void ZombieModeAI::DoShot()
void ZombieModeAI::DoSkill(int skill_id)
{
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()