AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bullet 'tracer' (https://forums.alliedmods.net/showthread.php?t=16877)

DahVid 08-21-2005 18:29

Bullet 'tracer'
 
I'm wondering how to create an entity to 'follow' a bullet. I looked at the tracer plugins but I didn't really figure it out. I didnt even see a create_entity or anything!

XxAvalanchexX 08-21-2005 18:34

Code:

#define        TE_TRACER                        6                // tracer effect from point to point
// coord, coord, coord (start)
// coord, coord, coord (end)

This is a temp entity (that's what TE stands for). So, just figure out when they fire, use get_user_origin with different paramaters to get starting and ending point, and send the message.

Code:
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); write_byte(6); // TE_TRACER write_coord(start[0]); write_coord(start[1]); write_coord(start[2]); write_coord(end[0]); write_coord(end[1]); write_coord(end[2]); message_end();

DahVid 08-21-2005 19:47

Do like this?
Code:

new origin[3]

get_user_origin(id,origin,1)

message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(6); // TE_TRACER
write_coord(origin[0]);
write_coord(origin[1]);
write_coord(origin[2]);
write_coord(end[0]);
write_coord(end[1]);
write_coord(end[2]);
message_end();

If that is it, I will try to figure out how to find the ending (get_user_aiming or something probably)

And for shotgun, would I make it

Code:

#define TE_MULTIGUNSHOT            126 // much more compact shotgun message
// This message is used to make a client approximate a 'spray' of gunfire.
// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is
// a good candidate for MULTIGUNSHOT use. (shotguns)
//
// NOTE: This effect makes the client do traces for each bullet, these client traces ignore
//      entities that have studio models.Traces are 4096 long.
//
// coord (origin)
// coord (origin)
// coord (origin)
// coord (direction)
// coord (direction)
// coord (direction)
// coord (x noise * 100)
// coord (y noise * 100)
// byte (count)
// byte (bullethole decal texture index)

The only way I would know how to figure out if shooting is see if user is on mouse1.. That wouldn't be right. Only fire one bullet!

Also -- How would I figure if that entity is there, like hook on the 'trail?'

Sorry, Like I said I am noob, hard for me to figure this stuff out! :(

v3x 08-21-2005 20:00

To get the ending point ( where the bullet will hit ):
Code:
get_user_origin(id,origin,3)

XxAvalanchexX 08-21-2005 21:46

Yes, you need to get the ending origin, and you can do it like v3x posted.

From that code it looks like TE_MULTIGUNSHOT will do some tracer action, and it will also create the bullet holes in the wall.

This is xeroblood's method of determining when a shot is fired:

Code:
#define MAX_PLAYERS 32 // Tracks players Shots-Fired: [0]=WeaponID, [1]=Ammo new g_nCurWeapon[MAX_PLAYERS][2] public plugin_init() {     register_event( "CurWeapon", "Event_ShotFired",  "b" ) } public Event_ShotFired( id ) {     // Players current weapon data..     new weaponID = read_data( 2 )     new wAmmo = read_data( 3 )     if( g_nCurWeapon[id-1][0] != weaponID ) // User Changed Weapons..     {         g_nCurWeapon[id-1][0] = weaponID         g_nCurWeapon[id-1][1] = wAmmo         return PLUGIN_CONTINUE     }     if( g_nCurWeapon[id-1][1] < wAmmo ) // User Reloaded..     {         g_nCurWeapon[id-1][1] = wAmmo         return PLUGIN_CONTINUE     }     if( g_nCurWeapon[id-1][1] == wAmmo ) // User did something else, but didn't shoot..         return PLUGIN_CONTINUE         // This far means user shot his/her gun..     // Save new weapon data..     g_nCurWeapon[id-1][1] = wAmmo     g_nCurWeapon[id-1][0] = weaponID     // Now you can do stuff, like:     // Get the origin of weapon hit-point     new nPoint[3]     get_user_origin( id, nPoint, 3 )     // blah blah blah...     return PLUGIN_CONTINUE }

DahVid 08-21-2005 22:14

Yes, I've already made it with a function that triggers on CurWeapon.. I think I will add a check like Xero's so it doesn't put a tracer on all currweap events..


All times are GMT -4. The time now is 14:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.