My CURRENCY DECORATE code

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

My CURRENCY DECORATE code

Post by Hidden Hands »

Code: Select all

ACTOR Bubble : Coin replaces Coin : Inventory native
{
  +DROPPED
  +NOTDMATCH
  +FLOORCLIP
  Inventory.MaxAmount 0x7fffffff
  +INVENTORY.INVBAR
  Tag "$TAG_COIN" // "bubble"
  Inventory.Icon "I_COIN"
  Inventory.PickupMessage "You picked up the bubble."
  States
  {
  Spawn:
    COIN A -1
    Stop
  }
}

ACTOR BubbleRed : Bubble
{
  Inventory.Amount 5
  Tag "$TAG_10GOLD" // "5 currency"
  Inventory.PickupMessage "You picked up 5 currency."
  States
  {
  Spawn:
    BRED ABCD
    Stop
  }
}

ACTOR BubblePurple : Bubble
{
  Inventory.Amount 15
  Tag "$TAG_25GOLD" // "15 currency"
  Inventory.PickupMessage "You picked up 15 currency."
  States
  {
  Spawn:
    BPRP ABCD
    Stop
  }
}

ACTOR BubbleGreen : Bubble
{
  Inventory.Amount 25
  Tag "$TAG_50GOLD" // "25 currency"
  Inventory.PickupMessage "You picked up 25 currency."
  States
  {
  Spawn:
    BGRN ABCD
    Stop
  }
}

ACTOR BubbleBlue : Bubble
{
  Inventory.Amount 35
  Tag "$TAG_50GOLD" // "35 currency"
  Inventory.PickupMessage "You picked up 35 currency."
  States
  {
  Spawn:
    BBLU ABCD
    Stop
  }
}

ACTOR BubbleYellow : Bubble
{
  Inventory.Amount 55
  Tag "$TAG_50GOLD" // "55 currency"
  Inventory.PickupMessage "You picked up 55 currency."
  States
  {
  Spawn:
    BYLO ABCD
    Stop
  }
}

ACTOR BubbleGold : Bubble
{
  Inventory.Amount 100
  Tag "$TAG_50GOLD" // "100 currency"
  Inventory.PickupMessage "You picked up 100 currency."
  States
  {
  Spawn:
    BGLD ABCD
    Stop
  }
}

ACTOR BubbleRainbow : Bubble
{
  Inventory.Amount 300
  Tag "$TAG_300GOLD" // "300 currency"
  Inventory.PickupMessage "$TXT_300GOLD" // "You picked up 300 currency."
  States
  {
  Spawn:
    BRNB ABCD
    Stop
  }
}
I'm having some trouble with this. I created a DECORATE for currency in my game but it's not working properly. What is wrong with my code? I'm working with Zdoom II in UDMF format.
Nevander
Posts: 2254
Joined: Mon Jan 06, 2014 11:32 pm

Re: My CURRENCY DECORATE code

Post by Nevander »

Hidden Hands wrote:

Code: Select all

ACTOR Bubble : Coin replaces Coin : Inventory native
it's not working properly. What is wrong with my code?
Because this isn't proper syntax. This should be:

Code: Select all

ACTOR Bubble : Coin replaces Coin
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: My CURRENCY DECORATE code

Post by Hidden Hands »

Thank you. I also have another issue with it. I'm getting "error line 666: expected "{" got ":" execution could not continue.
User avatar
AFADoomer
Posts: 1344
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: My CURRENCY DECORATE code

Post by AFADoomer »

What's on line 666?

Also in your above code... None of your frames have durations. "BPRP ABCD" et al need a number next to them.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: My CURRENCY DECORATE code

Post by Hidden Hands »

Code: Select all

ACTOR Bubble : Coin replaces Coin
{
  +DROPPED
  +NOTDMATCH
  +FLOORCLIP
  Inventory.MaxAmount 0x7fffffff
  +INVENTORY.INVBAR
  Tag "$TAG_COIN" // "bubble"
  Inventory.Icon "BREDAO"
  Inventory.PickupMessage "You picked up the bubble."
  States
  {
  Spawn:
    COIN A -1
    Stop
  }
}

ACTOR BubbleRed : Bubble
{
  Inventory.Amount 5
  Tag "$TAG_10GOLD" // "5 currency"
  Inventory.PickupMessage "You picked up 5 currency."
  States
  {
  Spawn:
    BRED ABCD 4
    Stop
  }
}

ACTOR BubblePurple : Bubble
{
  Inventory.Amount 15
  Tag "$TAG_25GOLD" // "15 currency"
  Inventory.PickupMessage "You picked up 15 currency."
  States
  {
  Spawn:
    BPRP ABCD 4
    Stop
  }
}

ACTOR BubbleGreen : Bubble
{
  Inventory.Amount 25
  Tag "$TAG_50GOLD" // "25 currency"
  Inventory.PickupMessage "You picked up 25 currency."
  States
  {
  Spawn:
    BGRN ABCD 4
    Stop
  }
}

ACTOR BubbleBlue : Bubble
{
  Inventory.Amount 35
  Tag "$TAG_50GOLD" // "35 currency"
  Inventory.PickupMessage "You picked up 35 currency."
  States
  {
  Spawn:
    BBLU ABCD 4
    Stop
  }
}

ACTOR BubbleYellow : Bubble
{
  Inventory.Amount 55
  Tag "$TAG_50GOLD" // "55 currency"
  Inventory.PickupMessage "You picked up 55 currency."
  States
  {
  Spawn:
    BYLO ABCD 4
    Stop
  }
}

ACTOR BubbleGold : Bubble
{
  Inventory.Amount 100
  Tag "$TAG_50GOLD" // "100 currency"
  Inventory.PickupMessage "You picked up 100 currency."
  States
  {
  Spawn:
    BGLD ABCD 4
    Stop
  }
}

ACTOR BubbleRainbow : Bubble
{
  Inventory.Amount 300
  Tag "$TAG_300GOLD" // "300 currency"
  Inventory.PickupMessage "$TXT_300GOLD" // "You picked up 300 currency."
  States
  {
  Spawn:
    BRNB ABCD 4
    Stop
  }
}
Updated code - How's this... is this okay? I think making currency work in my game is going to give me an aneurysm.
KuroTsuki
Posts: 47
Joined: Thu Mar 15, 2012 6:43 pm

Re: My CURRENCY DECORATE code

Post by KuroTsuki »

What is your problem exactly? What error does the game drop for it to "not work properly".
Also, i do not know how the Actor "Coin" works but in my little noob experience suggest you create your own currency by yourself and inherit from there.

For example this is mine and it works very well for my little coding skills:
Spoiler:
All my money pickups are inheriting from this one.
Fill us in with all the extra details so we can pinpoint your exact problem.

EDIT: I would really love to see the sprites for the rainbow bubble.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: My CURRENCY DECORATE code

Post by Hidden Hands »

Well basically, I have currency represented by different coloured bubbles. Think of the original Spyro The Dragon trilogy on PS1 - Each different coloured gem you collected had different values. That is the plan with mine.

RedBubble - 5
PurpleBubble - 15
GreenBubble - 25
BlueBubble - 35
YellowBubble - 55
GoldBubble - 100
RainbowBubble - 300

I've just looked at your code. Much nicer than my initial design - how would I go about adding the values of different colours in that Spyro-ish way I mentioned? I need the different variants of colours for different values but to all add up as a whole as one thing - BUBBLE CURRENCY. So basically, you get a blue, green and red bubble - but instead of it being that in the inventory, it just adds it up as "Bubbles - 65". (adding up all the values.)

I will share the rainbow bubble sprite shortly - temporarily I'm using a rip from puzzle bobble as a place holder.

BASICALLY - your code works fantastic - but how do I make variants of currency of different values? Doing them all individually makes them seperate in the inventory, as if they are different currencies.. I need them all to add up as one. Also, how do I get the little icon for the currency to show up in the corner of my screen next to health, armour etc.?

I made this code based on yours but now I have a new error:

Code: Select all

Actor RedBubble : Bubble inventory 11111
{
//$Category Keys
  Inventory.Amount 5
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 5 BUBBLE."
States
{
  Spawn:
    BRED ABCD 4
    Loop
  }
}

Actor BlueBubble : Bubble inventory 11112
{
//$Category Keys
  Inventory.Amount 15
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up the 15 BUBBLE."
States
{
  Spawn:
    BBLU ABCD 4
    Loop
  }
}

Actor GreenBubble : Bubble inventory 11113
{
//$Category Keys
  Inventory.Amount 25
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 25 BUBBLE."
States
{
  Spawn:
    BGRN ABCD 4
    Loop
  }
}

Actor PurpleBubble : Bubble inventory 11114
{
//$Category Keys
  Inventory.Amount 35
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 35 BUBBLE."
States
{
  Spawn:
    BPRP ABCD 4
    Loop
  }
}

Actor YellowBubble : Bubble inventory 11115
{
//$Category Keys
  Inventory.Amount 55
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 55 BUBBLE."
States
{
  Spawn:
    BYLO ABCD 4
    Loop
  }
}

Actor GoldBubble : Bubble inventory 11116
{
//$Category Keys
  Inventory.Amount 100
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 100 BUBBLE."
States
{
  Spawn:
    BGLD ABCD 4
    Loop
  }
}

Actor RainbowBubble : Bubble inventory 11117
{
//$Category Keys
  Inventory.Amount 300
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 300 BUBBLE."
States
{
  Spawn:
    BRNB ABCD 4
    Loop
  }
}
I've attached the screenshot of the error this code causes. Can someone please help me fix this.
Attachments
the error.png
the error.png (8.67 KiB) Viewed 1079 times
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: My CURRENCY DECORATE code

Post by Hidden Hands »

I fixed this by adding this new code. Now the game boots up but a new problem has occurred. Whatever I try to buy, I never seem to have "enough" currency now, even though I have picked up enough. I added this code above the other colours - and removed "inventory" from the others.

Code: Select all

Actor Bubble : inventory 11110
{
//$Category Keys
  Inventory.Amount 0
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up a BUBBLE."
States
{
  Spawn:
    BRED ABCD 4
    Loop
  }
}

Actor RedBubble : Bubble 11111
{
//$Category Keys
  Inventory.Amount 5
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 5 BUBBLE."
States
{
  Spawn:
    BRED ABCD 4
    Loop
  }
}

Actor BlueBubble : Bubble 11112
{
//$Category Keys
  Inventory.Amount 15
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up the 15 BUBBLE."
States
{
  Spawn:
    BBLU ABCD 4
    Loop
  }
}

Actor GreenBubble : Bubble 11113
{
//$Category Keys
  Inventory.Amount 25
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 25 BUBBLE."
States
{
  Spawn:
    BGRN ABCD 4
    Loop
  }
}

Actor PurpleBubble : Bubble 11114
{
//$Category Keys
  Inventory.Amount 35
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 35 BUBBLE."
States
{
  Spawn:
    BPRP ABCD 4
    Loop
  }
}

Actor YellowBubble : Bubble 11115
{
//$Category Keys
  Inventory.Amount 55
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 55 BUBBLE."
States
{
  Spawn:
    BYLO ABCD 4
    Loop
  }
}

Actor GoldBubble : Bubble 11116
{
//$Category Keys
  Inventory.Amount 100
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 100 BUBBLE."
States
{
  Spawn:
    BGLD ABCD 4
    Loop
  }
}

Actor RainbowBubble : Bubble 11117
{
//$Category Keys
  Inventory.Amount 300
  Inventory.MaxAmount 9999 
  Inventory.Icon "BREDA0"
  Inventory.PickupMessage "You picked up 300 BUBBLE."
States
{
  Spawn:
    BRNB ABCD 4
    Loop
  }
}
Can someone please help me fix this code so that it works properly please? My issue now is that it on identifies the first "BUBBLE" and not the colours and their values underneath.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: My CURRENCY DECORATE code

Post by Blue Shadow »

Use [wiki=Classes:CustomInventory]CustomInventoy[/wiki] to act as a container for the currency:

Code: Select all

actor BubbleCur : Inventory
{
    Inventory.MaxAmount 9999
    Inventory.Icon "BREDA0"
}

actor Bubble : CustomInventory 11110
{
    Inventory.PickupMessage "You picked up a BUBBLE."

    States
    {
    Spawn:
        BRED ABCD 4
        Loop

    Pickup:
        TNT1 A 0 A_GiveInventory("BubbleCur", 1)
        Stop
    }
}

actor RedBubble : CustomInventory 11111
{
    Inventory.PickupMessage "You picked up 5 BUBBLE."

    States
    {
    Spawn:
        BRED ABCD 4
        Loop

    Pickup:
        TNT1 A 0 A_GiveInventory("BubbleCur", 5)
        Stop
    }
}

// ... and so on...     
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: My CURRENCY DECORATE code

Post by Hidden Hands »

Blue Shadow wrote:Use [wiki=Classes:CustomInventory]CustomInventoy[/wiki] to act as a container for the currency:

Code: Select all

actor BubbleCur : Inventory
{
    Inventory.MaxAmount 9999
    Inventory.Icon "BREDA0"
}

actor Bubble : CustomInventory 11110
{
    Inventory.PickupMessage "You picked up a BUBBLE."

    States
    {
    Spawn:
        BRED ABCD 4
        Loop

    Pickup:
        TNT1 A 0 A_GiveInventory("BubbleCur", 1)
        Stop
    }
}

actor RedBubble : CustomInventory 11111
{
    Inventory.PickupMessage "You picked up 5 BUBBLE."

    States
    {
    Spawn:
        BRED ABCD 4
        Loop

    Pickup:
        TNT1 A 0 A_GiveInventory("BubbleCur", 5)
        Stop
    }
}

// ... and so on...       
I think you just fixed it! Will give it a proper test now. Thank you so much!

How can I get a little icon of the currency to appear in the corner also please? I attached a screenshot of where I need the icon to appear.
Attachments
where.png
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: My CURRENCY DECORATE code

Post by ramon.dexter »

If you have inventory, just put the currency into inventory.

Or use ACS to display amount of currency.
KuroTsuki
Posts: 47
Joined: Thu Mar 15, 2012 6:43 pm

Re: My CURRENCY DECORATE code

Post by KuroTsuki »

Fair notice.
This mod im going to share with you is crap, but i think and hope it will help you in the mod you are developing.
Spoiler:
Im sure there are way more better ways to do it but for now this should work for you as it worked for me.

It is basically a store that is browsed with the inventory scrolling and using keys, so you will need to configure the keys to browse your native inventory and also configure the keys for opening each of the 3 stores i coded.
This is extremely inefficient (But works) and should be upgraded to an ACS store menu as i have been currently doing, but the currency system, as unpolished as it is, have a very good functionality so be sure to browse all the code.

Included you will find something similar to what you want to do with the different kind of bubbles which gives different amount of money.
And ALSO, ¡Money multiplier! so you might also want to explore that.
You can also drop money for sharing by the way.

Also all the monsters have the currency added to their drop tables, included the most brutal and violent monster which spills blood everywhere just for fun, you know who...
Spoiler:
Feel free to ask anything about the code.

Now, regarding your thing about showing the currency on the screen, its done in 2 ways.
ACS and can also be done with the SBARINFO lump which you can find info on in the wiki, BUT, that function is included in my code too so you can guide yourself with that too.
And be mindful of the different HUDS used in the game(port) as you would need to code for all of them or it won't show in one(some) of them.

Also you should share with us why you are trying to buy with your currency so we can know why it tells you you do not have enough.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: My CURRENCY DECORATE code

Post by Hidden Hands »

Thank you so much for your fantastic post. I have currently got the currency working the way it should and I'm happy with it. But there is a problem with getting the icon to display on screen. I'm looking at your SBARINFO lump but cannot seem to figure out why its not working. I have four red 0's now at the top of the screen that do not change no matter how much currency I pick up. And I still cant get it to appear on the small version, in the bottom corners.

EDIT: Okay I fixed it. Finally, currency works 100%. Thank you!

But now it seems to have triggered a different issue. My custom monster used to show up in the monsters category in GZDOOM Builder, with a preview image, its name, everything. Now its not showing up and only displays as a question mark on the map. Why? How do I fix it?
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: My CURRENCY DECORATE code

Post by Hidden Hands »

One final issue on this currency thing... how do I get currency to carry over to the next level? I just tested out all first three levels. After collecting a ton of currency, i exit the level and all the currency resets. I want it to carry over like ammo. Can someone help with this please?
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: My CURRENCY DECORATE code

Post by Blue Shadow »

With the solution I provided above, that shouldn't happen. However, you want to look into [wiki=Actor_properties#Inventory.InterHubAmount]Inventory.InterHubAmount[/wiki].
Locked

Return to “Editing (Archive)”