Contamination hack


Questions, Explanations, Howtos

Shoals Surfer

Posts: 257

Joined: Tuesday, 24th September 2013, 17:52

Post Sunday, 14th September 2014, 23:11

Contamination hack

I'm trying to hack the contamination lamp (I think that's the word the devs use for these status effects in the HUD) to give me a numeric value for contamination level rather than the mostly useless color-coded word "contam". I've been all over output.cc and several other source files. I'm sure it's obvious, but I seem to be missing it. Can anyone tell me precisely where the I should be looking to modify this?
Current foes list: duvessa, TheDefiniteArticle
User avatar

Abyss Ambulator

Posts: 1210

Joined: Wednesday, 11th April 2012, 02:42

Location: Sydney, Australia

Post Sunday, 14th September 2014, 23:37

Re: Contamination hack

status.cc

  Code:
static void _describe_glow(status_info* inf)
{
    const int cont = get_contamination_level();
    if (cont > 0)
    {
        inf->light_colour = DARKGREY;
        if (cont > 1)
            inf->light_colour = _bad_ench_colour(cont, 3, 4);
        if (cont > 1
#if TAG_MAJOR_VERSION == 34
                || you.species != SP_DJINNI
#endif
                )
            inf->light_text = "Contam";
    }

    if (cont > 0)
    {
        inf->short_text =
                 (cont == 1) ? "very slightly " :
                 (cont == 2) ? "slightly " :
                 (cont == 3) ? "" :
                 (cont == 4) ? "moderately " :
                 (cont == 5) ? "heavily "
                             : "really heavily ";
        inf->short_text += "contaminated";
        inf->long_text = describe_contamination(cont);
    }
}


player.cc
  Code:
int get_contamination_level()
{
    const int glow = you.magic_contamination;

    if (glow > 60000)
        return glow / 20000 + 3;
    if (glow > 40000)
        return 5;
    if (glow > 25000)
        return 4;
    if (glow > 15000)
        return 3;
    if (glow > 5000)
        return 2;
    if (glow > 0)
        return 1;

    return 0;
}


status.cc

  Code:
bool fill_status_info(int status, status_info* inf)
{
...
    case STATUS_CONTAMINATION:
        _describe_glow(inf);
        break;
...
}


So what you want to do is something like this one-line change:

  Code:
static void _describe_glow(status_info* inf)
{
    const int cont = get_contamination_level();
    if (cont > 0)
    {
        inf->light_colour = DARKGREY;
        if (cont > 1)
            inf->light_colour = _bad_ench_colour(cont, 3, 4);
        if (cont > 1
#if TAG_MAJOR_VERSION == 34
                || you.species != SP_DJINNI
#endif
                )
            inf->light_text = make_stringf("Contam %d", (int)you.magic_contamination);
    }

    if (cont > 0)
    {
        inf->short_text =
                 (cont == 1) ? "very slightly " :
                 (cont == 2) ? "slightly " :
                 (cont == 3) ? "" :
                 (cont == 4) ? "moderately " :
                 (cont == 5) ? "heavily "
                             : "really heavily ";
        inf->short_text += "contaminated";
        inf->long_text = describe_contamination(cont);
    }
}

For this message the author Patashu has received thanks:
skjarl

Shoals Surfer

Posts: 257

Joined: Tuesday, 24th September 2013, 17:52

Post Monday, 15th September 2014, 00:39

Re: Contamination hack

That gave me precisely what I wanted and it's awesome. Thank you, Patashu. I'm not sure how I missed that in player.cc. I think I had my case sensitivity turned on when I was searching.
Current foes list: duvessa, TheDefiniteArticle
User avatar

Abyss Ambulator

Posts: 1210

Joined: Wednesday, 11th April 2012, 02:42

Location: Sydney, Australia

Post Monday, 15th September 2014, 00:52

Re: Contamination hack

skjarl wrote:That gave me precisely what I wanted and it's awesome. Thank you, Patashu. I'm not sure how I missed that in player.cc. I think I had my case sensitivity turned on when I was searching.

I hate when I do that! :)
User avatar

Pandemonium Purger

Posts: 1337

Joined: Saturday, 7th July 2012, 02:28

Location: Limbo

Post Monday, 15th September 2014, 05:58

Re: Contamination hack

The worst thing you could ever do is search with case sensitivity in the crawl codebase, so remember that.
take it easy
  Code:
!lg * won !DD-- min=turns -log
<Sequell> 20749. Bloax, XL24 VSTm, T:13320: http://crawl.lantea.net/crawl/morgue/Bloax/morgue-Bloax-20140907-000920.txt

Did you know that I like ruining crawl every now and then? Go check it out.

Shoals Surfer

Posts: 257

Joined: Tuesday, 24th September 2013, 17:52

Post Monday, 15th September 2014, 15:30

Re: Contamination hack

Yes, I know. I've been coding in one way or another for 27 years. I was looking for something very specific earlier and forgot to turn it off.
Current foes list: duvessa, TheDefiniteArticle

Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.