AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [L4D2] Melee hit cause explosives (https://forums.alliedmods.net/showthread.php?t=338200)

ddd123 06-16-2022 21:09

[L4D2] Melee hit cause explosives
 
Do you know "Ullapool Caber"?
Pretty much like that but with L4D2 mod and more effective against witch/tank (More damage, Stumble, etc)

I'm trying to making it kinda similar plugin but doesn't know how it work the code
Since, i'm really noob at making code (Literally just copy paste the other scripts and i have no idea if i'm editing right) can someone help me?

Code:

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

static const String:ENTPROP_MELEE_STRING[]    = "m_strMapSetScriptName";
static const String:CLASSNAME_MELEE_WPN[]    = "weapon_melee";


public OnClientPostAdminCheck(client)
{
    SDKHook(client, SDKHook_TraceAttack, OnTraceMeleeAttack);
}

public OnClientDisconnect(client)
{
    SDKUnhook(client, SDKHook_TraceAttack, OnTraceMeleeAttack);
}

public Action:OnTraceMeleeAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
    decl String:meleeweapon[128];
    GetEdictClassname(inflictor, meleeweapon, sizeof(meleeweapon));
   
    if (StrEqual(meleeweapon, CLASSNAME_MELEE_WPN))
    {
        GetEntPropString(GetPlayerWeaponSlot(attacker, 1), Prop_Data, ENTPROP_MELEE_STRING, meleeweapon, sizeof(meleeweapon));
    }
   
    if(StrEqual(meleeweapon, "cricket_bat"))
    {
                        int ent1 = 0;
                        int ent2 = 0;
                        float pos[3];
                        GetEntPropVector(victim, Prop_Send, "m_vecOrigin", pos);       
                        pos[2] += 50.0;

                        ent1 = CreateEntityByName("prop_physics");
                       
                        DispatchKeyValue(ent1, "model", "models/props_junk/propanecanister001a.mdl");
                        DispatchSpawn(ent1);
                        TeleportEntity(ent1, pos, NULL_VECTOR, NULL_VECTOR);
                        ActivateEntity(ent1);
                        SetEntityRenderMode(ent1, view_as<RenderMode>(3));
                        SetEntityRenderColor(ent1, 0, 0, 0, 0);
                        AcceptEntityInput(ent1, "Ignite", -1, -1);
                        AcceptEntityInput(ent1, "Break", -1, -1);
                       
                        ent2 = CreateEntityByName("prop_physics");
                       
                        DispatchKeyValue(ent2, "model", "models/props_junk/gascan001a.mdl");
                        DispatchSpawn(ent2);
                        TeleportEntity(ent2, pos, NULL_VECTOR, NULL_VECTOR);
                        ActivateEntity(ent2);
                        SetEntityRenderMode(ent2, view_as<RenderMode>(3));
                        SetEntityRenderColor(ent2, 0, 0, 0, 0);
                        AcceptEntityInput(ent2, "Ignite", -1, -1);
                        AcceptEntityInput(ent2, "Break", -1, -1);
                       
                        float radius = 150.0;
                        float pushforce = 500.0;
                       
                        int pointHurt = CreateEntityByName("point_hurt"); 
                       
                        DispatchKeyValueFloat(pointHurt, "Damage", damage*2.0);       
                        DispatchKeyValueFloat(pointHurt, "DamageRadius", radius);   
                        DispatchKeyValue(pointHurt, "DamageDelay", "0.0"); 
                        DispatchSpawn(pointHurt);
                        TeleportEntity(pointHurt, pos, NULL_VECTOR, NULL_VECTOR); 
                        AcceptEntityInput(pointHurt, "Hurt", -1);   
                        CreateTimer(0.1, DeletePointHurt, pointHurt);
                       
                        int push = CreateEntityByName("point_push");       
                        DispatchKeyValueFloat (push, "magnitude", pushforce);                   
                        DispatchKeyValueFloat (push, "radius", radius*1.0);                   
                        SetVariantString("spawnflags 24");                   
                        AcceptEntityInput(push, "AddOutput");
                        DispatchSpawn(push);
                        TeleportEntity(push, pos, NULL_VECTOR, NULL_VECTOR); 
                        AcceptEntityInput(push, "Enable", -1, -1);
                        CreateTimer(0.5, DeletePushForce, push);
                        return Plugin_Continue;
        }
   
    return Plugin_Continue;
}

stock bool:IsSurvivor(client)
{
    if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        return true;
    }
    return false;


public Action DeletePushForce(Handle timer, any ent)
{
        if (IsValidEntity(ent))
        {
                char classname[64];
                GetEdictClassname(ent, classname, sizeof(classname));
                if (StrEqual(classname, "point_push", false))
                {
                        AcceptEntityInput(ent, "Disable");
                        AcceptEntityInput(ent, "Slay");
                        RemoveEdict(ent);
                }
        }
}

public Action DeletePointHurt(Handle timer, any ent)
{
        if (IsValidEntity(ent))
        {
                char classname[64];
                GetEdictClassname(ent, classname, sizeof(classname));
                if (StrEqual(classname, "point_hurt", false))
                {
                        AcceptEntityInput(ent, "Slay");
                        RemoveEdict(ent);
                }
        }
}



All times are GMT -4. The time now is 05:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.