Trying to make a reusable inventory item

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
Empyre
Zandrone
Posts: 1316
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Trying to make a reusable inventory item

#1

Post by Empyre » Sat Nov 05, 2016 6:56 am

I am trying to make an inventory item that can be used an unlimited number of times, but with a cool-down time. Can this be done with DECORATE, and if so, how? I was unable to find the answer in Zoom's wiki.
"For the world is hollow, and I have touched the sky."

User avatar
madcat
Forum Regular
Posts: 361
Joined: Mon Jul 08, 2013 7:16 pm
Location: Czech republic
Clan Tag: [Sun]

Re: Trying to make a reusable inventory item

#2

Post by madcat » Sat Nov 05, 2016 12:32 pm

Yes, that is possible. Make the item give the player a powerup that does nothing, but has a certain duration. And make the item not do anything if the player has the powerup still active (a_jumpifinventory)

User avatar
Empyre
Zandrone
Posts: 1316
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Re: Trying to make a reusable inventory item

#3

Post by Empyre » Sat Nov 05, 2016 3:49 pm

Thanks, that is a simple and elegant solution to the cool-down, but how do I make the item not disappear from the inventory when used? The answer is probably so obvious that you assumed I already know it, but I don't.
"For the world is hollow, and I have touched the sky."

Catastrophe
Retired Staff / Community Team Member
Posts: 2569
Joined: Sat Jun 02, 2012 2:44 am

Re: Trying to make a reusable inventory item

#4

Post by Catastrophe » Sat Nov 05, 2016 6:03 pm

Add a "fail", which will stop the inventory item from being consumed.

User avatar
madcat
Forum Regular
Posts: 361
Joined: Mon Jul 08, 2013 7:16 pm
Location: Czech republic
Clan Tag: [Sun]

Re: Trying to make a reusable inventory item

#5

Post by madcat » Sat Nov 05, 2016 9:12 pm

or just use a_giveinventory("theitemitself") in the item

User avatar
Empyre
Zandrone
Posts: 1316
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Re: Trying to make a reusable inventory item

#6

Post by Empyre » Sat Nov 05, 2016 11:58 pm

I thought I had it figured out, but Zandronum fails, giving the following error message:

Code: Select all

Execution could not continue.

Script error, "opweapons2_b1.pk3:pickups.dec" line 37:
SC_GetNumber: Bad numeric constant "}".
Line 37 is the very last line in this code excerpt.

Code: Select all

ACTOR PowerGhostLauncherTimer : PowerTargeter
{
  Powerup.Duration 20
  -INVENTORY.HUBPOWER
  States
  {
  Targeter:
    Stop
  }
}

ACTOR GhostLauncherTimer : PowerupGiver
{
  Inventory.MaxAmount 0
  Powerup.Type "GhostLauncherTimer"
  +Inventory.AutoActivate
}

ACTOR GhostLauncher : CustomInventory
{
  Inventory.MaxAmount 1
  +Inventory.INVBAR
  Translation "Ice"
  RenderStyle "Add"
  Alpha 0.65
  Inventory.Icon "SKULA1"
  States
  {
  Use:
    TNT1 A 0 A_JumpIfInventory ("GhostLauncherTimer", 1, "NotYet")
	TNT1 A 0 A_GiveInventory ("GhostLauncherTimer", 1)
	TNT1 A 0 A_FireCustomMissile("OPGhost1",0,1,0,0,0,0)
// Pass-through
  NotYet:
    fail
  }
}
This is bizarre. Why is it expecting a number there?
"For the world is hollow, and I have touched the sky."

User avatar
madcat
Forum Regular
Posts: 361
Joined: Mon Jul 08, 2013 7:16 pm
Location: Czech republic
Clan Tag: [Sun]

Re: Trying to make a reusable inventory item

#7

Post by madcat » Sun Nov 06, 2016 6:37 am

I see what the problem is

Your last state should look like this:

NotYet:
TNT1 A 4
fail

User avatar
Empyre
Zandrone
Posts: 1316
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Re: Trying to make a reusable inventory item

#8

Post by Empyre » Sun Nov 06, 2016 6:41 am

Yeah, somebody in the DoomWorld forums pointed that out too, and when I added a frame there, it works. Thanks again!
"For the world is hollow, and I have touched the sky."

Post Reply