Raised This Month: $ Target: $400
 0% 

Artificial Bullet Spread(regarding velocity_by_aim)[SOLVED]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 21:24.


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