Quantcast

Jump to content

» «
Photo

Real Reload

GTA4 .NET script mod realism
23 replies to this topic
AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#1

Posted 21 April 2011 - 06:19 AM Edited by AngryAmoeba, 11 September 2013 - 04:49 AM.

WHAT IT DOES
More realistic reload model!
- Switching weapons no longer refills the gun's clip.
- Reloading discards the remaining ammo in the clip (except for shotguns that don't use magazines).

HOW TO INSTALL
This is a script for HazardX's .NET scripthook. Just place RealReload.cs and RealReload.ini into the 'scripts' folder of the .NET scripthook.
Note: If you don't use the R key for reloading, you'll have to change the key setting in RealReload.ini.

----------------


v1.3.2 - last updated January 15, 2013

ADF.LY DOWNLOAD
If you'd like to support me and my mods,
take 5 seconds and use this download link!

NORMAL DOWNLOAD
If you're in a hurry, use this one.


----------------

KNOWN BUGS
- Doesn't work with gamepads, unfortunately.
- When you switch weapons, your ammo will briefly look like the clip was refilled. As soon as you can aim the gun, the ammo numbers will revert back to what they were when you last used the gun.
- The sawn-off shotgun in TLAD shouldn't be affected, but I can't test it since I don't have TLAD.

----------------

CHANGE LOG
v1.3.2 — January 15, 2013
- Fixed bug where switching weapons during a reload caused a chain of reloads until all ammo disappeared

v1.3.1 — November 15, 2012
- Added INI setting for whether remaining ammo in clip is lost when you reload
- Very minor code cleanup

v1.3 — November 6, 2011
- Now you must change the default key in the INI if you don't use R (reverted from v1.2)
- Fixed bug where the reload key would be undetected if pressed too fast
- Fixed bug where switching weapons would refill the gun's clip
- Fixed bug where trying to reload with zero extra ammo would empty the clip
- You can now cancel a reload by switching weapons before it's complete
- Converted script from VB.NET to C#

v1.2 — May 24, 2011
- Bug fixed - no longer necessary to edit the code for reload keys other than R
- Bug maybe fixed - added TLAD sawn-off shotgun to unaffected weapons

v1.1 — April 22, 2011
- Bug fixed - no longer subtracts a whole clip of ammo when you try to reload with a full clip
- Bug fixed - no longer subtracts ammo multiple times when you press R multiple times
- Added info in script on how to edit for a reload key other than R


lolleroz
  • lolleroz

    Homeboy

  • Members
  • Joined: 29 Jul 2010
  • None

#2

Posted 21 April 2011 - 10:09 AM

HOLY sh*t I LOVE U OMG OMG OMG OMG MARRY ME

I was about to request such mod on PM to BR_Goianiense having idea how to build such script, although I was pretty sure it's impossible. DUDEILOVEUOMG

metacortex
  • metacortex

    3,4-dihydroxyphenethylamine

  • Members
  • Joined: 17 Jan 2011

#3

Posted 22 April 2011 - 10:09 PM

Damn nice work there sir, I like it a lot. Source is short but quite effective tounge.gif
cheers

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#4

Posted 23 April 2011 - 12:46 AM Edited by AngryAmoeba, 23 April 2011 - 01:42 AM.

I had a feeling there were other people out there who wanted this feature. smile.gif

Edit: Heads up, I uploaded a new version with some stupid bugs fixed.

HippieCommunist
  • HippieCommunist

    PWR2DPPL

  • Members
  • Joined: 25 Jan 2003

#5

Posted 23 April 2011 - 10:17 PM

great job! biggrin.gif icon14.gif

hkboondoggle
  • hkboondoggle

    Fail

  • Members
  • Joined: 08 Jul 2009

#6

Posted 24 April 2011 - 04:08 AM

Nice & neat indeed, good work!
Hope it will be compatible with gamepads in later version.

vava720
  • vava720

    Prankster

  • Members
  • Joined: 19 Feb 2011

#7

Posted 19 May 2011 - 06:48 AM

I download the file, and I have "Real Raload v1.1" without extension (with the extension .1) so I can't extract it (I think this is an archive ?).

I've tried to put ".rar" at the end, ".zip", and ".7z" but nothing worked.
Help please ! I'd like to use your fantastic mod !

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#8

Posted 19 May 2011 - 08:34 PM

The file should have a .vb extension. Thanks for letting me know it was missing! It's fixed now. (How many people downloaded the file without the extension? confused.gif )

This problem affected some of my other mods too, since I didn't realize renaming the files on Mediafire changed the actual file names...

vava720
  • vava720

    Prankster

  • Members
  • Joined: 19 Feb 2011

#9

Posted 20 May 2011 - 05:51 AM

Ok thank you for telling me ! I try your mod right now biggrin.gif

ikt
  • ikt

     

  • Members
  • Joined: 02 Oct 2006

#10

Posted 24 May 2011 - 04:45 PM

I might have another approach to your 'problem': Instead of checking for a key press, you could also check for the reloading animation to be active. I found HasReloadedWithMotionControl in the dirty, maybe you--
wait, that's the PS3 reloading with the motion controller, isn't it? Well crap. tounge.gif

It's awesome anyway. wink.gif

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#11

Posted 24 May 2011 - 09:34 PM

On the gtamodding.com list of animations, it looks like there are nine different reload animations for the various weapons. I don't think I want to check for each of those animations all the time...

I tried detecting GameKey.Reload, which seems like it would be perfect, but then the script just stopped working altogether. I never figured out why. bored.gif

ikt
  • ikt

     

  • Members
  • Joined: 02 Oct 2006

#12

Posted 24 May 2011 - 10:06 PM

Can't you use or (||) to check for the reloading anims?

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#13

Posted 24 May 2011 - 11:11 PM

New version in first post! Thanks to ikt for motivating me to work on this. biggrin.gif (I got the GameKey.Reload method working... It was really simple.)

Changes in v1.2
- Bug fixed - no longer necessary to edit the code for reload keys other than R
- Bug maybe fixed - gamepad support added?
- Bug maybe fixed - added TLAD sawn-off shotgun to unaffected weapons

If you have TLAD and/or a gamepad, please let me know if those bugs are fixed!

ikt
  • ikt

     

  • Members
  • Joined: 02 Oct 2006

#14

Posted 25 May 2011 - 10:52 AM

Tested it with gamepad, ammo doesn't substract. I'm using the x360 emu for the controller. It does work with kb/mouse, so that's working smile.gif

Fitfit
  • Fitfit

    Player Hater

  • Members
  • Joined: 26 Sep 2011

#15

Posted 10 October 2011 - 08:42 PM

Really good !
You should try to do something about " - When you switch weapons, the game refills the gun's clip using your stored ammo, if you have any. "
It would be perfect then ^^


TriXigT
  • TriXigT

    3DFANATIC

  • Members
  • Joined: 24 Oct 2009

#16

Posted 13 October 2011 - 04:20 PM

Hi, does not seem to work on 1.0.4.0 smile.gif

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#17

Posted 13 October 2011 - 08:10 PM

I'm using 1.0.4.0 and it works... Are you using a gamepad, perhaps?

TriXigT
  • TriXigT

    3DFANATIC

  • Members
  • Joined: 24 Oct 2009

#18

Posted 13 October 2011 - 10:36 PM

QUOTE (AngryAmoeba @ Thursday, Oct 13 2011, 22:10)
I'm using 1.0.4.0 and it works... Are you using a gamepad, perhaps?

No I'm not, I've placed the .vb script inside the "scripts"-folder as instructed - I can remove some of my other scripts to see if this one is working tomorrow.. I have contact missions, car store, ragdoll by pain(hippiec.) and first person scripts running. There may be an incompatibility or something!

Is there any way to test/see if a script is loaded and executed without errors in GTA IV?

(no gamepad)

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#19

Posted 14 October 2011 - 12:51 AM

I think those are all ASI scripts. Are you sure you have the .NET scripthook? Look for a file called ScriptHookDotNet.log, and if it's there, see if it has any error messages.

TriXigT
  • TriXigT

    3DFANATIC

  • Members
  • Joined: 24 Oct 2009

#20

Posted 16 October 2011 - 07:10 PM Edited by TriXigT, 17 October 2011 - 01:58 PM.

EDIT: Fixed the script!

I checked my log and it occurred to me that the tlad shotgun isn't present in my game as I'm only on IV - so I simply removed that line.. Here's the edited code:

CODE
Imports System
Imports System.Windows.Forms
Imports GTA

' More realistic reload model. Discarding a clip discards the remaining ammo in the clip.
' Does not apply to shotguns from vanilla GTA4. I don't know about EFLC.

Public Class RealReload
   Inherits Script
   
   Dim pc As ped = Player.Character

   Private Sub RealReload_KeyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
       If Game.isGameKeyPressed(GameKey.Reload) _
       AndAlso pc.Weapons.Current.AmmoInClip < pc.Weapons.Current.MaxAmmoInClip _
       AndAlso pc.Weapons.Current <> Weapon.Shotgun_Basic _
       AndAlso pc.Weapons.Current <> Weapon.Shotgun_Baretta Then
           pc.Weapons.Current.AmmoInClip = 0
       End If
   End Sub
End Class


I'm only coding in java (for android, as a note) so I don't have any experience in the language used here =)

Improvements to be done > if there is no more ammo except in the clip, the ammo in the shouldn't be affected by pressing R - make the current ammo condition of a weapon not be affected by changing the gun, it's very unrealistic.. I have a clue about how this could be done, but my experience is very limited outside Java confused.gif

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#21

Posted 16 October 2011 - 07:43 PM

QUOTE (TriXigT @ Sunday, Oct 16 2011, 13:43)
The log said that the tlad shotgun wasn't found and therefore the script failed, so I simply removed that line - although a new error says "an identifier is expected"..

Hm, I wonder why the TLAD shotgun couldn't be found. Are you using the latest version of the scripthook? (v1.7.1.7)

Anyway, you can fix the new error by deleting the _ before "Then". So it should be:
CODE
AndAlso pc.Weapons.Current <> Weapon.Shotgun_Baretta Then

TriXigT
  • TriXigT

    3DFANATIC

  • Members
  • Joined: 24 Oct 2009

#22

Posted 17 October 2011 - 02:08 PM

QUOTE (AngryAmoeba @ Sunday, Oct 16 2011, 21:43)
QUOTE (TriXigT @ Sunday, Oct 16 2011, 13:43)
The log said that the tlad shotgun wasn't found and therefore the script failed, so I simply removed that line - although a new error says "an identifier is expected"..

Hm, I wonder why the TLAD shotgun couldn't be found. Are you using the latest version of the scripthook? (v1.7.1.7)

Anyway, you can fix the new error by deleting the _ before "Then". So it should be:
CODE
AndAlso pc.Weapons.Current <> Weapon.Shotgun_Baretta Then

I edited my post right about the moment you posted your answer tounge.gif

Anyway; According to the log I'm using this version "ScriptHookDotNet v0.893 BETA", I believe it's the only one working with 1.0.4.0?

Yeah I compared your script with my edited one and found the thing with the " _ " - thx for the help anyway! biggrin.gif

When I edited my post yesterday I added some suggestions to it, I'll paste them here:
Improvements to be done > if there is no more ammo except the ammo in the clip, the ammo in the shouldn't be affected by pressing R - make the current ammo condition of a weapon not be affected by changing the gun, it's very unrealistic.. I have a clue about how the later could be done, but my experience is very limited outside Java confused.gif

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#23

Posted 17 October 2011 - 04:29 PM

QUOTE (TriXigT @ Monday, Oct 17 2011, 08:08)
Anyway; According to the log I'm using this version "ScriptHookDotNet v0.893 BETA", I believe it's the only one working with 1.0.4.0?

v0.893 is quite old! I'm using the latest scripthook with patch 1.0.4.0. And I don't have EFLC, but the TLAD shotgun doesn't break the script for me.

QUOTE
Improvements to be done > if there is no more ammo except the ammo in the clip, the ammo in the shouldn't be affected by pressing R

Wow, you're right. I could've sworn I checked for that, but looking at the code, obviously I didn't. You can just add this line to the list of conditions:
CODE
AndAlso pc.Weapons.Current.AmmoInClip < pc.Weapons.Current.Ammo _


QUOTE
make the current ammo condition of a weapon not be affected by changing the gun, it's very unrealistic.. I have a clue about how the later could be done, but my experience is very limited outside Java confused.gif

I agree, but I've been reluctant to make this script much bigger. I like it tiny. tounge.gif

The best way I can think of to solve that problem would be to keep a list of all previously selected weapons, as well as a list of how much ammo they each had before switching weapons. Then restore the ammo amount if they switch back to that weapon. Maybe there's a simpler way?

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#24

Posted 07 November 2011 - 12:11 AM

QUOTE (AngryAmoeba @ Monday, Oct 17 2011, 10:29)
QUOTE
make the current ammo condition of a weapon not be affected by changing the gun, it's very unrealistic.. I have a clue about how the later could be done, but my experience is very limited outside Java confused.gif

I agree, but I've been reluctant to make this script much bigger. I like it tiny. tounge.gif

The best way I can think of to solve that problem would be to keep a list of all previously selected weapons, as well as a list of how much ammo they each had before switching weapons. Then restore the ammo amount if they switch back to that weapon. Maybe there's a simpler way?

So I did this, and the script is no longer tiny. Update is in the first post.

Changes in v1.3
- Now you must change the default key in the INI if you don't use R (reverted from v1.2)
- Fixed bug where the reload key would be undetected if pressed too fast
- Fixed bug where switching weapons would refill the gun's clip
- Fixed bug where trying to reload with zero extra ammo would empty the clip
- You can now cancel a reload by switching weapons before it's complete
- Converted script from VB.NET to C#

New bug
- When you switch weapons, your ammo will briefly look like the clip was refilled. As soon as you can aim the gun, the ammo numbers will revert back to what they were when you last used the gun.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users