summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Skeleton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Skeleton.cpp')
-rw-r--r--src/Mobs/Skeleton.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 0d6d5e428..e48991a06 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -57,19 +57,15 @@ bool cSkeleton::Attack(std::chrono::milliseconds a_Dt)
Vector3d Inaccuracy = Vector3d(Random.RandReal<double>(-0.25, 0.25), Random.RandReal<double>(-0.25, 0.25), Random.RandReal<double>(-0.25, 0.25));
Vector3d Speed = (GetTarget()->GetPosition() + Inaccuracy - GetPosition()) * 5;
Speed.y += Random.RandInt(-1, 1);
- cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
- if (Arrow == nullptr)
- {
- return false;
- }
- if (!Arrow->Initialize(*m_World))
+
+ auto Arrow = cpp14::make_unique<cArrowEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
+ auto ArrowPtr = Arrow.get();
+ if (!ArrowPtr->Initialize(std::move(Arrow), *m_World))
{
- delete Arrow;
- Arrow = nullptr;
return false;
}
- ResetAttackCooldown();
+ ResetAttackCooldown();
return true;
}
return false;