Fixes bug with erupt pushing direction

This commit is contained in:
Linus Probert 2019-05-14 15:57:36 +02:00
parent 35164a9876
commit 8fb1bbcc1e
3 changed files with 29 additions and 3 deletions

View File

@ -974,12 +974,13 @@ skill_erupt(Skill *skill, SkillData *data)
gui_log("%s takes %d damage from the explosion", r->monster->label, result.dmg);
monster_set_bleeding(r->monster);
int lvl = 1 + player_has_artifact(player, PUSH_BACK);
int lvl = 2;//player_has_artifact(player, PUSH_BACK);
Vector2d dir = vector2d_to_direction(&VEC2D((float) i, (float) j));
monster_push(r->monster,
player,
rm,
VEC2D((float) ((i > 0 ? 1 : -1) * lvl),
(float) ((j > 0 ? 1 : -1) * lvl))
VEC2D(dir.x * (float) lvl,
dir.y * (float) lvl)
);
}
}

View File

@ -12,3 +12,25 @@ vector2d_is_opposite(Vector2d v1, Vector2d v2)
return ((v1.x > 0 && v2.x < 0) ^ (v1.y > 0 && v2.y < 0))
|| ((v1.x < 0 && v2.x > 0) ^ (v1.y < 0 && v2.y > 0));
}
Vector2d
vector2d_to_direction(const Vector2d *vec)
{
Vector2d new = VEC2D(vec->x, vec->y);
if (new.x > 0)
new.x = 1;
else if (new.x == 0)
new.x = 0;
else
new.x = -1;
if (new.y > 0)
new.y = 1;
else if (new.y == 0)
new.y = 0;
else
new.y = -1;
return new;
}

View File

@ -40,4 +40,7 @@ vector2d_equals(Vector2d, Vector2d);
bool
vector2d_is_opposite(Vector2d, Vector2d);
Vector2d
vector2d_to_direction(const Vector2d*);
#endif // VECTOR2D_H_