Check out Half-Life Re-imagined competition results!
Check out Skewing textures in Hammer, our newest tutorial!
Say hello to timadam, our newest member!
Well about a week ago I got my MSVC++ and decided to finally start tweaking the HL code. I came up with a simple first project, creating the Atomic Houndeye and making its very own entry in the fgd. Here's all it takes: The first and foremost thing to do is to find the file which contains the functions for our little friend - the houndeye - which so happens to be in houndeye.cpp. Now, around line 19 you will find the code for all the imports. It should look like this:
In order to get an explosion into the otherwise feeble houndeye, we must add one additional import:
Pretty self explanatory, right? Next, we must find the declaration of the function SonicAttack(), it should be located around line 93 and should look like:
Now, in order to alter this function in the new entity class (discussed later), you must add the virtual tag to this function so that it can be over ridden. It should now resemble this:
Now to making our very own houndeye. First, you should probably jump down to the bottom of the file for this part, so as to keep it seperated from the rest of the code and easier to find. In order to make our new class, you must extend the old CHoundeye class and declare it to override the SonicAttack() function and link it to its own entity name. The code should look something like this:
That was probably the hardest part to this. The next step is to begin the definition of your new SonicAttack() function It should look pretty much the same as this:
Then for its definition, you first must copy and paste the original SonicAttack() code for the new SonicAttack() Function. This code can be found at approximately line 560 and goes to about line 670. Don't worry about the size, there are a lot of braces and we are only concerned with a small portion of the entire block. After you paste the code in, you need to find the section in which damage is dealt to the player/entity. It should look like:
What's great about this is that you don't have to recalculate the area of effect, as the sonic attack itself has already done that for you. So all we must add is the explosion. And that goes right after the TakeDamage call, like this:
The function parameters are as follows:
All of the parameters are pretty self explanatory. Because of the nature of this function, angles is unused and has no effect on the outcome. The edict() function retuns an edict_s, which carries various information pertinent to the houndeye itself. The edict_s definition can be found in engine\edict.h. The final step before we move onto the FGD is to make our brand new monster immune to its own attack.... We don't want it to kill itself, now do we? In order for all houndeyes not to hurt each other, there is a second condition you must add to two separate, yet identical if statements. These can be found at around lines 622 and 1385. You will see the following if statement:
This is how it determines whether or not the entity in question is a houndeye. Now, to include our new friend to this, we must add a new condition. The final condition should look like this:
There, you now have a brand new Atomic Houndeye that won't hurt itself or other houndeyes with its sonic attack. Now onto the FGD. First,find the definition of the houndeye in the FGD. This can be done with a simple find for "houndeye". Now you copy and paste the entire code right below it. The only thing we are going to change is the very first line, and this will be done as follows:
And there you have it, save the changes to the FGD, load it into Hammer and you're ready to go. You may want to play around with the actual magnitude of the blast, but I found 3x its normal damage is a good number - just watch out for 'em in packs. Things to watch out for: Other Uses For this: In addition, I have included a new, working fgd, hl.dll, and houndeye.cpp for your viewing pleasure. |