Raised This Month: $51 Target: $400
 12% 

How to make mediguns give kritz and mega heal?


Post New Thread Reply   
 
Thread Tools Display Modes
ROMaster2
New Member
Join Date: Feb 2014
Old 04-24-2014 , 22:43   Re: How to make mediguns give kritz and mega heal?
Reply With Quote #11

Quote:
Originally Posted by xXDeathreusXx View Post
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
You are correct. I've only just started learning how to write plugins so I don't know off the top of my head how to separate the stock Medigun, Kritzkrieg, Quick-Fix and Vaccinator yet, but I will at some point.

I've modified the plugin I made a little bit so it works when a medigun has an attribute on it that does nothing at all to it, like cloak attributes. Requires TF2Attributes:
PHP Code:
#include <tf2_stocks>
#include <tf2attributes>

public Plugin:myinfo =
{
    
name "Super Uber",
    
author "ROMaster2",
    
description "Makes various ubercharges available for the Mediguns.",
    
version "1.1.2",
    
url "http://www.sourcemod.net/"
}
 
public 
OnPluginStart()
{
    
PrintToChatAll("Super Uber plugin loaded.");
    
HookEvent("player_chargedeployed"event_uberdeployed);
}

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(clientTFWeaponSlot_Secondary);
        new 
Float:valueA;
        new 
Float:valueB;
        new 
Float:valueC;
        new 
Float:valueD;
        new 
Address:attrA TF2Attrib_GetByName(medigun"cannot disguise");
        new 
Address:attrB TF2Attrib_GetByName(medigun"mult cloak meter regen rate");
        new 
Address:attrC TF2Attrib_GetByName(medigun"no double jump");
        new 
Address:attrD TF2Attrib_GetByName(medigun"disguise on backstab");
        if (
attrA != Address_NullvalueA 0.5;
        if (
attrB != Address_NullvalueB 0.5;
        if (
attrC != Address_NullvalueC 0.5;
        if (
attrD != Address_NullvalueD 0.5;
        if (
IsValidEntity(medigun))
        {
            
GetEdictClassname(medigunssizeof(s));
            if (
strcmp(s"tf_weapon_medigun"false) == 0)
            {
                
TF2_AddCondition(clientTFCond_UberchargedvalueAclient);
                
TF2_AddCondition(clientTFCond_HalloweenCritCandyvalueBclient);
                
TF2_AddCondition(clientTFCond_MegaHealvalueCclient);
                
TF2_AddCondition(clientTFCond_HalloweenSpeedBoostvalueDclient);
                new 
target GetHealingTarget(client);
                if (
IsValidClient(targetfalse) && IsPlayerAlive(target))
                {
                    
TF2_AddCondition(targetTFCond_UberchargedvalueAclient);
                    
TF2_AddCondition(targetTFCond_HalloweenCritCandyvalueBclient);
                    
TF2_AddCondition(targetTFCond_MegaHealvalueCclient);
                    
TF2_AddCondition(targetTFCond_HalloweenSpeedBoostvalueDclient);
                    
uberTarget[client] = target;
                }
                else 
uberTarget[client] = -1;
                
CreateTimer(0.3Timer_LazorEntIndexToEntRef(medigun), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
            }
        }
    }
    return 
Plugin_Continue;
}
public 
Action:Timer_Lazor(Handle:hTimerany:medigunid)
{
    new 
Float:valueA;
    new 
Float:valueB;
    new 
Float:valueC;
    new 
Float:valueD;
    new 
Address:attrA TF2Attrib_GetByName(medigunid"cannot disguise");
    new 
Address:attrB TF2Attrib_GetByName(medigunid"mult cloak meter regen rate");
    new 
Address:attrC TF2Attrib_GetByName(medigunid"no double jump");
    new 
Address:attrD TF2Attrib_GetByName(medigunid"disguise on backstab");
    if (
attrA != Address_NullvalueA 0.5;
    if (
attrB != Address_NullvalueB 0.5;
    if (
attrC != Address_NullvalueC 0.5;
    if (
attrD != Address_NullvalueD 0.5;
    new 
medigun EntRefToEntIndex(medigunid);
    if (
medigun && IsValidEntity(medigun))
    {
        new 
client GetEntPropEnt(medigunProp_Send"m_hOwnerEntity");
        new 
Float:charge GetEntPropFloat(medigunProp_Send"m_flChargeLevel");
        if (
IsValidClient(clientfalse) && IsPlayerAlive(client) && GetEntPropEnt(clientProp_Send"m_hActiveWeapon") == medigun)
        {
            new 
target GetHealingTarget(client);
            if (
charge 0.0375)
            {
                
TF2_AddCondition(clientTFCond_UberchargedvalueA);
                
TF2_AddCondition(clientTFCond_HalloweenCritCandyvalueB);
                
TF2_AddCondition(clientTFCond_MegaHealvalueC);
                
TF2_AddCondition(clientTFCond_HalloweenSpeedBoostvalueD);
                if (
IsValidClient(targetfalse) && IsPlayerAlive(target))
                {
                    
TF2_AddCondition(targetTFCond_UberchargedvalueA);
                    
TF2_AddCondition(targetTFCond_HalloweenCritCandyvalueB);
                    
TF2_AddCondition(targetTFCond_MegaHealvalueC);
                    
TF2_AddCondition(targetTFCond_HalloweenSpeedBoostvalueD);
                    
uberTarget[client] = target;
                }
                else 
uberTarget[client] = -1;
            }
        }
        if (
charge <= 0.0375)
        {
            return 
Plugin_Stop;
        }
    }
    else
        return 
Plugin_Stop;
    return 
Plugin_Continue;
}

stock GetHealingTarget(client)
{
    new 
String:s[64];
    new 
medigun GetPlayerWeaponSlot(clientTFWeaponSlot_Secondary);
    if (
medigun <= MaxClients || !IsValidEdict(medigun))
        return -
1;
    
GetEdictClassname(medigunssizeof(s));
    if (
strcmp(s"tf_weapon_medigun"false) == 0)
    {
        if (
GetEntProp(medigunProp_Send"m_bHealing"))
            return 
GetEntPropEnt(medigunProp_Send"m_hHealingTarget");
    }
    return -
1;
}
stock bool:IsValidClient(clientbool:nobots true)

    if (
client <= || client MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
    {
        return 
false
    }
    return 
IsClientInGame(client); 

It currently doesn't work on the Vaccinator since the plugin stops when the charge is under 3.75% while the Vaccinator can stop at 75%, 50%, 25% and 0%; it makes the plugin continue and doesn't remove the conditions. I'm also not totally sure it's as optimal as it should be, since it's constantly reading addresses when it deploys. It otherwise works like a charm.

I'm writing it up for the Uber Upgrades to allow for custom attributes.

Last edited by ROMaster2; 04-24-2014 at 22:46.
ROMaster2 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-25-2014 , 00:24   Re: How to make mediguns give kritz and mega heal?
Reply With Quote #12

TF2Attributes stuff doesn't belong in this forum.
__________________
asherkin is offline
Reply



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 02:49.


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