View unanswered posts | View active topics It is currently Mon Oct 07, 2024 3:53 pm



Reply to topic  [ 5 posts ] 
 A Gun that Shoots Guns 
Author Message
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post A Gun that Shoots Guns
Grif gave me this idea a few weeks ago. It's a weapon that shoots other weapons, which shoot people. Weird, eh?

I'm releasing this as a Proof of Concept, since I don't feel like it's a fully finished mod. I'm starting classes again soon, so I probably won't have much time to finish it. Plus I think the Lua code is worth taking a look it. It's a good example of how to use a weapon's PresetName to store information in place of messy, complicated globals.

Here's how it works:
    Walk up close to a gun laying on the ground
    Shoot at the gun to "load" it into the weapon
    Then point and fire that weapon at someone

I didn't program a limit to how many weapons you can load into the gun. So yeah, you can store a lot of guns into the weapon. The gif pretty much explains the rest:

Image
Oh, the gun will shatter before hitting an obstacle, so enemies can't pick up the gun and use it against you. Be willing to sacrifice these weapons, because your not getting them back.

Biggest issue with this gun that I couldn't get around was the FireTime of some weapons. Whenever you first pull out a weapon, some of them take a few seconds to arm before they can shoot. This also applies to weapons flying through the air :(. So like with a shotgun, you have to be a good distance away before you can actually get the launched shotgun to shoot someone.

On the plus side, the derbies of a gun shattering before hitting an enemy can sometimes do MASSIVE damage.

Attachment:
WeaponGun.rte.rar [3.53 KiB]
Downloaded 202 times


Lua Stuff:
If your decent enough with Lua, check out the code. It's got some charms in it that might interest you.

The way the weapon "stores" guns inside it is by adding the loaded weapons' preset names to the end of the launcher's preset name, separated by commas. Since self.PresetName is the same for any pointer, you are able to load the gun, drop it, pick it back up, and then still shoot the loaded weapon. It doesn't use any messy globals.

There is a drawback to this however. Some weapons have the same Preset Names. Like if you load up a Coalition sniper rifle, you'll end up shooting a dummy sniper rifle. I'm sure there is a way to fix this, and I might look into it later.

I also have code that I commented out which makes the gun turn and fire at nearby opponents as it flies past them. I found that in some instances it was more convenient for the gun to fire constantly in the direction it is flying, than to wait to fly past an enemy to fire. I thought about adding in a mode selected to switch between, but never got around to it. So I simply commented it out. (It's the code between the --[[ and --]]).


Fri Jan 15, 2010 12:37 pm
Profile
User avatar

Joined: Fri Mar 13, 2009 2:31 am
Posts: 217
Location: Earth... I think
Reply with quote
Post Re: A Gun that Shoots Guns
could you figure out a way for the guns to explode instead of just gib?

when the gun is firing is it in sharp aim? (I like my accuracy)


Fri Jan 15, 2010 4:49 pm
Profile
User avatar

Joined: Mon Feb 02, 2009 9:18 pm
Posts: 618
Location: Ancient Hispania
Reply with quote
Post Re: A Gun that Shoots Guns
I always dreamed with that, shown in CC epic moments?
(insta-DL)


Wed Feb 03, 2010 6:53 pm
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: A Gun that Shoots Guns
Kyred wrote:
There is a drawback to this however. Some weapons have the same Preset Names. Like if you load up a Coalition sniper rifle, you'll end up shooting a dummy sniper rifle. I'm sure there is a way to fix this, and I might look into it later.
Couldn't you store the gun as <Modulename>.rte/<Gun>, assuming there is a way to read which datamodule an object is from?


Thu Feb 04, 2010 7:31 am
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: A Gun that Shoots Guns
The problem is that there really isn't any way to read .rte after the fact. You can check it and verify it in all your code, but it's not possible to take a generic instance and find its .rte.


Thu Feb 04, 2010 7:52 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.065s | 14 Queries | GZIP : Off ]