Pages: 1 2 [3]
  Print  
Author Topic: Multiple Black Market entrances (bug)  (Read 2376 times)
gummybears123
Mossy
*
Posts: 5776


Yummy Gummy!


View Profile
« Reply #30 on: December 18, 2009, 03:40:13 PM »

Lines 187-205 of scrEntityGen detail the chances of generating the Black Market normally. Note that the generation is contained within a "with oSolid" block unlike the fall-back example. Note that marketChance is initialized at "160". If there are fewer than 160 exposed "oSolid" tiles then there is a chance the Black Market won't generate, but as this is physically impossible...

Quote
    with oSolid
    {
        // bg
        if (rand(1,100) == 1 and not collision_point(x, y-16, oSolid, 0, 0)) tile_add(bgTrees, 0, 0, 16, 48, x, y-32, 9005);
       
        if (not isInShop(x, y))
        {
       
        if (y > 32 and collision_point(x, y-16, oSolid, 0, 0) and global.genMarketEntrance and not global.madeMarketEntrance)
        {
            obj = instance_place(x, y-16, oSolid);
            if (obj.type != "Tree" and type != "Altar" and not obj.invincible and rand(1,global.marketChance) == 1)
            {
                instance_create(x, y-16, oXMarket);
                invincible = true;
                global.madeMarketEntrance = true;
            }
            else global.marketChance -= 1;
        }

Lines 281-297 of scrEntityGen detail Black Market force-generation code.

Quote
    // force market entrance
    if (global.genMarketEntrance and not global.madeMarketEntrance)
    {
        with oSolid
        {
            if (y > 32 and collision_point(x, y-16, oSolid, 0, 0))
            {
                obj = instance_place(x, y-16, oSolid);
                if (obj.type != "Tree" and type != "Altar" and not obj.invincible)
                {
                    instance_create(x, y-16, oXMarket);
                    invincible = true;
                    global.madeMarketEntrance = true;
                }
            }
        }
    }

Might I get one of you guys to run Spelunky with debug mode enabled, then the next time this happens, watch the value of global.marketChance? There's seriously nothing wrong with this code as far as I can tell, so this shouldn't be happening.

Only asking out of curiosity, because as I said there's nothing wrong with that code.

I don't understand any of that so I am inclined to call you a geek Grin
Logged

I made a rap.
It sounds dumb, like reading a map
I really should stop this thing before it goes too far
But I don't really car as long as I stay below the radar
Those big companies won't get me no
I'll get away before the fuzz show

-Most famous rapper of Mossmouth
Kirbylord
grieck
Mossy
*
Posts: 1042



View Profile Email
« Reply #31 on: December 18, 2009, 04:45:46 PM »

Lines 187-205 of scrEntityGen detail the chances of generating the Black Market normally. Note that the generation is contained within a "with oSolid" block unlike the fall-back example. Note that marketChance is initialized at "160". If there are fewer than 160 exposed "oSolid" tiles then there is a chance the Black Market won't generate, but as this is physically impossible...

Quote
    with oSolid
    {
        // bg
        if (rand(1,100) == 1 and not collision_point(x, y-16, oSolid, 0, 0)) tile_add(bgTrees, 0, 0, 16, 48, x, y-32, 9005);
       
        if (not isInShop(x, y))
        {
       
        if (y > 32 and collision_point(x, y-16, oSolid, 0, 0) and global.genMarketEntrance and not global.madeMarketEntrance)
        {
            obj = instance_place(x, y-16, oSolid);
            if (obj.type != "Tree" and type != "Altar" and not obj.invincible and rand(1,global.marketChance) == 1)
            {
                instance_create(x, y-16, oXMarket);
                invincible = true;
                global.madeMarketEntrance = true;
            }
            else global.marketChance -= 1;
        }

Lines 281-297 of scrEntityGen detail Black Market force-generation code.

Quote
    // force market entrance
    if (global.genMarketEntrance and not global.madeMarketEntrance)
    {
        with oSolid
        {
            if (y > 32 and collision_point(x, y-16, oSolid, 0, 0))
            {
                obj = instance_place(x, y-16, oSolid);
                if (obj.type != "Tree" and type != "Altar" and not obj.invincible)
                {
                    instance_create(x, y-16, oXMarket);
                    invincible = true;
                    global.madeMarketEntrance = true;
                }
            }
        }
    }

Might I get one of you guys to run Spelunky with debug mode enabled, then the next time this happens, watch the value of global.marketChance? There's seriously nothing wrong with this code as far as I can tell, so this shouldn't be happening.

Only asking out of curiosity, because as I said there's nothing wrong with that code.

I don't understand any of that so I am inclined to call you a geek Grin
You don't have to understand the code to get what he says, it isn't too hard to follow (I don't know all the code, lines, etc stuff myself either)
Logged
marsgreekgod
Big Bossy
Mossy
*
Posts: 9779


The will of the Galaxy.


View Profile WWW Email
« Reply #32 on: December 18, 2009, 05:10:01 PM »

Lines 187-205 of scrEntityGen detail the chances of generating the Black Market normally. Note that the generation is contained within a "with oSolid" block unlike the fall-back example. Note that marketChance is initialized at "160". If there are fewer than 160 exposed "oSolid" tiles then there is a chance the Black Market won't generate, but as this is physically impossible...

Quote
    with oSolid
    {
        // bg
        if (rand(1,100) == 1 and not collision_point(x, y-16, oSolid, 0, 0)) tile_add(bgTrees, 0, 0, 16, 48, x, y-32, 9005);
       
        if (not isInShop(x, y))
        {
       
        if (y > 32 and collision_point(x, y-16, oSolid, 0, 0) and global.genMarketEntrance and not global.madeMarketEntrance)
        {
            obj = instance_place(x, y-16, oSolid);
            if (obj.type != "Tree" and type != "Altar" and not obj.invincible and rand(1,global.marketChance) == 1)
            {
                instance_create(x, y-16, oXMarket);
                invincible = true;
                global.madeMarketEntrance = true;
            }
            else global.marketChance -= 1;
        }

Lines 281-297 of scrEntityGen detail Black Market force-generation code.

Quote
    // force market entrance
    if (global.genMarketEntrance and not global.madeMarketEntrance)
    {
        with oSolid
        {
            if (y > 32 and collision_point(x, y-16, oSolid, 0, 0))
            {
                obj = instance_place(x, y-16, oSolid);
                if (obj.type != "Tree" and type != "Altar" and not obj.invincible)
                {
                    instance_create(x, y-16, oXMarket);
                    invincible = true;
                    global.madeMarketEntrance = true;
                }
            }
        }
    }

Might I get one of you guys to run Spelunky with debug mode enabled, then the next time this happens, watch the value of global.marketChance? There's seriously nothing wrong with this code as far as I can tell, so this shouldn't be happening.

Only asking out of curiosity, because as I said there's nothing wrong with that code.
I can do better! I can change global.marketchance to really high to see if this bug happens! I'm on it!
Logged

Show your power, Gun Del Hell! Show them their fate! Yes! Yes! Yes! Yes! Yes! Here we go! Let's go, go, go, go, Django! Light and Dark! It comes down to this! Be afraid, Sun!
Kegluneq
Big Bossy
Mossy
*
Posts: 2219



View Profile Email
« Reply #33 on: December 18, 2009, 06:32:59 PM »

Sorry, I beat ya to it.

It happens if the marketChance is a negative number.

Strange thing is, if you set it to a really low number, like 1 or 16, it forces itself into a negative number.
Sort of.

To be honest it seems really random, I don't understand.
And how does it even get to be a negative number in the first place?
Logged

A wild SHINY MOSSY appeared!
Derek
Mossmouth
Bean
*
Posts: 126



View Profile Email
« Reply #34 on: December 18, 2009, 07:25:59 PM »

Thanks, Kegluneq, I think I fixed it.  Not sure how it becomes negative, however.  I'll look into it.
Logged
SeVeN
Seedling
*
Posts: 3


View Profile Email
« Reply #35 on: December 18, 2009, 08:26:43 PM »

Code:
else global.marketChance -= 1;

maybe it gets trapped in this condition?

also, where is y set? y-16? maybe it could be tested on this y value and that condition over there
« Last Edit: December 18, 2009, 08:28:56 PM by SeVeN » Logged
Derek
Mossmouth
Bean
*
Posts: 126



View Profile Email
« Reply #36 on: December 18, 2009, 08:40:30 PM »

Yeah, I believe what happens is that marketChance == 1 and then some other condition in that first if statement fails, like the object is a tree or an altar or an invincible block.

Although now that I think of it, global.madeMarketEntrance should still prevent it from making more than one...
« Last Edit: December 19, 2009, 01:12:24 AM by Derek » Logged
gummybears123
Mossy
*
Posts: 5776


Yummy Gummy!


View Profile
« Reply #37 on: December 18, 2009, 09:04:42 PM »

Sorry, I beat ya to it.

It happens if the marketChance is a negative number.

Strange thing is, if you set it to a really low number, like 1 or 16, it forces itself into a negative number.
Sort of.

To be honest it seems really random, I don't understand.
And how does it even get to be a negative number in the first place?

What the heck is marketChance?
Logged

I made a rap.
It sounds dumb, like reading a map
I really should stop this thing before it goes too far
But I don't really car as long as I stay below the radar
Those big companies won't get me no
I'll get away before the fuzz show

-Most famous rapper of Mossmouth
Kirbylord
marsgreekgod
Big Bossy
Mossy
*
Posts: 9779


The will of the Galaxy.


View Profile WWW Email
« Reply #38 on: December 18, 2009, 09:38:59 PM »

Sorry, I beat ya to it.

It happens if the marketChance is a negative number.

Strange thing is, if you set it to a really low number, like 1 or 16, it forces itself into a negative number.
Sort of.

To be honest it seems really random, I don't understand.
And how does it even get to be a negative number in the first place?

What the heck is marketChance?
It's a variable, long story short it's ment to be a swich to see if the market door spawns.
Logged

Show your power, Gun Del Hell! Show them their fate! Yes! Yes! Yes! Yes! Yes! Here we go! Let's go, go, go, go, Django! Light and Dark! It comes down to this! Be afraid, Sun!
GreyMario
Bean
*
Posts: 121


View Profile
« Reply #39 on: December 18, 2009, 10:09:23 PM »

Derek, what happens if you call the random function with 1 and 1 as a minimum and a maximum? Perhaps that's where it's breaking.
Logged
gummybears123
Mossy
*
Posts: 5776


Yummy Gummy!


View Profile
« Reply #40 on: December 18, 2009, 10:17:30 PM »

Derek, what happens if you call the random function with 1 and 1 as a minimum and a maximum? Perhaps that's where it's breaking.

I feel so stupid... am I supposed to know what you are talking about?  I'm only 13... Tongue
Logged

I made a rap.
It sounds dumb, like reading a map
I really should stop this thing before it goes too far
But I don't really car as long as I stay below the radar
Those big companies won't get me no
I'll get away before the fuzz show

-Most famous rapper of Mossmouth
Kirbylord
grieck
Mossy
*
Posts: 1042



View Profile Email
« Reply #41 on: December 18, 2009, 10:21:56 PM »

Derek, what happens if you call the random function with 1 and 1 as a minimum and a maximum? Perhaps that's where it's breaking.

I feel so stupid... am I supposed to know what you are talking about?  I'm only 13... Tongue

No you most certainly are not, regardless of age; age being a factor that matters little to the understanding of all this. I have a strong suspicion not everyone on the forum can speak in lines of code.  The best you can hope is to makes inferences based upon what little you can understand, as I do. (ie: MarketChance could only BE chance of the market appearing, though that one was kindly already revealed)
Logged
SeVeN
Seedling
*
Posts: 3


View Profile Email
« Reply #42 on: December 19, 2009, 08:33:51 AM »

So, this problem was solved? Good! I'm sure I'll miss the multi-black-market doors, but oh well, being so rare, most people never saw it happen anyways.

So, the method to force the door to be created goes crazy when the variable is too low/negative and creates it anywhere it can?

Just so I know, is there any other crazy bug I could keep an eye for?
« Last Edit: December 19, 2009, 08:40:59 AM by SeVeN » Logged
Pages: 1 2 [3]
  Print  
 
Jump to: