diff --git a/src/skill.c b/src/skill.c index 0e2b538..a81949b 100644 --- a/src/skill.c +++ b/src/skill.c @@ -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) ); } } diff --git a/src/vector2d.c b/src/vector2d.c index 7b711a3..3b4864a 100644 --- a/src/vector2d.c +++ b/src/vector2d.c @@ -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; +} diff --git a/src/vector2d.h b/src/vector2d.h index cefd0bd..149222e 100644 --- a/src/vector2d.h +++ b/src/vector2d.h @@ -40,4 +40,7 @@ vector2d_equals(Vector2d, Vector2d); bool vector2d_is_opposite(Vector2d, Vector2d); +Vector2d +vector2d_to_direction(const Vector2d*); + #endif // VECTOR2D_H_