View Single Post
naris
AlliedModders Donor
Join Date: Dec 2006
Old 05-22-2010 , 21:42   Re: [TF2] The Amplifier
Reply With Quote #97

I have modified this plugin to make it so that it can be configured to apply any condition, use(and regenerate) metal to apply conditions and/or have a percent chance of applying a condition.

It can also be configured to apply adverse conditions, such as slowed, jarated, taunting or on fire to enemies instead of krit or buffed to allies.

I have also added a native interface so it can be called form other plugins. I also modified it so that a player can have more than 1 amplifier, provided that another plugin (such as my remote control/build plugin http://forums.alliedmods.net/showthread.php?p=866626) is used to build a dispenser to be converted.

I have added the following convars:

amplifier_distance (default 200)
Distance the amplifier works.

amplifier_particle (0-1, default 1)
Enable the Buffed Particle.

amplifier_condition (1-22, default 16)
Condition that The amplifier dispenses (11=full crits, 16=mini crits, etc...)

amplifier_percent (0-100, default 100)
Percent chance of the amplifier applying the condition

amplifier_metal (default 5)
Amount of metal to use to apply a condition to a player (per second).

amplifier_regeneration (default 10)
Amount of metal to regenerate per second.

amplifier_max (default 400)
Maximum amount of metal an amplifier can hold.

Here is the native interface:

PHP Code:
/**
 * Assume control of the Amplifier plugin
 *
 * @param plugin_only     Set to 1 to assume complete control of Amplifier.
 * @return                none
 */
native ControlAmplifier(bool:plugin_only=true);

/**
 * Set the sate of the Amplifier flag
 *
 * @param index     Client index
 * @param enable    Set true so player builds an Amplifier instead of a dispenser
 * @param distance  Range of the amplifier (-1.0=use convar)
 * @param condition Condition to set players within range of the amplifier (-1=use convar)
 * @param percent   Percent (0-100) chance of applying the condition (-1=use convar)
 * @return            none
 */
native SetAmplifier(clientbool:enable=trueFloat:distance=-1.0TFCond:condition=TFCond:-1percent=-1);

/**
 * Count how many Amplifiers the client has constructed.
 *
 * @param index     Client index
 * @return            The number of Amplifiers the client has constructed.
 */
native HasAmplifier(client);

/**
 * Converts a dispenser into an Amplifier
 *
 * @param entity    Dispenser Entity to convert.
 * @param client     Client index of the owner.
 * @param distance  Range of the amplifier (-1.0=use convar)
 * @param condition Condition to set players within range of the amplifier (-1=use convar)
 * @param percent   Percent (0-100) chance of applying the condition (-1=use convar)
 * @return            none
 */
native ConvertToAmplifier(entityclientFloat:distance=-1.0TFCond:condition=TFCond:-1percent=-1);

/**
 * Gets called when the amplifier applys a condition to someone
 *
 * @param builder:  The index of the client that built the amplifier.
 * @param client:   The index of the player that is being afected.
 * @param condition The condition beign applied to the client.
 * @return            Plugin_Stop will prevent the client from being affected.
 */
forward Action:OnAmplify(builder,client,TFCond:condition); 
Here is an example of presenting a menu to select what type of amplifier and then using the Remote control plugin to build a dispenser and then converting it to an amplifier:
PHP Code:
WarpInAmplifier(clientamp_level)
{
    if (
m_BuildAvailable)
    {
            new 
Handle:menu=CreateMenu(Amplifier_Selected);
            
SetMenuTitle(menu,"[SC] Please choose Amplifier type:");

            new 
count HasAmplifier(client);
            
AddMenuItem(menu,"0","Slow Amplifier", (count amp_level && amp_level >= 3) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"1","Jar Amplifier", (count amp_level && amp_level >= 2) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"2","Fire Amplifier", (count amp_level && amp_level >= 4) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"3","Taunt Amplifier", (count amp_level && amp_level >= 4) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"4","Undisguising Amplifier", (count amp_level && amp_level >= 4) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"5","Decloaking Amplifier", (count amp_level && amp_level >= 4) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"6","Buff Amplifier", (count amp_level) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"7","Krit Amplifier", (count amp_level && amp_level >= 3) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"8","Uber Amplifier", (count amp_level && amp_level >= 4) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
AddMenuItem(menu,"9","Destroy Structure", (count 0) ? ITEMDRAW_DEFAULT ITEMDRAW_DISABLED);
            
DisplayMenu(menu,client,MENU_TIME_FOREVER);
        }
}

public 
Amplifier_Selected(Handle:menu,MenuAction:action,client,selection)
{
    static const 
String:typeName[] = { "Slow""Jar""Fire""Taunt""Undisguising",
                                       
"Decloaking""Buff""Krit""Uber" };

    static const 
TFCond:condition[] = { TFCond_Slowed,
                                        
TFCond_Jarated,
                                        
TFCond_OnFire,
                                        
TFCond_Taunting,
                                        
TFCond_Disguised,
                                        
TFCond_Cloaked,
                                        
TFCond_Buffed,
                                        
TFCond_Kritzkrieged,
                                        
TFCond_Ubercharged
                                      
};

    if (
action == MenuAction_Select)
    {
            
decl String:SelectionInfo[12];
            
GetMenuItem(menu,selection,SelectionInfo,sizeof(SelectionInfo));

            new 
item StringToInt(SelectionInfo);
            if (
item == 9)
            {
                
DestroyBuildingMenu(client);
            }
            else
            {
                    new 
object BuildObject(clientTFObjectType_Dispenser1falsetrue, .check=false);
                    if (
m_AmplifierAvailable)
                    {
                        new 
Float:rangepercent;
                        new 
level GetUpgradeLevel(client,raceID,amplifierID);
                        switch (
item)
                        {
                            case 
0// Slow
                            
{
                                
range 150.0 + (20.0*float(level));
                                
percent level 25;
                            }
                            case 
3// Taunt
                            
{
                                
range 100.0 + (20.0*float(level));
                                
percent level 5;
                            }
                            case 
4,5// Undisguise, Decloak
                            
{
                                
range 150.0 + (20.0*float(level));
                                
percent level 5;
                            }
                            case 
6// Buff
                            
{
                                
range 150.0 + (50.0*float(level));
                                
percent level 25;
                            }
                            case 
7,8// Krit, Uber
                            
{
                                
range 150.0 + (30.0*float(level));
                                
percent level 15;
                            }
                            default: 
// Jar, Fire
                            
{
                                
range 150.0 + (50.0*float(level));
                                
percent level 25;
                            }
                        }
                        
ConvertToAmplifier(objectclientrangecondition[item], percent);
                    }

            }
    }

Updated for new conditions and to change the waves yellow for conditions that affect enemies instead of allies
Attached Files
File Type: sp Get Plugin or Get Source (Amplifier.sp - 130 views - 28.4 KB)
File Type: inc Amplifier.inc (2.5 KB, 182 views)
File Type: inc remote.inc (11.3 KB, 123 views)
File Type: sp Get Plugin or Get Source (remote.sp - 173 views - 85.1 KB)

Last edited by naris; 06-10-2010 at 00:54.
naris is offline