mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-08 19:48:08 +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 "specialfx.h"
|
||||||
#include "g_phys.h"
|
#include "g_phys.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "../script/scriptexception.h"
|
||||||
|
|
||||||
Event EV_Object_HandleSetModel
|
Event EV_Object_HandleSetModel
|
||||||
(
|
(
|
||||||
|
@ -46,7 +47,14 @@ CLASS_DECLARATION(Animate, Object, NULL) {
|
||||||
{NULL, 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
|
Event EV_InteractObject_KilledEffect
|
||||||
(
|
(
|
||||||
|
@ -242,7 +250,6 @@ void ThrowObject::ThrowSound(Event *ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThrowObject::Touch(Event *ev)
|
void ThrowObject::Touch(Event *ev)
|
||||||
|
|
||||||
{
|
{
|
||||||
Entity *other;
|
Entity *other;
|
||||||
|
|
||||||
|
@ -283,7 +290,6 @@ void ThrowObject::Touch(Event *ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThrowObject::Throw(Event *ev)
|
void ThrowObject::Throw(Event *ev)
|
||||||
|
|
||||||
{
|
{
|
||||||
Entity *owner;
|
Entity *owner;
|
||||||
Sentient *targetent;
|
Sentient *targetent;
|
||||||
|
@ -300,6 +306,7 @@ void ThrowObject::Throw(Event *ev)
|
||||||
assert(owner);
|
assert(owner);
|
||||||
|
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
|
ScriptError("owner == NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,6 +318,7 @@ void ThrowObject::Throw(Event *ev)
|
||||||
targetent = (Sentient *)ev->GetEntity(3);
|
targetent = (Sentient *)ev->GetEntity(3);
|
||||||
assert(targetent);
|
assert(targetent);
|
||||||
if (!targetent) {
|
if (!targetent) {
|
||||||
|
ScriptError("targetent == NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,8 +336,12 @@ void ThrowObject::Throw(Event *ev)
|
||||||
|
|
||||||
gravity = grav;
|
gravity = grav;
|
||||||
|
|
||||||
|
if (targetent->IsSubclassOfSentient()) {
|
||||||
target = targetent->origin;
|
target = targetent->origin;
|
||||||
target.z += targetent->viewheight;
|
target.z += targetent->viewheight;
|
||||||
|
} else {
|
||||||
|
target = targetent->centroid;
|
||||||
|
}
|
||||||
|
|
||||||
setMoveType(MOVETYPE_BOUNCE);
|
setMoveType(MOVETYPE_BOUNCE);
|
||||||
setSolidType(SOLID_BBOX);
|
setSolidType(SOLID_BBOX);
|
||||||
|
@ -359,7 +371,6 @@ void ThrowObject::Throw(Event *ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThrowObject::Pickup(Event *ev)
|
void ThrowObject::Pickup(Event *ev)
|
||||||
|
|
||||||
{
|
{
|
||||||
Entity *ent;
|
Entity *ent;
|
||||||
Event *e;
|
Event *e;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue