fixed napalm not disappearing and stop napalm from overlaying

removed weaponalpha completly
replaced CBaseEntity::SetAbsVelocity with CBaseEntity::m_vecAbsVelocity
This commit is contained in:
BotoX 2016-08-08 10:20:23 +02:00
parent 73a72d37da
commit b286de5ce0
11 changed files with 134 additions and 360 deletions

View File

@ -27,9 +27,9 @@ vpath %.smx $(BUILDDIR)
SOURCEFILES=$(SOURCEDIR)/*.sp
OBJECTS=$(patsubst %.sp, %.smx, $(notdir $(wildcard $(SOURCEFILES))))
all: prepare_builddir $(OBJECTS)
all: prepare $(OBJECTS)
prepare: prepare_newlines prepare_builddir
prepare: clean prepare_builddir
prepare_newlines:
@echo "Removing windows newlines"
@ -46,5 +46,4 @@ prepare_builddir:
$(SPCOMP) -i$(SOURCEDIR) -i$(SMINCLUDES) -i$(ZRINCLUDES) -o$(BUILDDIR)/$@ $<
clean:
@echo "Removing build directory"
@rm -fr $(BUILDDIR)

View File

@ -1,14 +1,3 @@
"Games"
{
"cstrike"
{
"Signatures"
{
"CBaseEntity_SetAbsVelocity"
{
"library" "server"
"linux" "@_ZN11CBaseEntity14SetAbsVelocityERK6Vector"
}
}
}
}

View File

@ -373,3 +373,14 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang
Class_OnPlayerRunCmd(client, vel);
return Plugin_Continue;
}
/**
* When an entity is created
*
* @param entity Entity index
* @param classname Class name
*/
public OnEntityCreated(entity, const String:classname[])
{
NapalmOnEntityCreated(entity, classname);
}

View File

@ -222,6 +222,11 @@ public Action:DamageOnTakeDamage(client, &attacker, &inflictor, &Float:damage, &
decl String:classname[64];
GetEdictClassname(inflictor, classname, sizeof(classname));
// Get the attacker weapon name.
new String:weaponname[64];
if(attacker >= 1 && attacker < MAXPLAYERS)
GetClientWeapon(attacker, weaponname, sizeof(weaponname));
// If entity is a trigger, then allow damage. (Map is damaging client)
if (StrContains(classname, "trigger") > -1)
{
@ -266,6 +271,12 @@ public Action:DamageOnTakeDamage(client, &attacker, &inflictor, &Float:damage, &
return Plugin_Continue;
}
if (!clientzombie && attackerzombie && !StrEqual(weaponname, "weapon_knife"))
{
damage = 1.0;
return Plugin_Changed;
}
// Check if immunity module blocked or modified the damage.
new Action:immunityAction = ImmunityOnClientDamage(client, attacker, damage);
if (immunityAction != Plugin_Continue)

View File

@ -53,7 +53,6 @@ EventHook(bool:unhook = false)
UnhookEvent("player_hurt", EventPlayerHurt);
UnhookEvent("player_death", EventPlayerDeath);
UnhookEvent("player_jump", EventPlayerJump);
UnhookEvent("weapon_fire", EventWeaponFire);
// Stop after unhooking events.
return;
@ -68,7 +67,6 @@ EventHook(bool:unhook = false)
HookEvent("player_hurt", EventPlayerHurt);
HookEvent("player_death", EventPlayerDeath);
HookEvent("player_jump", EventPlayerJump);
HookEvent("weapon_fire", EventWeaponFire);
}
/**
@ -90,24 +88,8 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc
ZSpawnOnRoundStart();
VolOnRoundStart();
ZTeleOnRoundStart();
// Fire post round_start event.
//CreateTimer(0.0, EventRoundStartPost);
}
/**
* Event callback (round_start)
* The round is starting. *Post
*
* @param event The event handle.
* @param name Name of the event.
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
*/
//public Action:EventRoundStartPost(Handle:timer)
//{
// Forward event to modules.
//}
/**
* Event callback (round_freeze_end)
* The freeze time is ending.
@ -335,22 +317,3 @@ public Action:EventPlayerJumpPost(Handle:timer, any:client)
// Forward event to modules.
JumpBoostOnClientJumpPost(client);
}
/**
* Event callback (weapon_fire)
* Weapon has been fired.
*
* @param event The event handle.
* @param name Name of the event.
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
*/
public Action:EventWeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
{
// Get all required event info.
new index = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon));
// Forward event to modules.
NapalmOnWeaponFire(index, weapon);
}

View File

@ -84,26 +84,7 @@ NapalmOnTakeDamage(client, damagetype)
if (NapalmGetClientWaterLevel(client) >= douse)
{
// Put the fire out.
//ExtinguishEntity(client); <-- Don't use this. Takes off the FL_ONFIRE flag, but flame doesn't get extinguished.
// This works.
new fire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity");
if (IsValidEntity(fire))
{
// Make sure the entity is a flame, so we can extinguish it.
decl String:classname[64];
GetEdictClassname(fire, classname, sizeof(classname));
if (StrEqual(classname, "entityflame", false))
{
SetEntPropFloat(fire, Prop_Data, "m_flLifetime", 0.0);
}
// Log what entity was in that property, for future reference.
else
{
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Napalm, "Napalm Douse", "Found unexpected entity in prop \"m_flLifetime\": \"%s\"", classname);
}
}
NapalmExtinguishEntity(client);
return _:Plugin_Continue;
}
@ -156,11 +137,8 @@ NapalmOnClientHurt(client, attacker, const String:weapon[])
if (reset || !(flags & FL_ONFIRE))
{
// This stops the fire before re-ignition.
ExtinguishEntity(client);
// Ignite client.
IgniteEntity(client, napalm_time);
// Ignite the client or extend the current flames life.
NapalmIgniteEntity(client, napalm_time);
}
}
}
@ -173,17 +151,23 @@ NapalmOnClientHurt(client, attacker, const String:weapon[])
NapalmOnClientDeath(client)
{
// Extinguish any flames to stop burning sounds.
ExtinguishEntity(client);
NapalmExtinguishEntity(client);
}
/**
* Weapon has been fired.
* When an entity is created.
*
* @param client The client index.
* @param weapon The weapon name.
* @param entity Entity index
* @param classname Class name
*/
NapalmOnWeaponFire(client, const String:weapon[])
NapalmOnEntityCreated(entity, const String:classname[])
{
// Not a grenade.
if (strcmp(classname, "hegrenade_projectile", false))
{
return;
}
// If grenade fire is disabled, then stop.
new bool:napalmignite = GetConVarBool(g_hCvarsList[CVAR_NAPALM_IGNITE]);
if (!napalmignite)
@ -191,49 +175,34 @@ NapalmOnWeaponFire(client, const String:weapon[])
return;
}
// Hook entity spawn.
SDKHook(entity, SDKHook_SpawnPost, NapalmOnGrenadeSpawnPost);
}
/**
* Called after a grenade entity has been spawned.
*
* @param entity Entity index
*/
public NapalmOnGrenadeSpawnPost(entity)
{
// Get client who threw this grenade.
new client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
// Invalid client.
if (client > MaxClients || client <= 0)
{
return;
}
// If human class can't throw napalm grenades, then stop.
if (!ClassGetHasNapalm(client))
{
return;
}
// If weapon isn't a grenade, then stop.
if (!StrEqual(weapon, "hegrenade", false))
{
return;
}
// Wait .1 seconds.
CreateTimer(0.1, NapalmIgniteGrenade);
}
/**
* Timer callback, ignite's all hegrenade projectiles.
*
* @param timer The timer handle.
*/
public Action:NapalmIgniteGrenade(Handle:timer)
{
decl String:classname[64];
// Get max entities.
new maxentities = GetMaxEntities();
// x = entity index.
for (new x = 0; x <= maxentities; x++)
{
// If entity is invalid, then stop.
if(!IsValidEntity(x) || !IsValidEdict(x))
{
continue;
}
GetEdictClassname(x, classname, sizeof(classname));
if(StrEqual(classname, "hegrenade_projectile"))
{
IgniteEntity(x, GRENADE_FUSE_TIME);
}
}
// Ignite the grenade.
IgniteEntity(entity, GRENADE_FUSE_TIME);
}
/**
@ -246,4 +215,57 @@ stock NapalmGetClientWaterLevel(client)
{
// Return client's water-level.
return GetEntData(client, g_iToolsWaterLevel);
}
}
/**
* Actually extinguishes an entity.
*
* @param client The client index.
*/
stock NapalmExtinguishEntity(client)
{
//ExtinguishEntity(client); <-- Don't use this. Takes off the FL_ONFIRE flag, but flame doesn't get extinguished.
// This works.
new fire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity");
if (IsValidEntity(fire))
{
// Make sure the entity is a flame, so we can extinguish it.
decl String:classname[64];
GetEdictClassname(fire, classname, sizeof(classname));
if (StrEqual(classname, "entityflame", false))
{
SetEntPropFloat(fire, Prop_Data, "m_flLifetime", 0.0);
}
// Log what entity was in that property, for future reference.
else
{
LogEvent(false, LogType_Normal, LOG_GAME_EVENTS, LogModule_Napalm, "Napalm Douse", "Found unexpected entity in prop \"m_hEffectEntity\": \"%s\"", classname);
}
}
}
/**
* Ignites an entity or changes the current flames lifetime.
*
* @param client The client index.
* @param time Number of seconds to set on fire.
*/
stock NapalmIgniteEntity(client, Float:time)
{
new fire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity");
if (IsValidEntity(fire))
{
// Make sure the entity is a flame.
decl String:classname[64];
GetEdictClassname(fire, classname, sizeof(classname));
if (StrEqual(classname, "entityflame", false))
{
SetEntPropFloat(fire, Prop_Data, "m_flLifetime", GetGameTime() + time);
return;
}
}
// No flame entity found, ignite client.
IgniteEntity(client, time);
}

View File

@ -33,7 +33,6 @@ new g_iToolsLMV;
new g_iToolsHasNightVision;
new g_iToolsNightVisionOn;
new g_iToolsFOV;
new Handle:g_hToolsSetAbsVelocity = INVALID_HANDLE;
/**
* @endsection
@ -95,14 +94,7 @@ ToolsFindOffsets()
Handle hGameConf = LoadGameConfigFile("zombiereloaded");
if (hGameConf != INVALID_HANDLE)
{
StartPrepSDKCall(SDKCall_Player);
if (PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CBaseEntity_SetAbsVelocity"))
{
PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
g_hToolsSetAbsVelocity = EndPrepSDKCall();
}
else
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "SDKCall \"CBaseEntity::SetAbsVelocity\" was not found.");
// Reserved
CloseHandle(hGameConf);
}

View File

@ -35,14 +35,20 @@
*/
stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack = true)
{
// If retrieve if true, then get client's velocity.
static bool:gotoffset = false;
static offset = -1;
if(!gotoffset)
{
offset = FindDataMapInfo(client, "m_vecAbsVelocity");
if(offset != -1)
gotoffset = true;
}
// If retrieve is true, then get client's velocity.
if (!apply)
{
// x = vector component.
for (new x = 0; x < 3; x++)
{
vecVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
}
ToolsGetClientVelocity(client, vecVelocity);
// Stop here.
return;
@ -54,20 +60,16 @@ stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:
// Get client's velocity.
new Float:vecClientVelocity[3];
// x = vector component.
for (new x = 0; x < 3; x++)
{
vecClientVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
}
ToolsGetClientVelocity(client, vecClientVelocity);
AddVectors(vecClientVelocity, vecVelocity, vecVelocity);
}
// Apply velocity on client.
if(g_hToolsSetAbsVelocity == INVALID_HANDLE) // Fallback to old one
if(gotoffset) // Fixes trigger OnStartTouch/OnEndTouch bug
SetEntDataVector(client, offset, vecVelocity);
else // Fallback to old one
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vecVelocity);
else // Fixes trigger OnStartTouch/OnEndTouch bug
SDKCall(g_hToolsSetAbsVelocity, client, vecVelocity);
}
/**
@ -78,11 +80,7 @@ stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:
*/
stock ToolsGetClientVelocity(client, Float:vecVelocity[3])
{
// x = vector component.
for (new x = 0; x < 3; x++)
{
vecVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
}
GetEntDataVector(client, g_iToolsVelocity, vecVelocity);
}
/**
@ -203,9 +201,6 @@ stock ToolsSetClientAlpha(client, alpha)
// Set alpha value on the client.
SetEntityRenderColor(client, color[0], color[1], color[2], alpha);
// Forward event to modules.
WeaponAlphaOnClientAlphaChanged(client, alpha);
}
/**

View File

@ -591,7 +591,7 @@ public Action:RestrictCanUse(client, weapon)
// WARNING: This function is called _frequently_. Every game tick per
// player, I think. Make sure any code here is optimized.
new String:weaponentity[WEAPONS_MAX_LENGTH];
decl String:weaponentity[WEAPONS_MAX_LENGTH];
GetEdictClassname(weapon, weaponentity, sizeof(weaponentity));
// If weapon is a knife, then allow pickup.
@ -644,7 +644,7 @@ public Action:RestrictCanUse(client, weapon)
}
// Forward event to weapons module.
WeaponsOnItemPickup(client, weapon);
//WeaponsOnItemPickup(client, weapon);
// Allow pickup.
return Plugin_Continue;

View File

@ -1,155 +0,0 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: weaponalpha.inc
* Type: Core
* Description: Weapon alpha functions, and alpha updating on drop/pickup.
*
* 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/>.
*
* ============================================================================
*/
/**
* Default alpha on any CS:S weapon.
*/
#define WEAPONALPHA_DEFAULT_VALUE 255
/**
* Client is joining the server.
*
* @param client The client index.
*/
WeaponAlphaClientInit(client)
{
return;
SDKHook(client, SDKHook_WeaponDrop, WeaponAlphaDrop);
}
/**
* Client is leaving the server.
*
* @param client The client index.
*/
WeaponAlphaOnClientDisconnect(client)
{
return;
SDKUnhook(client, SDKHook_WeaponDrop, WeaponAlphaDrop);
}
/**
* Client has just picked up a weapon.
*
* @param client The client index.
* @param weapon The weapon index.
*/
WeaponAlphaOnItemPickupPost(client, weapon)
{
return;
if (Entity_HasChildren(weapon))
{
// Don't apply alpha value if weapon has children. Render mode is
// recursively applied to child entities that may not have the render
// mode attribute - and cause errors like this:
// Native "SetEntProp" reported: Property "m_nRenderMode" not found
// (entity 666/info_particle_system)
return;
}
// Get client's current alpha.
new alpha = ToolsGetEntityAlpha(client);
// Set new alpha on weapons.
WeaponAlphaApplyWeaponAlpha(weapon, alpha);
}
/**
* Callback function for Weapon_Drop.
* Called when a client drops their weapon.
*
* @param client The client index.
* @param weapon The weapon index.
*/
public Action:WeaponAlphaDrop(client, weapon)
{
return;
// If weapon isn't a valid entity, then stop.
if (weapon < MaxClients)
{
return;
}
// Set new alpha on weapons.
WeaponAlphaApplyWeaponAlpha(weapon, WEAPONALPHA_DEFAULT_VALUE);
}
/**
* A client's alpha has been changed by the plugin.
*
* @param client The client index.
*/
WeaponAlphaOnClientAlphaChanged(client, alpha)
{
return;
// Set new alpha on weapons.
WeaponAlphaApplyWeaponAlpha(client, alpha);
}
/**
* Set's the alpha on a client's weapons.
*
* @param entity If client index is given, alpha will be set on all their weapons.
* If a non-client index is given, alpha will be set on given entity.
* @param alpha The alpha to set the weapons to.
*/
WeaponAlphaApplyWeaponAlpha(entity, alpha)
{
return;
if (entity > MaxClients)
{
// Turn rendermode on, on the weapon.
SetEntityRenderMode(entity, RENDER_TRANSALPHA);
// Set alpha value on the weapon.
SetEntityRenderColor(entity, _, _, _, alpha);
// Entity alpha has been set, so stop.
return;
}
// Get client's list of weapons.
new weapons[WeaponsSlot];
WeaponsGetClientWeapons(entity, weapons);
// Loop through array slots and set alpha.
// x = weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
{
// If weapon is invalid, then stop.
if (weapons[x] == -1)
{
continue;
}
// Turn rendermode on, on the weapon.
SetEntityRenderMode(weapons[x], RENDER_TRANSALPHA);
// Set alpha value on the weapon.
SetEntityRenderColor(weapons[x], _, _, _, alpha);
}
}

View File

@ -94,7 +94,6 @@ new Handle:arrayWeapons = INVALID_HANDLE;
#include "zr/weapons/restrict"
#include "zr/weapons/weaponammo"
#include "zr/weapons/weaponalpha"
#include "zr/weapons/zmarket"
#include "zr/weapons/menu_weapons"
@ -319,7 +318,6 @@ WeaponsClientInit(client)
{
// Forward event to sub-modules.
RestrictClientInit(client);
WeaponAlphaClientInit(client);
ZMarketClientInit(client);
}
@ -343,7 +341,6 @@ WeaponsOnClientDisconnect(client)
{
// Forward event to sub-modules.
RestrictOnClientDisconnect(client);
WeaponAlphaOnClientDisconnect(client);
ZMarketOnClientDisconnect(client);
}
@ -381,56 +378,6 @@ WeaponsOnRoundEnd()
RestrictOnRoundEnd();
}
/**
* Called when a client picks up an item.
*
* @param client The client index.
* @param weapon The weapon index.
*/
WeaponsOnItemPickup(client, weapon)
{
// Forward event to sub-modules.
// Fire post OnItemPickup event.
// Fill datapack with event information.
new Handle:eventinfo = CreateDataPack();
WritePackCell(eventinfo, client);
WritePackCell(eventinfo, weapon);
// Create post delay timer.
CreateTimer(0.0, WeaponsOnItemPickupPost, eventinfo, TIMER_DATA_HNDL_CLOSE);
}
/**
* Called when a client picks up an item. *Post
*
* @param client The client index.
* @param weapon The weapon index.
*/
public Action:WeaponsOnItemPickupPost(Handle:timer, Handle:eventinfo)
{
// Get event info.
ResetPack(eventinfo);
new client = ReadPackCell(eventinfo);
new weapon = ReadPackCell(eventinfo);
// If client isn't in the game anymore, then stop.
if (!IsClientInGame(client))
{
return;
}
// If the weapon entity isn't valid anymore, then stop.
if (!IsValidEdict(weapon))
{
return;
}
// Forward event to sub-modules.
WeaponAlphaOnItemPickupPost(client, weapon);
}
/**
* Weapon data reading API.
*/