From ba4cc1a6ca6c491b2bcc36433c82c59bed46ee8e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 14 Apr 2018 11:33:17 +0300 Subject: [PATCH] Added activation type to WorldLine(Pre)Activated events https://forum.zdoom.org/viewtopic.php?t=60232 --- src/events.cpp | 15 +++++++++------ src/events.h | 9 +++++---- src/p_spec.cpp | 4 ++-- wadsrc/static/zscript/events.txt | 1 + 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/events.cpp b/src/events.cpp index 17fc30bea..e9c76a7bb 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -404,16 +404,16 @@ void E_WorldThingDestroyed(AActor* actor) handler->WorldThingDestroyed(actor); } -void E_WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate) +void E_WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate) { for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) - handler->WorldLinePreActivated(line, actor, shouldactivate); + handler->WorldLinePreActivated(line, actor, activationType, shouldactivate); } -void E_WorldLineActivated(line_t* line, AActor* actor) +void E_WorldLineActivated(line_t* line, AActor* actor, int activationType) { for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) - handler->WorldLineActivated(line, actor); + handler->WorldLineActivated(line, actor, activationType); } void E_PlayerEntered(int num, bool fromhub) @@ -545,6 +545,7 @@ DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageType); DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageFlags); DEFINE_FIELD_X(WorldEvent, FWorldEvent, DamageAngle); DEFINE_FIELD_X(WorldEvent, FWorldEvent, ActivatedLine); +DEFINE_FIELD_X(WorldEvent, FWorldEvent, ActivationType); DEFINE_FIELD_X(WorldEvent, FWorldEvent, ShouldActivate); DEFINE_FIELD_X(PlayerEvent, FPlayerEvent, PlayerNumber); @@ -795,7 +796,7 @@ void DStaticEventHandler::WorldThingDestroyed(AActor* actor) } } -void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate) +void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate) { IFVIRTUAL(DStaticEventHandler, WorldLinePreActivated) { @@ -805,6 +806,7 @@ void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, boo FWorldEvent e = E_SetupWorldEvent(); e.Thing = actor; e.ActivatedLine = line; + e.ActivationType = activationType; e.ShouldActivate = *shouldactivate; VMValue params[2] = { (DStaticEventHandler*)this, &e }; VMCall(func, params, 2, nullptr, 0); @@ -812,7 +814,7 @@ void DStaticEventHandler::WorldLinePreActivated(line_t* line, AActor* actor, boo } } -void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor) +void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor, int activationType) { IFVIRTUAL(DStaticEventHandler, WorldLineActivated) { @@ -822,6 +824,7 @@ void DStaticEventHandler::WorldLineActivated(line_t* line, AActor* actor) FWorldEvent e = E_SetupWorldEvent(); e.Thing = actor; e.ActivatedLine = line; + e.ActivationType = activationType; VMValue params[2] = { (DStaticEventHandler*)this, &e }; VMCall(func, params, 2, nullptr, 0); } diff --git a/src/events.h b/src/events.h index 09638b43e..072502501 100755 --- a/src/events.h +++ b/src/events.h @@ -41,9 +41,9 @@ void E_WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int d // called before AActor::Destroy of each actor. void E_WorldThingDestroyed(AActor* actor); // called in P_ActivateLine before executing special, set shouldactivate to false to prevent activation. -void E_WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate); +void E_WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate); // called in P_ActivateLine after successful special execution. -void E_WorldLineActivated(line_t* line, AActor* actor); +void E_WorldLineActivated(line_t* line, AActor* actor, int activationType); // same as ACS SCRIPT_Lightning void E_WorldLightning(); // this executes on every tick, before everything, only when in valid level and not paused @@ -143,8 +143,8 @@ public: void WorldThingRevived(AActor* actor); void WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int damage, FName mod, int flags, DAngle angle); void WorldThingDestroyed(AActor* actor); - void WorldLinePreActivated(line_t* line, AActor* actor, bool* shouldactivate); - void WorldLineActivated(line_t* line, AActor* actor); + void WorldLinePreActivated(line_t* line, AActor* actor, int activationType, bool* shouldactivate); + void WorldLineActivated(line_t* line, AActor* actor, int activationType); void WorldLightning(); void WorldTick(); @@ -203,6 +203,7 @@ struct FWorldEvent DAngle DamageAngle; // for line(pre)activated line_t* ActivatedLine = nullptr; + int ActivationType = 0; bool ShouldActivate = true; }; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 3185b6c20..e00d8a33a 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -191,7 +191,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe // [MK] Use WorldLinePreActivated to decide if activation should continue bool shouldactivate = true; - E_WorldLinePreActivated(line, mo, &shouldactivate); + E_WorldLinePreActivated(line, mo, activationType, &shouldactivate); if ( !shouldactivate ) return false; bool remote = (line->special != 7 && line->special != 8 && (line->special < 11 || line->special > 14)); @@ -206,7 +206,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe line->args[3], line->args[4]); // [MK] Fire up WorldLineActivated - if ( buttonSuccess ) E_WorldLineActivated(line, mo); + if ( buttonSuccess ) E_WorldLineActivated(line, mo, activationType); special = line->special; if (!repeat && buttonSuccess) diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index 1aa2e3b59..fc8b82721 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -27,6 +27,7 @@ struct WorldEvent native play version("2.4") native readonly double DamageAngle; // for line(pre)activated native readonly Line ActivatedLine; + native readonly int ActivationType; native bool ShouldActivate; }