Zombie AI to custom npc

  • Thread starter Thread starter EImo
  • Start date Start date
E

EImo

Guest
Hello.
We are making a mod to hl2sp. We are using our own models and animations for npc enemies.

We don't really have a coder so i'm trying to work out how to clone npc_zombie's AI to our own npc. I have some basic knowledge how c++ works (I understand it a bit but can't really create anything new with it).

I have managed to compile animations and ragdoll with our model. In game it plays idle animation, plays Tantrum when sees player and attacks when player comes near. However, he won't move.

Way I made it work was a bit "cheap" I'd guess :P I compiled the npc as "zombie/classic.mdl" and it appeared in hammer when we created "npc_zombie" entity there.

I managed to get rid of zombies legs and torso by editing npc_zombie.cpp.
So It won't split up when he dies from explosion.

I have tried to compile our npc with his real name "boy.mdl" and copy npc_zombie.cpp and rename it npc_boy.cpp. The problem is that Hammer can't find it.

So what I want to know is how to get zombie's AI to our npc and how to get it in Hammer.

And last little thing. Does the naming of bones have effect on cloning the AI. Since we named the bones in Motionbuilder-way (Hips, Spine, Spine1...).

Thanks for reading. I hope we can solve this since there is a bit of Source-honor in line :P This mod is a project in our school. We could choose if we wanted to use Source or Unreal-editor. And we chose Source, luckily...
 
Did you also change the entity name from "npc_zombie" to "npc_boy"? if so, you have to write your own .fgd file. This is easy. You just go to D:\Program Files\Valve\Steam\SteamApps\[username]\sourcesdk\bin and make a copy of halflife2.fgd and rename it to yourmodname.fgd. Then you open it and search for "npc_zombie" for example. You should find

@NPCClass base(BaseNPC) studio("models/Zombie/Classic.mdl") = npc_zombie : "Zombie"
[
]

then you rewrite that, or make a copy of it to:

@NPCClass base(BaseNPC) studio("models/boy.mdl") = npc_boy : "Boy"
[
]

Then in Hammer you go to Options and change the game data file from halflife2.fgd to yourmodname.fgd

In your npc_boy.cpp you also naturall have to precache and set the model as "models/boy.mdl".

If the model isn't moving there's probably something wrong with your walking/running animations.


One other thing, the zombie model also has the submodel of the headcrab. This is set off and on when the zombie dies and the headcrab jumps away. If your model doesn't have a submodel, or you don't want your npc to have this ability, then you probably have to remove this part of the code as well.
 
Uhhh...what he said ^

i look at scripting at its like looking at the american language : makes no sense.


*oooooooh low blow!*
 
Thanks for reply. I did what You told and it worked fine until I tried to run the game. The Boy doesn't show up and when I check the console, It says:

Attemted to create unknown entity type npc_boy!
Can't init npc_boy

I've been looking for a solution from other ccp and h files in project.
But now i'm helpless.
Any help would be appriciated.
Thanks for advance.
 
Back
Top