Replacing Weapons in DECORATE...

Discuss all aspects of editing for ZDoom.
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Replacing Weapons in DECORATE...

Postby solarsnowfall » Sat Jul 04, 2009 6:07 pm

I've never really messed with making weapons before, and now I seem to be paying the price. What I want to do is replace some of the default Doom weapons with slightly altered ones. All I'm trying to do is modify the Spawn state so that it executes a script. What's the correct way to do this? I've tried...
Code: Select allExpand view
actor _Shotgun : Shotgun replaces Shotgun
{
  states
  {
  Spawn:
    SHOT A 0
    SHOT A 0 ACS_ExecuteAlways(992, 0, 5)
    SHOT A -1
    Stop
  }
}

I've also tried inherriting from the DoomWeapon class and replacing the shotgun like this...
Code: Select allExpand view
actor _Shotgun : DoomWeapon replaces Shotgun
{
  Game Doom
  SpawnID 27
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 1
  Weapon.AmmoGive 8
  Weapon.AmmoType "Shell"
  Inventory.PickupMessage "$GOTSHOTGUN" // "You got the shotgun!"
  Obituary "$OB_MPSHOTGUN" // "%o chewed on %k's boomstick."
  States
  {
  Ready:
    SHTG A 1 A_WeaponReady
    Loop
  Deselect:
    SHTG A 1 A_Lower
    Loop
  Select:
    SHTG A 1 A_Raise
    Loop
  Fire:
    SHTG A 3
    SHTG A 7 A_FireShotgun
    SHTG BC 5
    SHTG D 4
    SHTG CB 5
    SHTG A 3
    SHTG A 7 A_ReFire
    Goto Ready
  Flash:
    SHTF A 4 Bright A_Light1
    SHTF B 3 Bright A_Light2
    Goto LightDone
  Spawn:
    SHOT A 0
    SHOT A 0 ACS_ExecuteAlways(992, 0, 5)
    SHOT A -1
    Stop
  }
}

The Shotgun is replaced with my _Shotgun, I can pick it up and the script gets run, so far so good. The problem I encounter is when using the weapon. Once I pick up the _Shotgun and it autoselects, I can't mouse-wheel to any of the other weapons. I have to select a weapon by pressing the coresponding # key. Then I can mouse-wheel between all other weapons except the _Shotgun, and I can't get back to it either by pressing 3. I tried adding the _Shotgun to slot 3 of the KEYCONF lump but that doesn't seem to make a difference. What am I ignorant about here, or can't this be done?
User avatar
solarsnowfall
 
Joined: 30 Jun 2005

Re: Replacing Weapons in DECORATE...

Postby Enjay » Sat Jul 04, 2009 6:15 pm

Until recently, you had to use a KEYCONF lump to allocate the weapons to the weapon slots. That method still works for backwards compatibility but it has been deprecated in favour of using a custom player definition and using "Player.WeaponSlot" in it to allocate the weapons to slots.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Replacing Weapons in DECORATE...

Postby Enjay » Sat Jul 04, 2009 6:18 pm

Example:

Code: Select allExpand view
ACTOR SolarPlayer : DoomPlayer
{
   Player.StartItem "_Pistol"
   Player.StartItem "_Fist"
   Player.StartItem "Clip", 50
   Player.WeaponSlot 1, _Fist, _Chainsaw
   Player.WeaponSlot 2, _Pistol
   Player.WeaponSlot 3, _Shotgun, _SuperShotgun
   Player.WeaponSlot 4, _Chaingun
   Player.WeaponSlot 5, _RocketLauncher
   Player.WeaponSlot 6, _PlasmaRifle
   Player.WeaponSlot 7, _BFG9000
}


That defines a player that assumes all the weapons have been replaced using ones whose names start with "_".

Oh, you'd still have to include a KEYCONF like this:

Code: Select allExpand view
clearplayerclasses
addplayerclass SolarPlayer
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Replacing Weapons in DECORATE...

Postby Gez » Sat Jul 04, 2009 6:25 pm

Or, more simply, "Weapon.SlotNumber" in the weapon declaration itself. This way, you don't have to redefine the player class and to mess with KEYCONF.

But indeed, the reason you can't use "next/previous weapon" is that it doesn't know which slot the weapon is in.
Gez
 
 
 
Joined: 06 Jul 2007

Re: Replacing Weapons in DECORATE...

Postby solarsnowfall » Sat Jul 04, 2009 6:28 pm

Thanks guys.
User avatar
solarsnowfall
 
Joined: 30 Jun 2005

Re: Replacing Weapons in DECORATE...

Postby Enjay » Sat Jul 04, 2009 6:34 pm

Gez wrote:"Weapon.SlotNumber"

Quite right. I forgot about that option. That's obviously the simplest choice. I guess that a disadvantage of that method would be that it doesn't clear existing the weapons out of the slots so if the player somehow happened to get a weapon that they weren't meant to have, it would be selectable.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland


Return to Editing (Archive)

Who is online

Users browsing this forum: No registered users and 3 guests