Need to start some were in modding right? Why not try the Half-Life modding Kit. This Kit is designed to have all the tools you need to start your own Half-Life mod, simple mods can be made or advance ones like Base Defense with this small set of tools. If you want to start modding Half-Life you should try this.

Post tutorial Report RSS How to Clone any Monster

This is a tutorial on how to clone monsters in gold source, this includes your basic ones like the zombie and your advance ones like the assassins.

Posted by on - Basic Server Side Coding

This is quite a simple thing to do, but time consuming. Even some one who knows nothing about coding could do this. But you need to know a few things

  • First what is cloning? To put it simple it is making a exact replica of a monster. So like if you want another barney because maybe you have another model you want to use you could clone him.
  • What is advance cloning and basic? Basic cloning is cloning were you do not have to mess with a bunch of things. The zombie for example you change a few lines and you are done but the soldier you have to change tasks and schedules
  • A few official NPCS are just clones, like Zombie Barney, Zombie Soldier, Male assassins, Otis

What you need

  • Visual Studio 6 (or another compiler) Google it and you can find it, can't buy it anymore so you have to get it another way, don't worry I won't tell
  • SDK 2.3

To get started open the SDK 2.3 folder and go to dlls

Inside there should be a hl.dsp file (mine looks like a text file) open that up.

Now I prefer to use the Fileview. VS 6 default to class view so over on the left close to the bottom click on File View it will make it a lot easier to find the files we need.

Basic Cloning

For basic Cloning I will teach you how to clone a zombie, so open up zombie.cpp. Copy all the text in zombie.cpp (hit Ctrl + A) Now we need a new file to put that in So go to file, new and make sure to chose C++ Source file (.cpp) You can name it anything it does not matter.

Now if you look at line 37 you should see this class CZombie : public CBaseMonster

The CZombie is what we need to change. Lets change it to CZombieSoldier and use the Zombie Soldier model that came with OP4. Now you need to go through the file and replace all the CZombie with CZombieSoldier, if you miss one your file will not compile. At the bottom there are 2 coded NPCS you can use that I made as an example.

After you replaced all the CZombie with CZombieSoldier go to line 67 and you should see LINK_ENTITY_TO_CLASS( monster_zombie, CZombieSoldier );

Here you need to change the monster_zombie to something you want. this is important however because you will need this to add to the FGD. I will be posting a tutorial on how to add stuff to the FGD Later. So lets make ours monster_zombie_soldier

That is it, you are all done with you zombie clone. If you get a error and it says CZombie in it go the the line number in the () and replace the CZombie with CZombieSoldier

Advance Cloning

This is a lot more frustrating, but don't quit just because you can't do it. One thing you do need to know is when fixing a Advance clones schedules so it will compile is you WILL create more errors. When I coded my Assassin2.cpp I started out with 6 errors and jumped to 22 when I started to work.

We are going to code a Assassin. So open the Assassin.cpp and copy it. Create a new .cpp and paste it

First things first. This takes a LONG time. First you need to Replace all the CAssassin with something new I just used CAssassin2 to make it fast and easy. Now replace the LINK_ENTITY_TO_CLASS(monster_assassin) with something new. Look at the basic cloning if you need help.

Now for the fun part. You need to rename all tasks and schedules. I don't know how to explain what is task and schdule so here are some examples

Original code


Task_t tlAssassinFail[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
{ TASK_WAIT_FACE_ENEMY, (float)2 },
// { TASK_WAIT_PVS, (float)0 },
{ TASK_SET_SCHEDULE, (float)SCHED_CHASE_ENEMY },
};

Schedule_t slAssassinFail[] =
{
{
tlAssassinFail,
ARRAYSIZE ( tlAssassinFail ),
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_PROVOKED |
bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 |
bits_COND_CAN_MELEE_ATTACK1 |
bits_COND_HEAR_SOUND,

bits_SOUND_DANGER |
bits_SOUND_PLAYER,
"AssassinFail"
},
};

New code

Task_t tlAssassin2Fail[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
{ TASK_WAIT_FACE_ENEMY, (float)2 },
// { TASK_WAIT_PVS, (float)0 },
{ TASK_SET_SCHEDULE, (float)SCHED_CHASE_ENEMY },
};

Schedule_t slAssassin2Fail[] =
{
{
tlAssassin2Fail,
ARRAYSIZE ( tlAssassin2Fail ),
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_PROVOKED |
bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 |
bits_COND_CAN_MELEE_ATTACK1 |
bits_COND_HEAR_SOUND,

bits_SOUND_DANGER |
bits_SOUND_PLAYER,
"Assassin2Fail"
},
};

If you need any help private message me or email me at halflifeinfinity@gmail.com

Special thanks to OSIRISGODOFTHEDEAD and Karim for teaching me how to do this and much more

Post comment Comments
D-Wanderer
D-Wanderer - - 136 comments

Thanks for the tutorial. I'm working on a mod where I sure could use some clones of exsisting monsters. Now I know how :) Keep up the good work!

Reply Good karma Bad karma+2 votes
badsniper365 Author
badsniper365 - - 204 comments

Thank you, I found you can make a lot of decent stuff using cloned files. I think I might make a tutorial for cloning weapons next

Reply Good karma+5 votes
CubesProduction
CubesProduction - - 282 comments

where do i save the file?

Reply Good karma Bad karma+1 vote
Sgt.McHale Online
Sgt.McHale - - 303 comments

Life saver.

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: