THE HANDY VANDAL'S ALMANAC
Game Design Resources for Half-Life
Home : Topics : Menu : Reviews
Almanac 2 : Xen Rebels

Site no longer actively maintained ... HV

"Turning the Valve on Your Brain-Tap"
 

Throwable Weapons
See also: Coding - Mods - Programming -
Updated July 3, 2004

 

Coding a Throwable Weapon from the HL-Coder mailing list

From: Raiko

Creating a weapon that is thrown to do damage, but stays useable

I'm wondering how I can create a weapon that is thrown at enemies to do damage. However, I want the weapon to stay active in game so it can be picked up and be thrown again.

From: "Jeffrey \"botman\" Broome"

Have 2 different states for the weapon (with separate Think and Touch functions).

When the weapon is thrown, it's in the "FlyingThroughThe Air" state and you would have a FlyingThink() and FlyingTouch() state. If the weapon hits someone in this state, do damage to them.

When the weapon hits the ground and comes to rest, change to the "RestingOnThe Ground" state (with RestingThink() and RestingTouch()). These would do the same stuff a current weapon Touch function does (gives the weapon to the toucher).

From: Marco Leise

Short form: How do I code a throwable knife.

Maybe by mixing the crossbow with the crowbar.

When the projectile hits something it is deleted and respawned as an item that can be picked up.

From: Raiko

Would I need to create a second entity (a la Crossbow Bolt) to do this? Meaning, would I have to make the weapon "fire" this entity to do damage and then be deleted and remade as a weapon that can be picked up? Is that what you mean?

From: "Jeffrey \"botman\" Broome"

No, you shouldn't need to create one entity that you can throw and other entity that can be picked up. You should be able to do everything with a single entity.

You WILL have to change the MOVETYPE and possibly change the size of the entity (using UTIL_SetSize) since each state will probably have different values for these (flying and small, or landed and large).

 

Handy Vandal's Almanac Logo

"Handy Vandal" and "Handy Vandal's Almanac" copyright 2008 by Karl Gregory Jones
Almanac: Half-Life : Half-Life 2
Xen Rebels
karljones.com
Contact the Handy Vandal

Half-Life © 1998-99 Sierra On-line and Valve L.L.C. All rights reserved. Half-Life and the Half-Life logo are trademarks of Sierra On-Line. Valve and the Valve logo are trademarks of Valve L.L.C. Half-Life images, textures, music, sound effects, and other graphic or audio content © 1998-99 Valve L.L.C. All rights reserved.