Page 1 of 1

[Request]: Reloading weapons in Decorate tutorial.

Posted: Wed Feb 08, 2006 17:00
by DuduKrazy
could someone make a tutorial or just tell me what do i do to make a weapon reload in Decorate?

Posted: Wed Feb 08, 2006 18:49
by wildweasel
I have been meaning to do this anyway...I'll put something together as soon as I can. It's going to be a little difficult to explain how it works though, since it's such a hack.

Posted: Wed Feb 08, 2006 19:26
by TheDarkArchon
I'll do it since I was the first one to make such a hack.
TheDarkArchon presents:
Load those Shellz

This tutorial assumes basic DECORATE weapons knowledge.

Define an ammo type which will define the size of the clip. For Example:

Code: Select all

ACTOR AssaultClip : Ammo
{
     Inventory.MaxAmount 30
     Ammo.BackpackAmount 0
     Ammo.BackpackMaxAmount 30 
     Inventory.Icon TNT1A0 //See endnote [1]
}
Now make this the primary ammo type for your weapon and make your reserve ammo type the secondary ammo. Also add the +AMMO_OPTIONAL flag or instead of reloading, your weapon will switch when it's clip is dry. Example:

Code: Select all

 Weapon.AmmoType1 "AssaultClip" //The weapons clip
 Weapon.AmmoType2 "Clip" //Doom's bullets. 
 Weapon.AmmoGive1 0 //See footnote's [2] and [3]
 Weapon.AmmoGive2 30 //Gives a clips worth of reserve ammo
 +AMMO_OPTIONAL 
Now we get to the state defining. Define your primary fire sequence and make the first state a 0 length, A_JumpIfNoAmmo codepointer which lands on the start of the AltFire sequence.

Code: Select all

  Fire:
    ASRG A 0 BRIGHT A_JumpIfNoAmmo(6)
    ASRF A 0 BRIGHT A_GunFlash
    ASRF A 2 BRIGHT A_FireBullets(2,2,1,8,"BulletPuff",1)
    ASRF B 2 BRIGHT
    ASRG A 2
    ASRG A 0 A_Refire
    Goto Ready
  AltFire:
Now define your reloading sequence:

Code: Select all

  AltFire:
    ASRR ABCD 2
    ASRR E 10 A_PlayWeaponSound("weapons/assaultout")
    ASRR E 8 A_PlayWeaponSound("weapons/assaultin")
    ASRR DCBA 2
    Goto Ready
Now we start adding the stuff that makes the reloading work. First add jump states that check for reserve ammuntion and full clips so reloading doesn't happen if the player has no reserve ammo and/or a full clip.

Code: Select all

  AltFire:
      ASRG A 0 A_JumpIfInventory("AssaultClip",30,2) //Clip check
      ASRG A 0 A_JumpIfInventory("Clip",1,2) //Reserve Check
      ASRG A 1
      Goto Ready
    ASRR ABCD 2
    ASRR E 10 A_PlayWeaponSound("weapons/assaultout")
    ASRR E 8 A_PlayWeaponSound("weapons/assaultin")
    ASRR DCBA 2
    Goto Ready
Then add two 0-length states after the checks during the animation that takes 1 reserve ammo and puts it into the clip.

Code: Select all

  AltFire:
      ASRG A 0 A_JumpIfInventory("AssaultClip",30,2) //Clip check
      ASRG A 0 A_JumpIfInventory("Clip",1,2) //Reserve Check
      ASRG A 1
      Goto Ready

    ASRR ABCD 2
    ASRR E 10 A_PlayWeaponSound("weapons/assaultout")
    ASRR E 0 A_GiveInventory("AssaultClip",1)
    ASRR E 0 A_TakeInventory("Clip",1)
    ASRR E 8 A_PlayWeaponSound("weapons/assaultin")
    ASRR DCBA 2
    Goto Ready
Then add 0-length checks for reserve ammo and a full clip. If the clip is full, skip the check for reserve ammo and does the rest of the animation. If the reserve ammo is checked and there is at least 1 available, make it skip to a 0-length state below the reloading animation which then has a goto back to the 0-length state thattakes 1 reserve ammo and puts it into the clip. This is complicated so I will comment the code as best as possible:

Code: Select all

  AltFire:
      ASRG A 0 A_JumpIfInventory("AssaultClip",30,2) //Clip check
      ASRG A 0 A_JumpIfInventory("Clip",1,2) //Reserve Check
      ASRG A 1
      Goto Ready
    ASRR ABCD 2
    ASRR E 10 A_PlayWeaponSound("weapons/assaultout")
    ASRR E 0 A_GiveInventory("AssaultClip",1)
    ASRR E 0 A_TakeInventory("Clip",1)  //Fill clip by 1
    ASGR E 0 A_JumpIfInventory("AssaultClip",30,2) //If clip is full, play rest of animation
    ASGR E 0 A_JumpIfInventory("Clip",1,6) //If reserve is present, jump to   bottom state.
    ASRR E 8 A_PlayWeaponSound("weapons/assaultin")
    ASRR DCBA 2
    Goto Ready
    ASRR E 0 //Reserve jumps lands here
    Goto AltFire+5 //Goes to the part where the clip is incremented
And now you're done making a reloading weapon. Note that the code does not work properly on "I'm Too Young To Die" or "Nightmare"