Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Psycho

Weapon reload tutorial?

Recommended Posts

Does anyone know of a Decorate weapon reload tutorial? I only found one, but had the same problem I did. The problem was that no matter how much ammo was in the weapon's clip/the fake ammo, the same amount of ammo came out of your real ammo when you reload. If anyone could help that would be great thanks.

Share this post


Link to post

Are you gunning for "realistic" style where you lose the remaining rounds in the magazine when you reload or Duke style reloading, where the weapon always drains reserve and just does an animation every x amount of shots?

Share this post


Link to post
TheDarkArchon said:

Are you gunning for "realistic" style where you lose the remaining rounds in the magazine when you reload or Duke style reloading, where the weapon always drains reserve and just does an animation every x amount of shots?


Realistic. I have most of the code down, it's just the fact that when I reload (lets say I have 4 bullets left out of 8 in the clip) the same amount comes out of the ammo, in this case it is 8. Here is my code:


actor MyPistol : Weapon Replaces Pistol
{
Weapon.SelectionOrder 1200
Weapon.AmmoUse 1
Weapon.AmmoGive2 10
Weapon.Kickback 40
Weapon.AmmoType1 "PistMag"
Weapon.AmmoType2 "Clip"
Weapon.AmmoGive 0
AttackSound "weapons/MyPistol"
Obituary "%o was pelted by %k's pistol."
+NOEXTREMEDEATH
+NOALERT
+AMMO_OPTIONAL
Inventory.Pickupmessage "Picked up a pistol"
+BLOODSPLATTER
States
{
Ready:
DISG A 1 A_WeaponReady
Loop
Deselect:
DISG A 1 A_Lower
NULL AA 0 A_Lower
Loop
Select:
NULL A 0 A_PlaySound("weapons/Draw")
DISG A 1 A_Raise
NULL AA 0 A_Raise
Loop
Fire:
DISG A 0
DISG A 0 A_JumpIfNoAmmo("Dryfire")
DISG A 5
DISF A 0 A_PlaySound("weapons/MyPistol")
DISF A 3 BRIGHT A_FireBullets(3,3,1,5.6)
DISG A 0 A_FireCustomMissile("Pistshell",0,0,-5)
DISG A 0 A_FireCustomMissile("Smoke1",0,0,3.2,6.5)
DISG A 0 A_FireCustomMissile("Alert",0,0)
DISF A 0 A_Recoil(0.3)
DISG A 0
DISG B 8
DISG A 0 A_Refire
Goto Ready
Dryfire:
DISG A 0
DISG A 17 A_PlaySound("weapons/dryfire")
Goto Ready
AltFire:
DISG A 0 A_JumpIfInventory("PistMag",8,3)
DISG A 0 A_JumpIfInventory("Clip",1,2)
DISG A 0
Goto Ready
DISG B 6 A_Lower
DISG B 35 A_PlaySound("weapons/glockout")
DISG A 0 A_FireCustomMissile("Clip1",0,0)
DISG B 35 A_PlaySound("weapons/glockin")
DISG A 0 A_TakeInventory("Clip",8)
DISG A 0 A_GiveInventory("PistMag",8)
DISG B 1 A_Raise
Goto Ready
Flash:
PISF A 7 Bright A_Light1
Goto LightDone
PISF A 7 Bright A_Light0
Goto LightDone
Spawn:
FORP A -1
Stop
}
}

Share this post


Link to post

To do what you're wanting to do, you need to do something like this

actor MyPistol : Weapon Replaces Pistol
{
  Weapon.SelectionOrder 1200
  Weapon.AmmoUse 1
  Weapon.AmmoGive2 10
  Weapon.Kickback 40
  Weapon.AmmoType1 "PistMag"
  Weapon.AmmoType2 "Clip"
  Weapon.AmmoGive 0
  AttackSound "weapons/MyPistol"
  Obituary "%o was pelted by %k's pistol."
  +NOEXTREMEDEATH
  +NOALERT
  +AMMO_OPTIONAL
  Inventory.Pickupmessage "Picked up a pistol"
  +BLOODSPLATTER
  States
  {
  Ready:
    DISG A 1 A_WeaponReady
    Loop
  Deselect:
    DISG A 1 A_Lower
    NULL AA 0 A_Lower
    Loop
  Select:
    NULL A 0 A_PlaySound("weapons/Draw")
    DISG A 1 A_Raise
    NULL AA 0 A_Raise
    Loop
  Fire:
    DISG A 0 
    DISG A 0 A_JumpIfNoAmmo("Dryfire")
    DISG A 5
    DISF A 0 A_PlaySound("weapons/MyPistol")
    DISF A 3 BRIGHT A_FireBullets(3,3,1,5.6)
    DISG A 0 A_FireCustomMissile("Pistshell",0,0,-5)
    DISG A 0 A_FireCustomMissile("Smoke1",0,0,3.2,6.5)
    DISG A 0 A_FireCustomMissile("Alert",0,0)
    DISF A 0 A_Recoil(0.3)
    DISG A 0 
    DISG B 8
    DISG A 0 A_Refire
    Goto Ready
  Dryfire:
    DISG A 0
    DISG A 17 A_PlaySound("weapons/dryfire")
    Goto Ready
  AltFire:
    DISG A 0 A_JumpIfInventory("PistMag",8,3)
    DISG A 0 A_JumpIfInventory("Clip",1,2)
    DISG A 0
    Goto Ready
    DISG B 6 A_Lower
    DISG B 35 A_PlaySound("weapons/glockout")
    DISG A 0 A_FireCustomMissile("Clip1",0,0)
    DISG B 35 A_PlaySound("weapons/glockin")
  ReloadLoop:
    DISG A 0 A_TakeInventory("Clip",1) //Take a bullet from the reserve
    DISG A 0 A_GiveInventory("PistMag",1) //Put a bullet into the magazine
    DISG A 0 A_JumpIfInventory("PistMag",0,2) //Stop the loop if mag is full (A zero in the amount parameter causes a check for the max amount of an item)
    DISG A 0 A_JumpIfInventory("Clip",1,"ReloadLoop") //If the clip is NOT full, but there's still reserve bullets, load the next bullet
    DISG B 1 A_Raise
    Goto Ready
  Flash:
    PISF A 7 Bright A_Light1
    Goto LightDone
    PISF A 7 Bright A_Light0
    Goto LightDone
  Spawn:
    FORP A -1
    Stop
  }
}
Note that the loop consists of all zero tic frames so that the player will perceive this as instantanious. Also, I see what you're doing with the reload animation at the moment and it won't work that way.

Share this post


Link to post

Ah it works great thanks alot! I will learn from this one. I can work around the reload by just making new frames where the gun lowers since I didn't have any reload sprites for my new pistol.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×