[Not ZDoom] USDF: Cost blocks do not remove inventory properly

Bugs that have been investigated and resolved somehow.

Moderator: Developers

USDF: Cost blocks do not remove inventory properly

Postby amv2k9 » Thu Jun 21, 2012 5:47 pm

When defining a cost block for a choice block in a conversation script for USDF, a glitch occurs:
Code: Select allExpand view
choice
{
 text = "Take my money!";
 cost
 {
  item = 168;
  amount = 50;
 }
 displaycost = false;
 nomessage = "You don't have any gold!";
 nextpage = 2;
 closedialog = false;
}
The above code *should* take away fifty gold. It doesn't. Instead, it gives you fifty, but only if you already have gold; otherwise it prints the nomessage.
Code: Select allExpand view
choice
{
 text = "Take my money!";
 cost
 {
  item = 168;
  amount = 0;
 }
 cost
 {
  item = 168;
  amount = 50;
 }
 displaycost = false;
 nomessage = "You don't have any gold!";
 nextpage = 3;
 closedialog = false;
}
The above code, however, does work. It should be noted that all vanilla Strife dialogue scripts which take something from the player also do this, from merchants that take your gold, to the medic and arms trainer who give you stamina and accuracy upgrades in exchange for the tokens awarded to you after mission completions.

Below is a test wad. Load it up, type "give gold50" at the console, then "changemap map34". Talk to Macil. The first option in his dialogue will give you 50 gold when it should be taking fifty, the second option will take fifty gold from you.

An uncompiled version of the dialogue script is contained in the pk3, in a standard txt format.
Attachments
usdf_cost_block_bug.pk3
(1.18 KiB) Downloaded 7 times
User avatar
amv2k9
Satanic Redux, Order & Chaos, Mutation, and Weapons of Rebellion Series Dev
 
Joined: 10 Jan 2010
Location: Southern California

Re: USDF: Cost blocks do not remove inventory properly

Postby Blzut3 » Thu Jun 21, 2012 7:42 pm

This appears to be either a bug in USDC or a limitation in the binary format. I'll have to check, but your dialog works just fine as native USDF (call the lump DIALOGxy).
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004

Re: USDF: Cost blocks do not remove inventory properly

Postby Blzut3 » Thu Jun 21, 2012 10:34 pm

I guess this is worth double posting over:

I've updated USDC to include fixes for vanilla strife (Changelog) so your dialog should work right once recompiled. You can download it here.

With more research in terms of ZDoom's binary lump support there are three options:
  • Do like Chocolate/Vanilla Strife and ignore any cost block with a cost amount <= 0. (When checking if the player has enough the cost is still read but the player will always have more than a negative number so the check always passes.)
    Code: Select allExpand view
    static void P_TakeDialogItem(player_t *player, int type, int amount)
    {
        int i;

        if(amount <= 0)
            return;

        // ... snip ...
    }
  • Take the absolute value of the cost which is probably prefered and would allow the new warning in USDC to be ignored.
  • Keep it as is.
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004

Re: USDF: Cost blocks do not remove inventory properly

Postby amv2k9 » Fri Jun 22, 2012 1:07 pm

Thanks for doing this! BTW, I was looking through more of Strife's dialogues, and it doesn't always do the "take zero first" trick. I'm kinda confused why it needs to do so in other scripts in the first place.
User avatar
amv2k9
Satanic Redux, Order & Chaos, Mutation, and Weapons of Rebellion Series Dev
 
Joined: 10 Jan 2010
Location: Southern California


Return to Closed Bugs

Who is online

Users browsing this forum: Bing [Bot] and 1 guest