Introduction to Half Life 2 Modding Seminar Eight

  • Slides: 7
Download presentation
Introduction to Half Life 2 Modding ● Seminar Eight – The story so far:

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

Starting point ● Files available from http: //www. hidden-source. com/downloads/itemcode. zip – Includes example

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

Making a Quad. Damage pickup ● The theory: – Once the player touches our

Making a Quad. Damage 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

Making a Quad. Damage pickup ● The practice – Adding a flag to the

Making a Quad. Damage pickup ● The practice – Adding a flag to the player ● Open hl 2 mp_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_b. Quad; // public class members can be accessed from anywhere (inside or out of the class) public: // Is. Quadded returns a boolean value bool Is. Quadded() { return m_b. Quad; } // Set. Quad takes a boolean but doesn't return anything at all void Set. Quad(bool value) { m_b. Quad = value; }

Making a Quad. Damage pickup ● Multiplying the damage – In hl 2 mp_player.

Making a Quad. Damage pickup ● Multiplying the damage – In hl 2 mp_player. cpp find On. Take. Damage ● Insert the following before the return statement: // cast from CBase. Entity to CHL 2 MP_Player *p. Attacker = dynamic_cast(input. Info. Get. Attacker()); // check pointer validity if ( p. Attacker ) { // copy input. Info CTake. Damage. Info new. Info = input. Info; // multiply the damage value by 4. new. Info. Set. Damage(new. Info. Get. Damage() * 4. 0 f); } // replace the standard return with our new multipled damage version return Base. Class: : On. Take. Damage( new. Info );

Making a Quad. Damage pickup ● Final touches – Ensure the player can't spawn

Making a Quad. Damage pickup ● Final touches – Ensure the player can't spawn with the quad damage effect ● In CHL 2 MP_Player: : Spawn – – Activate the effect when we pickup the quad damage item ● ● – Set m_b. Quad to false ( Set. Quad(false) ) Put the following code into our items “My. Touch” function before the return call // set the players quad flag to true. p. HL 2 Player->Set. Quad(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!

Expanding on the pickup ● How you could expand this system: – Setup a

Expanding on the pickup ● How you could expand this system: – Setup a timer (look at CHL 2 MP_Player: : Post. Think) to control the duration of the quad effect ● gp. Globals->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 Post. Think 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!