Jump to content

My way of doing Doom Reloads


Recommended Posts

Hi there. I'm Telemassacre and i wanted to write this.

 

So let's make a basic reloadable pistol.

But before we do that, we need to create 2 new ammo types.

Actor PistolAmmo : Ammo // collectable reserve ammo
{
  Inventory.PickupMessage "Picked up a clip."
  Inventory.Amount 15 
  Inventory.MaxAmount 150
  Ammo.BackpackAmount 15
  Ammo.BackpackMaxAmount 300
  Inventory.Icon "PMAGA0"
  +IGNORESKILL // added for realism, you can remove this if you want to
  States
  {
  Spawn:
    PMAG A -1
    Stop
  }
}
Actor PistolClip : Ammo // clip ammo
{
  Inventory.MaxAmount 15 // clip size of pistol
  Inventory.Icon "PMAGA0"
  +IGNORESKILL
}

Now we can add our pistol.

ACTOR Glock17 : Weapon
{
  Weapon.AmmoType "PistolClip" // What will actually be fired
  Weapon.AmmoUse 1
  Weapon.AmmoGive 15 // It is generally a good idea to give players a whole clip
  Weapon.AmmoType2 "PistolAmmo" // The ammo type you collect in the world and store as reserve
  Tag "Pistol"
  +WEAPON.NOAUTOFIRE // Lets us make this pistol semi-automatic -- not needed
  +WEAPON.AMMO_CHECKBOTH // Lets you select the pistol with reserve ammo and none in the clip

For the sake of simplicity, I have omitted other states that do not require special tags for this reload technique.

  States
  {
  Ready:
    PISG A 1 A_WeaponReady(WRF_ALLOWRELOAD) // Allows us to actually reload the pistol [default bind is R]
    Loop
  Fire:
    PISG A 0 A_JumpIfInventory("PistolClip",1,1) // Makes sure you have clip ammo before firing
	Goto Ready
    PISG B 2 A_FirePistol
    PISG C 2 A_Spawnitemex("BulletCasing",0,0,37,random(8,1),-6,random(5,8),270)
    Goto Ready 
  Reload:
    PISG A 0 A_JumpIfInventory("PistolAmmo",1,1) // Makes sure you have reserve ammo before reloading
	Goto Ready
    PISG D 2 // reload animation
	PISG E 2 A_PlayWeaponSound("pistol/reload1")
	PISG F 2 A_PlayWeaponSound("pistol/reload6")
	PISG GHIJ 4
	PISG K 4 A_PlayWeaponSound("pistol/reload2")
	PISG L 4 A_PlayWeaponSound("pistol/reload3")
	PISG ED 2
  ReloadCalc: // Does the actual calculations for reloading
	PISG A 0 A_JumpIfInventory("PistolClip",15,"Ready") // Makes sure you have less than the max clip size [this weapon has it set to 15]
	PISG A 0 A_JumpIfInventory("PistolAmmo",1,1) // Makes sure you have reserve ammo before calculating
	Goto Ready
	PISG A 0 A_TakeInventory("PistolAmmo",1) // Takes reserve
	PISG A 0 A_GiveInventory("PistolClip",1) // Gives clip
	Goto ReloadCalc // loops until the clip is full
  }
}

So i hope you understand this tutorial, i just really wanted to make this to show you all my way of reload code.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...