[Tutorial] How to make a sniper!

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
skib
Posts: 179
Joined: Sat Jan 29, 2011 6:30 pm

[Tutorial] How to make a sniper!

Post by skib »

Hello I’m here to tell you how to make a sniper in Decorate using Slade 3.
First, you need the sprites, you can download my zip with basic sprites (very basic)!
Now we add Important factors

Code: Select all

 
Actor Sniper : weapon replaces shotgun
{
  Game Doom
  +WEAPON.NOALERT
  SpawnID 27
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 1
  Weapon.AmmoGive 8
  Weapon.AmmoType "Clip"
  Inventory.PickupMessage "$You got the sniper!”
  Obituary "%o was sniped %k."
Now we add the ready, deselect etc states – make sure you use the weapon sprite names!

Code: Select all

 States
  {
  Ready:
    SNPG A 1 A_WeaponReady
    Loop
  Deselect:
    SNPG A 1 A_Lower
    Loop
  Select:
    SNPG A 1 A_Raise
    Loop 

Now we add the fire state

Code: Select all

 Fire:
    SNPG A 3
    SNPG B 7 A_FireBullets (0,0,1,12) //Horizontal angle - 0, Vertical angle - 0 Init. Bullets - 1, Damage - 12
    SNPG C 5 A_TakeInventory ("Clip",1) //This is to make it use clips
	SNPG C 0  A_PlaySound ("weapons/shotgf", CHAN_WEAPON) //It sounds like the shotgun
    SNPG A 4 A_Quake (1,1,0,0) //This makes it shift a bit!
    SNPG A 7 A_ReFire
    Goto Ready 
Now before we make the alt fire, we have to make the scope, make it like the sniper but with different sprites!

Code: Select all

 actor SniperScope : DoomWeapon 2001
{
  Game Doom
  +WEAPON.NOALERT
  SpawnID 27
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 1
  Weapon.AmmoGive 8
  Weapon.AmmoType "Clip"
  Inventory.PickupMessage "$GOTSHOTGUN" // "You got the shotgun!"
  Obituary "$OB_MPSHOTGUN" // "%o chewed on %k's boomstick."
  States
  {
  Ready:
    SNPS A 1 A_WeaponReady
	SNPS A 1 A_ZoomFactor (4) //This decides how far it zooms!
	SNPS A 1 Bright A_Light1
    Loop
  Deselect:
    SNPS A 1 A_Lower
    Loop
  Select:
    SNPS A 1 A_Raise
    Loop
  Fire:
	SNPS A 3 
    SNPS A 7 A_FireBullets (0,0,1,12)
	SNPS A 0 A_PlaySound ("weapons/shotgf", CHAN_WEAPON)
	SNPS A 0 A_TakeInventory ("Clip",1)
	SNPS A 2 A_Quake (1,1,0,0)
    SNPS A 7 A_ReFire
    Goto Ready
  AltFire:
    SNPS A 3
	SNPS A 3 A_SelectWeapon ("Sniper") //This makes it switch to the sniper!
	Goto Ready
  Flash: //Not needed!
    SHTF A 4 Bright A_Light1
    SHTF B 3 Bright A_Light2
    Goto LightDone
  }
} 
Now, going back to the sniper, the AltFire scope is needed

Code: Select all

 AltFire:
    SNPG A 3
	SNPG A 3 A_GiveInventory ("SniperScope") //Gives the Scope
	SNPG A 3 A_SelectWeapon ("SniperScope") //Selects the Scope
	Goto Ready 
Now, you may want to fiddle with stuff and add reloading .etc.
Attachments
Sniper Sprites.zip
(9.75 KiB) Downloaded 104 times
User avatar
David Ferstat
Posts: 1113
Joined: Wed Jul 16, 2003 8:53 am
Location: Perth, Western Australia
Contact:

Re: [Tutorial] How to make a sniper!

Post by David Ferstat »

Sniper? Or sniper rifle?
User avatar
Shadelight
Posts: 5113
Joined: Fri May 20, 2005 11:16 am
Location: Labrynna

Re: [Tutorial] How to make a sniper!

Post by Shadelight »

Isn't this the same exact tutorial as the one that's in the wiki?
User avatar
chopkinsca
Posts: 1325
Joined: Thu Dec 11, 2003 5:03 pm

Re: [Tutorial] How to make a sniper!

Post by chopkinsca »

Judging from Skib's previous postings, I don't believe he is capable enough of coming up with this on his own.
User avatar
skib
Posts: 179
Joined: Sat Jan 29, 2011 6:30 pm

Re: [Tutorial] How to make a sniper!

Post by skib »

It is?
I didn't know, seriously, i figured out for meself, believe it or not, i did!
Is it the exact same?
Do you think i would think you are dumb enough to not know, i didn't see it! I nly do basics on it!
User avatar
skib
Posts: 179
Joined: Sat Jan 29, 2011 6:30 pm

This is what the wiki looks like!

Post by skib »

A_ZoomFactor
From ZDoom Wiki
Jump to: navigation, search
A_ZoomFactor (float zoom [, int flags])

zoom: The amount to zoom in or out. The player's FOV is divided by this value.
flags: Flags to modify the behavior of the zoom.
A_ZoomFactor lets weapons scale their player's FOV. Each weapon maintains its own FOV scale independent from any other weapons the player may have.

Flags may be a combination of either of the following (or omitted):

ZOOM_INSTANT: The zoom is normally spread out across a few ticks to make a zooming effect. Use this flag to make the zoom instant.
ZOOM_NOSCALETURNING: Player turning is normally scaled as well by this function. Use this flag to retain the player's unzoomed sensitivity while zoomed.
Examples
This sniper pistol has two levels of zoom, 2x and 4x.

actor SniperPistol_Zoomed : Inventory
{
inventory.maxamount 2
}

actor SniperPistol : Pistol
{
States
{
AltFire:
PISG ABC 6
TNT1 A 0 A_JumpIfInventory("SniperPistol_Zoomed", 2, "ZoomOut")
TNT1 A 0 A_JumpIfInventory("SniperPistol_Zoomed", 1, "Zoom2")
//fall through
Zoom1:
TNT1 A 0 A_ZoomFactor(2.0)
TNT1 A 0 A_GiveInventory ("SniperPistol_Zoomed", 1)
Goto "AltFireDone"
Zoom2:
TNT1 A 0 A_ZoomFactor(4.0)
TNT1 A 0 A_GiveInventory ("SniperPistol_Zoomed", 1)
Goto "AltFireDone"
ZoomOut:
TNT1 A 0 A_ZoomFactor(1.0)
TNT1 A 0 A_TakeInventory ("SniperPistol_Zoomed", 2)
Goto "AltFireDone"
AltFireDone:
PISG C 5 A_ReFire
Goto "Ready"
Deselect:
TNT1 A 0 A_TakeInventory ("SniperPistol_Zoomed", 2)
TNT1 A 0 A_ZoomFactor(1.0)
Goto "Super::Deselect"
}
}
This is a fully functional sniper rifle. The altfire brings up the scope, and then gives a dummy inventory item. There's also an A_JumpIfInventory flag on the ready and fire states to check if the player have this dummy item, so the weapon can go to an alternate ready and fire states if you have pressed the altfire button.

ACTOR HKG3SG1 : Weapon replaces Berserk
{
Inventory.PickupMessage "H&K G3/SG1"
Inventory.PickupSound "misc/w_pkup"
Weapon.AmmoGive 10
Weapon.AmmoType "Clip"
Weapon.AmmoType2 "Clip"
Weapon.Ammouse 1
Weapon.Ammouse2 1
Weapon.Kickback 40
DamageType "FriendlyFire"
+NOAUTOFIRE
+NOALERT
Scale 0.14
States
{
Spawn:
G3SG A -1
LOOP
Ready:
HKG3 A 0 A_JumpIfInventory("G3Zoom", 1, "ReadyScope")
HKG3 A 1 A_WeaponReady
LOOP
ReadyScope:
ASNS A 1 A_WeaponReady(WRF_NoBob)
LOOP
Deselect:
TNT1 A 0 A_TakeInventory ("G3Zoom", 2)
TNT1 A 0 A_ZoomFactor(1.0)
HKG3 A 1 A_Lower
Goto Deselect+2
Select:
HKG3 A 1 A_Raise
TNT1 A 0 A_Raise
LOOP
Fire:
ASNS A 0 A_JumpIfInventory("G3Zoom", 1, "FireScope")
HKGF A 0 A_AlertMonsters
HKGF A 0 A_PlayWeaponSound("weapons/sg550_fire")
HKGF A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,5,9)
HKGF A 1 Bright A_FireBullets (1.5, 1.5, -1, 24, "Puff2")
HKG3 B 0 A_FireCustomMissile("556MMCasingSpawner",0,0,14,4)
HKG3 B 0 ACS_Execute(987,0,125,random(2,4),0)
HKG3 BCDEFGHI 1 A_WeaponReady(WRF_NoFire)
HKG3 A 9 A_WeaponReady(WRF_NoFire)
Goto Ready
FireScope:
ASNS A 0 A_AlertMonsters
ASNS A 0 A_PlayWeaponSound("weapons/sg550_fire")
ASNS A 1 Bright A_FireBullets (0, 0, -1, 24, "Puff2")
ASNS A 0 A_FireCustomMissile("556MMCasingSpawner",0,0,14,4)
ASNS A 0 ACS_Execute(987,0,95,random(2,4),0)
ASNS A 17
Goto ReadyScope
AltFire:
ASNS A 0 A_SetCrosshair(50)
ASNS A 2 A_WeaponReady(WRF_NoBob)
TNT1 A 0 A_JumpIfInventory("G3Zoom", 2, "ZoomOut")
TNT1 A 0 A_JumpIfInventory("G3Zoom", 1, "Zoom2")
//fall through
Zoom1:
TNT1 A 0 A_ZoomFactor(3.0)
TNT1 A 0 A_GiveInventory ("G3Zoom", 1)
Goto "AltFireDone"
Zoom2:
TNT1 A 0 A_ZoomFactor(8.0)
TNT1 A 0 A_GiveInventory ("G3Zoom", 1)
Goto "AltFireDone"
ZoomOut:
TNT1 A 0 A_SetCrosshair(0)
TNT1 A 0 A_ZoomFactor(1.0)
TNT1 A 0 A_TakeInventory ("G3Zoom", 2)
Goto "AltFireDone"
AltFireDone:
ASNS A 1 A_ReFire
Goto "Ready"
}
}

actor G3Zoom : Inventory
{
inventory.maxamount 2
}
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [Tutorial] How to make a sniper!

Post by NeuralStunner »

skib wrote:Hello I’m here to tell you how to make a sniper in Decorate using Slade 3.
... And Slade 3 is never mentioned again.
skib wrote:

Code: Select all

  Obituary "%o was sniped %k."
Heh.
skib wrote:

Code: Select all

    SNPG B 7 A_FireBullets (0,0,1,12) //Horizontal angle - 0, Vertical angle - 0 Init. Bullets - 1, Damage - 12
    SNPG C 5 A_TakeInventory ("Clip",1) //This is to make it use clips
	SNPG C 0  A_PlaySound ("weapons/shotgf", CHAN_WEAPON) //It sounds like the shotgun
Actually it will already do that. If you actually read the Wiki article on [wiki]A_FireBullets[/wiki] you'll find that the function already handles ammo usage just like it's supposed to. So your little hack is just going to needlessly waste ammunition.

Also your indentation is inconsistent, and terrible.
skib wrote:

Code: Select all

    SNPG A 4 A_Quake (1,1,0,0) //This makes it shift a bit!
What does "shift a bit" even mean? And a weapon typically related to precision somehow has a more horrendous kick than a gatling gun.
skib wrote:Now before we make the alt fire, we have to make the scope, make it like the sniper but with different sprites!
And the bst way to do that is with inheritance from the original weapon.

But you don't do that:
skib wrote:

Code: Select all

 actor SniperScope : DoomWeapon 2001
It's given a DoomEd number (even though it exists to be given by another weapon and not picked up.

And it contains a lot of dead code copied from the stock shotgun:
skib wrote:

Code: Select all

  Inventory.PickupMessage "$GOTSHOTGUN" // "You got the shotgun!"
  Obituary "$OB_MPSHOTGUN" // "%o chewed on %k's boomstick."
Did you actually read that message on just about every Wiki page containing Decorate? The one that says directly copying weapon code like this is silly?

And speaking of dead code:
skib wrote:

Code: Select all

  Flash: //Not needed!
Then take it out. A general rule of coding: Dead code is unneeded code.

Hacking in the giving and removing of a dummy weapon is unnecessary. With a simple Inventory flag you could put everything needed onto one weapon.

It's obvious you don't even know what you're doing. Novices should not write tutorials. Tutorials are from experienced people to inexperienced people. If you want to share a few bits of code you think are neat, that's fine. But don't try to be teaching until you can at least understand why the above list of mistakes are mistakes, and improve your skills.

That is all.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: [Tutorial] How to make a sniper!

Post by wildweasel »

User avatar
InsanityBringer
Posts: 3392
Joined: Thu Jul 05, 2007 4:53 pm
Location: opening the forbidden box

Re: [Tutorial] How to make a sniper!

Post by InsanityBringer »

Hey, lets not ego++ here!

Actually... I have to agree.. nevermind :P
Sodaholic
Posts: 1959
Joined: Sat Nov 03, 2007 4:13 pm

Re: [Tutorial] How to make a sniper!

Post by Sodaholic »

Why did you copy an entire wiki page, skib?

Also, this would be more appropriately named "The how to remake my solid color ms-paint sniper rifle without me explaining how anything actually works guide". This doesn't explain to the reader how the engine actually interprets the code, only what to put in to make your sniper rifle. They're not making anything or, or of their own, only to remake the exact same weapon themselves by copying and pasting code. This is not a tutorial.
koverhbarc
Posts: 230
Joined: Mon Dec 06, 2010 6:26 am

Re: [Tutorial] How to make a sniper!

Post by koverhbarc »

The wiki doesn't have any article called Sniper - where is this supposed to be copied from?
User avatar
InsanityBringer
Posts: 3392
Joined: Thu Jul 05, 2007 4:53 pm
Location: opening the forbidden box

Re: [Tutorial] How to make a sniper!

Post by InsanityBringer »

The wiki page copied was from A_ZoomFactor. It's in his third post in this thread.
User avatar
TheDarkArchon
Posts: 7656
Joined: Sat Aug 07, 2004 5:14 am
Location: Some cold place

Re: [Tutorial] How to make a sniper!

Post by TheDarkArchon »

koverhbarc wrote:The wiki doesn't have any article called Sniper - where is this supposed to be copied from?
skib wrote:A_ZoomFactor
From ZDoom Wiki
I'm guessing it's from the A_ZoomFactor page
User avatar
skib
Posts: 179
Joined: Sat Jan 29, 2011 6:30 pm

Re: [Tutorial] How to make a sniper!

Post by skib »

How did you get so good?
User avatar
Salad Viking
Posts: 752
Joined: Tue Apr 20, 2010 8:58 pm
Location: In high orbit

Re: [Tutorial] How to make a sniper!

Post by Salad Viking »

skib wrote:How did you get so good?
Because he has knowledge of the ZDoom engine and DECORATE script, and because he's been modding for years now. Also, he doesn't post tutorials when he has a tenuous understanding of modding at best.

That tutorial is actually far from the most complicated thing you can do with DECORATE. Seriously, if you're impressed by the example code in a tutorial, you absolutely should not be making your own tutorials. (BTW, I'm not belittling your tutorial in any way, WW)
Locked

Return to “Editing (Archive)”