|
Feedback
If you've got any feedback, suggestions, or bugs to report regarding the Collective website, go here!
Feedback (301)
|
|
|
|
|
|
recent articles
NPC and Item Placement Theory
17/03/05 11:35pm PST
Non-Player Character (NPC) and item placement can influence both the gameflow and immersion of a level. This article aims to give some pointers on how to properly place them.
- Hugh 'Hugh' Lloyd
|
|
Got Props?
13/03/05 08:32am PST
A common problem in HL2 mapping is props not showing up in game. This article explains why and offers solutions.
- Jeff 'Yesukai' Pritchard
|
|
Simulating Randomness
18/12/04 11:29pm PST
This article focuses on how to properly simulate random events that should occur at a certain average frequency, or within a certain probability per period of time.
- Skyler 'Zipster' York
|
|
Your world in HL2
06/12/04 12:17am PST
This article gives tips and advice to anyone wanting to make custom photorealistic textures to be used in Half-Life 2.
- Oksid
|
|
Hiding in Shadow
21/08/04 01:11pm PDT
Describes how to create a function that has monsters disregard you if you are hiding in a certain level of "darkness," which can be set from within map properties.
- Anders [Wolf] Jenbo (NoBody)
|
|
Bump Mapping in Half-Life
08/08/04 11:58am PDT
Details a method of achieving real-time bump mapping in Half-Life, and provides an implementation of the algorithm.
- Francis 'DeathWish' Woodhouse
|
|
Real-Time "TRON 2.0" Glow For Low-Spec Hardware
19/06/04 02:06pm PDT
A sequel to the original "Real-Time 'TRON 2.0' Glow" article, this describes how to implement real-time glow that works on low-spec graphics cards.
- Francis 'DeathWish' Woodhouse
|
|
Hitboxes and Code
05/06/04 06:25pm PDT
How do I make only one part of a monster take damage? Learn about the relationship between model hitboxes and what you can do with them in a characters code.
- Jonathan 'Teh_Freak' Smith
|
|
|
|
|
|
|
After hearing that the zombies in HL2 will have the headcrabs jump off them when it's killed, I decided to try it out, and it's not hard either...
First you'll need to get the modified zombie model here. It's not the HD one, just the good 'ol normal zombie. Got it? OK, now go into MSVC++ 6.0 (or whatever you use) and open zombie.cpp.
The Code
At the top there should be these #defines:
//========================================================= // Monster's Anim Events Go Here //========================================================= #define ZOMBIE_AE_ATTACK_RIGHT 0x01 #define ZOMBIE_AE_ATTACK_LEFT 0x02 #define ZOMBIE_AE_ATTACK_BOTH 0x03
|
|
Just add these ones:
// headcrab jumps from zombie #define ZOMBIE_AE_CRAB1 0x04 #define ZOMBIE_AE_CRAB2 0x05 #define ZOMBIE_AE_CRAB3 0x06 // headcrab jumps from zombie
|
|
Those just define the animation events used in the model for this, now just a few lines lower (after ZOMBIE_FLINCH_DELAY), add this:
#define ZOMBIE_CRAB "monster_headcrab" // headcrab jumps from zombie
|
|
That defines the ZOMBIE_CRAB, which will be used later to spawn a headcrab of all things.
Now add this line in the public definitions (right under int IgnoreConditions):
void SpawnCrab( void ); // headcrab jumps from zombie
|
|
Now plop this piece of code at the end of the file:
//========================================================= // Spawn Headcrab - headcrab jumps from zombie //========================================================= void CZombie :: SpawnCrab( void ) { CBaseEntity *pCrab = CBaseEntity::Create( ZOMBIE_CRAB, pev->origin, pev->angles, edict() ); // create the crab
pCrab->pev->spawnflags |= SF_MONSTER_FALL_TO_GROUND; // make the crab fall }
|
|
That top line just spawns a crab (notice the ZOMBIE_CRAB), and that second line makes the crab fall to the ground.
Almost done, now go to HandleAnimEvents function, at the bottom of it (before the default:)add this:
// headcrab jumps from zombie case ZOMBIE_AE_CRAB1: { ALERT( at_console, "Crab1 spawned!\n" ); pev->body = 1; // set the head to a skull SpawnCrab(); // spawn a headcrab } break;
case ZOMBIE_AE_CRAB2: { ALERT( at_console, "Crab2 spawned!\n" ); pev->body = 1; // set the head to a skull SpawnCrab(); // spawn a headcrab } break;
case ZOMBIE_AE_CRAB3: { ALERT( at_console, "Crab3 spawned!\n" ); pev->body = 1; // set the head to a skull SpawnCrab(); // spawn a headcrab } break; // headcrab jumps from zombie
|
|
The 'pev->body = 1' line sets the body to the skull found in the modified zombie model, and the 'SpawnCrab()' simply calls that function.
Now you may be thinking,"Why do I have three events that are the exact same?". Well that is so you can add different effects for the headcrab when it spawns (like the TE_IMPLOSION effect).
Finally, go to the Precache area of the code and add this:
UTIL_PrecacheOther( ZOMBIE_CRAB ); // headcrab jumps from zombie
|
|
Now compile it and run a test map, you may notice that the crab will only spawn when it isn't a headshot kill, makes the effect more realistic. Well, enjoy beheading those zombies!
The Model
For those of you that want to find out what's different about the model (besides a new head), read on, however, I'm not going to explain how to actually do the modeling part, this is about the .QC file.
When I made the zombie model I simply added new events to the .QC file, I'll explain a little about what does what in the .QC.
$bodygroup body { studio "Zom3_Template_Biped(White_Suit)1" studio "skullhead" }
|
|
If you open up normal zombies .QC file, you'll notice this bit isn't there. What this does it make the two bodygroups that the new zombie has. The new one here is skullhead, which 'pev->body = 1' is linked to, while 'pev->body = 0' would be the White_Suit.
$sequence dieheadshot "dieheadshot" X fps 20 ACT_DIE_HEADSHOT 1 { event 2001 19 } $sequence dieheadshot2 "dieheadshot2" fps 22 ACT_DIE_GUTSHOT 1 { event 2001 18 } $sequence diesimple "diesimple" X fps 20 ACT_DIESIMPLE 1 { event 2001 13 } { event 4 8 } $sequence diebackward "diebackward" fps 18 ACT_DIEBACKWARD 1 { event 2001 10 } { event 5 2 } $sequence dieforward "dieforward" X fps 18 ACT_DIEFORWARD 1 { event 2001 21 } { event 6 18 }
|
|
Those are the zombie's death animations. The only relevent parts here are the { event ## ##}. The first number calls the event that cooresponds to the number in the code, while the second one tells it what frame to do it on.
For example: ------------QC file------------ $sequence diesimple "diesimple" X fps 20 ACT_DIESIMPLE 1 { event 2001 13 } { event 4 8 }
------------cpp file------------ #define ZOMBIE_AE_CRAB1 0x04
|
|
As you can see, event 4 is called on frame 8. Event 4 is refered to in zombie.cpp as 0x04 with the name ZOMBIE_AE_CRAB1 (where the code is called).
$sequence dieheadshot "dieheadshot" X fps 20 ACT_DIE_HEADSHOT 1 { event 2001 19 } $sequence dieheadshot2 "dieheadshot2" fps 22 ACT_DIE_GUTSHOT 1 { event 2001 18 }
|
|
As you can see here, there are no new events for these two, this is what makes it so the crab won't jump off when its a headshot or a gutshot.
Well, now you know how the model is important for this effect as well as learning about the relationship between model events and the code. |
|
article created on Fri Jan 09, 2004 / 10:22pm PST
this item has been viewed 7946 times
|
[Half-Life / coding]
|
|
Only registered users can post comments. Have you registered yet?
25 results, 2 pages, viewing page 1. prev [ 1 2 ] next
user comments
displaying comments of normal or higher rating
1. |
Brandon "Shotgun" Mallea
Mon Jan 19, 2004 / 06:45pm PST
|
|
|
Complicated But I'll give a try... comment modified on Mon Jan 19, 2004 / 06:51pm PST |
|
3. |
Darrell 'Me2' Noice
Mon Jan 19, 2004 / 11:45pm PST
|
|
|
heh, thats all we need... more headcrabs.... nice |
|
4. |
Peter Lykkegard
Tue Jan 20, 2004 / 12:09am PST
|
|
|
You are crazy Wonder how tuff it'll be to have HL style MP game with maybe three teams - monsters, grunts and a single god like G.Freeman (maybe a few barneys/ossies to assist)
LOL |
|
5. |
Alex "Y_Less" Cole
Tue Jan 20, 2004 / 02:39am PST
|
|
|
Looks nice, I would give it a try but my MSVC 1.1 doesn't support long filenames so I can't compile the HL SDK |
|
6. |
Jonathan 'Teh_Freak' Smith
Tue Jan 20, 2004 / 03:19pm PST
|
|
|
Shotgun: It's not that complicated, the second part is just in case you wanted to know what changes were made to the model. |
|
7. |
Mitoh
Fri Jan 23, 2004 / 10:16am PST
|
|
|
Compiling... zombie.cpp C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(271) : error C2065: 'SpawnCrab' : undeclared identifier C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(386) : error C2373: 'SpawnCrab' : redefinition; different type modifiers C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(391) : error C2039: 'SpawnCrab' : is not a member of 'CZombie' C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(42) : see declaration of 'CZombie' C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(392) : error C2373: 'SpawnCrab' : redefinition; different type modifiers C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(393) : error C2065: 'pev' : undeclared identifier C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(393) : error C2227: left of '->origin' must point to class/struct/union C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(393) : error C2227: left of '->angles' must point to class/struct/union C:\Games\Projekt\HlSdk\The Spirit\dlls\zombie.cpp(393) : error C2065: 'edict' : undeclared identifier Error executing cl.exe.
hl.dll - 8 error(s), 0 warning(s)
What`s the problem here ? |
|
8. |
Loki
Fri Jan 23, 2004 / 10:43am PST
|
|
|
this really is cool, I'm just trying to figure out how to get the headbrab to JUMP off of the zombie 'cos at the moment it looks like it spawns on the chest of the zombie, depending on the death animation, but in the meantime, I've made a HD version of the zombie. I haven't given it a skull cos in the game it looks like the scientists heads have been dissolved away or something, so I've just made it a headless corpse when the crab goes bungee jumping. comment modified on Fri Jan 23, 2004 / 10:44am PST |
|
10. |
Jonathan 'Teh_Freak' Smith
Sat Jan 24, 2004 / 09:08am PST
|
|
|
Mitoh: Did you do exactly what the tutorial said to do?
towig: I shouldn't have said 'jump off', this just makes a crab spawn when the zombie dies. |
|
11. |
Andy 'Vengeance' Godseck
Sat Jan 24, 2004 / 09:08pm PST
|
|
|
Im fairly new to coding and it worked perfectly for me with no problems at all. Excellent job on the tutorial Teh_Freak. Btw towig if you would send me that modified HD zombie model it would be much appreciated |
|
12. |
Mitoh
Sun Jan 25, 2004 / 08:30am PST
|
|
|
i guess yes , but can you attache the zombie.cpp please ? |
|
13. |
Loki
Thu Jan 29, 2004 / 02:15pm PST
|
|
|
Sure Vengeance, how do I get the zip file on here? |
|
15. |
Alex "Y_Less" Cole
Sat Jan 31, 2004 / 04:13am PST
|
|
|
To attach a zip, you need to take the tutorial off VERC, upload it in your articles area, attach it and resubmit the article, this isn't good as it means losing all the comments.
The best way is to upload it somewhere else (e.g. geocities) and give us the link. |
|
16. |
Cameron
Tue Feb 03, 2004 / 07:40pm PST
|
|
|
ok I have the modified model and devc++ but how do I get the zombie.cpp.....I have a huntch I need the sdk thing....... |
|
18. |
Arlen 'Combat' Anderson
Sun Feb 15, 2004 / 01:34am PST
|
|
|
For those of you that want a better effect, here's a way:
Instead of using the zombie's origin to pick the spawn spot, use the zombie's view_ofs ( eye position) This will make the headcrab spawn where the zombie's head is.
Couldn't you add a velocity to the headcrab in the direction the zombie is facing? That would give the illusion that the headcrab is jumping from the zombie's head. |
|
19. |
Anders [Wolf] Jenbo (NoBody)
Mon Aug 23, 2004 / 04:40am PDT
|
|
|
bah i did this for the grunt about 2 months before this article was ridden
comment modified on Mon Aug 23, 2004 / 04:42am PDT |
|
20. |
Beasty
Sat Dec 25, 2004 / 12:42am PST
|
|
|
So ... what do I do with the old version of Zombie? And do I have to change or create any settings or stuff for Hammer? Cool article as well! |
|
25 results, 2 pages, viewing page 1. prev [ 1 2 ] next
|
|
|
|