Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin
Archive › Old Forum Threads › Help › Tutorials › Changing Rate of Fire
15 posts, 7 people · 3,470 views Thread Rating: ★★★★★
closedChanging Rate of Fire
Started by Wilson [29th ID] on 01-20-2007, 05:35 AM
Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
01-20-2007, 05:35 AM #1

This is barely a tutorial. It's more like a reference for those who already know somewhat how to do it.rnrnI found the pdata offsets for weapon's rate of fire in dod.rnrn

// These are the offsets and the values when the player isrn// standing still, not firing, ready to fire.rnrn#define OFFSET_1 103rn#define OFFSET_2 104rnrn#define VALUE_1 -1.0rn#define VALUE_2 -0.001
rnrnBoth 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.rnrnHere 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)rnrn
rnpublic cmd_set_pdata( id ) {rn	new num, args[16];rn	read_args( args, 199 );rn	num = str_to_num( args );rn	rn	new clip, ammo, weaponID = get_user_weapon(id,clip,ammo)rn	new weapon[32]rn	xmod_get_wpnlogname( weaponID, weapon, 31 );rn	format( weapon, 31, "weapon_%s", weapon );rn	new wpnent = detect_weapon_id( id, weapon );rn	rn	if( num == 1 ) set_pdata_float( wpnent, OFFSET_1, VALUE_1 );rn	else if( num == 2 ) set_pdata_float( wpnent, OFFSET_2, VALUE_2 );rn	rn	console_print( id, "Set pdata" );rn	return PLUGIN_HANDLED;rn}rnrnstock detect_weapon_id( id, szWpn[32] ) {rn	new m_iCurEnt = -1, m_iWpn = 0;rnrn	// Get User Originrn	new Float:m_flOrigin[3];rn	pev( id, pev_origin, m_flOrigin );rn	rn	// Find Dummy Weaponrn	while( ( m_iCurEnt = engfunc( EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0 ) ) != 0 ) {rn		new m_szClassname[32];rn		pev( m_iCurEnt, pev_classname, m_szClassname, 31 );rn    rn		if( equal( m_szClassname, szWpn ) )rn			m_iWpn = m_iCurEnt;rn	}rn	return m_iWpn;rn}rn
rnrnSo 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_2rnrnSo 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"rnrnTry it out it's extremely fun, and hopefully I'll have a customisable rate of fire plugin soon enough.

Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
03-02-2007, 06:42 AM #2

On a separate note, just as a reference, the offset for the clip ammo is 108.rnAdjusting this will allow you to, say, give the Thompson 100 rounds per magazine, or make a ten shot webley :PrnrnWeapon ID (matches dod_const.inc) is offset 91

S Spectral2
posted here
Posts: 16
Threads: 1
Joined: Mar 2007
04-25-2007, 10:27 PM #3

how are you getting these offsets?

Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
04-25-2007, 10:29 PM #4

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)rnrnAre you trying to find offsets for another mod? Or for something else? I might be able to help point you in the right direction.rnrnHopefully one of these days I'll release FM Research too :P

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
04-25-2007, 10:32 PM #5

ya im having a bitch of a time finding offsets...nnneither by doing it over and over with the offset reading from a cvar and i manually change it 1 at a time lol..nnor 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]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
04-26-2007, 03:49 PM #6

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]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
11-11-2007, 10:58 PM #7

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.rnrnalias +rapidfire "+attack"rnalias -rapidfire "-attack;wait;wait;fm_pdata wpn 103 -1.0"rnbind mouse1 +rapidfirernrnIf you want an effective gun...just try the k98 without the boltaction to slow you down :P

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
11-12-2007, 12:37 AM #8

lmao.. nnthat plus a 500 round clip = unstoppablennn...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
posted here
Posts: 688
Threads: 75
Joined: Jun 2006
11-13-2007, 05:10 AM #9

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!!!nnHehehehnnCheers!

blobby
posted here
Posts: 421
Threads: 47
Joined: Apr 2007
11-13-2007, 03:59 PM #10
lmao.. rnrnthat plus a 500 round clip = unstoppablernrnrn...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)
rnrnrnI bet that is dead funny d-o LMAO ill have to try that cos i can get away with anything on my server lol

V vitalsfa
posted here
Posts: 5
Threads: 2
Joined: Jan 2008
01-23-2008, 08:34 PM #11

quick question how would i say change the rate of fire on the thompson

blobby
posted here
Posts: 421
Threads: 47
Joined: Apr 2007
01-24-2008, 06:15 PM #12

This topic tells you how to change the rate of fire on all weapons

V vitalsfa
posted here
Posts: 5
Threads: 2
Joined: Jan 2008
01-24-2008, 06:23 PM #13

it doesn't work for the thompson the offset 103 appears to change when fired is there any way to lock the pdata offsetrnrunning on a deticated serverrnbeentrying to do it all day

Wilson [29th ID]
started this thread
Posts: 623
Threads: 57
Joined: Oct 2005
01-28-2008, 08:59 AM #14

Hook FM_PlayBackEventnTest if eventindex == DODW_THOMPSONnIf so, set the pdata offset like you did.nnThis basically does it every time you fire.nBTW if it doesn't work, hook it in post.

S sreeja
posted here
Posts: 5
Threads: 0
Joined: Feb 2008
02-05-2008, 08:08 AM #15

Thank you for the information.Very useful.

Archive › Old Forum Threads › Help › Tutorials › Changing Rate of Fire
DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC