PDA

View Full Version : Changing Rate of Fire


Wilson [29th ID]
01-20-2007, 05:35 AM
This is barely a tutorial. It's more like a reference for those who already know somewhat how to do it.

I found the pdata offsets for weapon's rate of fire in dod.

// These are the offsets and the values when the player is
// standing still, not firing, ready to fire.

#define OFFSET_1 103
#define OFFSET_2 104

#define VALUE_1 -1.0
#define VALUE_2 -0.001

Both get set to 0.49 when Firing the k98's primary fire, and set to 0.538 when bayoneting. Obviously this would be different for each weapon, but I believe it is the time before it can be fired/bayoneted again.

Here is some example code for changing the rate of fire. It basically makes it unlimited ROF so you can fire completely semi auto with any weapon (kar can shoot as fast as pistol or carbine)


public cmd_set_pdata( id ) {
new num, args[16];
read_args( args, 199 );
num = str_to_num( args );

new clip, ammo, weaponID = get_user_weapon(id,clip,ammo)
new weapon[32]
xmod_get_wpnlogname( weaponID, weapon, 31 );
format( weapon, 31, "weapon_%s", weapon );
new wpnent = detect_weapon_id( id, weapon );

if( num == 1 ) set_pdata_float( wpnent, OFFSET_1, VALUE_1 );
else if( num == 2 ) set_pdata_float( wpnent, OFFSET_2, VALUE_2 );

console_print( id, "Set pdata" );
return PLUGIN_HANDLED;
}

stock detect_weapon_id( id, szWpn[32] ) {
new m_iCurEnt = -1, m_iWpn = 0;

// Get User Origin
new Float:m_flOrigin[3];
pev( id, pev_origin, m_flOrigin );

// Find Dummy Weapon
while( ( m_iCurEnt = engfunc( EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0 ) ) != 0 ) {
new m_szClassname[32];
pev( m_iCurEnt, pev_classname, m_szClassname, 31 );

if( equal( m_szClassname, szWpn ) )
m_iWpn = m_iCurEnt;
}
return m_iWpn;
}


So it gets the user's origin, then finds the weapon entity in that origin that matches the weapon name that the user is holding, then depending on whether the command's argument was 1 or 2, it sets primary or secondary fire to the VALUE_1 / VALUE_2

So you'd register the client command in plugin_init like register_clcmd("setpdata", "cmd_set_pdata") then, for example, bind MOUSE1 "+attack;setpdata 1" and bind MOUSE2 "+attack2;setpdata 2"

Try it out it's extremely fun, and hopefully I'll have a customisable rate of fire plugin soon enough.

Wilson [29th ID]
03-02-2007, 06:42 AM
On a separate note, just as a reference, the offset for the clip ammo is 108.
Adjusting this will allow you to, say, give the Thompson 100 rounds per magazine, or make a ten shot webley :P

Weapon ID (matches dod_const.inc) is offset 91

Spectral2
04-25-2007, 11:27 PM
how are you getting these offsets?

Wilson [29th ID]
04-25-2007, 11:29 PM
Using a developer plugin I made, fakemeta research. You log pdata bytes 0 - 200, then fire and quickly compare bytes 0 - 200 to the original "logged set". Check what changed. If nothing hints at a rate of fire offset, move to 201 - 400, then 401 - 600, etc. (the weapon's pdata)

Are you trying to find offsets for another mod? Or for something else? I might be able to help point you in the right direction.

Hopefully one of these days I'll release FM Research too :P

diamond-optic
04-25-2007, 11:32 PM
ya im having a bitch of a time finding offsets...


either by doing it over and over with the offset reading from a cvar and i manually change it 1 at a time lol..

or thru a loop that goes thru a whole bunch of offset values to begin with.. but its pretty sloppy and i only made it look for a value i specify

Wilson [29th ID]
04-26-2007, 04:49 PM
Message me on AIM and I'll send you fm research. Development with pev, cd, es, and pdata is sooooo much easier with it.

Wilson [29th ID]
11-11-2007, 10:58 PM
Update - download FM Research from the developer plugins section, then use this script to give you rapid fire for any weapon. It basically allows you to fire, say, the k98 or garand as quickly as you can fire the m1carbine or pistol.

alias +rapidfire "+attack"
alias -rapidfire "-attack;wait;wait;fm_pdata wpn 103 -1.0"
bind mouse1 +rapidfire

If you want an effective gun...just try the k98 without the boltaction to slow you down :P

diamond-optic
11-12-2007, 12:37 AM
lmao..

that plus a 500 round clip = unstoppable


...im tempted to play around with that lol, seems i can get away with all sorts of stuff on my server.. i found that ppl dont even question you when you buttstock them from across the map (out of probably 100+ ppl .. maybe 2 or 3 have even said anything)

Zor
11-13-2007, 05:10 AM
I would like to get the pdata from the DoD Dev team, but you know they wont give that shit out. But would like to!!!

Heheheh

Cheers!

blobby
11-13-2007, 03:59 PM
lmao..

that plus a 500 round clip = unstoppable


...im tempted to play around with that lol, seems i can get away with all sorts of stuff on my server.. i found that ppl dont even question you when you buttstock them from across the map (out of probably 100+ ppl .. maybe 2 or 3 have even said anything)


I bet that is dead funny d-o LMAO ill have to try that cos i can get away with anything on my server lol

vitalsfa
01-23-2008, 08:34 PM
quick question how would i say change the rate of fire on the thompson

blobby
01-24-2008, 06:15 PM
This topic tells you how to change the rate of fire on all weapons

vitalsfa
01-24-2008, 06:23 PM
it doesn't work for the thompson the offset 103 appears to change when fired is there any way to lock the pdata offset
running on a deticated server
beentrying to do it all day

Wilson [29th ID]
01-28-2008, 08:59 AM
Hook FM_PlayBackEvent
Test if eventindex == DODW_THOMPSON
If so, set the pdata offset like you did.

This basically does it every time you fire.
BTW if it doesn't work, hook it in post.

sreeja
02-05-2008, 08:08 AM
Thank you for the information.Very useful.