ZR: adding forwards for Napalm

This commit is contained in:
neon 2019-07-14 20:07:25 +02:00
parent ca0d766afb
commit d46bc97bd1
5 changed files with 146 additions and 0 deletions

View File

@ -34,6 +34,7 @@
#include <zr/infect.zr> #include <zr/infect.zr>
#include <zr/respawn.zr> #include <zr/respawn.zr>
#include <zr/class.zr> #include <zr/class.zr>
#include <zr/napalm.zr>
public SharedPlugin __pl_zombiereloaded = public SharedPlugin __pl_zombiereloaded =
{ {

View File

@ -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 <http://www.gnu.org/licenses/>.
*
* ============================================================================
*/
/**
* 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);

View File

@ -44,6 +44,7 @@
#include "zr/api/infect.api" #include "zr/api/infect.api"
#include "zr/api/respawn.api" #include "zr/api/respawn.api"
#include "zr/api/class.api" #include "zr/api/class.api"
#include "zr/api/napalm.api"
/** /**
* Initializes all main natives and forwards. * Initializes all main natives and forwards.
@ -54,6 +55,7 @@ APIInit()
APIInfectInit(); APIInfectInit();
APIRespawnInit(); APIRespawnInit();
APIClassInit(); APIClassInit();
APINapalmInit();
} }
/** /**

90
src/zr/api/napalm.api.inc Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*
* ============================================================================
*/
/**
* @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();
}

View File

@ -271,6 +271,13 @@ stock NapalmExtinguishEntity(client)
*/ */
stock NapalmIgniteEntity(client, Float:time) 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"); new fire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity");
if (IsValidEntity(fire)) if (IsValidEntity(fire))
{ {
@ -286,4 +293,5 @@ stock NapalmIgniteEntity(client, Float:time)
// No flame entity found, ignite client. // No flame entity found, ignite client.
IgniteEntity(client, time); IgniteEntity(client, time);
APIOnClientIgnited(client, time);
} }