Page 1 of 1

[fixed]CustomInventory doesn't add to inventory?

Posted: Sat Mar 18, 2006 1:51
by anakin s.
Maybe I'm just doing something wrong, but I've been unable to add one of my CustomInventory items into my inventory. Here it is:

Code: Select all

ACTOR WeaponUpgrade : CustomInventory
{
//	+AUTOACTIVATE
	+ALWYASPICKUP
	+INVBAR
	Inventory.PickupMessage "You shouldn't see this message."
	Inventory.Amount 1
	Inventory.MaxAmount 10
	States
	{
	Spawn:
		TNT1 A -1
		Stop
	Pickup:
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 1, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 2!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("FullHealth", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 2, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 3!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("HealthUpgrade", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 3, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 4!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("FullHealth", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 4, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 5!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("HealthUpgrade", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 5, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 6!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("FullHealth", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 6, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 7!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("HealthUpgrade", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 7, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 8!") 
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("FullHealth", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 8, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 9!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("HealthUpgrade", 1)
		Goto Pickup+36
		TNT1 A 1 A_JumpIfInventory("WeaponUpgrade", 9, 4)
		TNT1 A 0 A_Print("You gained a level!  You are now at level 10!") 		
		TNT1 A 1 A_PlaySound("misc/levelup")
		TNT1 A 0 A_GiveInventory("FullHealth", 1)
		
		TNT1 A 1 A_GiveInventory("LevelCounter2", 1)
		Stop
	}
}
When I give it to myself or summon it, it's just placed on the ground where I stand and I keep running over it and it never enters my inventory. If I walk over it, it just keeps the screen in a constant shade of yellow and keeps printing the pickup message repeatedly as I try to pick it up but can't. :?

Posted: Sat Mar 18, 2006 2:18
by Graf Zahl
A CustomInventory item only goes into the inventory if it has a USE state. This means that even after fixing the bug this item won't work.

Posted: Sat Mar 18, 2006 2:23
by anakin s.
Is it as simple as changing the Pickup to Use and all the Goto Pickup+36 to Goto Use+36 and adding a dummy Pickup state? I tried that and I couldn't even pick it up at all.

Posted: Sat Mar 18, 2006 2:36
by Graf Zahl
This thing is buggy so I'll have to fix it before you can do anything with it.

Posted: Sat Mar 18, 2006 3:26
by anakin s.
So it's certain that this is a bug with gzdoom and not my code? Thank you for fixing it.

Posted: Sat Mar 18, 2006 11:12
by Graf Zahl
Fixed the bug. Now I wish you good luck converting the item to something usable.

Posted: Sun Mar 19, 2006 5:34
by anakin s.
What do you mean? I used Ammo as parent in the zdoom version and it worked, but now that I changed it to fit gzdoom, I have to use CustomInventory as the parent to get the Pickup and Use states. It's supposed to be that another item keeps track of the experience the player gains, and then it gives them the WeaponUpgrade to signal that they've leveled up. The weapons themselves have A_JumpIfInventory statements that make them have different attacks depending on how many WeaponUpgrades they have.

Also, what was the problem? Was it really just that the item couldn't be picked up or was it something more complicated than that?

Posted: Sun Mar 19, 2006 10:02
by Graf Zahl
The behavior has been changed because Randy didn't want to put the Pickup/Use states into the main inventory class. So in order to keep my code in line I changed that as well. The old implementation is 2.0.96x only and won't get into anything else. So I'm sorry but you have to find other means to do this stuff. I'd seriously consider using ACS instead of creating inventory hacks (e.g. create a pickup item that only calls a script which in turn handles the things you want to do.) This is not what the Pickup state was designed for. It was more for something like the morph items that shoot some projectiles when activated or for giving powerup combinations to the player. But it was not designed to be a script replacement.


THe problem was that after being picked up the item wasn't removed from the map. Randy simply forgot to add the code.

Posted: Mon Mar 20, 2006 4:28
by anakin s.
Rats. I guess there's no avoiding that. But now the CustomInventory item gets put in your inventory, right? Before, it treated it as though I had zero WeaponUpgrades whenever I walked over it for the upteenth time. It not only wouldn't remove it from the ground, it also wouldn't give it to me.

Posted: Mon Mar 20, 2006 9:49
by Graf Zahl
It only goes into the inventory when it has a use state. But to make it short: Don't use the pickup item itself as the counter. Instead give the player a secondary item you can use as the counter.