AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Artificial Bullet Spread(regarding velocity_by_aim)[SOLVED] (https://forums.alliedmods.net/showthread.php?t=56818)

World Crafter 06-21-2007 18:11

Artificial Bullet Spread(regarding velocity_by_aim)[SOLVED]
 
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.

_Master_ 06-22-2007 03:13

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
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.

World Crafter 06-22-2007 12:43

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
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.

XxAvalanchexX 06-22-2007 14:01

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
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.

stupok 06-22-2007 19:31

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
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)


XxAvalanchexX 06-22-2007 22:07

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
That won't do any damage, but it'll create the effect I guess.

World Crafter 06-22-2007 22:50

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
Is it possible to check where those fake bullets end up?

XxAvalanchexX 06-22-2007 23:18

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
No, it's calculated on the client with TE_MULTIGUNSHOT.

World Crafter 06-23-2007 01:07

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
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 );

_Master_ 06-23-2007 03:23

Re: Artificial Bullet Spread(regarding velocity_by_aim)
 
You could use the traces generated by TE_MULTIGUNSHOT...


All times are GMT -4. The time now is 21:24.

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