From d46bc97bd17b9880defa51ea1ed5e45702a2237e Mon Sep 17 00:00:00 2001 From: neon <> Date: Sun, 14 Jul 2019 20:07:25 +0200 Subject: [PATCH] ZR: adding forwards for Napalm --- src/include/zombiereloaded.inc | 1 + src/include/zr/napalm.zr.inc | 45 +++++++++++++++++ src/zr/api/api.inc | 2 + src/zr/api/napalm.api.inc | 90 ++++++++++++++++++++++++++++++++++ src/zr/napalm.inc | 8 +++ 5 files changed, 146 insertions(+) create mode 100644 src/include/zr/napalm.zr.inc create mode 100644 src/zr/api/napalm.api.inc diff --git a/src/include/zombiereloaded.inc b/src/include/zombiereloaded.inc index c6bfef4..797e831 100644 --- a/src/include/zombiereloaded.inc +++ b/src/include/zombiereloaded.inc @@ -34,6 +34,7 @@ #include #include #include +#include public SharedPlugin __pl_zombiereloaded = { diff --git a/src/include/zr/napalm.zr.inc b/src/include/zr/napalm.zr.inc new file mode 100644 index 0000000..82bbc66 --- /dev/null +++ b/src/include/zr/napalm.zr.inc @@ -0,0 +1,45 @@ +/* + * ============================================================================ + * + * Zombie:Reloaded + * + * File: napalm.zr.inc + * Type: Include + * Description: Napalm-related natives/forwards. + * + * Copyright (C) 2009-2013 Greyscale, Richard Helgeby + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * ============================================================================ + */ + +/** + * Called when a zombie is about to be set on fire. + * + * @param client The client to ignite. + * @param duration The burn duration. + * + * @return Plugin_Handled to block the zombie being set on fire. Anything else + * (like Plugin_Continue) to allow it. + */ +forward Action ZR_OnClientIgnite(int &client, float &duration); + +/** + * Called after a zombie has been set on fire. + * + * @param client The client to ignite. + * @param duration The burn duration. + */ +forward void ZR_OnClientIgnited(int client, float duration); \ No newline at end of file diff --git a/src/zr/api/api.inc b/src/zr/api/api.inc index 934145a..1b160b9 100644 --- a/src/zr/api/api.inc +++ b/src/zr/api/api.inc @@ -44,6 +44,7 @@ #include "zr/api/infect.api" #include "zr/api/respawn.api" #include "zr/api/class.api" +#include "zr/api/napalm.api" /** * Initializes all main natives and forwards. @@ -54,6 +55,7 @@ APIInit() APIInfectInit(); APIRespawnInit(); APIClassInit(); + APINapalmInit(); } /** diff --git a/src/zr/api/napalm.api.inc b/src/zr/api/napalm.api.inc new file mode 100644 index 0000000..3a7c3a6 --- /dev/null +++ b/src/zr/api/napalm.api.inc @@ -0,0 +1,90 @@ +/* + * ============================================================================ + * + * Zombie:Reloaded + * + * File: napalm.api.inc + * Type: Core + * Description: Native handlers for the ZR API. (Napalm module) + * + * Copyright (C) 2009-2013 Greyscale, Richard Helgeby + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * ============================================================================ + */ + +/** + * @section Global forward handles. + */ +new Handle:g_hAPIFwdOnClientIgnite = INVALID_HANDLE; +new Handle:g_hAPIFwdOnClientIgnited = INVALID_HANDLE; +/** + * @endsection + */ + +/** + * Initializes all natives and forwards related to infection. + */ +APINapalmInit() +{ + // Infect module natives/forwards (napalm.zr.inc) + + // Forwards + g_hAPIFwdOnClientIgnite = CreateGlobalForward("ZR_OnClientIgnite", ET_Hook, Param_CellByRef, Param_FloatByRef); + g_hAPIFwdOnClientIgnited = CreateGlobalForward("ZR_OnClientIgnited", ET_Hook, Param_CellByRef, Param_FloatByRef); + +} + +/** + * Called when a zombie is about to be set on fire. + * + * @param client The client to ignite. + * @param duration The burn duration. + * + */ +Action:APIOnClientIgnite(&client, &Float:duration) +{ + // Start forward call. + Call_StartForward(g_hAPIFwdOnClientIgnite); + + // Push the parameters. + Call_PushCellRef(client); + Call_PushFloatRef(duration); + + // Get what they returned. + new Action:result; + Call_Finish(result); + return result; +} + +/** + * Called after a client has been set on fire. + * + * @param client The client to ignite. + * @param duration The burn duration. + * + */ +APIOnClientIgnited(&client, &Float:duration) +{ + // Start forward call. + Call_StartForward(g_hAPIFwdOnClientIgnited); + + // Push the parameters. + Call_PushCellRef(client); + Call_PushFloatRef(duration); + + // Finish the call. + Call_Finish(); +} diff --git a/src/zr/napalm.inc b/src/zr/napalm.inc index e115c37..05ea03d 100644 --- a/src/zr/napalm.inc +++ b/src/zr/napalm.inc @@ -271,6 +271,13 @@ stock NapalmExtinguishEntity(client) */ stock NapalmIgniteEntity(client, Float:time) { + new Action:result = APIOnClientIgnite(client, time); + // Check if infection should be blocked. + if (result == Plugin_Handled) + { + return; + } + new fire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity"); if (IsValidEntity(fire)) { @@ -286,4 +293,5 @@ stock NapalmIgniteEntity(client, Float:time) // No flame entity found, ignite client. IgniteEntity(client, time); + APIOnClientIgnited(client, time); }