New Member
|
04-24-2014
, 22:43
Re: How to make mediguns give kritz and mega heal?
|
#11
|
Quote:
Originally Posted by xXDeathreusXx
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(client, TFWeaponSlot_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_Null) valueA = 0.5; if (attrB != Address_Null) valueB = 0.5; if (attrC != Address_Null) valueC = 0.5; if (attrD != Address_Null) valueD = 0.5; if (IsValidEntity(medigun)) { GetEdictClassname(medigun, s, sizeof(s)); if (strcmp(s, "tf_weapon_medigun", false) == 0) { TF2_AddCondition(client, TFCond_Ubercharged, valueA, client); TF2_AddCondition(client, TFCond_HalloweenCritCandy, valueB, client); TF2_AddCondition(client, TFCond_MegaHeal, valueC, client); TF2_AddCondition(client, TFCond_HalloweenSpeedBoost, valueD, client); new target = GetHealingTarget(client); if (IsValidClient(target, false) && IsPlayerAlive(target)) { TF2_AddCondition(target, TFCond_Ubercharged, valueA, client); TF2_AddCondition(target, TFCond_HalloweenCritCandy, valueB, client); TF2_AddCondition(target, TFCond_MegaHeal, valueC, client); TF2_AddCondition(target, TFCond_HalloweenSpeedBoost, valueD, client); uberTarget[client] = target; } else uberTarget[client] = -1; CreateTimer(0.3, Timer_Lazor, EntIndexToEntRef(medigun), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); } } } return Plugin_Continue; } public Action:Timer_Lazor(Handle:hTimer, any: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_Null) valueA = 0.5; if (attrB != Address_Null) valueB = 0.5; if (attrC != Address_Null) valueC = 0.5; if (attrD != Address_Null) valueD = 0.5; new medigun = EntRefToEntIndex(medigunid); if (medigun && IsValidEntity(medigun)) { new client = GetEntPropEnt(medigun, Prop_Send, "m_hOwnerEntity"); new Float:charge = GetEntPropFloat(medigun, Prop_Send, "m_flChargeLevel"); if (IsValidClient(client, false) && IsPlayerAlive(client) && GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon") == medigun) { new target = GetHealingTarget(client); if (charge > 0.0375) { TF2_AddCondition(client, TFCond_Ubercharged, valueA); TF2_AddCondition(client, TFCond_HalloweenCritCandy, valueB); TF2_AddCondition(client, TFCond_MegaHeal, valueC); TF2_AddCondition(client, TFCond_HalloweenSpeedBoost, valueD); if (IsValidClient(target, false) && IsPlayerAlive(target)) { TF2_AddCondition(target, TFCond_Ubercharged, valueA); TF2_AddCondition(target, TFCond_HalloweenCritCandy, valueB); TF2_AddCondition(target, TFCond_MegaHeal, valueC); TF2_AddCondition(target, TFCond_HalloweenSpeedBoost, valueD); 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(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); }
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.
|
|