Fake inventory - add amount?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Sergeant Hoppy
Posts: 42
Joined: Mon Jun 21, 2021 11:24 am

Fake inventory - add amount?

Post by Sergeant Hoppy »

Hm, I can't figure out how to add numbers to my fake inventory, I got an experimental zombieman setup where there is a chance that he will drop a dollar bundle, I forget how to make it so the player can pick it up, and have a random amount given to the inventory, any thoughts?

Code: Select all

 // Zombieman drops random loot

ACTOR ZombieMoneyMan : ZombieMan 3004
{

  DropItem "Money", 85
  DropItem "Clip", 85
}

//The money object

Actor Money 10999
{
  States
  {
  Spawn:
    MONY A -1
    Stop
  }
}

//Your wallet
Actor Wallet : Inventory
{
   Inventory.Amount 1
   Inventory.MaxAmount 9000000
}
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Fake inventory - add amount?

Post by Logan MTM »

Sergeant Hoppy wrote:

Code: Select all

 // Zombieman drops random loot

ACTOR ZombieMoneyMan : ZombieMan 3004
{

  DropItem "Money", 85
  DropItem "Clip", 85
}

//The money object

Actor Money 10999
{
  States
  {
  Spawn:
    MONY A -1
    Stop
  }
}

//Your wallet
Actor Wallet : Inventory
{
   Inventory.Amount 1
   Inventory.MaxAmount 9000000
}
Actor Money : Inventory 10999
Go Go modder! :mrgreen:
Inventory is the class that make things pickable and without It, your Actor is Just decorative.
I guess...
Sergeant Hoppy
Posts: 42
Joined: Mon Jun 21, 2021 11:24 am

Re: Fake inventory - add amount?

Post by Sergeant Hoppy »

Hm, if I understand what you are saying correctly, I could do this?:

Code: Select all

Actor Money : CustomInventory 10999
{
 +COUNTITEM
 +INVENTORY.INVBAR
 +INVENTORY.HUBPOWER
 Tag "$TAG_CASH"
  States
  {
  Spawn:
    MONY A -1
    Stop
  Pickup:
    TNT1 A 0 A_GiveInventory ("Wallet", 2)
    stop
  }
}

In game the player is able to pick up the money atleast =)

Also, on a slight sidenote: I don't really get scripts which I will need in order to display the amount of money collected, I got zcommon.acs which includes "#include "Script.acs""

the script is just:

Code: Select all

// My first ACS script

#include "zcommon.acs"
 
script 1 ENTER
{
  print (s:"Hello world!");
}
In order to test if I can get it to display, however ingame I don't get any message?

P.S: I must have done something really stupid, as I get compilation errors with zcommon.acs
I'll include what I've done here: https://upload1.easyupload.io/uhudb9
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Fake inventory - add amount?

Post by Jarewill »

Are you loading the script using LOADACS?
Also if this is for a gameplay mod, you should also specify a library.
Sergeant Hoppy
Posts: 42
Joined: Mon Jun 21, 2021 11:24 am

Re: Fake inventory - add amount?

Post by Sergeant Hoppy »

I didn't use LOADACS.

I did my best to follow along the wiki, this is the result:
https://ibb.co/TtTLzWN

script.acs:
https://ibb.co/5rfk1wH

zcommon.acs:
https://ibb.co/Zz74Krp

loadacs:
https://ibb.co/SXCyxZm


Guess what? You helped me get it working! thanks a lot for putting up with me!
Sergeant Hoppy
Posts: 42
Joined: Mon Jun 21, 2021 11:24 am

Re: Fake inventory - add amount?

Post by Sergeant Hoppy »

Now, if I want to print the current amount in the wallet inventory and the max amount, how would I go about that?
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Fake inventory - add amount?

Post by Jarewill »

There's CheckInventory and GetMaxInventory you can use.
Also it's recommended to use HudMessages instead of printing it, as HudMessage doesn't override things like "no key" messages and such, also it's more flexible.

Now, I don't think the way you have it setup will work.
You should have only 1 compiled script that includes both a library and include "zcommon.acs"
zcommon.acs should not even be a file in your wad.
This is how the script file should look like:
Spoiler:
As for LOADACS, it should only include the script filename and nothing else:

Note: This screenshot was taken in a quickly thrown together .wad file, but it looks the same way in a .pk3 file.
Extensions don't need to be specified in LOADACS.
Guest

Re: Fake inventory - add amount?

Post by Guest »

Alright! I did some clean up now that you cleared up some misconceptions I had.

But, I am having an issue with the acshud, when I compile it says "\ACSHUD.acs:10: Function getmaxinventory is used but not defined."

I must have missunderstood the structure, I though i defined it in the DECORATE with this code:


"

//The money object
Actor Money : CustomInventory 10999
{
+COUNTITEM
+INVENTORY.INVBAR
+INVENTORY.HUBPOWER
Tag "$TAG_CASH"
Inventory.Amount 1
Inventory.MaxAmount 999
States
{
Spawn:
MONY A -1
Stop
Use:
TNT1 A 0 A_GiveInventory ("Wallet", 2)
"
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Fake inventory - add amount?

Post by Jarewill »

The error is about the function, not the money actor.
Are you using Zandronum by chance?
If so you will have to edit the HudMessage to have a static max amount instead of the function one.
What I mean is this:

Code: Select all

s:"Money: ", i:CheckInventory("Wallet"), s:" / 999" 
Guest

Re: Fake inventory - add amount?

Post by Guest »

I am using GzDoom, but I thank you for the tip! I did not know a static max amount was an option.
Guest

Re: Fake inventory - add amount?

Post by Guest »

Okay, thanks to you guys I almost got it working! I am pretty excited I must say. The hud message now shows, and the player can pick up the money dropped by monsters, and now that things are working better I can see that I made a blunder somewhere, and I suspect it is how the money object is made:

//The money object
Actor Money : CustomInventory 10999
{
+COUNTITEM
+INVENTORY.HUBPOWER
Tag "$TAG_CASH"
Inventory.Amount 1
Inventory.MaxAmount 999
States
{
Spawn:
MONY A -1
Stop
Use:
TNT1 A 0 A_GiveInventory ("Wallet", 2)
stop
}
}

//Your wallet
Actor Wallet : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 9000000
}

In theory, as I see it, when the player gets the money, "Wallet" gets an increase of 2, yet when I pick the money up ingame it does not increase.
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Fake inventory - add amount?

Post by Jarewill »

The issue here is that the Money item doesn't go into it's Use state to give the Wallet item.
For CustomInventory items, you usually want to call functions from the Pickup state instead.
Guest

Re: Fake inventory - add amount?

Post by Guest »

Hm, okay. I changed it into pickup state, but I still do not get any new results.
Guest

Re: Fake inventory - add amount?

Post by Guest »

As it turns out, I wasn't paying enough attention and I had a runaway script error with the HUD, what causes a script to be branded "runaway?"

#library "ACSHUD"
#include "zcommon.acs"

Script "InitializeHUD" ENTER
{
SetHudSize (320,200,0); //SetHudSize will make the HudMessage scale to the specified resolution, perfect for HUDs
SetFont("SMALLFONT");
While(true) //It's required that the script will loop, otherwise it won't update the HUD
{
HudMessage(s:"Cash: ", i:CheckInventory("Wallet"), s:" / 999"
;HUDMSG_PLAIN,100,CR_UNTRANSLATED,160.0,200.2,0);
Delay(1); //Delay will prevent termination
}
}
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Fake inventory - add amount?

Post by Jarewill »

Nothing seems to be wrong here.
It has a 1-tic delay, so it shouldn't be terminated as a runaway script.
Just as a question, did you compile it after changing the code?
Post Reply

Return to “Scripting”