AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   TF2Items (https://forums.alliedmods.net/forumdisplay.php?f=146)
-   -   How to make mediguns give kritz and mega heal? (https://forums.alliedmods.net/showthread.php?t=235673)

WildCard65 02-18-2014 10:07

How to make mediguns give kritz and mega heal?
 
How would I force tf2 to "Seperate" the attributes "medigun charge is crit boost" and "medigun charge is megaheal" so that I can make a medigun(when uber deployed) act like a hybrid quick-fix and kritzkrieg. Atm, tf2 treats the 3 attributes for the 3 non-regular ubercharge mediguns as 1 attribute(with a numbering system from 1 to 3 with 1 being crits and 3 being resists).
Edit, may a combo of using a forward to tell when an uber was removed, event when uber was deployed, and the forward for crits.
Edit2: This is what I got started so far:
Code:

//Unnessecary code replaced by this comment
new Handle:specialcrits;
//Unnessecary code replaced by this comment
public OnPluginStart(){
        //Unnessecary code replaced by this comment
        HookEvent("player_chargedeployed", OnUberCharge);
        //Unnessecary code replaced by this comment
        specialcrits = CreateArray(2);
}
//Unnessecary code replaced by this comment
public OnUberCharge(Handle:event, const String:name[], bool:dontBroadcast){
        new medicID = GetEventInt(event, "userid");
        new targetID = GetEventInt(event, "targetid");
        new medic = GetClientOfUserId(medicID);
        new target = GetClientOfUserId(targetID);
        if(!IsValidClient(medic)){
                Flex_Debug("Medic is not a valid client anymore.");
        }else if(!IsValidClient(target)){
                Flex_Debug("Target is not a valid client or medic ubered himself.");
        }else{
                decl String:medicname[MAX_NAME_LENGTH];
                decl String:targetname[MAX_NAME_LENGTH];
                GetClientName(medic,medicname,MAX_NAME_LENGTH);
                GetClientName(target,targetname,MAX_NAME_LENGTH);
                decl buffer[2];
                new ArraySize = GetArraySize(specialcrits);
                if(ArraySize==0){
                        Flex_Debug("Crits array has no size, giving it one.");
                        ArraySize=1;
                        ResizeArray(specialcrits, ArraySize);
                }else{
                        Flex_Debug("Crits array has a size, checking if there's room.");
                        GetArrayArray(specialcrits, ArraySize-1, buffer);
                        if(buffer[0] > 0){
                                Flex_Debug("Crits array has no room. Giving it room.");
                                ArraySize++;
                                ResizeArray(specialcrits, ArraySize);
                        }
                }
                if(CheckCommandAccess(medic, "root_weapons_override", ADMFLAG_ROOT)){
                        Flex_Debug("%s has access to root_weapons_override, %s will be given crits.", medicname, targetname);
                }
        }
}
//Unnessecary code replaced by this comment, including the function for the debug.


xerox_i_ 02-20-2014 15:48

Re: How to make mediguns give kritz and mega heal?
 
u dont need a plugin u can do this on tf2items_weapons.txt

WildCard65 02-20-2014 15:55

Re: How to make mediguns give kritz and mega heal?
 
Have you ever tried combining: medigun charge is megaheal with value of 2 and medigun charge is crit boost with value of 1?

xerox_i_ 02-20-2014 21:37

Re: How to make mediguns give kritz and mega heal?
 
yeah several times and works!

WildCard65 02-21-2014 12:13

Re: How to make mediguns give kritz and mega heal?
 
O_O Odd cause when I try, it always adds it to value of 3.
From what I noticed in items_game.txt, the 3 attributes for the 3 none standard mediguns are in a number like system.

xerox_i_ 03-04-2014 09:55

Re: How to make mediguns give kritz and mega heal?
 
Quote:

Originally Posted by WildCard65 (Post 2102934)
O_O Odd cause when I try, it always adds it to value of 3.
From what I noticed in items_game.txt, the 3 attributes for the 3 none standard mediguns are in a number like system.

k them the attrib to change weapon modes in the most causes its additive u can try this:

18 ; 1

231 ; 1

WildCard65 03-04-2014 11:27

Re: How to make mediguns give kritz and mega heal?
 
No, there additive alright but additive in a way that you can mismatch them into being different charges(the one applied to kritzkrieg can be turned into one that does what the one applied to quick-fix does):
PHP Code:

"medigun charge is crit boost"
{
    
"attribute_class"    "set_charge_type"
    "value"    "1"
}
"medigun charge is megaheal"
{
    
"attribute_class"    "set_charge_type"
    "value"    "2"
}
"medigun charge is resists"
{
    
"attribute_class"    "set_charge_type"
    "value"    "3"


Looking at the above charges attributes, you can easily notice that A) they share the same attribute_class and B) follow a number ordering system.
so doing 18 with value of 2 does exactly like 231 with value of 2.
Doing 18 with value of 1 and 231 with value of 2 does exactly the same as 473 with value of 3

xerox_i_ 03-05-2014 13:49

Re: How to make mediguns give kritz and mega heal?
 
Quote:

Originally Posted by WildCard65 (Post 2107331)
No, there additive alright but additive in a way that you can mismatch them into being different charges(the one applied to kritzkrieg can be turned into one that does what the one applied to quick-fix does):
PHP Code:

"medigun charge is crit boost"
{
    
"attribute_class"    "set_charge_type"
    "value"    "1"
}
"medigun charge is megaheal"
{
    
"attribute_class"    "set_charge_type"
    "value"    "2"
}
"medigun charge is resists"
{
    
"attribute_class"    "set_charge_type"
    "value"    "3"


Looking at the above charges attributes, you can easily notice that A) they share the same attribute_class and B) follow a number ordering system.
so doing 18 with value of 2 does exactly like 231 with value of 2.
Doing 18 with value of 1 and 231 with value of 2 does exactly the same as 473 with value of 3

i will try later my pc broke right now i cant test anything and i cant play but soon i will test

ROMaster2 03-20-2014 17:22

Re: How to make mediguns give kritz and mega heal?
 
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!

xXDeathreusXx 04-12-2014 14:14

Re: How to make mediguns give kritz and mega heal?
 
Quote:

Originally Posted by ROMaster2 (Post 2113976)
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


All times are GMT -4. The time now is 23:35.

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