Raised This Month: $ Target: $400
 0% 

Changing Weapon Rate of Fire


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 01-22-2011 , 13:13   Changing Weapon Rate of Fire
Reply With Quote #1

When I say rate of fire, I'm talking about making a fully automatic weapon shoot semi-automatic, and then controlling the refire time. I wanted to see if anyone has a working method for this. Thanks for any help.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-22-2011 , 13:16   Re: Changing Weapon Rate of Fire
Reply With Quote #2

You mean like make a burst mod on ak47 ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 01-22-2011 , 14:06   Re: Changing Weapon Rate of Fire
Reply With Quote #3

Not a burst. Like, I'm trying to make the gun shoot one bullet per click. I'm trying some different things, and right now the one I got is pretty close.

I'm trying to make like a laser tag mod, and I don't want to make custom weapons. So what I've done now is basically I gave a player a weapon, and then I set that player to no ammo. Then I can trigger the firing based upon when they use their fire key, and track a delay based on their last release of the button. It works ingame pretty good, except there is a delay between click and fire, and I'm working on removing the annoying dryfire sound.

Or... hmm, what if I blocked the attack and right when I block the attack, I block the animation of the gun firing from playing by playing the animation of idle. This would sort of create a semi-auto gun. I think I'll try doing that in a bit.

Code:
public fw_CmdStart( id, uc_handle, randseed )
{
    if (!g_isAlive[id])
        return FMRES_IGNORED
        
    new button = get_uc( uc_handle , UC_Buttons );
    new oldbutton = pev(id, pev_oldbuttons)
    
    if( button & IN_ATTACK && !(oldbutton & IN_ATTACK))
        g_isFiring[id] = true
    else if( oldbutton & IN_ATTACK && !(button & IN_ATTACK) && g_isFiring[id])
        g_isFiring[id] = false

    return FMRES_IGNORED;
}

public fw_PlayerPreThink(id)
{
    if (!g_isAlive[id])
        return FMRES_IGNORED
    
    if (g_fLastAttack[id]+ATTACK_DELAY > get_gametime())
        return FMRES_IGNORED;
    g_fLastAttack[id] = get_gametime();
    
    if (g_isFiring[id])
    {
        emit_sound(id,CHAN_WEAPON,LASER_SOUND, 1.0, ATTN_NORM, 0, PITCH_NORM);
    }

    return FMRES_IGNORED;
}
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 01-22-2011 at 14:09.
Tirant is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-22-2011 , 14:30   Re: Changing Weapon Rate of Fire
Reply With Quote #4

Like the deagle (actually any pistols) ? If so, what the CS code does is in DEAGLEFire() function, for example, is to check if m_iShotsFired offset is > 1, then if so it stops here. So you can play with the *Fire() function on the weapon you need.

Without orpheu, you would need to do something near of your code, checking if old_buttons doesn't contain IN_ATTACK and blocking the attack, though I'm not sure why you are using PreThink.
__________________
Arkshine is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 01-22-2011 , 15:08   Re: Changing Weapon Rate of Fire
Reply With Quote #5

Well, I played around with it for a bit, and I've reached what I needed. Basically, I made it so people can hold down their attack buttons for repeating fire (with the delay). It works really nicely ingame, the last thing I need to fix now is to possibly make the laser work better. I have an idea that I'll try and I'll post if it works later.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 01-22-2011 , 16:26   Re: Changing Weapon Rate of Fire
Reply With Quote #6

Well, I was able to improve the laser a lot, and it is looking pretty cool ingame. I optimized it so it isn't too bad. It's not as smooth as I wanted it, but it's better then it was, and you don't notice it much because it shoots fast. I think I'm pretty much done with the first part of my new mod now .
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant 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 08:02.


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