diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 77516b1..f58130d 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -134,6 +134,18 @@ void Human::Initialize() float Human::GetSpeed() { + { + Buff* buff = GetBuffByEffectId(kBET_JumpTo); + if (buff) { + return buff->meta->param2; + } + } + { + Buff* buff = GetBuffByEffectId(kBET_Pull); + if (buff) { + return buff->meta->param2; + } + } if (downed) { return meta->i->move_speed3(); } else { @@ -1240,7 +1252,7 @@ void Human::DoSkill() ResetSkill(); playing_skill = true; last_use_skill_frameno_ = room->GetFrameNo(); - #if 1 + #if 0 skill_target_id = GetEntityUniId(); #endif Entity* entity = room->GetEntityByUniId(skill_target_id); @@ -1854,30 +1866,59 @@ int Human::GetSkinConfigLv(int skin_id) return itr != skin_configs.end() ? itr->second : 0; } +bool Human::HasSpecMove() +{ + return GetBuffByEffectId(kBET_JumpTo) || + GetBuffByEffectId(kBET_Pull); +} + +void Human::_UpdateSpecMove() +{ + if (!HasSpecMove()) { + return; + } + bool move_end = false; + float target_distance = target_pos.Distance(GetPos()); + if (target_distance <= 0.000001f) { + move_end = true; + } else { + a8::Vec2 old_move_dir = move_dir; + move_dir = target_pos - GetPos(); + move_dir.Normalize(); + bool is_collision = false; + std::function old_on_move_collision = on_move_collision; + on_move_collision = + [&is_collision] () { + is_collision = true; + return false; + }; + + _UpdateMove(std::min((int)target_distance, (int)GetSpeed())); + + on_move_collision = old_on_move_collision; + move_dir = old_move_dir; + target_distance = target_pos.Distance(GetPos()); + if (is_collision || target_distance <= 1.0001f) { + move_end = true; + } + } + if (move_end) { + if (GetBuffByEffectId(kBET_JumpTo)) { + RemoveBuffByEffectId(kBET_JumpTo); + } + if (GetBuffByEffectId(kBET_Pull)) { + RemoveBuffByEffectId(kBET_Pull); + } + } +} + void Human::_UpdateMove(int speed) { - #if 1 do { int distance = std::min(5, speed); _InternalUpdateMove(distance); speed -= distance; } while (speed > 0); - #else - for (int i = 0; i < speed; ++i) { - a8::Vec2 old_pos = GetPos(); - SetPos(GetPos() + move_dir); - if (IsCollisionInMapService()) { - SetPos(old_pos); - FindPathInMapService(); - #if 0 - if (rand() % 3 == 0) { - i += 1; - } - #endif - } - room->grid_service->MoveHuman(this); - } - #endif } void Human::ChangeToRace(RaceType_e race, int level) @@ -1972,6 +2013,15 @@ void Human::WinExp(Human* sender, int exp) } } +bool Human::IsEnemy(Human* hum) +{ + if (room->GetRoomMode() == kZombieMode) { + return hum->GetRace() != GetRace(); + } else { + return team_id != hum->team_id; + } +} + void Human::_InternalUpdateMove(float speed) { float nx = move_dir.x * speed; @@ -3266,7 +3316,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set& ta Entity* entity = room->GetEntityByUniId(skill_target_id); if (entity && entity->IsEntityType(ET_Player)) { Human* hum = (Human*)entity; - if (hum->team_id != team_id) { + if (IsEnemy(hum)) { target_list.insert(hum); } } @@ -3304,10 +3354,10 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set& ta ( [this, &target_pos, &target_list] (Human* hum, bool& stop) { - if ((hum == this || hum->team_id != team_id) && - hum->GetPos().Distance(target_pos) < skill_meta_->i->skill_distance()) { - target_list.insert(hum); - } + if ((hum == this || this->IsEnemy(hum)) && + hum->GetPos().Distance(target_pos) < skill_meta_->i->skill_distance()) { + target_list.insert(hum); + } }); } break; @@ -3316,7 +3366,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set& ta Entity* entity = room->GetEntityByUniId(skill_target_id); if (entity && entity->IsEntityType(ET_Player)) { Human* hum = (Human*)entity; - if (hum->team_id != team_id) { + if (IsEnemy(hum)) { target_list.insert(hum); } } diff --git a/server/gameserver/human.h b/server/gameserver/human.h index b13eb0c..3fdfb11 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -281,6 +281,8 @@ class Human : public MoveableEntity Entity* GetLastCollisionDoor() { return last_collision_door_; } void SetLastCollisionDoor(Entity* door) { last_collision_door_ = door; } ObjectSyncFlags* GetObjectSyncFlags(int obj_uniid); + bool HasSpecMove(); + void _UpdateSpecMove(); void _UpdateMove(int speed); RaceType_e GetRace() { return race_; } void ChangeToRace(RaceType_e race, int level); @@ -288,6 +290,7 @@ class Human : public MoveableEntity void WinExp(Human* sender, int exp); HumanCar& GetCar() { return car_; } void DeadDrop(); + bool IsEnemy(Human* hum); protected: void _InternalUpdateMove(float speed); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index bb642f9..25c65dd 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -54,8 +54,12 @@ void Player::InternalUpdate(int delta_time) if (poisoning) { poisoning_time += delta_time; } - if (moving) { - UpdateMove(); + if (HasSpecMove()) { + _UpdateSpecMove(); + } else { + if (moving) { + UpdateMove(); + } } if (room->GetFrameNo() % 2 == 0) { if (drop_weapon) { diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 3b1c9d7..497308c 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -2603,7 +2603,11 @@ void Room::AddPlayerPostProc(Player* hum) RandRemoveAndroid(); } if (GetRoomMode() == kZombieMode) { + #if 1 + hum->ChangeToRace(kZombieRace, 3); + #else hum->ChangeToRace(kHumanRace, 1); + #endif } #ifdef DEBUG xtimer.AddRepeatTimerAndAttach diff --git a/server/gameserver/zombie.ai.cc b/server/gameserver/zombie.ai.cc index 78a3a06..adb5532 100644 --- a/server/gameserver/zombie.ai.cc +++ b/server/gameserver/zombie.ai.cc @@ -136,8 +136,12 @@ void ZombieAI::UpdateAI() } break; } - if (node_->moving) { - DoMove(); + if (hum->HasSpecMove()) { + hum->_UpdateSpecMove(); + } else { + if (node_->moving) { + DoMove(); + } } }