SHARE
TWEET

Tyrone Cocksmasher explains oldschool Decorate Reloading

a guest Jul 27th, 2014 267 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. this is the basic Decorate stuff needed for a reloading weapon, I trust that you understand the need for KEYCONF and SNDINFO already
  2. I'll note that this is a very crude way of doing it, and is probably outdated, but it works like a charm
  3. the demonstration weapon will be an AKM, the famous Soviet standard rifle developed from the AK-47 prototypes
  4.  
  5.  
  6. before we start, these lines need to be in KEYCONF
  7.  
  8. addkeysection "extra keys" ultimatekeys
  9.  
  10. addmenukey "Reload" +u_reload                    
  11. alias +u_reload "use Action_Reload"
  12. alias -u_reload "use Action_ReloadCancel"
  13. defaultbind r +u_reload
  14.  
  15. you can NOT have these line in a Decorate lump, so do not include them in the Decorate file
  16. defaultbind can be any key you want, i find R makes sense
  17.  
  18. Also, these lines would have to be in the SNDINFO lump if you want the weapon to make any noise, edit as needed:
  19. weapons/akmfire     dsakmfir
  20. weapons/akcock      dsakcock
  21. weapons/akin        dsakin
  22. weapons/akout       dsakout
  23.  
  24.  
  25. you'll need these first three actors for this kind of reload
  26. they should be in the players inventory, either by defining the player in decorate, or by making sure he has these with ACS
  27. the fourth actor is to make sure monsters can "hear" when you fire the weapon
  28.  
  29. DECORATE CODE STARTS BELOW! Comments starts with //
  30. ---------------------------------------------------------------------------------------------------------------------------------------
  31.  
  32. ACTOR IsReloading : Inventory
  33. {
  34.         Inventory.MaxAmount 1
  35.         -COUNTITEM
  36. }
  37.  
  38. ACTOR Action_Reload : CustomInventory
  39. {
  40.    Inventory.Amount 1
  41.    Inventory.MaxAmount 1
  42.    -INVBAR
  43.    -COUNTITEM
  44.  
  45.    States
  46.    {
  47.        Use:
  48.        TNT1 A 0 A_GiveInventory("IsReloading",1)
  49.        Fail
  50.    }
  51. }
  52.  
  53. ACTOR Action_ReloadCancel : CustomInventory
  54. {
  55.    Inventory.Amount 1
  56.    Inventory.MaxAmount 1
  57.    -INVBAR
  58.    -COUNTITEM
  59.  
  60.    States
  61.    {
  62.        Use:
  63.        TNT1 A 0 A_TakeInventory("IsReloading",1)
  64.        Fail
  65.    }
  66. }
  67.  
  68. ACTOR CheapAlert
  69. {
  70.    Health 1000
  71.    Radius 1
  72.    Height 1
  73.    Speed  0
  74.    Damage 0
  75.    Mass     1
  76.        
  77.    PROJECTILE
  78.    +NOCLIP
  79.    States
  80.    {
  81.       Spawn:
  82.       NULL A 0
  83.       NULL A 1 A_AlertMonsters
  84.       Stop //this would spawn with every gunshot, and alert any monster that would be able to hear the gun fire
  85.    } //needless to say, if you're making a silenced weapon or a melee weapon, you can make the weapon just not spawn this actor
  86. }
  87.  
  88.  
  89. ACTOR AKM : Weapon Replaces Chaingun //this will make sure the weapon spawns instead of the chaingun, but this is optional
  90. {
  91.      +WEAPON.NOAUTOFIRE //this flag makes sure that the gun won't repeatedly click when you hold down the trigger on an empty gun
  92.      +WEAPON.NOALERT //this flag makes sure that an empty gun clicking or an ejecting casing will not alert monsters
  93.      +WEAPON.AMMO_OPTIONAL //this flag makes sure that there's an empty state for the gun
  94.      +WEAPON.ALT_AMMO_OPTIONAL //this as well
  95.      Weapon.SelectionOrder 19 //this is irrelevant for our purposes
  96.      Inventory.PickupMessage "Got the AKM rifle." //message displayed when the weapon is picked up
  97.      Weapon.AmmoGive1 0 //this should be zero, otherwise picking up another AK would magically insert rounds in the mag in your gun
  98.      Weapon.AmmoUse1 1 //this should be one, but doesn't have to be
  99.      Weapon.AmmoType1 "AKMInMagazine" //AmmoType1 will be our magazine
  100.      Weapon.AmmoGive2 30 //this should be 30, so that when you pick up an AK, you get it's 30 round magazine
  101.      Weapon.AmmoUse2 0 //this should be 0
  102.      Weapon.AmmoType2 "Clip" //AmmoType2 will be our type of ammunition. Since you don't have a 7.62x39mm actor defined, use Clip
  103.      Weapon.Kickback 110 //This refers to how hard a monster is pushed, unless you're John Woo, this should be relatively low
  104.      Obituary "%o was shot by %k's AKM" //this is for Deathmatch, %o is the person killed, %k is the killer
  105.      AttackSound "weapons/ak47" //this refers to the assigned fire sound in the SNDINFO lump
  106.      Scale 0.31 //This is used to scale the size of the weapons pickup sprite
  107.      States    //unless your pickup sprite is too big, you shouldn't have to define this, you can delete the Scale command
  108.      {
  109.      Ready:
  110.      KALR A 1 A_WeaponReady
  111.      NULL A 0 A_JumpIfInventory("IsReloading",1,"Reload")
  112.      Loop
  113.    Deselect:
  114.      KALR A 1 A_Lower
  115.      KALR A 0 A_Lower //the added 0 tic A_Lower and A_Raise is to make the weapon faster to switch
  116.      Loop            //This is something I just do personally
  117.    Select:
  118.      KALR A 1 A_Raise
  119.      KALR A 0 A_Raise
  120.      Loop
  121.    Reload:
  122.      NULL A 0 A_JumpIfInventory("AKMInMagazine",30,2) //this jumps to the 3rd NULL (which goes to Ready) if you don't need to reload
  123.      NULL A 0 A_JumpIfInventory("clip",1,2) //this jumps to KALL A 2 if you have bullets to reload with
  124.      NULL A 0
  125.      Goto Ready
  126.      KALL A 2
  127.      KALL B 2
  128.      KALL C 2
  129.      KALL D 4
  130.      KALL E 2 A_PlaySound("weapons/akout") //this refers to the soundfile labeled under weapons/akout in SNDINFO, change as needed
  131.      KALL F 16
  132.      NULL A 0 //this is the frame the gun will jump to after a round has been taken from your inventory and inserted into the mag
  133.      NULL A 0 A_JumpIfInventory("AKMInMagazine",30,2)
  134.      NULL A 0 A_JumpIfInventory("clip",1,2)
  135.      NULL A 0 //if the mag is full, or there are no more bullets, it will jump to the end of the reload state
  136.      Goto Reload+18
  137.      NULL A 0 A_JumpIfInventory("AKMInMagazine",30,5)
  138.      NULL A 0 A_TakeInventory("clip",1) //remove one round from your stockpile
  139.      NULL A 0 A_GiveInventory("AKMInMagazine",1) //create a new round in your magazine
  140.      NULL A 0 A_JumpIfInventory("AKMInMagazine",30,2)
  141.      Goto Reload+10
  142.      NULL A 0 //from here on, the end of the reload animation plays (inserting the magazine and pulling the charging handle)
  143.      KALL E 4 //needless to say, you can alter these numbers and frames to your liking
  144.      KALL F 12 //but remember that when you change these things, state jumps would need to be recalculated
  145.      KALL E 2 //as in, if I add an extra frame here now, I would have to add one each to Goto Reload+18 and Goto Reload+10
  146.      KALL D 3 A_PlaySound("weapons/akin")
  147.      KALL C 2 //so they would now be Goto Reload+19 and Goto Reload+11
  148.      KALL B 2
  149.      KALL A 2
  150.      KALC A 2 //this is 100% irrelevant to anything but I think girls with small breasts are cute
  151.      KALC B 2
  152.      KALC C 2
  153.      KALC D 3
  154.      KALC E 2 A_PlaySound("weapons/akcock")
  155.      KALC F 4
  156.      KALC E 2
  157.      KALC D 2
  158.      KALC C 1
  159.      KALC B 1
  160.      KALC A 1
  161.      Goto Ready
  162.    Fire:
  163.      NULL A 0 A_JumpIfInventory("AkInMagazine", 1, 4) //if there are rounds in the magazine, the gun will to to the fire state
  164.      KALR A 1
  165.      KALR B 1 A_PlaySoundEx("empty/machgun",0) //CLICK!
  166.      KALR B 1 //I personally find it's more convenient for the gun to go to the reload check when it's empty, but you may disagree
  167.      Goto Reload
  168.      NULL A 0 A_FireCustomMissile("CheapAlert",0,0,0,0) //this actor alerts monsters
  169.      KALF A 1 BRIGHT A_FireBullets(5,5,1,15,0) //horizontal spread, vertical spread, number of bullets, damage per bullet
  170.      KALF B 1 BRIGHT //I prefer my muzzleflashes to be bright and have 1 tic per frame, but you might not
  171.      KALR C 1 //A_Firecustommissile("RifleCasingSpawner",0,0,9,0) don't need this as you don't have ejecting casings
  172.      KALR B 1
  173.      KALR A 1 A_ReFire //this overrides the NO_AUTOFIRE flag
  174.      Goto Ready //if you hold the fire button down by the time it reaches A_ReFire, the weapon will continue to fire
  175.    Flash:      //If you don't want the weapon to be fully automatic, remove the A_ReFire command
  176.      KALF A 0 //this i the flash state, I always found this cumbersome and rather did solid sprites
  177.      KALF B 0 Bright A_Light1 //that said, some people have accomplished some amazing things by tricking about with the flash state
  178.      NULL A 0 BRIGHT A_Light0
  179.      Goto LightDone
  180.    Spawn:
  181.      AKMR W -1 //this is the pickup sprite and state, it should be -1 or otherwise loop, or the weapon will despawn in an instant
  182.      Stop
  183.  
  184.      }
  185.   }
  186.  
  187. ACTOR AKMInMagazine : Ammo
  188. { //this is our magazine
  189.         Game Doom
  190.         SpawnID 11
  191.         Inventory.PickupMessage "" //this should be left blank
  192.         Inventory.MaxAmount 30 //this should be how big you want the magazine to be, your weapons code should also correspond to this
  193.         Ammo.BackpackAmount 0 //this should be zero, or picking up a backpack would magically fill the mag in your gun
  194.         Ammo.BackpackMaxAmount 30 //this should stay the same
  195.         Inventory.Icon "TNT1A0" //this is the icon that would display next to the number in the HUD, TNT1A0 is the same as NULL
  196.         States //also, you'll want the player to start out with a "loaded magazine" so to speak
  197.         { //or the weapon will be empty when you pick it up, requiring the player to manually load it when first picked up
  198.         Spawn:
  199.                 TNT1 A -1 //this is the same as NULL
  200.                 Stop //ZDoom and it's branches will have this frame in it's source .wad so don't worry your pretty little head
  201.         }
  202. }
  203.  
  204. //DECORATE CODE ENDS HERE
  205. ---------------------------------------------------------------------------------------------------------------------------------------
  206. I'm not including any sprites or anything, as this is meant to be a blank slate for making your own weapon with
  207. note that weapons that reload one round at a time work somewhat differently
  208. basically, there'd be an animation displayed before every inserted round, rather than invisible, unnoticeable 0 tic frames
  209.  
  210. Rest in piece General Mikhail Timofeyevich Kalashnikov, 10 November 1919 – 23 December 2013, the father of the AK, and many others
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top