Last active 1741880025

jackz's Avatar Jackie revised this gist 1658894873. Go to revision

1 file changed, 83 insertions

witch_attack.sp(file created)

@@ -0,0 +1,83 @@
1 + #pragma semicolon 1
2 + #pragma newdecls required
3 +
4 + #include <sourcemod>
5 + #include <sdktools>
6 +
7 + // #include <l4d2_behavior>
8 + #include <actions>
9 +
10 + Handle g_hWitchAttack;
11 +
12 + public void OnPluginStart()
13 + {
14 + GameData data = new GameData("l4d2_behavior");
15 +
16 + StartPrepSDKCall(SDKCall_Raw);
17 + PrepSDKCall_SetFromConf(data, SDKConf_Signature, "WitchAttack::WitchAttack");
18 + PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
19 + g_hWitchAttack = EndPrepSDKCall();
20 +
21 + LoadTranslations("common.phrases");
22 +
23 + delete data;
24 +
25 + RegAdminCmd("sm_witch_attack", Command_WitchAttack, ADMFLAG_CHEATS);
26 + }
27 +
28 + public Action Command_WitchAttack(int client, int args) {
29 + if(args < 1) {
30 + ReplyToCommand(client, "Usage: sm_witch_attack <user> [# of witches or 0 for all]");
31 + }else{
32 + char arg1[32];
33 + GetCmdArg(1, arg1, sizeof(arg1));
34 + char target_name[MAX_TARGET_LENGTH];
35 + int target_list[1], target_count;
36 + bool tn_is_ml;
37 + if ((target_count = ProcessTargetString(
38 + arg1,
39 + client,
40 + target_list,
41 + 1,
42 + COMMAND_FILTER_ALIVE, /* Only allow alive players */
43 + target_name,
44 + sizeof(target_name),
45 + tn_is_ml)) <= 0)
46 + {
47 + /* This function replies to the admin with a failure message */
48 + ReplyToTargetError(client, target_count);
49 + return Plugin_Handled;
50 + }
51 +
52 + GetCmdArg(2, arg1, sizeof(arg1));
53 + int maxCount = StringToInt(arg1);
54 + if(maxCount < 0) maxCount = 0;
55 + int count;
56 + int target = target_list[0];
57 +
58 + if(GetClientTeam(target) == 2) {
59 + int witch = INVALID_ENT_REFERENCE;
60 + while ((witch = FindEntityByClassname(witch, "witch")) != INVALID_ENT_REFERENCE) {
61 + // WitchBehavior works best, but ideally any action?
62 + BehaviorAction action = ActionsManager.GetAction(witch, "WitchBehavior");
63 + if(action == INVALID_ACTION) {
64 + PrintToServer("Could not get action for WitchAttack");
65 + return Plugin_Stop;
66 + }
67 + BehaviorAction newAction = ActionsManager.Allocate(18556);
68 +
69 + SDKCall(g_hWitchAttack, newAction, target);
70 +
71 + action.StorePendingEventResult(CHANGE_TO, newAction);
72 + // newAction.StorePendingEventResult(DONE);
73 + if(maxCount > 0 && ++count >= maxCount) break;
74 + }
75 + ShowActivity(client, "%d witches target %s", count, target_name);
76 + }else{
77 + ReplyToTargetError(client, target_count);
78 + }
79 + }
80 + return Plugin_Handled;
81 + }
82 +
83 +
Newer Older