添加特殊移动逻辑
This commit is contained in:
parent
eb46ffae0c
commit
b87ab4089f
@ -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<bool ()> 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<Entity*>& 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,7 +3354,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
|
||||
(
|
||||
[this, &target_pos, &target_list] (Human* hum, bool& stop)
|
||||
{
|
||||
if ((hum == this || hum->team_id != team_id) &&
|
||||
if ((hum == this || this->IsEnemy(hum)) &&
|
||||
hum->GetPos().Distance(target_pos) < skill_meta_->i->skill_distance()) {
|
||||
target_list.insert(hum);
|
||||
}
|
||||
@ -3316,7 +3366,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& 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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -54,9 +54,13 @@ void Player::InternalUpdate(int delta_time)
|
||||
if (poisoning) {
|
||||
poisoning_time += delta_time;
|
||||
}
|
||||
if (HasSpecMove()) {
|
||||
_UpdateSpecMove();
|
||||
} else {
|
||||
if (moving) {
|
||||
UpdateMove();
|
||||
}
|
||||
}
|
||||
if (room->GetFrameNo() % 2 == 0) {
|
||||
if (drop_weapon) {
|
||||
UpdateDropWeapon();
|
||||
|
@ -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
|
||||
|
@ -136,10 +136,14 @@ void ZombieAI::UpdateAI()
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (hum->HasSpecMove()) {
|
||||
hum->_UpdateSpecMove();
|
||||
} else {
|
||||
if (node_->moving) {
|
||||
DoMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZombieAI::UpdateIdle()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user