Quantcast

Jump to content

» «
Photo

Weapon Weight

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

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#1

Posted 25 April 2011 - 06:32 AM Edited by AngryAmoeba, 11 September 2013 - 04:45 AM.

WeaponWeight_DuffelBag.pngWeaponWeight_Adrenaline.png

WHAT IT DOES
Slowed Movement
This script decreases your speed on foot, depending on the weapons, ammo, and cash you're carrying. (All speed penalties can be tweaked.)
Hurrying
Holding ALT increases movement speed by 20%. Doing so while sprinting uses Adrenaline, shown as a white bar under the radar. (This can be tweaked or disabled.)
Weapon Bag
Large amounts of cash and all weapons except the knife and pistols are stored in a backpack or duffel bag, not in your magic pockets. (This can be tweaked or disabled.)
Weapon Removal
Pressing * on the numpad drops the current weapon permanently. While unarmed, hold PageDown and press * to remove armor. (This can be disabled.)

HOW TO INSTALL
This is a script for HazardX's .NET scripthook. Just place the files in the 'scripts' folder of the .NET scripthook.

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


v1.2.8 - last updated October 28, 2012

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.


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

TIPS
- Tweak the settings in the INI file to suit your preferences.
- Carrying lots of guns and ammo can have a major effect on your speed. Drop weapons you don't need.
- I recommend using my Weapon Storage mod if you want to get rid of weapons without losing them forever.
- Having 1 armor affects your speed the same as 100 armor. When your armor gets low, it might be a good idea to just remove it.
- To avoid being slowed down too much by your cash, use my Bank Account mod to store money at ATMs. Or set the cash speed penalty to 0.0.
- For realism, I recommend editing your WeaponInfo.xml file and decreasing the max ammo for every weapon to something realistic.
- Adrenaline recharges more slowly when you're moving fast.
- After the "MaxTotalPenalty" is reached, additional weight just makes the hurry button less effective, until hurrying has no effect.

KNOWN BUGS
- Unfortunately, you can't get weapons back after dropping them, due to script limitations. See this post for an alternate (sometimes buggy) version that I use, which allows dropped weapons to be picked back up.
- Melee weapons disappear when dropped, instead of falling to the ground.

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


CHANGE LOG
v1.2.8 — October 28, 2012
- When bags are unavailable for the current player model, they are disabled to prevent errors.
- Fixed bug where OtherMeleeBag INI setting applied to all melee weapons.

v1.2.7 — October 23, 2012
- Added support for non-vanilla thrown/melee weapons (INI settings OtherThrownPenalty, OtherMeleePenalty, OtherMeleeBag).
- Fixed bug where grenades slowed you down much more than intended.

v1.2.6 hotfix 2 — September 29, 2012
- Fixed bug where cash never gave you a bag.
- Very minor optimization when loading.

v1.2.6 hotfix — September 3, 2012
- Fixed constant player animation twitching caused by updating the bag too often.

v1.2.6 — September 3, 2012
- Added INI settings for bag behavior.
- Fixed incorrect setting in INI file (was RemoveArmorModifier instead of RemoveArmorModifierKey).
- Renamed AdrenRechargePerSec INI setting to AdrenRegenPerSec.
- Code cleanup.

v1.2.5 — September 1, 2012
- Ammo is measured per round instead of per clip.
- Fixed bug where sniper rifles and heavy weapons wouldn't give you a duffel bag.
- Fixed bug where dropped melee weapons weren't removed from your inventory.
- Minor optimization and significant cleanup.

v1.2.4 — December 31, 2011
- Added readme.
- Fixed bug where sprinting while the sprint key wasn't pressed wouldn't drain Adrenaline properly.
- Fixed bug where the cell phone could be dropped like a weapon.
- Minor optimization and cleanup.

v1.2.3 — September 27, 2011
- Added MaxTotalPenalty INI setting, default is 30%. This prevents super-slow-mo movement.
- Removed AdrenBarHeight INI setting. The bar now approximately matches the health/armor bar size.
- Fixed bug where a very high total penalty would make you slide around really fast.
- Minor optimization.

v1.2.2 — September 6, 2011
- Cash is now carried in a backpack if you have at least $65,000, a duffel bag for at least $500,000.
- Cash also has a speed penalty now, 0.003% per $1,000. Adds up if you carry a lot of money.

v1.2.1 — August 8, 2011
- Adrenaline is now shown as a bar under the radar.
- Adrenaline now recharges faster when not running.
- Minor fixes and optimization.
- Changed version numbering scheme.

v1.2 — May 6, 2011
- Compiled script and included INI file for settings.
- Incorporated my "Hurry Up" script into the mod. Holding Alt increases movement speed, and while sprinting it drains adrenaline. Without adrenaline, sprinting speed is normal.
- Changed default drop-weapon key to * on the numpad.
- Added "ModifierKey" (PageDown by default), which has to be held down to remove armor, to avoid removing accidentally.
- SMG, grenades, and molotovs are stored in backpack instead of duffel bag.
- Misc. fixes

v1.1b — April 26, 2011
- Removed guns now fall to the ground instead of disappearing (melee weapons still just disappear, all weapons still can't be picked up again)
- Pressing the remove weapon key while unarmed will remove armor

v1.1 — April 26, 2011
- Added ability to remove weapons with Y


HippieCommunist
  • HippieCommunist

    PWR2DPPL

  • Members
  • Joined: 25 Jan 2003

#2

Posted 25 April 2011 - 07:00 AM

NICE!

keep it up dude!!
cookie.gif cookie.gif cookie.gif cookie.gif

lolleroz
  • lolleroz

    Homeboy

  • Members
  • Joined: 29 Jul 2010
  • None

#3

Posted 25 April 2011 - 08:05 AM

'Conflicts with my Hurry Up script. I use this and Hurry Up merged together into one script, so if anyone wants that I can post it.'
Yeah, post it please.

Great job, matey. Will prove as an useful realism thingy, long time ago I tried to trunk mod, but having sh*tload of weps didn't slow you down at all, and this is where you come in. Thanks alot for the mod.

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#4

Posted 25 April 2011 - 08:26 AM Edited by AngryAmoeba, 26 April 2011 - 11:31 AM.

QUOTE (lolleroz @ Apr 25 2011, 02:05)
'Conflicts with my Hurry Up script. I use this and Hurry Up merged together into one script, so if anyone wants that I can post it.'
Yeah, post it please.

Ask and ye shall receive! biggrin.gif

http://www.mediafire...ma284z8uz9118mg

lolleroz
  • lolleroz

    Homeboy

  • Members
  • Joined: 29 Jul 2010
  • None

#5

Posted 25 April 2011 - 08:47 AM

Thanks alot, bro.
One thing by the way...in future, you need to make a script where Niko can dump the weapons tounge.gif It will be useful for two things - first, for dropping the weapons you don't need which slow u down, and second, for roleplaying. Getting rid of the gun after you kill someone etc

ikt
  • ikt

    *poof*

  • Members
  • Joined: 02 Oct 2006
  • None

#6

Posted 25 April 2011 - 12:07 PM

Maybe a realistic weapon carrying mod in combination of this? 2 main weapons, one on your back, a knife and pistol. Heavier penalties for all weapons.

Dropping weapons like in Crysis 1. (Shooting all your ammo to get rid of that shotgun you never use anyway isn't the most silent approach to dump weapons)


AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#7

Posted 25 April 2011 - 11:26 PM

QUOTE
Maybe a realistic weapon carrying mod in combination of this? 2 main weapons, one on your back, a knife and pistol. Heavier penalties for all weapons.

Well, what I did for my own game is edit WeaponInfo.xml (in common\data) so that the sniper rifles, assault rifles, and RPG all use the same slot.

To do that, change the "slot" of a weapon to the same slot as another weapon. For example, change the sniper slot from "SNIPER" to "RIFLE" to make snipers use the same slot as assault rifles.

The problem with this method is that you can't have two generic 'main weapon' slots that accept any main weapon. Instead, one slot accepts some weapons and the other slot accepts different weapons. I'll try to figure out a better way to do this...

And then for heavier penalties, you can just open up the script file and change the values for any of the penalties.

QUOTE
One thing by the way...in future, you need to make a script where Niko can dump the weapons tounge.gif It will be useful for two things - first, for dropping the weapons you don't need which slow u down, and second, for roleplaying. Getting rid of the gun after you kill someone etc
QUOTE
Dropping weapons like in Crysis 1. (Shooting all your ammo to get rid of that shotgun you never use anyway isn't the most silent approach to dump weapons)

I did try to include weapon dropping, but it always dropped the weapon right where I was standing, forcing me to pick it up again immediately. The other solutions I tried were to just 'remove' the weapon instead of dropping it, or set the weapon ammo to 0, but then you can't pick it back up.

I'll keep thinking about it, and maybe I'll come up with a solution. Any programmers: advice is welcome!

lolleroz
  • lolleroz

    Homeboy

  • Members
  • Joined: 29 Jul 2010
  • None

#8

Posted 25 April 2011 - 11:43 PM

How about for now you include script where you can dump the weapons (setting the ammo to 0) and in future you'll make something better out? tounge.gif

ikt
  • ikt

    *poof*

  • Members
  • Joined: 02 Oct 2006
  • None

#9

Posted 26 April 2011 - 06:07 AM

QUOTE (AngryAmoeba @ Apr 26 2011, 01:26)
QUOTE
Maybe a realistic weapon carrying mod in combination of this? 2 main weapons, one on your back, a knife and pistol. Heavier penalties for all weapons.

Well, what I did for my own game is edit WeaponInfo.xml (in common\data) so that the sniper rifles, assault rifles, and RPG all use the same slot.

To do that, change the "slot" of a weapon to the same slot as another weapon. For example, change the sniper slot from "SNIPER" to "RIFLE" to make snipers use the same slot as assault rifles.

The problem with this method is that you can't have two generic 'main weapon' slots that accept any main weapon. Instead, one slot accepts some weapons and the other slot accepts different weapons. I'll try to figure out a better way to do this...

And then for heavier penalties, you can just open up the script file and change the values for any of the penalties.

QUOTE
One thing by the way...in future, you need to make a script where Niko can dump the weapons tounge.gif It will be useful for two things - first, for dropping the weapons you don't need which slow u down, and second, for roleplaying. Getting rid of the gun after you kill someone etc
QUOTE
Dropping weapons like in Crysis 1. (Shooting all your ammo to get rid of that shotgun you never use anyway isn't the most silent approach to dump weapons)

I did try to include weapon dropping, but it always dropped the weapon right where I was standing, forcing me to pick it up again immediately. The other solutions I tried were to just 'remove' the weapon instead of dropping it, or set the weapon ammo to 0, but then you can't pick it back up.

I'll keep thinking about it, and maybe I'll come up with a solution. Any programmers: advice is welcome!

Could you maybe add force to it for it to fly away?
Remove ammo for when player is in range, if out of range, add ammo again.

Although I don't know if you can add ammo to a dropped weapon, since I've not seen anything in Scripting.h that relates to that.

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#10

Posted 26 April 2011 - 09:15 AM

I found that dropping the weapon always had a chance to fire on hitting the ground, which is instant death with a rocket launcher. suicidal.gif The native function "STOP_PED_WEAPON_FIRING_WHEN_DROPPED" didn't do anything, and even when ammo is set to 0 before dropping, they can still fire.

So to implement it, I ended up just removing the weapons, which sucks. The weapon disappears into thin air. But it's better than having to shoot all your ammo, so I've updated the files in the first post.

ikt
  • ikt

    *poof*

  • Members
  • Joined: 02 Oct 2006
  • None

#11

Posted 26 April 2011 - 09:47 AM Edited by ikt, 26 April 2011 - 09:50 AM.

QUOTE (AngryAmoeba @ Apr 26 2011, 11:15)
I found that dropping the weapon always had a chance to fire on hitting the ground, which is instant death with a rocket launcher. suicidal.gif The native function "STOP_PED_WEAPON_FIRING_WHEN_DROPPED" didn't do anything, and even when ammo is set to 0 before dropping, they can still fire.

So to implement it, I ended up just removing the weapons, which sucks. The weapon disappears into thin air. But it's better than having to shoot all your ammo, so I've updated the files in the first post.

Have you tried ForceCharToDropWeapon(Ped ped)?
Maybe that's the one used when you empty your guns.

Also try emptying the ammo in the clip.

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#12

Posted 26 April 2011 - 11:19 AM

Good call on the clip ammo, that fixed the gun firing problem. So now I've gotten it to where you can drop weapons (except melee, those still force you to pick them up). But you still can't pick them up again.

I started looking into creating pickups via native functions... Does anyone know how that works? I found some that look useful, like CREATE_PICKUP_WITH_AMMO, but I can't figure out how to use them.

lolleroz
  • lolleroz

    Homeboy

  • Members
  • Joined: 29 Jul 2010
  • None

#13

Posted 26 April 2011 - 12:27 PM

We already have dumping weapons, that's good.
Now, you need to make a script where we will be able to store the guns in trunk of our car. Someone has already done it, but it was...not too good. The script remembered the ammo in your guns and the guns you've had, though, so when you took the guns out of the trunk you got all of them back with proper ammo.

Prof_Farnsworth
  • Prof_Farnsworth

    Ambient Modder

  • Members
  • Joined: 25 Feb 2011

#14

Posted 26 April 2011 - 01:04 PM Edited by Prof_Farnsworth, 26 April 2011 - 01:06 PM.

Sweet work Ameoba. I especially like the duffel bag. Nice ambient touch.

Off the top of my head, here is what I would try for dropping the weapon.

1. When weapon is dropped, set player weapon of same slot to different type of weapon(i.e. combat and regular shotgun). When you carry a different type, the game prompts you to swap the replacement.
2. Apply force to weapon (ideally forward) to act as weapon throw, while also setting player weapon select to an adjacent slot (lower or higher, can't remember default in game).
3. Once player is "x" distance away. Set new weapon ammo to 0 and it should just disappear, allowing you to pick up your dropped gun again.

Doing this, you should not need to set the ammo to 0 each time for weapon dropped.

Worst case is if the player switches back to their previous weapon before being out of range, they will see their weapon disappear (Though the range would be small, so less likely). Also, this will not work for the rocket launcher, as I am fairly certain there is only one type of those.

Great work on the mod!

lolleroz
  • lolleroz

    Homeboy

  • Members
  • Joined: 29 Jul 2010
  • None

#15

Posted 26 April 2011 - 01:06 PM

QUOTE (Prof_Farnsworth @ Apr 26 2011, 13:04)
Sweet work Ameoba. I especially like the duffel bag. Nice ambient touch.

Off the top of my head, here is what I would try for dropping the weapon.

1. When weapon is dropped, set player weapon of same slot to different type of weapon(i.e. combat and regular shotgun). When you carry a different type, the game prompts you to swap the replacement.
2. Apply force to weapon (ideally forward) to act as weapon throw, while also setting player weapon select to an adjacent slot (lower or higher, can't remember default in game).
3. Once player is "x" distance away. Set new weapon ammo to 0 and it should just disappear, allowing you to pick up your dropped gun again.

Worst case is if the player switches back to their previous weapon before being out of range, they will see their weapon disappear. Also, this will not work for the rocket launcher, as I am fairly certain there is only one type of those.

Great work on the mod!

The point is, if Amoeba will make the dumped weapon change to pickup, the ammo on it will change to one clip anyway (like 30 instead of 300) so it doesn't make sense.

ikt
  • ikt

    *poof*

  • Members
  • Joined: 02 Oct 2006
  • None

#16

Posted 26 April 2011 - 02:28 PM

CreatePickupWithAmmo(eModel model, ePickupType pickupType, u32 unknown, f32 x, f32 y, f32 z, Pickup *pPickup)

eModel is character models or object models, so I assumt you get the niko skin for that
PickupType: isn;t in enums. try using Ammo or numbers. In the worst case this only handles picked up objects like cans, but i doubt this since it has ammo.
u32 unknown: don't know for sure, but this might be ammo (because of u32, so this is how many ammo it will have on pickup)
x, y, z are the position, I think you know what this does.
*pPickup: don't know, but it might be data that could be saved, maybe you won't need it. just try putting &bla there and see if it doesn't return errors.

I suggest you just try it and see what the error messages say, those saved me a lot of times already tounge.gif

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#17

Posted 28 April 2011 - 06:55 AM

Alright guys, I had to write a couple essays for school but now I have some time to work on this...

While I was experimenting with native functions, I discovered a much easier function:
Pickup.CreateWeaponPickup(Vector3 position, GTA.Weapon weapon, int ammo, Vector3 rotation).

So using that I got it to where I can create a pickup of the appropriate weapon with the appropriate amount of ammo. But my new problems are: the pickup is not physics-enabled, and I don't know how to check whether the pickup will be created inside a wall or another object.

Can anyone help with these issues?

ikt
  • ikt

    *poof*

  • Members
  • Joined: 02 Oct 2006
  • None

#18

Posted 28 April 2011 - 10:26 AM

After the weapon is created, add force to it (just a very little bit) and hope the weapon will get launched outwards a building.

By the way, what do you mean with non-native functions?

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#19

Posted 28 April 2011 - 12:31 PM

QUOTE (ikt @ Apr 28 2011, 04:26)
After the weapon is created, add force to it (just a very little bit) and hope the weapon will get launched outwards a building.

The pickups don't seem to be objects, just models without physics, so I can't apply force to them.

QUOTE
By the way, what do you mean with non-native functions?

To invoke a native function, you do this: GTA.Native.Function.Call("CREATE_WEAPON_PICKUP", params).

But there is also a comparable function in the Pickup class, invoked like this: GTA.Pickup.CreateWeaponPickup(params).

I couldn't get the native function working, but the Pickup one works, except for the physics.

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#20

Posted 29 April 2011 - 02:38 AM

Sorry for the double post...

I realized that pickups get saved in the save game... This means that if I create a pickup inside a wall or something, and I can't get to it, there's no way to get rid of it. I made a 'cleanup' function to delete pickups after a length of time, but that can't guarantee that they will all be deleted before the game is saved.

Does anyone know of a way to trigger cleanup code right before saving?

ikt
  • ikt

    *poof*

  • Members
  • Joined: 02 Oct 2006
  • None

#21

Posted 29 April 2011 - 05:49 AM

QUOTE (AngryAmoeba @ Apr 29 2011, 04:38)
Sorry for the double post...

I realized that pickups get saved in the save game... This means that if I create a pickup inside a wall or something, and I can't get to it, there's no way to get rid of it. I made a 'cleanup' function to delete pickups after a length of time, but that can't guarantee that they will all be deleted before the game is saved.

Does anyone know of a way to trigger cleanup code right before saving?

IsAutoSaveInProgress()

This is probably the same R* uses for when missions are over, and to remove wanted level and such.

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#22

Posted 07 May 2011 - 03:17 AM Edited by AngryAmoeba, 08 August 2011 - 05:38 AM.

New version in first post!

Changes in v1.2:
- Compiled script and included INI file for settings.
- Incorporated my "Hurry Up" script into the mod. Holding Alt increases movement speed, and while sprinting it drains adrenaline. Without adrenaline, sprinting speed is normal.
- Changed default drop-weapon key to * on the numpad.
- Added "ModifierKey" (PageDown by default), which has to be held down to remove armor, to avoid removing accidentally.
- SMG, grenades, and molotovs are stored in backpack instead of duffel bag.
- Misc. fixes

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#23

Posted 08 August 2011 - 05:49 AM Edited by AngryAmoeba, 07 September 2011 - 03:49 AM.

New version in first post. I updated my Hurry Up mod, which is included in this mod. Also fixed some things.

Changes in v1.2.1
- Adrenaline is now shown as a bar under the radar.
- Adrenaline now recharges faster when not running.
- Minor fixes and optimization.
- Changed version numbering scheme.

ricardo8086
  • ricardo8086

    Player Hater

  • Members
  • Joined: 28 Jul 2011

#24

Posted 10 August 2011 - 04:27 AM

QUOTE (ikt @ Friday, Apr 29 2011, 05:49)
QUOTE (AngryAmoeba @ Apr 29 2011, 04:38)
Sorry for the double post...

I realized that pickups get saved in the save game... This means that if I create a pickup inside a wall or something, and I can't get to it, there's no way to get rid of it. I made a 'cleanup' function to delete pickups after a length of time, but that can't guarantee that they will all be deleted before the game is saved.

Does anyone know of a way to trigger cleanup code right before saving?

IsAutoSaveInProgress()

This is probably the same R* uses for when missions are over, and to remove wanted level and such.

Where did you find this function IsAutoSaveInProgress() ? I want to use it, but couldn't find it.

Excelent mod, by the way, AngryAmoeba!

janusantsky
  • janusantsky

    Rat

  • Members
  • Joined: 27 Apr 2010

#25

Posted 20 August 2011 - 01:47 PM

hello i have a bug when i use this mod luis go superslow or superfast , if someone has already that and know how to fix it,
maybe the reason is that i use a lot of other mod but maybe someone has the response, thanks

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#26

Posted 20 August 2011 - 10:54 PM

When does he go super-slow, and when does he go super-fast?

And does it happen even when carrying only default weapons (no added weapons)?

janusantsky
  • janusantsky

    Rat

  • Members
  • Joined: 27 Apr 2010

#27

Posted 24 August 2011 - 08:33 AM

i think this is with added weapons when i spawn with trainer, but i have a question is there a script to carry medikit, it would be cool cause i'm playing with a bigger difficulty or a script to heal with a small animation

lolleroz
  • lolleroz

    Homeboy

  • Members
  • Joined: 29 Jul 2010
  • None

#28

Posted 28 August 2011 - 02:36 PM

hey man, sorry for dissapointing you while we were testing the script, i had some IRL probs and stopped playing IV for a while, but I see you did a great job, nice work!

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#29

Posted 07 September 2011 - 03:49 AM Edited by AngryAmoeba, 27 September 2011 - 09:54 AM.

Small update in first post.


v1.2.2
- Cash is now carried in a backpack if you have at least $65,000, a duffel bag for at least $500,000.
- Cash also has a speed penalty now, 0.003% per $1,000. Adds up if you carry a lot of money.

AngryAmoeba
  • AngryAmoeba

    Symbiote

  • Members
  • Joined: 12 Jan 2009

#30

Posted 27 September 2011 - 09:54 AM Edited by AngryAmoeba, 01 January 2012 - 04:25 AM.

New update in first post. This is mainly a bug fix update, but the alternate version received some significant changes behind the scenes.


Changes in v1.2.3
- Added MaxTotalPenalty INI setting, default is 30%. This prevents super-slow-mo movement.
- Removed AdrenBarHeight INI setting. The bar now approximately matches the health/armor bar size.
- Fixed bug where a total penalty of over 100% would make you slide around really fast.
- Minor optimization.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users