Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this is the basic Decorate stuff needed for a reloading weapon, I trust that you understand the need for KEYCONF and SNDINFO already
- I'll note that this is a very crude way of doing it, and is probably outdated, but it works like a charm
- the demonstration weapon will be an AKM, the famous Soviet standard rifle developed from the AK-47 prototypes
- before we start, these lines need to be in KEYCONF
- addkeysection "extra keys" ultimatekeys
- addmenukey "Reload" +u_reload
- alias +u_reload "use Action_Reload"
- alias -u_reload "use Action_ReloadCancel"
- defaultbind r +u_reload
- you can NOT have these line in a Decorate lump, so do not include them in the Decorate file
- defaultbind can be any key you want, i find R makes sense
- Also, these lines would have to be in the SNDINFO lump if you want the weapon to make any noise, edit as needed:
- weapons/akmfire dsakmfir
- weapons/akcock dsakcock
- weapons/akin dsakin
- weapons/akout dsakout
- you'll need these first three actors for this kind of reload
- they should be in the players inventory, either by defining the player in decorate, or by making sure he has these with ACS
- the fourth actor is to make sure monsters can "hear" when you fire the weapon
- DECORATE CODE STARTS BELOW! Comments starts with //
- ---------------------------------------------------------------------------------------------------------------------------------------
- ACTOR IsReloading : Inventory
- {
- Inventory.MaxAmount 1
- -COUNTITEM
- }
- ACTOR Action_Reload : CustomInventory
- {
- Inventory.Amount 1
- Inventory.MaxAmount 1
- -INVBAR
- -COUNTITEM
- States
- {
- Use:
- TNT1 A 0 A_GiveInventory("IsReloading",1)
- Fail
- }
- }
- ACTOR Action_ReloadCancel : CustomInventory
- {
- Inventory.Amount 1
- Inventory.MaxAmount 1
- -INVBAR
- -COUNTITEM
- States
- {
- Use:
- TNT1 A 0 A_TakeInventory("IsReloading",1)
- Fail
- }
- }
- ACTOR CheapAlert
- {
- Health 1000
- Radius 1
- Height 1
- Speed 0
- Damage 0
- Mass 1
- PROJECTILE
- +NOCLIP
- States
- {
- Spawn:
- NULL A 0
- NULL A 1 A_AlertMonsters
- Stop //this would spawn with every gunshot, and alert any monster that would be able to hear the gun fire
- } //needless to say, if you're making a silenced weapon or a melee weapon, you can make the weapon just not spawn this actor
- }
- ACTOR AKM : Weapon Replaces Chaingun //this will make sure the weapon spawns instead of the chaingun, but this is optional
- {
- +WEAPON.NOAUTOFIRE //this flag makes sure that the gun won't repeatedly click when you hold down the trigger on an empty gun
- +WEAPON.NOALERT //this flag makes sure that an empty gun clicking or an ejecting casing will not alert monsters
- +WEAPON.AMMO_OPTIONAL //this flag makes sure that there's an empty state for the gun
- +WEAPON.ALT_AMMO_OPTIONAL //this as well
- Weapon.SelectionOrder 19 //this is irrelevant for our purposes
- Inventory.PickupMessage "Got the AKM rifle." //message displayed when the weapon is picked up
- Weapon.AmmoGive1 0 //this should be zero, otherwise picking up another AK would magically insert rounds in the mag in your gun
- Weapon.AmmoUse1 1 //this should be one, but doesn't have to be
- Weapon.AmmoType1 "AKMInMagazine" //AmmoType1 will be our magazine
- Weapon.AmmoGive2 30 //this should be 30, so that when you pick up an AK, you get it's 30 round magazine
- Weapon.AmmoUse2 0 //this should be 0
- Weapon.AmmoType2 "Clip" //AmmoType2 will be our type of ammunition. Since you don't have a 7.62x39mm actor defined, use Clip
- Weapon.Kickback 110 //This refers to how hard a monster is pushed, unless you're John Woo, this should be relatively low
- Obituary "%o was shot by %k's AKM" //this is for Deathmatch, %o is the person killed, %k is the killer
- AttackSound "weapons/ak47" //this refers to the assigned fire sound in the SNDINFO lump
- Scale 0.31 //This is used to scale the size of the weapons pickup sprite
- States //unless your pickup sprite is too big, you shouldn't have to define this, you can delete the Scale command
- {
- Ready:
- KALR A 1 A_WeaponReady
- NULL A 0 A_JumpIfInventory("IsReloading",1,"Reload")
- Loop
- Deselect:
- KALR A 1 A_Lower
- KALR A 0 A_Lower //the added 0 tic A_Lower and A_Raise is to make the weapon faster to switch
- Loop //This is something I just do personally
- Select:
- KALR A 1 A_Raise
- KALR A 0 A_Raise
- Loop
- Reload:
- 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
- NULL A 0 A_JumpIfInventory("clip",1,2) //this jumps to KALL A 2 if you have bullets to reload with
- NULL A 0
- Goto Ready
- KALL A 2
- KALL B 2
- KALL C 2
- KALL D 4
- KALL E 2 A_PlaySound("weapons/akout") //this refers to the soundfile labeled under weapons/akout in SNDINFO, change as needed
- KALL F 16
- 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
- NULL A 0 A_JumpIfInventory("AKMInMagazine",30,2)
- NULL A 0 A_JumpIfInventory("clip",1,2)
- NULL A 0 //if the mag is full, or there are no more bullets, it will jump to the end of the reload state
- Goto Reload+18
- NULL A 0 A_JumpIfInventory("AKMInMagazine",30,5)
- NULL A 0 A_TakeInventory("clip",1) //remove one round from your stockpile
- NULL A 0 A_GiveInventory("AKMInMagazine",1) //create a new round in your magazine
- NULL A 0 A_JumpIfInventory("AKMInMagazine",30,2)
- Goto Reload+10
- NULL A 0 //from here on, the end of the reload animation plays (inserting the magazine and pulling the charging handle)
- KALL E 4 //needless to say, you can alter these numbers and frames to your liking
- KALL F 12 //but remember that when you change these things, state jumps would need to be recalculated
- 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
- KALL D 3 A_PlaySound("weapons/akin")
- KALL C 2 //so they would now be Goto Reload+19 and Goto Reload+11
- KALL B 2
- KALL A 2
- KALC A 2 //this is 100% irrelevant to anything but I think girls with small breasts are cute
- KALC B 2
- KALC C 2
- KALC D 3
- KALC E 2 A_PlaySound("weapons/akcock")
- KALC F 4
- KALC E 2
- KALC D 2
- KALC C 1
- KALC B 1
- KALC A 1
- Goto Ready
- Fire:
- NULL A 0 A_JumpIfInventory("AkInMagazine", 1, 4) //if there are rounds in the magazine, the gun will to to the fire state
- KALR A 1
- KALR B 1 A_PlaySoundEx("empty/machgun",0) //CLICK!
- 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
- Goto Reload
- NULL A 0 A_FireCustomMissile("CheapAlert",0,0,0,0) //this actor alerts monsters
- KALF A 1 BRIGHT A_FireBullets(5,5,1,15,0) //horizontal spread, vertical spread, number of bullets, damage per bullet
- KALF B 1 BRIGHT //I prefer my muzzleflashes to be bright and have 1 tic per frame, but you might not
- KALR C 1 //A_Firecustommissile("RifleCasingSpawner",0,0,9,0) don't need this as you don't have ejecting casings
- KALR B 1
- KALR A 1 A_ReFire //this overrides the NO_AUTOFIRE flag
- Goto Ready //if you hold the fire button down by the time it reaches A_ReFire, the weapon will continue to fire
- Flash: //If you don't want the weapon to be fully automatic, remove the A_ReFire command
- KALF A 0 //this i the flash state, I always found this cumbersome and rather did solid sprites
- KALF B 0 Bright A_Light1 //that said, some people have accomplished some amazing things by tricking about with the flash state
- NULL A 0 BRIGHT A_Light0
- Goto LightDone
- Spawn:
- 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
- Stop
- }
- }
- ACTOR AKMInMagazine : Ammo
- { //this is our magazine
- Game Doom
- SpawnID 11
- Inventory.PickupMessage "" //this should be left blank
- Inventory.MaxAmount 30 //this should be how big you want the magazine to be, your weapons code should also correspond to this
- Ammo.BackpackAmount 0 //this should be zero, or picking up a backpack would magically fill the mag in your gun
- Ammo.BackpackMaxAmount 30 //this should stay the same
- Inventory.Icon "TNT1A0" //this is the icon that would display next to the number in the HUD, TNT1A0 is the same as NULL
- States //also, you'll want the player to start out with a "loaded magazine" so to speak
- { //or the weapon will be empty when you pick it up, requiring the player to manually load it when first picked up
- Spawn:
- TNT1 A -1 //this is the same as NULL
- Stop //ZDoom and it's branches will have this frame in it's source .wad so don't worry your pretty little head
- }
- }
- //DECORATE CODE ENDS HERE
- ---------------------------------------------------------------------------------------------------------------------------------------
- I'm not including any sprites or anything, as this is meant to be a blank slate for making your own weapon with
- note that weapons that reload one round at a time work somewhat differently
- basically, there'd be an animation displayed before every inserted round, rather than invisible, unnoticeable 0 tic frames
- Rest in piece General Mikhail Timofeyevich Kalashnikov, 10 November 1919 – 23 December 2013, the father of the AK, and many others
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement