View Single Post
Author Message
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-14-2007 , 21:20   [SNIPPET] Beampoints from a player's weapon tip
Reply With Quote #1

I figured out how to do this a couple of days ago, and I thought that I might as well archive it in case others are curious.

Overview

If you've used temp entities, you probably know what beampoints are. You may have also seen in HookMod and EntMod that it's possible to attach such beams to the tip of a player's weapon. To do this, you can't use TE_BEAMPOINTS, you will need to use TE_BEAMENTPOINT instead. The format for this temp entity is available in message_const.inc.

In order to get it to attach to the player's weapon (instead of his origin), you must attach the 0x1000 flag to the entity index in your write_short. Below is a screenshot of first- and third-person views. The red line is without the flag, and the blue line is with the flag. For example, these are the two different write_short's that you would use to get either line type.

Code:
write_short(id); // red line write_short(id | 0x1000); // blue line





This flag also works for TE_BEAMENTS, as shown below.



You can see the exact code that I used to generate these lines in the attached SMA.

Extra Details

The exact way this works is by using the position of a model's attachments. Take the attachment index of the attachment that you want to use, add one to it, and then the flag for that attachment would be 0xn000. For example, in gign.qc:

Code:
// 2 attachments
$attachment 0 "Bip01 R Hand" 10.855000 -0.416715 1.870680
$attachment 1 "Bip01 L Hand" 10.855000 -0.416715 1.870680
Attachment 0 is the right hand. Add one, put it into the flag "formula," and you get 0x1000. On the other hand (HA HA HA HA), the left hand is attachment 1. So if you wanted to position an effect there, you would use the flag 0x2000.

You can use these attachment flags for almost any message that takes an entity index, and you can use it on any entities that have attachments.
Attached Files
File Type: sma Get Plugin or Get Source (gunpoint.sma - 2105 views - 2.5 KB)
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 04-24-2007 at 21:32.
XxAvalanchexX is offline