Adjust/Increase health

Got problems with your models? Struggling with textures? Get help with your custom assets.

Adjust/Increase health

Postby v1ruZ on Sat Feb 12, 2011 5:07 pm

Hey!
How do I increase the players health? The mod is using classes, I only want to adjust 1 of the classes.
Thanks :)
Image
v1ruZ
Member
Member
 
Joined: Sat Dec 04, 2010 5:18 pm

Re: Adjust/Increase health

Postby Welsh Mullet on Sat Feb 12, 2011 5:51 pm

Have a look at how classes are done in the sdk template mod. They allow for changes of health, armour and moove speed based on class.
That's what she said.
User avatar
Welsh Mullet
Regular
Regular
 
Joined: Mon Jul 12, 2010 10:37 am
Location: Reading... Or sometimes Wales for the weekend.

Re: Adjust/Increase health

Postby v1ruZ on Sat Feb 12, 2011 5:56 pm

Welsh Mullet wrote:Have a look at how classes are done in the sdk template mod. They allow for changes of health, armour and moove speed based on class.


They allow changes for armor, move speed, and such, but not health :(
Must be somewhere in the code, I can add it
Image
v1ruZ
Member
Member
 
Joined: Sat Dec 04, 2010 5:18 pm

Re: Adjust/Increase health

Postby Jman on Sat Feb 12, 2011 9:49 pm

Find where the speed/armor, etc are declared/defined and add your own function like SetPlayerHealth that edits the m_iHealth and m_iMaxHealth variables of the player.
User avatar
Jman
Veteran
Veteran
 
Joined: Wed Mar 30, 2005 11:01 pm

Re: Adjust/Increase health

Postby Welsh Mullet on Sun Feb 13, 2011 1:19 am

I'll look into it as soon as i get my c++ working.
You are building a mod on the sdk template? I would be interested to hear of your experiance and code changes so far, as i am building a mod creation application using the sdk template.

EDIT: Right, i think we should be looking at sdk_playerclass_info_parse.h and sdk_playerclass_info_parse.cpp
I'm trying adding some health code now. Obviously you'll also need to add health info to the class scripts as well.
That's what she said.
User avatar
Welsh Mullet
Regular
Regular
 
Joined: Mon Jul 12, 2010 10:37 am
Location: Reading... Or sometimes Wales for the weekend.

Re: Adjust/Increase health

Postby Jman on Sun Feb 13, 2011 3:34 am

When I added a SetHealth/MaxHealth function I just added it to hl2mp_player, though I'm not running playerclasses.
User avatar
Jman
Veteran
Veteran
 
Joined: Wed Mar 30, 2005 11:01 pm

Re: Adjust/Increase health

Postby Welsh Mullet on Sun Feb 13, 2011 3:45 am

Jman, would you be willing to share your function?
Then it would just need to be edited to read in the variables from the class scripts.
That's what she said.
User avatar
Welsh Mullet
Regular
Regular
 
Joined: Mon Jul 12, 2010 10:37 am
Location: Reading... Or sometimes Wales for the weekend.

Re: Adjust/Increase health

Postby Jman on Sun Feb 13, 2011 4:56 am

Code: Select all
void CHL2MP_Player::SetHealthValue( int value )
{
   m_iHealth = value;
}


// Max Health Settings.
void CHL2MP_Player::SetMaxHealthValue( int MaxHealthValue )
{
   m_iMaxHealth = MaxHealthValue;
}
User avatar
Jman
Veteran
Veteran
 
Joined: Wed Mar 30, 2005 11:01 pm

Re: Adjust/Increase health

Postby Welsh Mullet on Sun Feb 13, 2011 5:36 pm

Just testing some code now
EDIT: Got it working :3
I'll upload all the changes later.
On a side note, does anyone know why my open develouper console is bugged in the template?
That's what she said.
User avatar
Welsh Mullet
Regular
Regular
 
Joined: Mon Jul 12, 2010 10:37 am
Location: Reading... Or sometimes Wales for the weekend.

Re: Adjust/Increase health

Postby zombie@computer on Mon Feb 14, 2011 1:34 pm

what developer console what bug what template?
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Adjust/Increase health

Postby Welsh Mullet on Mon Feb 14, 2011 3:13 pm

My `button (The button used to open the console) is acting wierd, i don't think it's the mod itself. It's kinda sticking and if the next key is a vowel, it gives it an accent ie, ìàòùỳ. If its not a vowel, it closes the console.
That's what she said.
User avatar
Welsh Mullet
Regular
Regular
 
Joined: Mon Jul 12, 2010 10:37 am
Location: Reading... Or sometimes Wales for the weekend.

Re: Adjust/Increase health

Postby zombie@computer on Mon Feb 14, 2011 4:28 pm

thats because of your language settings (in windows). In languages with many ìàòùỳ's this is a preferred setting because they are easy to set up. You will also notice the same effect for ' (é) and "(ë).
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Adjust/Increase health

Postby Welsh Mullet on Mon Feb 14, 2011 5:32 pm

Ta Zombie, i had UK extended instead of UK. Stupid dead keys....
Anyway, now that's fixed, the code will be up tonight
That's what she said.
User avatar
Welsh Mullet
Regular
Regular
 
Joined: Mon Jul 12, 2010 10:37 am
Location: Reading... Or sometimes Wales for the weekend.

Re: Adjust/Increase health

Postby zombie@computer on Mon Feb 14, 2011 7:08 pm

Welsh Mullet wrote:Ta Zombie, i had UK extended instead of UK. Stupid dead keys....
Anyway, now that's fixed, the code will be up tonight

Yeah, its stupid. Whats even more stupid is that Valve apparently never heard of this, making quick access and entering commands in source's console impossible. (since you cant change the ~ to another key).
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Adjust/Increase health

Postby Welsh Mullet on Mon Feb 14, 2011 8:16 pm

Right, heres the code.
Edits are made to sdk_shareddefs.h, sdk_gamerules.cpp, sdk_playerclass_info_parse.cpp (and .h) and sdk_player_shared.h

WARNING!!!
My bots are now bugged, but i'm not sure if it was this code edit that did it. This was written on a late night coding stint and is not fully tested, but does seem to do exactly what you wanted to do.

sdk_player_shared.h: Add

Code: Select all
int m_iHealth;
   int m_iMaxHealth;


at around line 128, just after some stuff about sprinting.

sdk_gamerules.cpp: Add
Code: Select all
pPlayer->SetHealth(pClassInfo.m_iHealth);
   pPlayer->SetMaxHealth(pClassInfo.m_iMaxHealth);

at about line 705, just after the players armour is also set in a similar way.

sdk_shareddefs.h: Add
Code: Select all
#define SDK_DEFAULT_PLAYER_HEALTH         100
#define   SDK_DEFAULT_PLAYER_MAXHEALTH      100


at line 138, around where the default runspeeds are declaired as well.

sdk_playerclass_info_parse.cpp: Add

Code: Select all
m_iHealth         = pKeyValuesData->GetInt( "health", 0);
   m_iMaxHealth      = pKeyValuesData->GetInt( "maxhealth", 0);

at line 136, just after m_iArmor.


sdk_playerclass_info_parse.h: Add
Code: Select all
int m_iHealth;
   int m_iMaxHealth;

at line 50 ish, also after m_iArmor.


Now you need to add the lines
"health" and "maxhealth" to your class scripts (These work the same as armour)

Just let me know of any problems, and i can try and sort them out.
That's what she said.
User avatar
Welsh Mullet
Regular
Regular
 
Joined: Mon Jul 12, 2010 10:37 am
Location: Reading... Or sometimes Wales for the weekend.
Next

Return to Custom Asset Help

Who is online

Users browsing this forum: No registered users