Altering the properties of items

Discuss all aspects related to modding Zandronum here.
Post Reply
NeuroSephiroth
 
Posts: 26
Joined: Thu Mar 28, 2013 9:12 pm
Location: Texas
Contact:

Altering the properties of items

#1

Post by NeuroSephiroth » Mon Sep 11, 2017 2:32 am

Long time player, first time modder; I'm making a mod for Ultimate Doom that starts you with 200 HP and Armor at the start of each episode (by placing a Supercharge and Mega armor in front of you) but takes out any other health or armor pickups throughout the whole episode, so you basically clear each episode on one health bar. Problem is, the Berserk; I would love to know how to alter the Berserk so it doesn't raise your HP to 100 if your HP is under 100, but being relatively new I'm not sure how to do that.

Thanks for the help in advance, sorry for the noob-like question! :biggrin:

Konda
Forum Regular
Posts: 487
Joined: Thu Jun 07, 2012 5:22 pm

Re: Altering the properties of items

#2

Post by Konda » Mon Sep 11, 2017 7:00 am

I don't know how familiar you are with Decorate since you're new to modding, but here's how the Berserk item is defined in Decorate: https://zdoom.org/wiki/Classes:Berserk
As you might be able to see, the problematic line here is this:

Code: Select all

TNT1 A 0 HealThing(100, 0)
That line makes the item heal the player. So we need to create a new Berserk item that behaves exactly the same as Berserk but has that line removed. And we also have to make that new berserk actually replace the old berserk items in the map. Here's how you define a new berserk item that does this.

Code: Select all

ACTOR NewBerserk : Berserk replaces Berserk
{
  States
  {
  Pickup:
    TNT1 A 0 A_GiveInventory("PowerStrength")
    TNT1 A 0 A_SelectWeapon("Fist")
    Stop
  }
}
The ": Berserk" part of the first line is called inheritance and it makes our new berserk inherit (copy-paste) all the properties and states of the old "Berserk" item/class. Then we write a new Pickup state for the new berserk which effectively replaces the Pickup state inherited from the old berserk.
The "replaces Berserk" part of the first line makes the game replace all "Berserk" actors/items in the map with "NewBerserk" actors/items.

To make this finally work, if your mod is a .wad, then put that code I gave you inside the DECORATE lump, and if you're making a .pk3, put it inside decorate.txt


We could also have defined the new berserk item just by copypasting the native berserk definition and removing the line which heals the user (and adding the "replaces Berserk" at the end of the first line):

Code: Select all

ACTOR NewBerserk : CustomInventory replaces Berserk
{
  +COUNTITEM
  +INVENTORY.ALWAYSPICKUP
  Inventory.PickupMessage "$GOTBERSERK" // "Berserk!"
  Inventory.PickupSound "misc/p_pkup"
  States
  {
  Spawn:
    PSTR A -1
    Stop
  Pickup:
    TNT1 A 0 A_GiveInventory("PowerStrength")
    TNT1 A 0 A_SelectWeapon("Fist")
    Stop
  }
}
But the method using inheritance is generally preferred over this. If you inherit from a user-made class, then when you change the user-made class, the changes also get reflected on the classes which inherit from that class as well, so that's an advantage of using inheritance.

Post Reply