Raised This Month: $ Target: $400
 0% 

Create a shotgun burst with tracers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Max!
Member
Join Date: Jun 2009
Old 08-12-2009 , 07:50   Create a shotgun burst with tracers
Reply With Quote #1

Ive been trying to achieve a shotgun burst effect with tracers but i cant figure out how to do it. atm it shoots 8 tracers in the same spot, where i need to to shoot 8 tracers in a random spread

Help is appreciated
Max! is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-12-2009 , 08:49   Re: Create a shotgun burst with tracers
Reply With Quote #2

You can use the Ham_TraceAttack forward. There you get the player eyes origin and the end position of the trace handle, and create the tracers.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Max!
Member
Join Date: Jun 2009
Old 08-12-2009 , 08:51   Re: Create a shotgun burst with tracers
Reply With Quote #3

Code:
public GunShot(id)
{
    new aiming[3], Float:origin[3]
    get_user_origin(id, aiming, 3);
    pev(id, pev_origin, origin)
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY) //  MSG_PAS MSG_BROADCAST
    write_byte(TE_TRACER)
    write_coord(floatround(origin[0]))
    write_coord(floatround(origin[1]))
    write_coord(floatround(origin[2]))
    write_coord(aiming[0])
    write_coord(aiming[1])
    write_coord(aiming[2])
    message_end()
    message_begin(0, SVC_TEMPENTITY, _, 0);
    write_byte(TE_GUNSHOTDECAL);
    write_coord(aiming[0]);
    write_coord(aiming[1]);
    write_coord(aiming[2]);
    write_short(0);
    write_byte(41);
    message_end();
}
thats what i wrote, and when i call it i loop it 8 times, how would i add some spread to that?
Max! is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-12-2009 , 08:53   Re: Create a shotgun burst with tracers
Reply With Quote #4

No, it is not needed to do that, you can find out all the shots exactly where they hit with the method I posted above.
Edit: Now I have read more carefully. You would like the tracers random? Or would you like the tracers to go exactly where the shot ends?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 08-12-2009 at 08:57.
ot_207 is offline
Max!
Member
Join Date: Jun 2009
Old 08-13-2009 , 03:23   Re: Create a shotgun burst with tracers
Reply With Quote #5

i awnt the tracers to go from 1 point to 8 random points near each other where the bullets should hit
Max! is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-13-2009 , 03:49   Re: Create a shotgun burst with tracers
Reply With Quote #6

Here! I have tested it! It works ;)

PHP Code:
/* Script generated by Pawn Studio */

#define PLUGIN    "Tracer"
#define AUTHOR    "OT"
#define VERSION    "1.0"

#include <amxmodx> 
#include <fakemeta> 
#include <engine> 
#include <hamsandwich> 
#include <xs> 

new Trie:RegisteredClasses 

public plugin_precache() 

    
RegisteredClasses TrieCreate() 
    
    
register_forward(FM_Spawn,"spawn"


public 
spawn(id

    if(
pev_valid(id)) 
    { 
        static 
classname[32
        
pev(id,pev_classname,classname,charsmax(classname)) 
         
        if(!
TrieKeyExists(RegisteredClasses,classname)) 
        { 
            
RegisterHam(Ham_TraceAttack,classname,"fw_global_traceatt"
            
TrieSetCell(RegisteredClasses,classname,true
        } 
    } 


public 
plugin_init() 

    
register_plugin(PLUGIN,VERSION,AUTHOR
     
    
RegisterHam(Ham_TraceAttack,"worldspawn","fw_global_traceatt"
}  


public 
fw_global_traceatt(entattackerFloat:damageFloat:direction[3], tracehdldamagebits

    new 
trace create_tr2() 
    new 
Float:start[3], Float:view_offs[3], Floatend[3
    
pev(attackerpev_originstart
    
pev(attackerpev_view_ofsview_offs

    
// player eye origin 
    
xs_vec_add(startview_offsstart
     
    
get_tr2(tracehdlTR_vecEndPosend
     
    
engfunc(EngFunc_TraceLinestartendDONT_IGNORE_MONSTERSattackertrace
     
    
get_tr2(traceTR_vecEndPosend
    
msg_tracer(start,end)     

    
free_tr2(trace)

    return 
HAM_IGNORED 


stock msg_tracer(Floatorigin[3], Floatend[3]) 

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY//  MSG_PAS MSG_BROADCAST 
    
write_byte(TE_TRACER
    
engfunc(EngFunc_WriteCoordorigin[0]) 
    
engfunc(EngFunc_WriteCoordorigin[1]) 
    
engfunc(EngFunc_WriteCoordorigin[2]) 
    
engfunc(EngFunc_WriteCoordend[0]) 
    
engfunc(EngFunc_WriteCoordend[1]) 
    
engfunc(EngFunc_WriteCoordend[2]) 
    
message_end() 

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 08-13-2009 at 04:01.
ot_207 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-13-2009 , 03:50   Re: Create a shotgun burst with tracers
Reply With Quote #7

You can check this plugin -> http://forums.alliedmods.net/showthread.php?p=544649 has shotgun tracers.

@ot_207 - TraceAttack for "worldspawn" ?
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 08-13-2009 at 03:52.
Alka is offline
Old 08-13-2009, 03:54
Arkshine
This message has been deleted by Arkshine. Reason: nvm
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-13-2009 , 03:57   Re: Create a shotgun burst with tracers
Reply With Quote #8

Quote:
Originally Posted by Alka View Post
You can check this plugin -> http://forums.alliedmods.net/showthread.php?p=544649 has shotgun tracers.

@ot_207 - TraceAttack for "worldspawn" ?
Yes ;) it works!
LE: You can check these plugins: http://forums.alliedmods.net/showthread.php?t=94916 and http://forums.alliedmods.net/showthread.php?p=663892 both are using them .
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 08-13-2009 at 03:59.
ot_207 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-13-2009 , 07:17   Re: Create a shotgun burst with tracers
Reply With Quote #9

Mine also use worldspawn, but it wont help to reproduce shotgun.


This could help :

Code:
// special deathmatch shotgun spreads
#define VECTOR_CONE_DM_SHOTGUN	Vector( 0.08716, 0.04362, 0.00  )// 10 degrees by 5 degrees
#define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees

void CShotgun::PrimaryAttack()
{
	Vector vecSrc	 = m_pPlayer->GetGunPosition( );
	Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );

	Vector vecDir;

#ifdef CLIENT_DLL
	if ( bIsMultiplayer() )
#else
	if ( g_pGameRules->IsMultiplayer() )
#endif
	{
		vecDir = m_pPlayer->FireBulletsPlayer( 4, vecSrc, vecAiming, VECTOR_CONE_DM_SHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
	}
	else
	{
		// regular old, untouched spread. 
		vecDir = m_pPlayer->FireBulletsPlayer( 6, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
	}
}

/*
================
FireBullets

Go to the trouble of combining multiple pellets into a single damage call.

This version is used by Players, uses the random seed generator to sync client and server side shots.
================
*/
Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand )
{
	static int tracerCount;
	TraceResult tr;
	Vector vecRight = gpGlobals->v_right;
	Vector vecUp = gpGlobals->v_up;
	float x, y, z;

	if ( pevAttacker == NULL )
		pevAttacker = pev;  // the default attacker is ourselves

	ClearMultiDamage();
	gMultiDamage.type = DMG_BULLET | DMG_NEVERGIB;

	for ( ULONG iShot = 1; iShot <= cShots; iShot++ )
	{
		//Use player's random seed.
		// get circular gaussian spread
		x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 );
		y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 );
		z = x * x + y * y;

		Vector vecDir = vecDirShooting +
						x * vecSpread.x * vecRight +
						y * vecSpread.y * vecUp;
		Vector vecEnd;

		vecEnd = vecSrc + vecDir * flDistance;
		UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev)/*pentIgnore*/, &tr);
		
		// do damage, paint decals
		if (tr.flFraction != 1.0)
		{
			CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);

			if ( iDamage )
			{
				pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB) );
				
				TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType);
				DecalGunshot( &tr, iBulletType );
			} 
			else switch(iBulletType)
			{
			default:
			case BULLET_PLAYER_9MM:		
				pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET); 
				break;

			case BULLET_PLAYER_MP5:		
				pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET); 
				break;

			case BULLET_PLAYER_BUCKSHOT:	
				 // make distance based!
				pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgBuckshot, vecDir, &tr, DMG_BULLET); 
				break;
			
			case BULLET_PLAYER_357:		
				pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg357, vecDir, &tr, DMG_BULLET); 
				break;
				
			case BULLET_NONE: // FIX 
				pEntity->TraceAttack(pevAttacker, 50, vecDir, &tr, DMG_CLUB);
				TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType);
				// only decal glass
				if ( !FNullEnt(tr.pHit) && VARS(tr.pHit)->rendermode != 0)
				{
					UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG(0,2) );
				}

				break;
			}
		}
		// make bullet trails
		UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (flDistance * tr.flFraction) / 64.0 );
	}
	ApplyMultiDamage(pev, pevAttacker);

	return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 );
}
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-13-2009 , 07:24   Re: Create a shotgun burst with tracers
Reply With Quote #10

Quote:
Here! I have tested it! It works ;)
__________________
Arkshine is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:23.


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