Skip to content

Commit f418555

Browse files
author
Semphris
committed
Improvements to haywire code
1 parent 0015c73 commit f418555

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/badguy/haywire.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Haywire::collision_squished(GameObject& object)
103103
void
104104
Haywire::active_update(float dt_sec)
105105
{
106+
auto* player = get_nearest_player();
107+
106108
if (is_exploding) {
107109
ticking->set_position(get_pos());
108110
grunting->set_position(get_pos());
@@ -126,7 +128,6 @@ Haywire::active_update(float dt_sec)
126128

127129
if (is_exploding)
128130
{
129-
auto player = Sector::get().get_nearest_player(m_col.m_bbox);
130131
if (on_ground() && std::abs(m_physic.get_velocity_x()) > 40.f && player)
131132
{
132133
//jump over 1-tall roadblocks
@@ -154,7 +155,7 @@ Haywire::active_update(float dt_sec)
154155
gap_box.set_bottom(m_col.m_bbox.get_bottom() + 28.f);
155156

156157
if (Sector::get().is_free_of_statics(gap_box)
157-
&& (get_nearest_player()->get_bbox().get_bottom() <= m_col.m_bbox.get_bottom()))
158+
&& (player->get_bbox().get_bottom() <= m_col.m_bbox.get_bottom()))
158159
{
159160
m_physic.set_velocity_y(-325.f);
160161
}
@@ -174,17 +175,16 @@ Haywire::active_update(float dt_sec)
174175
walk_right_action = "active-right";
175176
}
176177

177-
auto p = get_nearest_player ();
178178
float target_velocity = 0.f;
179179

180180
if (stomped_timer.get_timeleft() >= 0.05f)
181181
{
182182
target_velocity = 0.f;
183183
}
184-
else if (p && time_stunned == 0.0f)
184+
else if (player && time_stunned == 0.0f)
185185
{
186186
/* Player is on the right or left*/
187-
target_velocity = (p->get_pos().x > get_pos().x) ? walk_speed : (-1.f) * walk_speed;
187+
target_velocity = (player->get_pos().x > get_pos().x) ? walk_speed : (-1.f) * walk_speed;
188188
}
189189

190190
WalkingBadguy::active_update(dt_sec, target_velocity, 3.f);

0 commit comments

Comments
 (0)