Adding class based health differences
This is a short tutorial which will allow you to set different health values for different classes in your mod. Since I'm new to this tutorial business, this might make little sense. Feel free to tidy it up, post bug fixes and ask questions on the talk page. --Welsh Mullet 20:24, 14 February 2011 (UTC)
This tutorial is designed to work on the SDK template mod, on the 2007 base.
Open the solution in a C++ editor of your choise.
Edits are made to sdk_shareddefs.h, sdk_gamerules.cpp, sdk_playerclass_info_parse.cpp (and .h) and sdk_player_shared.h
sdk_player_shared.h: Add
[code]int m_iHealth; int m_iMaxHealth;[/code]
at around line 128, just after some stuff about sprinting.
sdk_gamerules.cpp: Add [code]pPlayer->SetHealth(pClassInfo.m_iHealth); pPlayer->SetMaxHealth(pClassInfo.m_iMaxHealth);[/code] at about line 705, just after the players armour is also set in a similar way.
sdk_shareddefs.h: Add [code]#define SDK_DEFAULT_PLAYER_HEALTH 100
- define SDK_DEFAULT_PLAYER_MAXHEALTH 100[/code]
at line 138, around where the default runspeeds are declaired as well.
sdk_playerclass_info_parse.cpp: Add
[code]m_iHealth = pKeyValuesData->GetInt( "health", 0); m_iMaxHealth = pKeyValuesData->GetInt( "maxhealth", 0);[/code] at line 136, just after m_iArmor.
sdk_playerclass_info_parse.h: Add
[code]int m_iHealth;
int m_iMaxHealth;[/code]
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)
Pictures to come soon~!