Check out Half-Life Re-imagined competition results!
Check out Skewing textures in Hammer, our newest tutorial!
Welcome, timadam, our newest member!
Ok, so you want two monsters that are actually a lot alike, for example, Human Grunts and Male Assassins (from Gearbox's Opposing Force) or a scientist in a cleansuit (also from Opposing Force). Well, this is actually really simple even if you have the most basic of C++ knowlege. Now, programming time, let's make a cleansuit scientist. Open up your scientist.cpp file and find the Spawn function of CDeadScientist. After it we want to declare our new scientist, so:
This of course is our class and the functions it has. Notice that it is public CScientist. This gives our CCleanSuitScientist all the same funcions as a normal CScientist. However, we are overriding three of the CScientist functions with our own functions. We need a new Spawn function because this is where the model for the monster is set, and our cleansuit scientist has a cleansuit on, not a normal lab coat. A new Precache is needed because the cleansuits model file is precached here by the engine, and we wouldn't want to precache the wrong model, now would we? Finally, we have an overridden CanHeal function because the normal Opposing Force model doesn't have a needle to even heal you with, so having a cleansuit scientist heal you with nothing wouldn't make sense, right? So, now we need the actual bodies of these functions, which will go right below, but first don't forget the link function which adds your monster to an entity name!
That should do, now for the three functions.
Ok, this is our overridden CanHeal function. It always returns FALSE no matter what, so the scientist will never be able to heal you. Now for the Spawn function.
Notice that it is almost exactly like the normal scientists Spawn function, except we are setting the model to have a different model. Next up is the Precache function!
Again this is almost exactly like the CScientist's Spawn function, but we are precaching our cleansuit model and not the normal scientist model. Oddly enough, thats it! Now you should be able to add in your monster_cleansuit_scientist entry into the .fgd and place him in a map. All should work fine assuming you have the model in your models directory! While this technique seems quite a waste compared too the other shorter method of creating such slightly different monsters, it works. However, I find this method perfect when making things very similar like different zombie types, or perhaps new marine types with different settings and the like. Good luck and good programming! |