Reloading problem

Do you have a question about making weapon mods, or do you just need some tutorials and resources? Ask about all of that here.

Moderator: wildweasel

Locked
User avatar
Epoch
Posts: 69
Joined: Sat Nov 05, 2005 14:38
Location: Somewhere

Reloading problem

Post by Epoch »

I am making a weapon for a mod of mine, the Assault Rifle. It is basically a weapon that uses an "AsltClip" for the ammo expended, and takes the ammo from the "Clip" pile. Everything works fine, but I can't get it to stop reloading when the Clips run out.

To be specific. If your clips are at zero when the reloading sequence begins, nothing happens. But if they're even one above, it gives you 30 ammo.
I want it to give you only as much ammo as you have clips.

Code: Select all

ACTOR AssaultRifle1 : Weapon 2061
{
  Inventory.PickupSound "misc/w_pkup"
  Inventory.PickupMessage "You got the Assault Rifle!"
  Obituary "%o was turned to swiss cheese by %k."
  AttackSound "weapons/carbine"
  Weapon.AmmoType "AsltClip"
  Weapon.AmmoType2 "GrenadePickup"
  Weapon.AmmoGive 30
  Weapon.AmmoGive2 4
  Weapon.AmmoUse 1
  Weapon.AmmoUse2 1
  +Ammo_optional
  States
   {
  Spawn:
   M16P A -1
   Loop
  Deselect:
   M16A A 1 A_Lower
   Loop
  Select:
   M16A AAAAAAAAAAAAAAA 1 A_Raise
   M16A A 0 A_playweaponsound("weapons/reload")   
   M16A OPQR 6
   Loop
  Ready:
   M16A A 1 A_WeaponReady
   Loop
  Fire:
   M16A A 0 A_JumpIfNoammo(5)
   M16A B 2 BRIGHT A_FireBullets(6,2,1,4,0,1)
   M16A C 2 BRIGHT
   M16A A 2 A_refire
   M16A D 6   
   Goto Ready
   M16A A 0 A_JumpifInventory("Clip",1,1)               //This seems to be where the problem starts
   Goto Ready
   M16A A 0 A_Takeinventory("Clip",1)                    //Unfortunately, it doesn't seem to be checking if there's ammo properly
   M16A A 0 A_Giveinventory("AsltClip",1)               //So it ends up taking 0 clip ammo and giving 30 assault clips
   M16A A 0 A_JumpifInventory("AsltClip",30,1)
   Goto Fire+6                                                      //I think this may be the source of the problem
   M16A DIKLMGHID 4
   Goto Ready
  Altfire:
   M16A A 8 A_GunFlash
   M16A D 5
   M16A A 3
   M16A E 3
   M16A F 6
   M16A E 6
   Goto Ready
  Flash:
   M203 A 3 BRIGHT
   M203 B 5 BRIGHT A_FireCustomMissile("GrenadeThrow",0,1,6,1)
   M203 C 5 BRIGHT
   Stop
   }
}
User avatar
TheDarkArchon
Posts: 1000
Joined: Wed Jul 06, 2005 11:58
Location: What's that fucking smell
Contact:

Post by TheDarkArchon »

You haven't checked for partial reloads for a start.
User avatar
Epoch
Posts: 69
Joined: Sat Nov 05, 2005 14:38
Location: Somewhere

Post by Epoch »

What exactly do you mean?
User avatar
TheDarkArchon
Posts: 1000
Joined: Wed Jul 06, 2005 11:58
Location: What's that fucking smell
Contact:

Post by TheDarkArchon »

You don't check if the player has less than 30 bullets.

E.G

Code: Select all

ACTOR MPistol : Weapon 2002
{
   Weapon.SelectionOrder 400
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "You got the Machine Pistol!"
   Weapon.AmmoType1 "SMGClip"
   Weapon.AmmoType2 "Clip"
   Weapon.AmmoGive 0
   Weapon.AmmoGive2 40
   Weapon.AmmoUse 1
   Weapon.Kickback 40
   AttackSound "weapons/smgfire"
   +NOALERT
   +AMMO_OPTIONAL
   States
   {
   Spawn:
      MAGN A -1
      Loop
   Ready:
      MACG A 1 A_WeaponReady
      Goto Ready
   Deselect:
      MACG A 1 A_Lower
      Loop
   Select:
      MACG A 1 A_Raise
      Loop
   Fire:
      MACG A 0 A_JumpIfNoAmmo(7)
      MACG A 0 A_GunFlash
      MACF A 0 A_FireCustomMissile("CheapAlert",0,0,0,0)
      MACF B 2 BRIGHT A_FireBullets(3,3,-1,5,0,1)
      MACF A 2 BRIGHT
      MACG A 0 A_FireCustomMissile("BulletCasing",315+random(-8,8),0,10,3)
      MACG B 1  
      Goto Ready
    AltFire:
      MACG A 0 A_JumpIfInventory("SMGClip",40,38)
      MACG A 0 A_JumpIfInventory("Clip",1,1)
      Goto Ready
      MACG A 2 
      MACR A 4
      MACR B 2 A_PlayWeaponSound("weapons/smgout")
      MACR C 1 A_FireCustomMissile("Clip2",180,0,10,3)
      MACR DEFGHI 1
      MACR T 20
      MACR IHGFEDC 1
      MACR B 2
      MACR A 4 A_PlaySound("weapons/smgin")
      MACR A 0 A_TakeInventory("Clip",1)
      MACR A 0 A_GiveInventory("SMGClip",1)
      MACR A 0 A_JumpIfInventory("SMGClip",40,2)
      MACR A 0 A_JumpIfInventory("Clip",1,15) 
      MACG A 4
      MACR JKL 1
      MACR M 2
      MACR N 3 A_PlayWeaponSound("weapons/smgbolt")
      MACR U 3
      MACR O 5 
      MACR P 2
      MACR QR 1
      MACR S 3
      MACG A 2
      MACG A 0
      goto Ready
      MACR A 0
      Goto AltFire+22
   Flash:
      TNT1 A 2 BRIGHT A_Light2
      TNT1 A 2 BRIGHT A_Light1
      TNT1 A 1 BRIGHT A_Light0
      Stop
   }
}
User avatar
Epoch
Posts: 69
Joined: Sat Nov 05, 2005 14:38
Location: Somewhere

Post by Epoch »

So what do you recommend I do for my weapon?
How can I make it take the amount of bullets that I have?
User avatar
TheDarkArchon
Posts: 1000
Joined: Wed Jul 06, 2005 11:58
Location: What's that fucking smell
Contact:

Re: Reloading problem

Post by TheDarkArchon »

I'll fix it

Code: Select all

ACTOR AssaultRifle1 : Weapon 2061
{
  Inventory.PickupSound "misc/w_pkup"
  Inventory.PickupMessage "You got the Assault Rifle!"
  Obituary "%o was turned to swiss cheese by %k."
  AttackSound "weapons/carbine"
  Weapon.AmmoType "AsltClip"
  Weapon.AmmoType2 "GrenadePickup"
  Weapon.AmmoGive 30
  Weapon.AmmoGive2 4
  Weapon.AmmoUse 1
  Weapon.AmmoUse2 1
  +Ammo_optional
  States
   {
  Spawn:
   M16P A -1
   Loop
  Deselect:
   M16A A 1 A_Lower
   Loop
  Select:
   M16A AAAAAAAAAAAAAAA 1 A_Raise
   M16A A 0 A_playweaponsound("weapons/reload")   
   M16A OPQR 6
   Loop
  Ready:
   M16A A 1 A_WeaponReady
   Loop
  Fire:
   M16A A 0 A_JumpIfNoammo(5)
   M16A B 2 BRIGHT A_FireBullets(6,2,1,4,0,1)
   M16A C 2 BRIGHT
   M16A A 2 A_refire
   M16A D 6   
   Goto Ready
   M16A A 0 A_JumpifInventory("Clip",1,1)               //This seems to be where the problem starts
   Goto Ready
   M16A A 0 A_Takeinventory("Clip",1)                    //Unfortunately, it doesn't seem to be checking if there's ammo properly
   M16A A 0 A_Giveinventory("AsltClip",1)               //So it ends up taking 0 clip ammo and giving 30 assault clips
   M16A A 0 A_JumpifInventory("AsltClip",30,2)
   M16A A 0 A_JumpIfInventory("Clip",1,10)
   M16A DIKLMGHID 4
   Goto Ready
   M16A A 0
   Goto Fire+6
  Altfire:
   M16A A 8 A_GunFlash
   M16A D 5
   M16A A 3
   M16A E 3
   M16A F 6
   M16A E 6
   Goto Ready
  Flash:
   M203 A 3 BRIGHT
   M203 B 5 BRIGHT A_FireCustomMissile("GrenadeThrow",0,1,6,1)
   M203 C 5 BRIGHT
   Stop
   }
}
User avatar
Epoch
Posts: 69
Joined: Sat Nov 05, 2005 14:38
Location: Somewhere

Post by Epoch »

AWESOME!
:mrgreen:
Thanks, that kicks ass!
By the way, Tainted Decorum was awesome!
Locked

Return to “Weapon Modding Help & Resources”