Jump to content


Photo
- - - - -

Tds Weapon Example-2800+ Downloads!


  • Please log in to reply
60 replies to this topic

#1 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 14 March 2010 - 06:26 PM

  • Title: TDS Weapon Example
  • Description: A very basic way to create weapons in a TDS, heavily commented.
  • GM Version: 8.1
  • Registered: No
  • File Type: .gm81
  • File Size: 0.06 mb
  • File Link: Here
Summary
This tutorial teaches how to create a weapon system using arrays. It is lite compatible, heavily commented, and easy to expand upon. Features include:
Lite Compatible!
Every unique line of code commented!
6 Guns: Pistol, Rifle, Shotgun, Sniper Rifle, Rocket Launcher, and Flame Thrower
Different sprites depending on gun
Fast-fire or not
Reload Time
Spray
Recoil
Multiple Bullets per shot
Different bullets depending on gun
Very easy to add new guns and properties

UPDATE 5 July, code cleaned up significantly, add flame thrower
UPDATE 7 July, added basic enemies/dummies. No AI, but you can experiment with your weapons on them, they can be shot, blown up (no explosions) or set on fire. Rockets now go to enemies.

DLs before host change: 1926

Edited by CaptainLepidus, 11 February 2013 - 04:11 AM.

  • 1

#2 DarkLopo

DarkLopo

    GMC Elite

  • New Member
  • 803 posts

Posted 16 March 2010 - 06:03 PM

___________________________________________
ERROR in
action number 1
of  Step Event
for object obj_player:

In script update_gun:
Error in code at line 12:
   if gun[wep,1]<1//if out of ammo
				 ^
at position 16: Cannot compare arguments.

This comes at start, have you ever tested this?
  • 0

#3 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 16 March 2010 - 10:26 PM

___________________________________________
ERROR in
action number 1
of  Step Event
for object obj_player:

In script update_gun:
Error in code at line 12:
   if gun[wep,1]<1//if out of ammo
				 ^
at position 16: Cannot compare arguments.

This comes at start, have you ever tested this?

Yes I have, that's a result of something I must have added at the last second. Here's the fix: (I'll update GMK ASAP)
//place in step event, just for reloading and changing weapons
var i;//look up 'var' in the manual for a description of what this does
for(i=0;i<gunmax;i+=1)//scrolls through all weapons
{
if keyboard_check(gun[i,2])//if you're pressing the key to change weapins
{
wep=i//weapon set to currect amount
}
}
if timer>0//if the timer is more than 0
{timer-=1}//move down the timer
if is_real(gun[wep,1])//if its a string
{
if gun[wep,1]<1//if out of ammo
{wep=0}//makes the weapon the start weapon
}

  • 0

#4 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 19 March 2010 - 01:09 AM

Come on, guys. 150+ views and only 1 reply?
  • 0

#5 javierkos

javierkos

    GMC Member

  • GMC Member
  • 715 posts

Posted 19 March 2010 - 04:30 PM

Very usefull!
  • 0

#6 RowanFN

RowanFN

    Mr. Awesome

  • GMC Member
  • 1480 posts

Posted 19 March 2010 - 04:56 PM

very kl, can u update it so the player changes sprite also to suit the gun as people would like that feature
  • 0

#7 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 19 March 2010 - 11:21 PM

very kl, can u update it so the player changes sprite also to suit the gun as people would like that feature

Thanks to both of you, and yes will do. I'll update it in like ten minutes.
  • 0

#8 RowanFN

RowanFN

    Mr. Awesome

  • GMC Member
  • 1480 posts

Posted 20 March 2010 - 01:40 AM

np,

another thing could be different kinds of bullets? if u want more ideas i could think of some lol
  • 0

#9 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 20 March 2010 - 01:56 AM

np,

another thing could be different kinds of bullets? if u want more ideas i could think of some lol

LOL, sure I'll update it with some different kinds of bullets (new gun-rocket launcher (w00t :) ) ) and I'll add different reload times for guns. I might even someday include an AI that switches weapons-but that's not currently the point of this tutorial.
  • 0

#10 RowanFN

RowanFN

    Mr. Awesome

  • GMC Member
  • 1480 posts

Posted 20 March 2010 - 02:15 AM

yeah lol, different types as well like flame thrower or electric, one with laser sight lol
  • 0

#11 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 20 March 2010 - 02:22 AM

yeah lol, different types as well like flame thrower or electric, one with laser sight lol

I may have to say no to those, because the purpose of this example is to show how to make a weapon system, not to show how to make laser sight, flame throwers, ect. There's other examples for that.
  • 0

#12 opeth14

opeth14

    GMC Member

  • New Member
  • 8 posts

Posted 20 March 2010 - 04:13 AM

The shooting didn't work for me (unregistered) because there was still an 'image_angle' in the shoot_gun script. I deleted the line and it worked fine other than the bullets being oddly angled, so thanks for the good tutorial.
  • 0

#13 cruzer323

cruzer323

    Multimedia Megamix

  • GMC Member
  • 531 posts
  • Version:GM:Studio

Posted 20 March 2010 - 06:03 AM

Looks pretty good, here's my suggestions...

Have an enemy to shoot at so you can set varying damage amounts for each weapon.
When you fire a shotgun, it sprays pellets out, it doesn't just fire a single bullet.
Add some variation to the bullet; a bullet will rarely, if ever, go exactly where it is aimed.
Maybe some recoil?
And for some reason, when I fire the rocket launcher, the rocket gets stuck to my mouse, and the only way to get rid of it is to take my mouse out of the game window.

Other than that, it looks great, keep up the good work.
  • 0

#14 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 20 March 2010 - 01:44 PM

Looks pretty good, here's my suggestions...

Have an enemy to shoot at so you can set varying damage amounts for each weapon.
When you fire a shotgun, it sprays pellets out, it doesn't just fire a single bullet.
Add some variation to the bullet; a bullet will rarely, if ever, go exactly where it is aimed.
Maybe some recoil?
And for some reason, when I fire the rocket launcher, the rocket gets stuck to my mouse, and the only way to get rid of it is to take my mouse out of the game window.

Other than that, it looks great, keep up the good work.

Yes, the bullets with the rocket launcher chase after the mouse, it's like heat seeking or something (I was just trying to show variation in bullets). Sure, I'll make some damage, recoil, spread, and multiple bullets.
EDIT: Damage can easily be made by having multiple bullet object, perhaps with a parent. Stop getting me so distracted from the point of this tutorial! :)

Edited by CaptainLepidus, 20 March 2010 - 02:03 PM.

  • 0

#15 Shadowrend

Shadowrend

    Master of Shadows

  • GMC Member
  • 1571 posts
  • Version:GM8

Posted 21 March 2010 - 05:06 PM

Good, but it can be better. Thinking of uploading my own... Its a bit complicated but bug free and many many many options (different bullet shells for each weapons! and more). It could do some more job.
  • 0

#16 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 21 March 2010 - 05:43 PM

Good, but it can be better. Thinking of uploading my own... Its a bit complicated but bug free and many many many options (different bullet shells for each weapons! and more). It could do some more job.

This has many options too. I didn't want too many though, because this is supposed to be a fairly simple example and it's mainly focused on creating and cycling through various weapons. I denied some earlier requests (look at previous posts) because they simply went too far from the main point of the example.
  • 0

#17 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 24 March 2010 - 09:34 PM

Is anybody still interested in this? Should I add something to it?
  • 0

#18 Jdc1197

Jdc1197

    GMC Member

  • New Member
  • 17 posts

Posted 25 March 2010 - 02:59 AM

This is really a nice design especaily because you came make your own (easily).


-:P
  • 0

#19 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 25 March 2010 - 03:09 AM

This is really a nice design especaily because you came make your own (easily).


-:P

Thanks for the compliments. Any suggestions?
  • 0

#20 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 07 April 2010 - 09:17 PM

Wow, so many downloads, so few replies. I feel unloved. :rolleyes:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users