Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Half Life 2 Modding ● Seminar Eight – The story so far: ● Creating a mod via Source SDK ● Introduction to Hammer ● Hammer techniques ●

Similar presentations


Presentation on theme: "Introduction to Half Life 2 Modding ● Seminar Eight – The story so far: ● Creating a mod via Source SDK ● Introduction to Hammer ● Hammer techniques ●"— Presentation transcript:

1 Introduction to Half Life 2 Modding ● Seminar Eight – The story so far: ● Creating a mod via Source SDK ● Introduction to Hammer ● Hammer techniques ● Importing custom art content ● Starting with code manipulation – This week: ● Adding an item via code

2 Starting point ● Files available from http://www.hidden-source.com/downloads/itemcode.zip http://www.hidden-source.com/downloads/itemcode.zip – Includes example code for adding an item ● Create a new folder in the 'dlls' folder of the source directory – place the cpp file there. – Add the file to the server project – Also includes models, materials and an FGD ● What else could this code be used for? – 'Relic' style pickups? – QuadDamage? ● We'll look at making a QuadDamage pickup

3 Making a QuadDamage pickup ● The theory: – Once the player touches our pickup we want to set a flag so that any further damage done by that player is multiplied ● We need a way of setting a flag ● We need a way of checking for the flag when damage is caused ● If the flag is set, we need to multiply the damage done

4 Making a QuadDamage pickup ● The practice – Adding a flag to the player ● Open hl2mp_player.h and put the following below the line that reads “DECLARE_DATADESC” // private class members cannot be accessed from outside the class private: // bool variables are either true or false (boolean values) bool m_bQuad; // public class members can be accessed from anywhere (inside or out of the class) public: // IsQuadded returns a boolean value bool IsQuadded() { return m_bQuad; } // SetQuad takes a boolean but doesn't return anything at all void SetQuad(bool value) { m_bQuad = value; }

5 Making a QuadDamage pickup ● Multiplying the damage – In hl2mp_player.cpp find OnTakeDamage ● Insert the following before the return statement: // cast from CBaseEntity to CHL2MP_Player CHL2MP_Player *pAttacker = dynamic_cast (inputInfo.GetAttacker()); // check pointer validity if ( pAttacker ) { // copy inputInfo CTakeDamageInfo newInfo = inputInfo; // multiply the damage value by 4. newInfo.SetDamage(newInfo.GetDamage() * 4.0f); // replace the standard return with our new multipled damage version return BaseClass::OnTakeDamage( newInfo ); }

6 Making a QuadDamage pickup ● Final touches – Ensure the player can't spawn with the quad damage effect ● In CHL2MP_Player::Spawn – Set m_bQuad to false ( SetQuad(false) ) – Activate the effect when we pickup the quad damage item ● Put the following code into our items “MyTouch” function before the return call ● // set the players quad flag to true. pHL2Player->SetQuad(true); – Create a suitable entry in the FGD file (use the flag example as a basis) remember to add the FGD when you open hammer!

7 Expanding on the pickup ● How you could expand this system: – Setup a timer (look at CHL2MP_Player::PostThink) to control the duration of the quad effect ● gpGlobals->curtime will give you the current time – You could store a time value when the quad is collected (current time + duration) and compare that against the current time in PostThink – Make more pickup items that have different effects ● Increase health, boost speed, reduce damage (this ones easy!) ● Create custom art content for each pickup you make!


Download ppt "Introduction to Half Life 2 Modding ● Seminar Eight – The story so far: ● Creating a mod via Source SDK ● Introduction to Hammer ● Hammer techniques ●"

Similar presentations


Ads by Google