Skip to content

Commit b0bbf48

Browse files
authored
Updates by @01Pollux (#2)
1 parent d434772 commit b0bbf48

File tree

95 files changed

+23740
-18139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+23740
-18139
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This repository contains subplugins from the [Freak Fortress 2 sub-forum](https://forums.alliedmods.net/forumdisplay.php?f=154 "VSH / Freak Fortress - AlliedModders"). [original branch](https://github.com/Batfoxkid/FF2-Library/tree/original "Batfoxkid/FF2-Library: Time saving solution to getting Freak Fortress 2 subplugins or plugins for a server.") contains subplugins in their original state while [edited branch](https://github.com/Batfoxkid/FF2-Library/tree/edited "Batfoxkid/FF2-Library: Time saving solution to getting Freak Fortress 2 subplugins or plugins for a server.") contains subplugins that have been edited from what they were on the sub-forum.
55

66
Only few subplugins are owned by me, **all other subplugins are not owned by me, authors are in the sourcecode.**
7+
**This repository have a different/modified versions of subplugins.**
78

89
***
910

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
"Games"
2+
{
3+
"tf"
4+
{
5+
"Functions"
6+
{
7+
"CWeaponMedigun::AllowedToHealTarget"
8+
{
9+
"signature" "CWeaponMedigun::AllowedToHealTarget"
10+
"callconv" "thiscall"
11+
"return" "bool"
12+
"this" "entity"
13+
"arguments"
14+
{
15+
"heal_target"
16+
{
17+
"type" "cbaseentity"
18+
}
19+
}
20+
}
21+
"CBaseCombatWeapon::ItemPostFrame"
22+
{
23+
"offset" "CBaseCombatWeapon::ItemPostFrame"
24+
"hooktype" "entity"
25+
"return" "void"
26+
"this" "entity"
27+
}
28+
"CBaseCombatWeapon::PrimaryAttack"
29+
{
30+
"offset" "CBaseCombatWeapon::PrimaryAttack"
31+
"hooktype" "entity"
32+
"return" "void"
33+
"this" "entity"
34+
}
35+
}
36+
37+
"Signatures"
38+
{
39+
"CGlobalEntityList::FindEntityInSphere"
40+
{
41+
"library" "server"
42+
"linux" "@_ZN17CGlobalEntityList18FindEntityInSphereEP11CBaseEntityRK6Vectorf"
43+
"windows" "\x55\x8B\xEC\x83\xEC\x0C\x53\x56\x57\x8B\xF9\x8B\x4D\x08"
44+
}
45+
"CWeaponMedigun::AllowedToHealTarget"
46+
{
47+
"library" "server"
48+
"linux" "@_ZN14CWeaponMedigun19AllowedToHealTargetEP11CBaseEntity"
49+
"windows" "\x55\x8B\xEC\x53\x8B\xD9\x56\x57\x8B\xB3\xE8\x01\x00\x00"
50+
}
51+
"CEconItemSchema::GetItemDefinition"
52+
{
53+
"library" "server"
54+
"linux" "@_ZN15CEconItemSchema17GetItemDefinitionEi"
55+
"windows" "\x55\x8B\xEC\x56\x8B\xF1\x8D\x45\x08\x57\x50\x8D\x8E\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x85\xC0"
56+
}
57+
"CEconItemSchema"
58+
{
59+
"library" "server"
60+
"linux" "@_Z15GEconItemSchemav"
61+
"windows" "\xE8\x2A\x2A\x2A\x2A\x83\xC0\x04\xC3"
62+
}
63+
}
64+
"Offsets"
65+
{
66+
"CBaseCombatWeapon::GetSlot"
67+
{
68+
"linux" "332"
69+
"windows" "326"
70+
}
71+
"CBaseCombatWeapon::PrimaryAttack"
72+
{
73+
"linux" "285"
74+
"windows" "279"
75+
}
76+
"CBaseCombatWeapon::ItemPostFrame"
77+
{
78+
"linux" "271"
79+
"windows" "265"
80+
}
81+
"CEconItemDefinition::m_pszItemIconClassname"
82+
{
83+
"linux" "216"
84+
"windows" "216"
85+
}
86+
}
87+
}
88+
}
+219
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
methodmap AMSSettings < StringMap {
2+
public AMSSettings(const FF2Prep player, Handle pContext, const char[] plugin, const char[] ability, const char[] prefix) {
3+
StringMap ams = new StringMap();
4+
5+
ams.SetValue("this", pContext);
6+
ams.SetString("this_plugin", plugin);
7+
ams.SetString("prefix", prefix);
8+
ams.SetString("ability", ability);
9+
ams.SetValue("cooldown", GetGameTime() + player.GetArgF(plugin, ability, "initial cd", 1001, 0.0));
10+
ams.SetValue("abilitycd", player.GetArgF(plugin, ability, "ability cd", 1002, 10.0));
11+
12+
char str[128]; player.GetArgS(plugin, ability, "this_name", 1003, str, sizeof(str));
13+
ams.SetString("this_name", str);
14+
15+
player.GetArgS(plugin, ability, "display_desc", 1004, str, sizeof(str));
16+
ams.SetString("display_desc", str);
17+
18+
ams.SetValue("this_cost", player.GetArgF(plugin, ability, "cost", 1005, 25.0));
19+
ams.SetValue("this_end", player.GetArgI(plugin, ability, "can end", 1006, 0));
20+
21+
return view_as<AMSSettings>(ams);
22+
}
23+
24+
public bool IsValid() {
25+
return this != null;
26+
}
27+
28+
public bool GetPrefix(char[] prefix, int size) {
29+
return this.GetString("prefix", prefix, size);
30+
}
31+
32+
public float GetCurrentCooldown() {
33+
float cd;
34+
return this.GetValue("cooldown", cd) ? cd:0.0;
35+
}
36+
public void SetCurrentCooldown(float cd) {
37+
this.SetValue("cooldown", cd + GetGameTime());
38+
}
39+
public void AddCooldown()
40+
{
41+
float cd;
42+
this.GetValue("abilitycd", cd);
43+
this.SetCurrentCooldown(cd);
44+
}
45+
46+
public bool CanEnd()
47+
{
48+
bool canend; this.GetValue("this_end", canend);
49+
return canend;
50+
}
51+
52+
public float GetCost() {
53+
float cost;
54+
this.GetValue("this_cost", cost);
55+
return cost;
56+
}
57+
public float SetCost(float cost) {
58+
this.SetValue("this_cost", cost);
59+
}
60+
61+
}
62+
63+
FF2Parse GlobalAMS[MAXCLIENTS];
64+
AMSSettings AMS_Settings[MAXCLIENTS][MAXABILITIES];
65+
66+
public AMSResult Handle_AMSPreAbility(int client, int index)
67+
{
68+
Call_StartForward(AMSForward[hPreAbility]);
69+
Call_PushCell(client);
70+
int idx = index;
71+
Call_PushCellRef(idx);
72+
AMSResult action = AMS_Ignore;
73+
Call_PushCellRef(action);
74+
Action result = Plugin_Continue;
75+
Call_Finish(result);
76+
if(result == Plugin_Stop) {
77+
return AMS_Deny;
78+
}
79+
else if(result != Plugin_Continue) {
80+
index = idx;
81+
}
82+
if(result == Plugin_Handled && action != AMS_Ignore) {
83+
return action;
84+
}
85+
return AMS_CanInvoke(client, index);
86+
}
87+
88+
static AMSResult AMS_CanInvoke(int client, int index)
89+
{
90+
AMSResult AMSAction = AMS_Accept;
91+
Handle hPlugin;
92+
Function hFunc;
93+
if(AMS_GetThisFunction(client, index, "%s_CanInvoke", hPlugin, hFunc)) {
94+
Call_StartFunction(hPlugin, hFunc);
95+
Call_PushCell(client);
96+
Call_PushCell(index);
97+
Call_Finish(AMSAction);
98+
}
99+
if(AMSAction == AMS_Overwrite) {
100+
if(AMS_GetThisFunction(client, index, "%s_Overwrite", hPlugin, hFunc)) {
101+
Call_StartFunction(hPlugin, hFunc);
102+
Call_PushCell(client);
103+
Call_PushCell(index);
104+
Call_Finish();
105+
}
106+
} else if(AMSAction == AMS_Accept) {
107+
AMS_Settings[client][index].AddCooldown();
108+
}
109+
return AMSAction;
110+
}
111+
112+
static void AMS_DoInvoke(int client, int index)
113+
{
114+
Handle hPlugin;
115+
Function hFunc;
116+
if(AMS_GetThisFunction(client, index, "%s_Invoke", hPlugin, hFunc)) {
117+
Call_StartFunction(hPlugin, hFunc);
118+
Call_PushCell(client);
119+
Call_PushCell(index);
120+
Call_Finish();
121+
122+
static char buffer[64];
123+
GlobalAMS[client].GetString("cast-particle", buffer, sizeof(buffer));
124+
if(!IsEmptyString(buffer)) {
125+
CreateTimedParticle(client, buffer, 1.0);
126+
}
127+
}
128+
}
129+
130+
public void Handle_AMSOnAbility(int client, int index)
131+
{
132+
Call_StartForward(AMSForward[hOnAbility]);
133+
Call_PushCell(client);
134+
Call_PushCell(index);
135+
static char plugin[64]; AMS_Settings[client][index].GetString("this_plugin", plugin, sizeof(plugin));
136+
Call_PushString(plugin);
137+
AMS_Settings[client][index].GetString("ability", plugin, sizeof(plugin));
138+
Call_PushString(plugin);
139+
Call_Finish();
140+
141+
AMS_DoInvoke(client, index);
142+
}
143+
144+
public void Handle_AMSOnEnd(int client, int index)
145+
{
146+
Call_StartForward(AMSForward[hPreForceEnd]);
147+
Call_PushCell(client);
148+
int idx = index;
149+
Call_PushCellRef(idx);
150+
AMSResult action = AMS_Ignore;
151+
Call_PushCellRef(action);
152+
Action result = Plugin_Continue;
153+
Call_Finish(result);
154+
if(result == Plugin_Stop || action <= AMS_Deny) {
155+
return;
156+
}
157+
else if(result != Plugin_Continue) {
158+
index = idx;
159+
}
160+
161+
Handle hPlugin;
162+
Function hFunc;
163+
if(AMS_GetThisFunction(client, index, "%s_EndAbility", hPlugin, hFunc)) {
164+
Call_StartFunction(hPlugin, hFunc);
165+
Call_PushCell(client);
166+
Call_PushCell(index);
167+
Call_Finish();
168+
}
169+
}
170+
171+
static bool AMS_GetThisFunction(int client, int index, const char[] format, Handle &IPlugin, Function &Func)
172+
{
173+
174+
if(!AMS_Settings[client][index].GetValue("this", IPlugin) || IPlugin == null) {
175+
return false;
176+
}
177+
178+
static char func[32], prefix[8];
179+
if(!AMS_Settings[client][index].GetPrefix(prefix, sizeof(prefix))) {
180+
return false;
181+
}
182+
183+
FormatEx(func, sizeof(func), format, prefix);
184+
Func = GetFunctionByName(IPlugin, func);
185+
return Func != INVALID_FUNCTION;
186+
}
187+
188+
static stock void CreateTimedParticle(int client, char[] particle, float duration)
189+
{
190+
int entity = CreateEntityByName("info_particle_system");
191+
192+
float vecPos[3]; GetEntPropVector(client, Prop_Send, "m_vecOrigin", vecPos);
193+
TeleportEntity(entity, vecPos, NULL_VECTOR, NULL_VECTOR);
194+
195+
static char buffer[64];
196+
FormatEx(buffer, sizeof(buffer), "target%i", client);
197+
DispatchKeyValue(client, "targetname", buffer);
198+
199+
DispatchKeyValue(entity, "targetname", "tf2particle");
200+
DispatchKeyValue(entity, "parentname", buffer);
201+
DispatchKeyValue(entity, "effect_name", particle);
202+
DispatchSpawn(entity);
203+
204+
SetVariantString(buffer);
205+
AcceptEntityInput(entity, "SetParent", entity, entity);
206+
207+
SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
208+
ActivateEntity(entity);
209+
AcceptEntityInput(entity, "start");
210+
211+
CreateTimer(duration, Timer_KillEntity, EntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);
212+
}
213+
214+
public Action Timer_KillEntity(Handle timer, any EntRef)
215+
{
216+
int entity = EntRefToEntIndex(EntRef);
217+
if(IsValidEntity(entity))
218+
RemoveEntity(entity);
219+
}

0 commit comments

Comments
 (0)