Raised This Month: $ Target: $400
 0% 

[TF2] Change specific class size/health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SPYderman
Senior Member
Join Date: Aug 2013
Old 03-18-2014 , 19:32   [TF2] Change specific class size/health
Reply With Quote #1

So currently I'm learning a bit of SourcePawn and have came up with a couple, very simple plugins for what I have planned in mind. However, I haven't gotten that far to knowing how to make the plugin I am requesting.

I am requesting a plugin that will increase the size of the classes Scout, Demoman, and HeavyWeapons by 2.0 (pretty sure this is the size of MVM giants, which is what I need), and I also would like their health increased by x10 (I don't want this acting like a medic overheal buff where it decreases over time). If someone could set up the plugin like this, I could possibly edit the plugin myself if needed to.

I'm not that big on money right now, so if anyone could do this for free that would be great, thanks.
SPYderman is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-28-2014 , 14:19   Re: [TF2] Change specific class size/health
Reply With Quote #2

Hey ! I hope it's not too late but here, you have a good start.

It does do all what you ask, BUT there is so small 'bugs'.
I'm pretty sure you know how to fix them if you understand this code.

PHP Code:
#include <sourcemod>
#include <tf2attributes>
//THIS. IS. LIFE! tf2attributes == EVERYTHING!, you can add/remove/edit any of the attrbiuts here : http://wiki.teamfortress.com/wiki/List_of_item_attributes !!!
#include <tf2>
#include <tf2_stocks>

//Those are needed in all plugin, they give some usefull infos. 
public Plugin:myinfo =  
{  
    
name "Resize And Add Health (RAAH)",                                         //Name of plugin
    
author "Arkarr",                                                          //Auhtor of the plugin
    
description "Resize and add healht on spawn, based on player classe.",      //Description, you should write something good here. (Not like me :3)
    
version "1.0",                                                             //Version of the plugin, don't forget to change it every update !  
    
url "http://www.sourcemod.net/"                                              //Your custom url ?
}; 

//In this bloc, you usually create your command, cvar and your event hook...
public OnPluginStart()  
{        
    
//RegAdminCmd("sm_a_command_name", CMD_TEST, ADMFLAG_CHEATS, "A test command."); We don't need a command, just in case if you need a exemple in the future.
    
    //Hooking the event "player_spawn", all TF2 event can be found here https://wiki.alliedmods.net/Team_Fortress_2_Events :
    
HookEvent("player_spawn"Event_PlayerRespawn);
}

/*public Action:CMD_TEST(client, args)
{
    PrintToChat(client, "test :D !");
}*/

public Action:Event_PlayerRespawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//First, we grab the client (player) ID, now we can target action on him :
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
    
//And now, we should grab is class :
    
new TFClassType:PlayerClass TF2_GetPlayerClass(client);
    
    
//And test it if he is as Scout, Demoman or Heavy :
    
if(PlayerClass == TFClass_DemoMan || PlayerClass == TFClass_Scout || PlayerClass == TFClass_Heavy)
    {
        
//If he his, then set is size to 2.0 and multiplie his health by 10 :
        
        //Yep, setting the size of the model is that simple :) :
        
SetEntPropFloat(clientProp_Send"m_flModelScale"2.0);
        
        
//For setting the health * 10, we should get the actual health first :
        
new actual_health GetClientHealth(client);
        
        
//TF2Attrib_SetByName only account 'Float' as value, so we should convert actual_health (int) as float using the stock float() + multiplie it by 10
        
new Float:multiplied_health float(actual_health)*10.0;
        
        
TF2Attrib_SetByName(client"max health additive bonus"multiplied_health);
    }
    else
    {
        
//Otherwise, reset value to default :
        
SetEntPropFloat(clientProp_Send"m_flModelScale"1.0);
        
        
TF2Attrib_RemoveByName(client"max health additive bonus");
    }
    
    return 
Plugin_Continue;

This should help you a bit, ask me if you don't understand something...
__________________
Want to check my plugins ?

Last edited by Arkarr; 03-28-2014 at 14:21.
Arkarr is offline
SPYderman
Senior Member
Join Date: Aug 2013
Old 03-28-2014 , 23:16   Re: [TF2] Change specific class size/health
Reply With Quote #3

Quote:
Originally Posted by Arkarr View Post
Hey ! I hope it's not too late but here, you have a good start.

It does do all what you ask, BUT there is so small 'bugs'.
I'm pretty sure you know how to fix them if you understand this code.

PHP Code:
#include <sourcemod>
#include <tf2attributes>
//THIS. IS. LIFE! tf2attributes == EVERYTHING!, you can add/remove/edit any of the attrbiuts here : http://wiki.teamfortress.com/wiki/List_of_item_attributes !!!
#include <tf2>
#include <tf2_stocks>
 
//Those are needed in all plugin, they give some usefull infos. 
public Plugin:myinfo =  
{  
    
name "Resize And Add Health (RAAH)",                                         //Name of plugin
    
author "Arkarr",                                                          //Auhtor of the plugin
    
description "Resize and add healht on spawn, based on player classe.",      //Description, you should write something good here. (Not like me :3)
    
version "1.0",                                                             //Version of the plugin, don't forget to change it every update !  
    
url "http://www.sourcemod.net/"                                              //Your custom url ?
}; 
 
//In this bloc, you usually create your command, cvar and your event hook...
public OnPluginStart()  
{        
    
//RegAdminCmd("sm_a_command_name", CMD_TEST, ADMFLAG_CHEATS, "A test command."); We don't need a command, just in case if you need a exemple in the future.
 
    //Hooking the event "player_spawn", all TF2 event can be found here https://wiki.alliedmods.net/Team_Fortress_2_Events :
    
HookEvent("player_spawn"Event_PlayerRespawn);
}
 
/*public Action:CMD_TEST(client, args)
{
    PrintToChat(client, "test :D !");
}*/
 
public Action:Event_PlayerRespawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//First, we grab the client (player) ID, now we can target action on him :
    
new client GetClientOfUserId(GetEventInt(event"userid"));
 
    
//And now, we should grab is class :
    
new TFClassType:PlayerClass TF2_GetPlayerClass(client);
 
    
//And test it if he is as Scout, Demoman or Heavy :
    
if(PlayerClass == TFClass_DemoMan || PlayerClass == TFClass_Scout || PlayerClass == TFClass_Heavy)
    {
        
//If he his, then set is size to 2.0 and multiplie his health by 10 :
 
        //Yep, setting the size of the model is that simple :) :
        
SetEntPropFloat(clientProp_Send"m_flModelScale"2.0);
 
        
//For setting the health * 10, we should get the actual health first :
        
new actual_health GetClientHealth(client);
 
        
//TF2Attrib_SetByName only account 'Float' as value, so we should convert actual_health (int) as float using the stock float() + multiplie it by 10
        
new Float:multiplied_health float(actual_health)*10.0;
 
        
TF2Attrib_SetByName(client"max health additive bonus"multiplied_health);
    }
    else
    {
        
//Otherwise, reset value to default :
        
SetEntPropFloat(clientProp_Send"m_flModelScale"1.0);
 
        
TF2Attrib_RemoveByName(client"max health additive bonus");
    }
 
    return 
Plugin_Continue;

This should help you a bit, ask me if you don't understand something...
Oh wow, someone actually replied, thanks, I was beginning to think this was dead. But my only problem is that I have never tried compiling a plugin that requires another one, help for that would be nice.

EDIT: Nevermind, I found out how because experimenting is awesome - testing now.

EDIT 2: Tested it, I just need the following bugs fixed:
- Players getting unlimited health after death/round end/etc. regardless of class.
That's it. I noticed players will die when they take fall damage, that's something I don't need fixed. I was able to understand the code but not in a way where I know how to fix the issue with health. I also have a couple of other minor requests if you're willing to do them for me, I think I'd be nearly done.

Last edited by SPYderman; 03-28-2014 at 23:56.
SPYderman is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-29-2014 , 05:38   Re: [TF2] Change specific class size/health
Reply With Quote #4

Quote:
Originally Posted by SPYderman View Post
Oh wow, someone actually replied, thanks, I was beginning to think this was dead. But my only problem is that I have never tried compiling a plugin that requires another one, help for that would be nice.

EDIT: Nevermind, I found out how because experimenting is awesome - testing now.

EDIT 2: Tested it, I just need the following bugs fixed:
- Players getting unlimited health after death/round end/etc. regardless of class.
That's it.
I noticed players will die when they take fall damage, that's something I don't need fixed. I was able to understand the code but not in a way where I know how to fix the issue with health. I also have a couple of other minor requests if you're willing to do them for me, I think I'd be nearly done.
EDIT 1 : Yup, sorry, I forget to say that you need to compille it manually (sourcemod/scripting/compille.exe, drag&drop the sp file into this exe) and put the correct include files (in this case, tf2attributes.inc) in the include folder (sourcemod/scripting/include).

EDIT 2 : Hum ? When I tested it, it does simply overheal me if my class wasn't Scout, Demoman or Heavy. In this case you should simply add TF2_RegeneratePlayer(client); after TF2Attrib_RemoveByName(client, "max health additive bonus");.
So, it should be something like this :
PHP Code:
else
    {
        
//Otherwise, reset value to default :
        
SetEntPropFloat(clientProp_Send"m_flModelScale"1.0);
 
        
TF2Attrib_RemoveByName(client"max health additive bonus");

        
TF2_RegeneratePlayer(client);
    } 
Request : I'm gonna HELP you but NOT doing this for you, you should learn a bit too
__________________
Want to check my plugins ?
Arkarr is offline
SPYderman
Senior Member
Join Date: Aug 2013
Old 03-29-2014 , 13:50   Re: [TF2] Change specific class size/health
Reply With Quote #5

Quote:
Originally Posted by Arkarr View Post
EDIT 1 : Yup, sorry, I forget to say that you need to compille it manually (sourcemod/scripting/compille.exe, drag&drop the sp file into this exe) and put the correct include files (in this case, tf2attributes.inc) in the include folder (sourcemod/scripting/include).

EDIT 2 : Hum ? When I tested it, it does simply overheal me if my class wasn't Scout, Demoman or Heavy. In this case you should simply add TF2_RegeneratePlayer(client); after TF2Attrib_RemoveByName(client, "max health additive bonus");.
So, it should be something like this :
PHP Code:
else
    {
        
//Otherwise, reset value to default :
        
SetEntPropFloat(clientProp_Send"m_flModelScale"1.0);
 
        
TF2Attrib_RemoveByName(client"max health additive bonus");
 
        
TF2_RegeneratePlayer(client);
    } 
Request : I'm gonna HELP you but NOT doing this for you, you should learn a bit too
Sounds like an efficient idea, would help a lot. As of now, I'm working on a timer plugin for these classes. Will test as soon as I'm done with other activities. Thanks!
SPYderman is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-29-2014 , 14:03   Re: [TF2] Change specific class size/health
Reply With Quote #6

Quote:
Originally Posted by SPYderman View Post
Sounds like an efficient idea, would help a lot. As of now, I'm working on a timer plugin for these classes. Will test as soon as I'm done with other activities. Thanks!
You welcome. Anyway, if you have any other ask, I will be really happy if I could answers them.
__________________
Want to check my plugins ?
Arkarr is offline
SPYderman
Senior Member
Join Date: Aug 2013
Old 03-30-2014 , 19:21   Re: [TF2] Change specific class size/health
Reply With Quote #7

Quote:
Originally Posted by Arkarr View Post
You welcome. Anyway, if you have any other ask, I will be really happy if I could answers them.
So it has stopped the health keep after switching classes and such, however it still gives the giants unlimited health (100k+...) after respawn. First try picking the class it gives you normal health. I've tried a couple things but it didn't work.
SPYderman is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-31-2014 , 16:05   Re: [TF2] Change specific class size/health
Reply With Quote #8

Quote:
Originally Posted by SPYderman View Post
So it has stopped the health keep after switching classes and such, however it still gives the giants unlimited health (100k+...) after respawn. First try picking the class it gives you normal health. I've tried a couple things but it didn't work.
GetClientHealth isn't necessarily the best thing to use here. I'd highly recommend using the netprops of the player resource entity... such as this:

PHP Code:
#include <sdktools>

    
new resource GetPlayerResourceEntity();
    new 
actual_health GetEntProp(resourceProp_Send"m_iMaxHealth"_client);
    new 
Float:multiplied_health float(actual_health)*9.0// 9 because this is being added to the current health, so 9+1 = 10. 
The other catch is that health setting REALLY needs to be done in the post_inventory_application event handler, not player_spawn. This is because player health is adjusted by equipped items, so reading their max health will be wrong until item calculations are finished.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 03-31-2014 at 16:10.
Powerlord is offline
SPYderman
Senior Member
Join Date: Aug 2013
Old 04-11-2014 , 23:08   Re: [TF2] Change specific class size/health
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
GetClientHealth isn't necessarily the best thing to use here. I'd highly recommend using the netprops of the player resource entity... such as this:

PHP Code:
#include <sdktools>
 
    
new resource GetPlayerResourceEntity();
    new 
actual_health GetEntProp(resourceProp_Send"m_iMaxHealth"_client);
    new 
Float:multiplied_health float(actual_health)*9.0// 9 because this is being added to the current health, so 9+1 = 10. 
The other catch is that health setting REALLY needs to be done in the post_inventory_application event handler, not player_spawn. This is because player health is adjusted by equipped items, so reading their max health will be wrong until item calculations are finished.
Thanks Powerlord, post_inventory_application seemed to have done the trick.
SPYderman 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 21:47.


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