mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Add delegates related for kill/damage
This commit is contained in:
parent
7f64ef05d5
commit
b813f7ee56
3 changed files with 90 additions and 65 deletions
|
@ -2673,7 +2673,7 @@ void Entity::DamageEvent(Event *ev)
|
|||
Vector momentum;
|
||||
Vector position, direction, normal;
|
||||
int knockback, damageflags, meansofdeath, location;
|
||||
Event *event;
|
||||
Event event;
|
||||
float m;
|
||||
EntityPtr This;
|
||||
|
||||
|
@ -2759,67 +2759,79 @@ void Entity::DamageEvent(Event *ev)
|
|||
|
||||
if (health <= 0) {
|
||||
if (attacker) {
|
||||
event = new Event(EV_GotKill);
|
||||
event->AddEntity(this);
|
||||
event->AddInteger(damage);
|
||||
event->AddEntity(inflictor);
|
||||
event->AddInteger(meansofdeath);
|
||||
event->AddInteger(0);
|
||||
const EntityPtr attackerPtr = attacker;
|
||||
|
||||
attacker->ProcessEvent(event);
|
||||
event = Event(EV_GotKill, 5);
|
||||
event.AddEntity(this);
|
||||
event.AddInteger(damage);
|
||||
event.AddEntity(inflictor);
|
||||
event.AddInteger(meansofdeath);
|
||||
event.AddInteger(0);
|
||||
|
||||
attackerPtr->ProcessEvent(event);
|
||||
if (attackerPtr) {
|
||||
attackerPtr->delegate_gotKill.Execute(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (!This) {
|
||||
return;
|
||||
}
|
||||
|
||||
event = new Event(EV_Killed);
|
||||
event->AddEntity(attacker);
|
||||
event->AddFloat(damage);
|
||||
event->AddEntity(inflictor);
|
||||
event->AddVector(position);
|
||||
event->AddVector(direction);
|
||||
event->AddVector(normal);
|
||||
event->AddInteger(knockback);
|
||||
event->AddInteger(damageflags);
|
||||
event->AddInteger(meansofdeath);
|
||||
event->AddInteger(location);
|
||||
event = Event(EV_Killed, 10);
|
||||
event.AddEntity(attacker);
|
||||
event.AddFloat(damage);
|
||||
event.AddEntity(inflictor);
|
||||
event.AddVector(position);
|
||||
event.AddVector(direction);
|
||||
event.AddVector(normal);
|
||||
event.AddInteger(knockback);
|
||||
event.AddInteger(damageflags);
|
||||
event.AddInteger(meansofdeath);
|
||||
event.AddInteger(location);
|
||||
|
||||
ProcessEvent(event);
|
||||
|
||||
if (!This) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify scripts
|
||||
Unregister(STRING_DAMAGE);
|
||||
if (!This) {
|
||||
return;
|
||||
}
|
||||
|
||||
delegate_killed.Execute(event);
|
||||
return;
|
||||
}
|
||||
|
||||
event = new Event(EV_Pain);
|
||||
event->AddEntity(attacker);
|
||||
event->AddFloat(damage);
|
||||
event->AddEntity(inflictor);
|
||||
event->AddVector(position);
|
||||
event->AddVector(direction);
|
||||
event->AddVector(normal);
|
||||
event->AddInteger(knockback);
|
||||
event->AddInteger(damageflags);
|
||||
event->AddInteger(meansofdeath);
|
||||
event->AddInteger(location);
|
||||
event = Event(EV_Pain, 10);
|
||||
event.AddEntity(attacker);
|
||||
event.AddFloat(damage);
|
||||
event.AddEntity(inflictor);
|
||||
event.AddVector(position);
|
||||
event.AddVector(direction);
|
||||
event.AddVector(normal);
|
||||
event.AddInteger(knockback);
|
||||
event.AddInteger(damageflags);
|
||||
event.AddInteger(meansofdeath);
|
||||
event.AddInteger(location);
|
||||
|
||||
ProcessEvent(event);
|
||||
|
||||
if (!This) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify scripts
|
||||
Unregister(STRING_DAMAGE);
|
||||
if (!This) {
|
||||
return;
|
||||
}
|
||||
|
||||
delegate_damage.Execute(event);
|
||||
}
|
||||
|
||||
qboolean Entity::IsTouching(Entity *e1)
|
||||
|
||||
{
|
||||
if (e1->absmin.x > absmax.x) {
|
||||
return false;
|
||||
|
|
|
@ -51,6 +51,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "script.h"
|
||||
#include "listener.h"
|
||||
#include "simpleentity.h"
|
||||
#include "../qcommon/delegate.h"
|
||||
|
||||
// modification flags
|
||||
#define FLAG_IGNORE 0
|
||||
|
@ -296,6 +297,12 @@ public:
|
|||
//====
|
||||
#endif
|
||||
|
||||
MulticastDelegate<void (const Event& ev)> delegate_damage;
|
||||
MulticastDelegate<void (const Event& ev)> delegate_killed;
|
||||
MulticastDelegate<void (const Event& ev)> delegate_gotKill;
|
||||
|
||||
public:
|
||||
|
||||
Entity();
|
||||
virtual ~Entity();
|
||||
|
||||
|
|
|
@ -1368,7 +1368,7 @@ void Sentient::ArmorDamage(Event *ev)
|
|||
Vector position;
|
||||
Vector normal;
|
||||
Vector direction;
|
||||
Event *event;
|
||||
Event event;
|
||||
int dflags;
|
||||
int meansofdeath;
|
||||
int knockback;
|
||||
|
@ -1582,50 +1582,56 @@ void Sentient::ArmorDamage(Event *ev)
|
|||
health = 0;
|
||||
|
||||
if (attacker) {
|
||||
// Added in OPM
|
||||
event = new Event(EV_GotKill);
|
||||
event->AddEntity(this);
|
||||
event->AddInteger(damage);
|
||||
event->AddEntity(inflictor);
|
||||
event->AddInteger(meansofdeath);
|
||||
event->AddInteger(0);
|
||||
const EntityPtr attackerPtr = attacker;
|
||||
|
||||
attacker->ProcessEvent(event);
|
||||
// Added in OPM
|
||||
event = Event(EV_GotKill);
|
||||
event.AddEntity(this);
|
||||
event.AddInteger(damage);
|
||||
event.AddEntity(inflictor);
|
||||
event.AddInteger(meansofdeath);
|
||||
event.AddInteger(0);
|
||||
|
||||
attackerPtr->ProcessEvent(event);
|
||||
if (attackerPtr) {
|
||||
attackerPtr->delegate_gotKill.Execute(event);
|
||||
}
|
||||
}
|
||||
|
||||
event = new Event(EV_Killed, 10);
|
||||
event->AddEntity(attacker);
|
||||
event->AddFloat(damage);
|
||||
event->AddEntity(inflictor);
|
||||
event->AddVector(position);
|
||||
event->AddVector(direction);
|
||||
event->AddVector(normal);
|
||||
event->AddInteger(knockback);
|
||||
event->AddInteger(dflags);
|
||||
event->AddInteger(meansofdeath);
|
||||
event->AddInteger(location);
|
||||
event = Event(EV_Killed, 10);
|
||||
event.AddEntity(attacker);
|
||||
event.AddFloat(damage);
|
||||
event.AddEntity(inflictor);
|
||||
event.AddVector(position);
|
||||
event.AddVector(direction);
|
||||
event.AddVector(normal);
|
||||
event.AddInteger(knockback);
|
||||
event.AddInteger(dflags);
|
||||
event.AddInteger(meansofdeath);
|
||||
event.AddInteger(location);
|
||||
|
||||
ProcessEvent(event);
|
||||
delegate_killed.Execute(event);
|
||||
}
|
||||
|
||||
if (health > 0) {
|
||||
// Send pain event
|
||||
event = new Event(EV_Pain, 10);
|
||||
event->AddEntity(attacker);
|
||||
event->AddFloat(damage);
|
||||
event->AddEntity(inflictor);
|
||||
event->AddVector(position);
|
||||
event->AddVector(direction);
|
||||
event->AddVector(normal);
|
||||
event->AddInteger(knockback);
|
||||
event->AddInteger(dflags);
|
||||
event->AddInteger(meansofdeath);
|
||||
event->AddInteger(location);
|
||||
event = Event(EV_Pain, 10);
|
||||
event.AddEntity(attacker);
|
||||
event.AddFloat(damage);
|
||||
event.AddEntity(inflictor);
|
||||
event.AddVector(position);
|
||||
event.AddVector(direction);
|
||||
event.AddVector(normal);
|
||||
event.AddInteger(knockback);
|
||||
event.AddInteger(dflags);
|
||||
event.AddInteger(meansofdeath);
|
||||
event.AddInteger(location);
|
||||
|
||||
ProcessEvent(event);
|
||||
}
|
||||
|
||||
return;
|
||||
delegate_damage.Execute(*ev);
|
||||
}
|
||||
|
||||
qboolean Sentient::CanBlock(int meansofdeath, qboolean full_block)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue