ComputerScienceHouse / bingehack

A fork of nethack with semi-multiplayer features and other customizations. (An in-heavy-development fork version is at https://github.com/computersciencehouse/bingehack4 )
http://nethack.csh.rit.edu
23 stars 4 forks source link

Added 107 hats. Fixes #81 #82

Closed ekosz closed 13 years ago

ekosz commented 13 years ago

After trying to create a new item type for a white, I gave up and figured that it didn't make sense to add a different slot just for novelty hats. Though if someone wants to do this still you should be able to make my code work with a new item type very easily.

This code is untested, but should be good enough right now for a code review.

Thoughts/Questions/Concerns?

clockfort commented 13 years ago

This is dumb though; you just added items. They're just items. I assumed the concept of TF2 hats would involve, you know, them lasting over multiple games, getting them from achievements, a different random drop system...

ekosz commented 13 years ago

I like that idea. We could change the algorithm to 1% drop a random hat. All of those hat objects I just created would just have to dial their probability to 0 so they never spawn on their own (easy one line change).

Spencer was just filling me in on what people had in mind for hats. I though people just wanted some rare hats to be dropped once in a while. I didn't know people were thinking about cross-game items or changing the avatar look (things I think are dumb).

clockfort commented 13 years ago

I think those things are dumb too.

ekosz commented 13 years ago

I was taking a look at the source code for generating random items and I believe (if I'm understanding the code correctly) that by creating all of these helm objects with a .oc_prop of 1 they will not overwhelm the probability of geting something with a .oc_prop of 10 (like a regular helm). I could create 1,000 objects with an .oc_prop of 1 and they'd still never be created 99% of the time.

The code in question (I'm 99% sure)

struct obj *
mkobj(oclass, artif)
char oclass;
boolean artif;
{
    int tprob, i, prob = rnd(1000);

    if(oclass == RANDOM_CLASS) {
        const struct icp *iprobs =
#ifdef REINCARNATION
                    (Is_rogue_level(&u.uz)) ?
                    (const struct icp *)rogueprobs :
#endif
                    Inhell ? (const struct icp *)hellprobs :
                    (const struct icp *)mkobjprobs;

        for(tprob = rnd(100);
            (tprob -= iprobs->iprob) > 0;
            iprobs++);
        oclass = iprobs->iclass;
    }

    i = bases[(int)oclass];
    while((prob -= objects[i].oc_prob) > 0) i++;

    if(objects[i].oc_class != oclass || !OBJ_NAME(objects[i]))
        panic("probtype error, oclass=%d i=%d", (int) oclass, i);

    return(mksobj(i, TRUE, artif));
}

Please correct me if I'm wrong here.