Raised This Month: $ Target: $400
 0% 

How to make mediguns give kritz and mega heal?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
xXDeathreusXx
Veteran Member
Join Date: Mar 2013
Location: pPlayer->GetOrigin();
Old 04-12-2014 , 14:14   Re: How to make mediguns give kritz and mega heal?
Reply With Quote #10

Quote:
Originally Posted by ROMaster2 View Post
I'm trying to do something similar by making a Medigun with both features from the Quick-Fix and the Vaccinator. Unfortunately I believe they're hard-coded in, as they're based on the same attribute class, set_weapon_mode.

The same applies to the Ubercharges, which is dependent on set_charge_type. Setting it to 1 creates Kritzkrieg's Crits, 2 creates Quick-Fix's Megaheal, 3 creates Vaccinator's Resists (which can be very buggy), and leaving it empty is a standard Invulnerability. The VS Saxton Hale plug-in worked around it and I tweaked it a little for what I'm trying to make:
Code:
#include <tf2_stocks>
 
public OnPluginStart()
{
    HookEvent("player_chargedeployed", event_uberdeployed);
    CreateTimer(0.2, ClientTimer, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

new uberTarget[MAXPLAYERS + 1];

public Action:event_uberdeployed(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    new String:s[64];
    if (IsValidClient(client) && IsPlayerAlive(client))
    {
        new medigun = GetPlayerWeaponSlot(client, TFWeaponSlot_Secondary);
        if (IsValidEntity(medigun))
        {
            GetEdictClassname(medigun, s, sizeof(s));
            if (strcmp(s, "tf_weapon_medigun", false) == 0)
            {
                TF2_AddCondition(client, TFCond_HalloweenCritCandy, 0.5, client);
                TF2_AddCondition(client, TFCond_MegaHeal, 0.5, client);
                new target = GetHealingTarget(client);
                if (IsValidClient(target, false) && IsPlayerAlive(target))
                {
                    TF2_AddCondition(target, TFCond_HalloweenCritCandy, 0.5, client);
                    TF2_AddCondition(target, TFCond_MegaHeal, 0.5, client);
                    uberTarget[client] = target;
                }
                else uberTarget[client] = -1;
                CreateTimer(0.4, Timer_Lazor, EntIndexToEntRef(medigun), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
            }
        }
    }
    return Plugin_Continue;
}
public Action:Timer_Lazor(Handle:hTimer, any:medigunid)
{
    new medigun = EntRefToEntIndex(medigunid);
    if (medigun && IsValidEntity(medigun))
    {
        new client = GetEntPropEnt(medigun, Prop_Send, "m_hOwnerEntity");
        if (IsValidClient(client, false) && IsPlayerAlive(client) && GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon") == medigun)
        {
            new target = GetHealingTarget(client);
            if (TF2_IsPlayerInCondition(client, TFCond_Ubercharged))
            {
                TF2_AddCondition(client, TFCond_HalloweenCritCandy, 0.5);
                TF2_AddCondition(client, TFCond_MegaHeal, 0.5);
                if (IsValidClient(target, false) && IsPlayerAlive(target))
                {
                    TF2_AddCondition(target, TFCond_HalloweenCritCandy, 0.5);
                    TF2_AddCondition(target, TFCond_MegaHeal, 0.5);
                    uberTarget[client] = target;
                }
                else uberTarget[client] = -1;
            }
        }
        if (!TF2_IsPlayerInCondition(client, TFCond_Ubercharged))
        {
            return Plugin_Stop;
        }
    }
    else
        return Plugin_Stop;
    return Plugin_Continue;
}

stock GetHealingTarget(client)
{
    new String:s[64];
    new medigun = GetPlayerWeaponSlot(client, TFWeaponSlot_Secondary);
    if (medigun <= MaxClients || !IsValidEdict(medigun))
        return -1;
    GetEdictClassname(medigun, s, sizeof(s));
    if (strcmp(s, "tf_weapon_medigun", false) == 0)
    {
        if (GetEntProp(medigun, Prop_Send, "m_bHealing"))
            return GetEntPropEnt(medigun, Prop_Send, "m_hHealingTarget");
    }
    return -1;
}
stock bool:IsValidClient(client, bool:nobots = true)
{ 
    if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
    {
        return false; 
    }
    return IsClientInGame(client); 
}
That'll only work with the normal Medigun. I hope that's what you're looking for!
Looking at this, it should actually in theory work on all mediguns, as all of them share that medigun class your comparing the string of
__________________
Plugins|Profile
Requests closed

I'm a smartass by nature, get used to it
xXDeathreusXx is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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