-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
explosivearrows.sp
74 lines (60 loc) · 2.45 KB
/
explosivearrows.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Explosive Arrows perk.
* Copyright (C) 2023 Filip Tomaszewski
*
* 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/>.
*/
#define Damage Float[0]
#define Force Float[1]
#define Radius Float[2]
DEFINE_CALL_APPLY(ExplosiveArrows)
public void ExplosiveArrows_Init(const Perk perk)
{
Events.OnEntitySpawned(perk, ExplosiveArrows_OnArrowSpawn, ExplosiveArrows_ValidClassname, Retriever_OwnerEntity);
}
public void ExplosiveArrows_ApplyPerk(const int client, const Perk perk)
{
Cache[client].Damage = perk.GetPrefFloat("damage", 100.0);
Cache[client].Force = perk.GetPrefFloat("force", 80.0);
Cache[client].Radius = perk.GetPrefFloat("radius", 100.0);
}
public void ExplosiveArrows_OnArrowSpawn(const int client, const int iArrow)
{
SDKHook(iArrow, SDKHook_StartTouchPost, ExplosiveArrows_ArrowTouch);
}
public void ExplosiveArrows_ArrowTouch(int iEntity, int iOther)
{
int iExplosion = CreateEntityByName("env_explosion");
if (iExplosion <= MaxClients)
return;
int client = GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity");
DispatchKeyValueFloat(iExplosion, "iMagnitude", Cache[client].Damage);
DispatchKeyValueFloat(iExplosion, "DamageForce", Cache[client].Force);
DispatchKeyValueFloat(iExplosion, "iRadiusOverride", Cache[client].Radius);
DispatchSpawn(iExplosion);
ActivateEntity(iExplosion);
SetEntPropEnt(iExplosion, Prop_Data, "m_hOwnerEntity", GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity"));
float fPos[3];
GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fPos);
TeleportEntity(iExplosion, fPos, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(iExplosion, "Explode");
AcceptEntityInput(iExplosion, "Kill");
}
bool ExplosiveArrows_ValidClassname(const char[] sCls)
{
return StrEqual(sCls, "tf_projectile_healing_bolt") || StrEqual(sCls, "tf_projectile_arrow");
}
#undef Damage
#undef Force
#undef Radius