Quantcast

Jump to content

» «
Photo

[Q] Create custom weapons based on an existing model

20 replies to this topic
Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#1

Posted 26 July 2014 - 12:27 PM

Hello. I was creating a mod that gives you a gun (with default pistol model) on the press of a button. I want to create the gun from pure coding, and not creating a new weapon from stats and stuff.

The gun I want to make is simple. Explodes the area on shoot. So no bullet and stuff. I know this is possible because I've seen it before but I don't exactly know what mod was it. I have VB.Net but I can convert C# code too.

Question 2: How do I detect shooting of a specific weapon?

Thanks. I am typing on mobile so pardon my mistakes.

LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#2

Posted 26 July 2014 - 01:08 PM Edited by LetsPlayOrDy, 26 July 2014 - 03:44 PM.

(Q.1)If you are wanting a new gun that you can hold, then I don't believe that is possible in scripting.
Explodes the area on shoot? You mean it just spawns explosions around you or something? That would be easy. Use World.AddExplosion

(Q.2)I was trying to figure that out not too long ago also, didn't find a solution. So, that means either it is not possible or I just didn't look in the right places.  :/

I know you can make weapons that you DON'T hold. Like, for example, the Batmobile script by JulioNIB. He made custom machine guns with it, using the FIRE_SINGLE_BULLET native (and adding ptfx and stuff).

(I'm on my mobile too lol)


Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#3

Posted 26 July 2014 - 01:42 PM Edited by Sadra1122, 26 July 2014 - 01:57 PM.

@LetsPlayOrDy

Thanks for the help.

 

What I meant on Q.1 was that creating a custom weapon (With .net script) with the model of the default pistol that you can shoot and then an event happens(in this case, explode the area that you shot in, but that's not really important, cause as you said, I can use world.addexplosion).

 

Is there absolutely no way you can create a custom weapon? Ah... if I find the mod, I'll link it over here so you guys can inspect

 

Thanks. :)

 

Edit: I found somethings related to a 'GravityGun'

A thread about it here:

http://gtaforums.com...iv-gravity-gun/

Also, JulioNIB's Ghostrider script has a weapon-style chain AND also a custom shotgun:

http://www.gta4-mods...mod-v241-f18079

 

Hope someone clears this out for me.


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#4

Posted 26 July 2014 - 01:55 PM

There isn't any way that I know of (in scripting), but if you do find any .NET script that creates a new weapon, just give us a link and I'll decompile it to see how it is creating the weapon.


Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#5

Posted 26 July 2014 - 01:59 PM

There isn't any way that I know of (in scripting), but if you do find any .NET script that creates a new weapon, just give us a link and I'll decompile it to see how it is creating the weapon.

I just did. Check it out. :p


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#6

Posted 26 July 2014 - 02:36 PM

Looked at both of them. They do not create new weapons, just use already created ones.


Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#7

Posted 26 July 2014 - 03:01 PM Edited by Sadra1122, 26 July 2014 - 03:08 PM.

Hmm, is it possible to change the shooting effect? For example, change the shooting effect of a pistol from bullet to explosive shot.

 

Thank you. :)


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#8

Posted 26 July 2014 - 03:24 PM Edited by LetsPlayOrDy, 26 July 2014 - 03:45 PM.

Hmm, is it possible to change the shooting effect? For example, change the shooting effect of a pistol from bullet to explosive shot.

 

Thank you. :)

I don't think it is possible by script. You can achieve that by editing the weaponinfo.xml file though (GTA IV directory -> common -> data -> weaponinfo.xml).

 

You can also use the GTA IV Weapon Editor. It just simplifies the process of editing weaponinfo.xml.


Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#9

Posted 26 July 2014 - 03:26 PM

@LetsPlayOrDy

 

Last question -- I meant if it was possible via scripting. Or maybe something else. On shoot, the bullet goes through, but also an explosive shot goes too. Which comes to my 2nd question again. Is it possible to capture shooting of a specific weapon?

 

 

Again, thank you for all the help. :)


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#10

Posted 26 July 2014 - 03:42 PM Edited by LetsPlayOrDy, 26 July 2014 - 03:45 PM.

No, in scripting it is not. That is why I told you how you *could* do it. :p

 

It's not really possible to track the position of the bullet you just fired, so the only way you could do that is by doing basically what is in this video, but setting the visibility of the object to invisible, removing the ptfx, and making it so it is firing from your character, not your car.

 

Capture shooting? Do you mean like detect if the gun is shooting? I answered that already :p


Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#11

Posted 26 July 2014 - 03:46 PM

No, in scripting it is not. That is why I told you how you *could* do it. :p

It's not really possible to track the position of the bullet you just fired, so the only way you could do that is by doing basically what is in this video, but setting the visibility of the object to invisible, removing the ptfx, and making it so it is firing from your character, not your car.

Capture shooting? Do you mean like detect if the gun is shooting? I answered that already :p

Ah, okay. Thank you for all the help. Have a  :cookie: . :D


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#12

Posted 26 July 2014 - 03:48 PM

No problem at all... and... WHY THANK YOU!  :karmaeater:  :cookie:


InfamousSabre
  • InfamousSabre

    Harpocrates

  • Members
  • Joined: 03 Jan 2013

#13

Posted 27 July 2014 - 12:49 AM Edited by InfamousSabre, 27 July 2014 - 01:01 AM.

Of course you can detect if a weapon is firing. Player.isShooting. It's pretty useful.

 

To answer your other question: You can also edit WeaponInfo.xml in memory while the game is running. Look for something called StructEdit on thaCURSEDpie's Github

Technically you could create a whole new weapon in place of another by just editing in its info over an existing weapon. Peds could possibly end up with that weapon though, and then you'd be in for it, lol. Just check them all and swap their gun with something else if you want to be the only one with your super-gun.


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#14

Posted 27 July 2014 - 01:50 AM

Is Player.isShooting true when the left mouse button is pressed and you have a weapon, or is it when a bullet is fired? I don't know which Sadra is thinking of, but the latter is what I've been trying to find.

 

Yeah I didn't think of that lol


InfamousSabre
  • InfamousSabre

    Harpocrates

  • Members
  • Joined: 03 Jan 2013

#15

Posted 27 July 2014 - 03:48 AM Edited by InfamousSabre, 27 July 2014 - 03:49 AM.

Is Player.isShooting true when the left mouse button is pressed and you have a weapon, or is it when a bullet is fired? I don't know which Sadra is thinking of, but the latter is what I've been trying to find.

 

Yeah I didn't think of that lol

it returns true when a bullet is fired or anything else really, including thrown weapons like molotov. I didn't think it would work this way either, but it does and its very very useful.
And actually, I think I made a mistake. It should be Ped.isShooting. So, Player.Character.isShooting


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#16

Posted 27 July 2014 - 03:50 AM

Well thanks for letting me know. This is gonna be fun :D

Rugz007
  • Rugz007

    Scripters ... roll out !

  • Members
  • Joined: 19 Apr 2014
  • India

#17

Posted 27 July 2014 - 04:50 AM

Guys how to do it without editing weapons. Xml

LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#18

Posted 27 July 2014 - 04:52 AM

Guys how to do it without editing weapons. Xml

Did you even read the posts in the topic?

Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#19

Posted 27 July 2014 - 05:36 AM

@InfamousSabre

Wonderful.

Thank you for the info. :) 


julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#20

Posted 27 July 2014 - 06:51 PM

@LetsPlayOrDy

Thanks for the help.

 

What I meant on Q.1 was that creating a custom weapon (With .net script) with the model of the default pistol that you can shoot and then an event happens(in this case, explode the area that you shot in, but that's not really important, cause as you said, I can use world.addexplosion).

 

Is there absolutely no way you can create a custom weapon? Ah... if I find the mod, I'll link it over here so you guys can inspect

 

Thanks. :)

 

Edit: I found somethings related to a 'GravityGun'

A thread about it here:

http://gtaforums.com...iv-gravity-gun/

Also, JulioNIB's Ghostrider script has a weapon-style chain AND also a custom shotgun:

http://www.gta4-mods...mod-v241-f18079

 

Hope someone clears this out for me.

 

the Chain in Ghost Rider is a pure script action, the script cretes and handles the visual, the attacks are just detect peds and play anims on them or applyforce+burn

we can create some cool weapons like Jerry can and Minigun with scripting

about detect bullets/shots, there is a method that seems to identify bullets fired, but i never succeed using it:
 

 

from SCO files:

 

IS_BULLET_IN_AREA( 1011.15600000, -324.52100000, 21.96700000, 2.80000000, 1 )

 

i believe parameters are: x, y, z, radius and a boolean

 

i never tried too much too ^^

if SCO "use", you may be able to use too

 

 

also this probably is not what you need for you script

if you want create a exposive round i believe the best is run a list of possible targets (peds/vehicles/objects) then check who has been damaged by player, then clear the damage status + add the explosion on the thing, bigger issue is the objects because we need to get all objects instead of limit per area

  •  
  • hardsty1e likes this

Sadra..
  • Sadra..

    Custom member title

  • Members
  • Joined: 10 Sep 2011

#21

Posted 28 July 2014 - 05:29 AM Edited by Sadra.., 28 July 2014 - 05:34 AM.

 

@LetsPlayOrDy

Thanks for the help.

 

What I meant on Q.1 was that creating a custom weapon (With .net script) with the model of the default pistol that you can shoot and then an event happens(in this case, explode the area that you shot in, but that's not really important, cause as you said, I can use world.addexplosion).

 

Is there absolutely no way you can create a custom weapon? Ah... if I find the mod, I'll link it over here so you guys can inspect

 

Thanks. :)

 

Edit: I found somethings related to a 'GravityGun'

A thread about it here:

http://gtaforums.com...iv-gravity-gun/

Also, JulioNIB's Ghostrider script has a weapon-style chain AND also a custom shotgun:

http://www.gta4-mods...mod-v241-f18079

 

Hope someone clears this out for me.

 

the Chain in Ghost Rider is a pure script action, the script cretes and handles the visual, the attacks are just detect peds and play anims on them or applyforce+burn

we can create some cool weapons like Jerry can and Minigun with scripting

about detect bullets/shots, there is a method that seems to identify bullets fired, but i never succeed using it:
 

 

from SCO files:

 

IS_BULLET_IN_AREA( 1011.15600000, -324.52100000, 21.96700000, 2.80000000, 1 )

 

i believe parameters are: x, y, z, radius and a boolean

 

i never tried too much too ^^

if SCO "use", you may be able to use too

 

 

also this probably is not what you need for you script

if you want create a exposive round i believe the best is run a list of possible targets (peds/vehicles/objects) then check who has been damaged by player, then clear the damage status + add the explosion on the thing, bigger issue is the objects because we need to get all objects instead of limit per area

  •  

 

That is exactly what I did. I used your method to get the player's target and then exploded it.  :) Thanks.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users