Hey, I'm just some kid who makes games for fun :)

Report RSS Swimming with Engines

Posted by on

[SCROLL TO BOTTOM FOR PICTURES]

WARNING: Swimming with live engines could be hazardous to your health! Specially when they explode!

Heh, lately I have been modding Half Life 2: Ep2. It's really fun, and I'm definitely getting somewhere. So, after creating my first entity (Logical entity, one you can't see), I obviously moved on to the second tutorial, the model entity (One you can see). Well, as you can see from the pictures provided below that went well. Before I began the tutorial I though I was just going to finish this one up, then move along to the next one and see what would happen next. But, as I was about to find out, there was a bit of text in the model tutorial:

Authoring wrote: Our entity won't begin moving until prompted by InputToggle(). Changing this behaviour so that it starts active (which isn't just as simple as changing m_bActive in the code above!) would be a good project once you finish the tutorial proper.


Ok, so after I finished the tutorial, went back and challenged myself to do just that. Instead of maknig it activate by a button, I made the model start all on it's own (You can still toggle it on/off, it will just start automatically).

While I was messing with this, I began to look at the engine model. And it sparked my imagination. I just though "Wow that looks like a little ship.. that's moving around backwards". Well, usually ships don't move around on all 3 axes (meaning the model would fly, as in take off and move up). So I decided to mess with it some more.

So to get the moving to work on two axes I needed to change a line (or two). Really what I did is not important. What IS important however is this:
To make a vector you need 3 variables. X, Y, and Z. Valve has decided to use their own float types called vec_t. Well, for some stupid reason it took me 1-2 hours to find out that I was not typing vec_t but I was actually typing (and reading) vect_t. Notice the extra T. Yes, 2 hours. I looked at the VDC, studyied Vectors on wikipedia (which made little to no sense) and searched through the given HL2 code. Then I looked at my code again and found out that I had an extra T. Compiled, tested everything worked. The problem was my reading ability. Go me :)

After that dilemma, instead of being able to move anyway it wants, it can only move on two axes, x and y (Meaning it can't move up or down). Then because of the earlier "ship" looking decision, I also decided to put smoke on it. Well, like the pictures go, there is no smoke (Maybe I'll add it now!) but I did steal the grenade's sprite trail effect (the red glowing line that follows the grenade) and slapped it on my thing. I also modified it so it lasts longer.

Ok, so then in hammer I stuck a whole bunch of these together because I wanted to see what they would all look like. Now, keep in mind that I did test this all behind a glass wall that was toggled off when I stepped on two platforms (Thanks to my first logical entity). So, I put in a bunch of little flying thingies, then it struck me again. They look like fish!

Ok, now that really doesn't have much to do with anything but since they look like fish swimming around I decided to put water in the background. Made no difference, but that's how that got there.

Next comes explosions and gibs. And the fact that they can explode. Ok, generally when you shoot an airboat engine [in the movies] it blows up, So I then decided lets make them die (Buhaha). Started looking around, and found npc_combinecamera. That's the little camera that gets out of it's little cage, and looks at you. And when you shoot it, it creates an explosion and goes back up never to come back down again (lol).

So after many a minute searching and looking through it's code, I retyped my own code copy and pasted the code, modified it to my own will, and voila! It did nothing. That's right, it did nothing at all. It just kinda sat there and went back to floating aimlessly when I shot at it.

Ok, that didn't go to well. So being who I am I persisted until it finally worked. So at this point I had a flying engine that just stopped when I shot it enough. It just stopped. Didn't do anything. Ok, MORE searching! Now to find a function that removes/kills the entity! (Basically a function that just gets rid of the entity I'm working with. When I say remove/kill I mean just play vanish never to be seen again. No fancy effects).

Then after much searching the VDC, and knowing I couldn't find anything I went back to searching through the original source code only to find nothing. Ok, being a smartass that I am I know a little bit about coding. So I did this:

Ok, so you might not be a coder. Basically I went through every single function and looked for one that had anything to do with killing, getting rid of etc.. the entity. As you can see from the little bar this took a while (Damn that's a lot of methods/functions!)

So I finally found it. Do you want to know what it's called? Here I'll show you!

code:
Remove();

Ok so I spent at least 2 hours looking for something so obvious. Go me again :)

Well at that point, when you shot and "killed" one of the things, it just dissapeared. Now, that's what I wanted mind you! I hadn't added any special effects yet!

Now onto the more visual aspect of the killing of innocent airboat engines. Looked again at npc_combinecamera and found out how the explosions were made. Turns out it's one line of code (for pre-made Valve explosions). I'm not going to bother you with it though :)

Then came the gibs (which you may be able to see in the last picture). Again, I looked at Valve's code. This time at npc_scanner. You know, those scanners that go around and take pictures of you? Yeah those. They have gibs and that's what I want. And if you don't know, look at wikipedia to find out what gibs are. Although wikipedia says they're organic, they don't have to be.

So after much toil, and 3 days worth of messing around I present to you the "final" fishes that leave random red trails behind for no reason. And explode when shot at (enough).

Here, have some pictures!
Swimming EnginesSwimming EnginesSwimming Engines

And I guess that's all! If anybody reads this, may you suggest anything else I can do to these little rascals?

So, until next time
~Wurmy AKA Kill3rTomato

Post a comment

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