Raised This Month: $ Target: $400
 0% 

Artificial Bullet Spread(regarding velocity_by_aim)[SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
World Crafter
Junior Member
Join Date: Jul 2006
Old 06-21-2007 , 18:11   Artificial Bullet Spread(regarding velocity_by_aim)[SOLVED]
Reply With Quote #1

Sorry to post 2 topics asking for help so close to each other, especially after I figured out the simple solution to my last question. But this one is different, this one I have no clue about and have been searching for an answer for hours now.

Again with WeaponMod, I am trying to make a sawed-off shotgun. The main problem is that WeaponMod doesn't come with a simple native for creating a bullet with spread(bullets always go straight and ignore recoil), so I have to create bullets dynamically as fast-moving entities. I can make a bullet that moves straight, but I can't seem to get the bullet to fire at an angle. I've been searching for hours and I know that I have to do something to alter the velocity or angle values, but I can't just change them without breaking the plugin as far as I know. So how can I make this bullet fire in a random direction(angles should be -5 to 5 degrees).

Code:
public makebullet(id){     new bullet = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))     if(!bullet) return PLUGIN_CONTINUE             set_pev(bullet,pev_classname,"sawedoffbullet")     engfunc(EngFunc_SetModel,bullet,PELLET)     set_pev(bullet,pev_owner,id)     set_pev(bullet,pev_movetype,MOVETYPE_FLY)     set_pev(bullet,pev_solid,SOLID_BBOX)                 set_pev(bullet,pev_mins,Float:{-0.01,-0.01,-0.01})     set_pev(bullet,pev_maxs,Float:{0.01,0.01,0.01})                 new Float:fStart[3]     wpn_projectile_startpos(id,64,-12,-16,fStart)     set_pev(bullet,pev_origin,fStart)                 new Float:fVel[3]     velocity_by_aim(id,BULLET_SPEED,fVel)       set_pev(bullet,pev_velocity,fVel)                 new Float:fAngles[3]     fAngles[0] = random_num(-5,5)     fAngles[1] = random_num(-5,5)     fAngles[2] = random_num(-5,5)     vec_to_angle(fVel,fAngles)     set_pev(bullet,pev_angles,fAngles)         //For checking where the bullet goes     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)     write_byte(TE_BEAMFOLLOW)     write_short(bullet)     write_short(g_trail)     write_byte(25)     write_byte(1)     write_byte(224)     write_byte(224)     write_byte(255)     write_byte(255)     message_end()     }

Of course, if there is a more simple way to do this, please tell me. I'm hurting my head.
__________________

Last edited by World Crafter; 06-24-2007 at 17:01.
World Crafter is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-22-2007 , 03:13   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #2

You shouldn't do that. Bullets aren't supposed to be "random". A bullet direction depends on player movement direction, type of material the player is on (ground, air, water, etc.), player's velocity and maybe some other things I can't remember right now.

Then again you could just add that random angles but it's a sloppy way of doing it. Realism would have nothig to do with it in this case.
_Master_ is offline
World Crafter
Junior Member
Join Date: Jul 2006
Old 06-22-2007 , 12:43   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #3

I realize all that, but its far too complicated for me with the little amount of Pawn that I know. For now I just want bullets that don't go straight in front of you every time.
__________________
World Crafter is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 06-22-2007 , 14:01   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #4

Take a look at the shotgun secondary attack from the HL source code. I don't think you can do the multi damage but you can do TakeDamage with Ham Sandwich.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 06-22-2007 , 19:31   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #5

Couldn't he just use this?

(message_const.inc)
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.
//
// write_byte(TE_MULTIGUNSHOT)
// write_coord(origin.x)
// write_coord(origin.y)
// write_coord(origin.z)
// write_coord(direction.x)
// write_coord(direction.y)
// write_coord(direction.z)
// write_coord(x noise * 100)
// write_coord(y noise * 100)
// write_byte(count)
// write_byte(bullethole decal texture index)
stupok is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 06-22-2007 , 22:07   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #6

That won't do any damage, but it'll create the effect I guess.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
World Crafter
Junior Member
Join Date: Jul 2006
Old 06-22-2007 , 22:50   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #7

Is it possible to check where those fake bullets end up?
__________________

Last edited by World Crafter; 06-22-2007 at 22:55.
World Crafter is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 06-22-2007 , 23:18   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #8

No, it's calculated on the client with TE_MULTIGUNSHOT.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
World Crafter
Junior Member
Join Date: Jul 2006
Old 06-23-2007 , 01:07   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #9

I'm looking at the SDK code for the shotgun right now, but I don't see how this helps me. It's completely different and none of it is compatible with amxx.

Code:
vecDir = m_pPlayer->FireBulletsPlayer( 12, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
__________________
World Crafter is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-23-2007 , 03:23   Re: Artificial Bullet Spread(regarding velocity_by_aim)
Reply With Quote #10

You could use the traces generated by TE_MULTIGUNSHOT...
_Master_ 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 04:58.


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