[solution found] Giving multiple Custominventory items

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
cypherphage
Posts: 213
Joined: Sun Feb 27, 2011 2:54 am

[solution found] Giving multiple Custominventory items

Post by cypherphage »

For some reason, when the player receives more than 1 of a custom inventory, only one of them has any effect. Here is a simple example:
Spoiler:
this bug happens in r3334, and I am really hoping for a fix. Also, i tested whether increasing maxAmount had any effect, it didn't and this bug also happens with the console's give command.Ideas?


edit: a solution was found.
Attachments
customInvtest.wad
(783 Bytes) Downloaded 36 times
Last edited by cypherphage on Tue May 08, 2012 10:32 pm, edited 3 times in total.
User avatar
cypherphage
Posts: 213
Joined: Sun Feb 27, 2011 2:54 am

Re: [r3334] A_Giveinventory Custom inventory bug

Post by cypherphage »

So...is this fixable? It is very annoying.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [r3334] A_Giveinventory Custom inventory bug

Post by NeuralStunner »

I've only had this happen wen the item has a Pickup state. This might be for a good reason.

I haven't tried this yet, but what about changing Pickup to Use, and flagging the items [wiki=Actor_flags#INVENTORY.AUTOACTIVATE]INVENTORY.AUTOACTIVATE[/wiki]?

Also, you really shouldn't collapse your code like that. It's especially hard to read.
User avatar
cypherphage
Posts: 213
Joined: Sun Feb 27, 2011 2:54 am

Re: [r3334] A_Giveinventory Custom inventory bug

Post by cypherphage »

Code: Select all

Actor superFlask : CustomInventory
{
  +INVENTORY.ALWAYSPICKUP
  +INVENTORY.INVBAR
  states
  {
  Spawn:
	PTN2 ABC 4
	loop
  Use://Pickup:
    TNT1 A 0 A_GiveInventory ("doubleFlask")
	TNT1 A 0 A_GiveInventory ("doubleFlask")
	TNT1 A 0 A_GiveInventory ("doubleFlask")
    stop
  }
}

Actor doubleFlask : CustomInventory
{
  +INVENTORY.ALWAYSPICKUP
  INVENTORY.MaxAmount 1
  +INVENTORY.AUTOACTIVATE
  states
  {
  Spawn:
	PTN2 ABC 4
	loop
  Use://Pickup:
    TNT1 A 0 A_GiveInventory ("ArtiHealth", 10)
    stop
  }
}
Given that this doesn't work, the problem seems to be with receiving more than 1 cutominventory at a time, no matter how they are given. Hell, using the console to give the player multiple "doubleflasks" directly didn't work.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49223
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [r3334] A_Giveinventory Custom inventory bug

Post by Graf Zahl »

I think the advice here should be clear:

Do not use CustomInventory items for tasks that can be achieved by other means. In the end they are merely a hack and have some limitations.

Furthermore, A_GiveInventory("item", count) doesn't give you 'count' items. It gives you one item with an itemcount setting of 'count' so obviously the pickup state only gets called once.
Can't say much about your last attempt yet, except that you better learn to use the proper features to do what you want.
User avatar
cypherphage
Posts: 213
Joined: Sun Feb 27, 2011 2:54 am

Re: [r3334] A_Giveinventory Custom inventory bug

Post by cypherphage »

Well, I suppose after a little thinking about it, custominventory working that way makes sense given that it can do more than just give items. Sorry Graf, I was trying to use custominventory to be able to give X copies of items in the item. Oh well.
User avatar
Major Cooke
Posts: 8206
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: [r3334] A_Giveinventory Custom inventory bug

Post by Major Cooke »

For one, you're far better off having the superflask give 30 artihealth instead of three doubleflasks.

And if you're wanting to give multiple of said item, as already stated, you would use A_GiveInventory("Item",3)
User avatar
cypherphage
Posts: 213
Joined: Sun Feb 27, 2011 2:54 am

Re: [r3334] A_Giveinventory Custom inventory bug

Post by cypherphage »

Muwhaha, I figured out a way to do this!

Code: Select all

Actor superFlask : CustomInventory
{	
+INVENTORY.HUBPOWER
+INVENTORY.ALWAYSPICKUP
+INVENTORY.AUTOACTIVATE
+INVENTORY.INVBAR
	 INVENTORY.MaxAmount 100
states { Spawn:
PTN2 ABC 4
loop
use:
TNT1 A 0 A_GiveInventory ("doubleFlask", 1)
stop
}}

Actor doubleFlask : CustomInventory
{ +INVENTORY.ALWAYSPICKUP
states { 
Pickup:
TNT1 A 0 A_GiveInventory ("ArtiPoisonBag", 1)
TNT1 A 0 A_GiveInventory ("ArtiHealth", 1)
TNT1 A 0 A_TakeInventory ("superFlask", 1)
TNT1 A 0 a_jumpifinventory("superFlask",1,"pickup")
stop }}

// try giving yourself this, you'll now get 10 of both items meaning this works
Actor superFlaskTest : CustomInventory
{states { Spawn:
PTN2 ABC 4
loop
pickup:
TNT1 A 0 A_GiveInventory ("superFlask", 10)
stop
}}
this both allows for the giving of a bunch of stuff at once, and also allows for the awesome sauce that is a looped custominvnetory function. For instance, if you wanted to do some complex action 3 times, give three custominventories set up this way...which is sort of horribly ugly hack but is IMO cool beyond words :).
Post Reply

Return to “Closed Bugs [GZDoom]”