mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-08 11:38:01 +03:00
Make ThrowObject::Throw throws an exception when the owner and targetent is NULL, also use centroid if the target entity is not a sentient
This commit is contained in:
parent
881df7193b
commit
52424f63f0
1 changed files with 21 additions and 10 deletions
|
@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "specialfx.h"
|
||||
#include "g_phys.h"
|
||||
#include "game.h"
|
||||
#include "../script/scriptexception.h"
|
||||
|
||||
Event EV_Object_HandleSetModel
|
||||
(
|
||||
|
@ -46,7 +47,14 @@ CLASS_DECLARATION(Animate, Object, NULL) {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
Event EV_InteractObject_Setup("_setup", EV_DEFAULT, NULL, NULL, "Sets up an object.");
|
||||
Event EV_InteractObject_Setup
|
||||
(
|
||||
"_setup",
|
||||
EV_DEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
"Sets up an object."
|
||||
);
|
||||
|
||||
Event EV_InteractObject_KilledEffect
|
||||
(
|
||||
|
@ -242,7 +250,6 @@ void ThrowObject::ThrowSound(Event *ev)
|
|||
}
|
||||
|
||||
void ThrowObject::Touch(Event *ev)
|
||||
|
||||
{
|
||||
Entity *other;
|
||||
|
||||
|
@ -283,7 +290,6 @@ void ThrowObject::Touch(Event *ev)
|
|||
}
|
||||
|
||||
void ThrowObject::Throw(Event *ev)
|
||||
|
||||
{
|
||||
Entity *owner;
|
||||
Sentient *targetent;
|
||||
|
@ -300,6 +306,7 @@ void ThrowObject::Throw(Event *ev)
|
|||
assert(owner);
|
||||
|
||||
if (!owner) {
|
||||
ScriptError("owner == NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -311,6 +318,7 @@ void ThrowObject::Throw(Event *ev)
|
|||
targetent = (Sentient *)ev->GetEntity(3);
|
||||
assert(targetent);
|
||||
if (!targetent) {
|
||||
ScriptError("targetent == NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -328,8 +336,12 @@ void ThrowObject::Throw(Event *ev)
|
|||
|
||||
gravity = grav;
|
||||
|
||||
if (targetent->IsSubclassOfSentient()) {
|
||||
target = targetent->origin;
|
||||
target.z += targetent->viewheight;
|
||||
} else {
|
||||
target = targetent->centroid;
|
||||
}
|
||||
|
||||
setMoveType(MOVETYPE_BOUNCE);
|
||||
setSolidType(SOLID_BBOX);
|
||||
|
@ -359,7 +371,6 @@ void ThrowObject::Throw(Event *ev)
|
|||
}
|
||||
|
||||
void ThrowObject::Pickup(Event *ev)
|
||||
|
||||
{
|
||||
Entity *ent;
|
||||
Event *e;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue