Adding class based health differences: Difference between revisions
Welsh Mullet (talk | contribs) m (having fun finding out code tags don't work) |
No edit summary |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This is a short tutorial which will allow you to set different health values for different classes in your mod. | {{orphan}} | ||
{{cleanup}} | |||
This is a short tutorial which will allow you to set different [[health]] values for different classes in your mod. This will create a system very similar to that used in [[Team Fortress 2]] and other class-based games to great effect. | |||
Higher health can be balanced against lower speeds and used to create a unique class-based multiplayer experience. | |||
Open the solution in a C++ editor of your | ---- | ||
This tutorial is designed to work on the [[SDK]] template mod, on the 2007 base, as this version already has many class based systems implemented. Modification to work on other bases could be done, but it would be complicated as other systems would need to be implemented first. | |||
Only a basic understanding of C++ is required for this tutorial. | |||
Open the solution in a C++ editor of your choice. | |||
Edits are made to sdk_shareddefs.h, sdk_gamerules.cpp, sdk_playerclass_info_parse.cpp (and .h) and sdk_player_shared.h | 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 | '''sdk_player_shared.h:''' | ||
Add | |||
int m_iHealth; | int m_iHealth; | ||
Line 16: | Line 24: | ||
at around line 128, just after some stuff about sprinting. | at around line 128, just after some stuff about sprinting. | ||
sdk_gamerules.cpp: Add | '''sdk_gamerules.cpp:''' | ||
Add | |||
pPlayer->SetHealth(pClassInfo.m_iHealth); | pPlayer->SetHealth(pClassInfo.m_iHealth); | ||
Line 23: | Line 32: | ||
at about line 705, just after the players armour is also set in a similar way. | at about line 705, just after the players armour is also set in a similar way. | ||
sdk_shareddefs.h: Add | |||
'''sdk_shareddefs.h:''' | |||
Add | |||
#define SDK_DEFAULT_PLAYER_HEALTH 100 | #define SDK_DEFAULT_PLAYER_HEALTH 100 | ||
Line 30: | Line 41: | ||
at line 138, around where the default runspeeds are declaired as well. | at line 138, around where the default runspeeds are declaired as well. | ||
sdk_playerclass_info_parse.cpp: Add | '''sdk_playerclass_info_parse.cpp:''' | ||
Add | |||
m_iHealth = pKeyValuesData->GetInt( "health", 0); | m_iHealth = pKeyValuesData->GetInt( "health", 0); | ||
Line 38: | Line 50: | ||
sdk_playerclass_info_parse.h: Add | '''sdk_playerclass_info_parse.h:''' | ||
Add | |||
int m_iHealth; | int m_iHealth; | ||
Line 49: | Line 62: | ||
"health" and "maxhealth" to your class scripts (These work the same as armour) | "health" and "maxhealth" to your class scripts (These work the same as armour) | ||
[[Category:Tutorials]] | |||
[[Category:Programming]] |
Latest revision as of 18:07, 13 March 2011

You can help by


For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
This is a short tutorial which will allow you to set different health values for different classes in your mod. This will create a system very similar to that used in Team Fortress 2 and other class-based games to great effect.
Higher health can be balanced against lower speeds and used to create a unique class-based multiplayer experience.
This tutorial is designed to work on the SDK template mod, on the 2007 base, as this version already has many class based systems implemented. Modification to work on other bases could be done, but it would be complicated as other systems would need to be implemented first.
Only a basic understanding of C++ is required for this tutorial.
Open the solution in a C++ editor of your choice.
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
int m_iHealth; int m_iMaxHealth;
at around line 128, just after some stuff about sprinting.
sdk_gamerules.cpp: Add
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
#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
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
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)