From d4f8d1c8fde01a58bc757b588c9850e69225bc24 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Nov 2013 01:46:24 +0000 Subject: Corrected a small bug in Entity::print(), added nudge randomizer option. --- src/core/entity.cc | 22 ++++++++++++++-------- src/core/entity.h | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/entity.cc b/src/core/entity.cc index 5c1fe5c..7d538a0 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -291,7 +291,7 @@ void Entity::print() const con_print << " ^Nmodule type ^B" << moduletype() << std::endl; // print entity flags - con_print << " ^Nflags ^B"; + con_print << " ^Nflags ^B"; if (has_flag(NonSolid)) { con_print << " nonsolid"; } @@ -311,6 +311,9 @@ void Entity::print() const if (inventory()) { con_print << " ^Ninventory ^Byes" << std::endl; } + if (slots()) { + con_print << " ^Nslots ^Byes" << std::endl; + } if (faction()) { con_print << " ^Nfaction ^B" << faction()->label() << std::endl; } @@ -843,7 +846,7 @@ void EntityDynamic::set_state(int state) } } -void EntityDynamic::nudge() +void EntityDynamic::nudge(const bool randomize) { if (!zone()) { return; @@ -857,12 +860,15 @@ void EntityDynamic::nudge() const float r = radius() + other->radius(); if ( d < r ) { - // nudge into randomize direction - math::Axis nudge_axis(axis()); - nudge_axis.change_direction(math::randomf(60.0f) - 30.0f); - nudge_axis.change_pitch(math::randomf(60.0f) - 30.0f); - set_location(location() + nudge_axis.forward() * (r - d + 0.001f)); - + if (randomize) { + // nudge into randomize direction + math::Axis nudge_axis(axis()); + nudge_axis.change_direction(math::randomf(60.0f) - 30.0f); + nudge_axis.change_pitch(math::randomf(60.0f) - 30.0f); + set_location(location() + nudge_axis.forward() * (r - d + 0.001f)); + } else { + set_location(location() + axis().forward() * (r - d + 0.001f)); + } // restart search it = zone()->content().begin(); } diff --git a/src/core/entity.h b/src/core/entity.h index de4f210..f5a6d52 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -681,8 +681,9 @@ public: /** * @brief nudge the entity out of the radius of other entities in its current zune + * @param randomize if false, nudge according to axus.forward(), if false, nudge along a random axis */ - void nudge(); + void nudge(const bool randomize = true); /** * @brief physics collision callback -- cgit v1.2.3