jcmcbeth / Planets

2 stars 1 forks source link

Fix do_hail cost calculation #22

Open jcmcbeth opened 3 years ago

jcmcbeth commented 3 years ago

When you have zero credits it will let you use hail but still say it charged you for it. It doesn't look like it does charge you as you still show 0 credits in score after using it. This should be fixed.

Also, I believe the price is tied to the character's level. Since that isn't really tied to in-character game play anymore we should use an alternate method for determining the cost. Since hail is such a good quality of life feature I would like it to not have the cost discourage use. I think it works as a minor credit sink and might potentially discourage any kind of exploits that could benefit from a zero cost hail.

That being said, it should probably just be fixed at 20 credits for now.

For this part:

if (ch->gold < (ch->top_level - 9))
{
  send_to_char("You don't have enough credits!\n\r", ch);
  return;
}

Given a normal player's top_level is 0, this evaluates to ch->gold < -9 which should never be true since 0 should be the minimum.

ch->gold -= UMAX(ch->top_level - 9, 0);

This will always be 0 for normal players. This should just be changed to be 20 credits and use a macro in mud.h for store that value.

Last point,

send_to_char("A speederbike picks you up and drives you to a safe location.\n\rYou pay the driver 20 credits.\n\r\n\n", ch);

The text that indicates the amount paid is hard coded and incorrect. This should be changed to use ch_printf and output the actual amount charged.

PracticalMetal commented 3 years ago

Hi, I would like to work on this, can you suggest me ways to get started?

jcmcbeth commented 3 years ago

@PracticalMetal If you are looking for instructions on how to compile and run the MUD I can provide those. Currently it doesn't support Windows, so the instructions would be for Linux. There is also some setup involved before the MUD will start correctly and some more setup to do to be able to get the MUD in a state to test the hail command.

The easiest way I'd recommend is just making the change and sending the PR and I can test it.

As for the code change, I would look over the do_hail function in misc.c and focus on the ch->gold property as that is the value where the characters money is stored. The mud.h file should have most if not all of the data structures defined that are used in the function. You should only have to make modifications to the three lines from the original issue description. I would create a constant in that method to store the new cost of 20 and replace the calculation used with that constant.

The last part where send_to_char is used it can be replaced with ch_printf which behaves similar to printf: ch_printf(ch, "A speederbike picks you up and drives you to a safe location.\n\rYou pay the driver %d credits.\n\r\n\n", HAIL_COST);

Assuming HAIL_COST is what you name the constant you create.