Pages: 1 ... 8 9 [10] 11 12 ... 64
  Print  
Author Topic: Game Maker Help Thread!  (Read 310915 times)
Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #135 on: January 26, 2010, 05:22:47 AM »

You can add it fairly easily to an existing shop, creating a whole new one might be too much trouble anyway (at least for a single item).
Open the Level generation folder in the Scripts folder. Look for scrShopItemsGen, and scroll down to the shop you want (probably the weapon shop)

Then copy the code for the last item on the list and paste it directly under:
Code:
}
else if (shopType == "Weapon")
{
    m = 20;
    while (true)
    {
        n = rand(1,4);
        if (m <= 0) { obj = instance_create(xpos+8, ypos+10, oBombBag); break; }
        else if (rand(1,12)==1)
        {
            if (not instance_exists(oWebCannon)) { obj = instance_create(xpos+8, ypos+12, oWebCannon); break; }
        }
        else if (rand(1,5)==1)
        {
            if (not instance_exists(oShells)) { obj = instance_create(xpos+8, ypos+12, oShells); break; }
        }
        else if (rand(1,6)==1) { obj = instance_create(xpos+8, ypos+10, oBombBox); break; }
        else if (n == 1)
        {
            if (not instance_exists(oPistol)) { obj = instance_create(xpos+8, ypos+12, oPistol); break; }
        }
        else if (n == 2)
        {
            if (not instance_exists(oMachete)) { obj = instance_create(xpos+8, ypos+12, oMachete); break; }
        }
        else if (n == 3) { obj = instance_create(xpos+8, ypos+10, oBombBag); break; }
        else if (n == 4)
        {
            if (not instance_exists(oBow)) { obj = instance_create(xpos+8, ypos+12, oBow); break; }
        }
        {//copied
            if (not instance_exists(oBow)) { obj = instance_create(xpos+8, ypos+12, oBow); break; }   
        }
        m -= 1;
    }
}
Now just change the specifics to your item:

Code:
{
         if (not instance_exists(oLipstick)) { obj = instance_create(xpos+8, ypos+12, oLipstick); break; }
        }
You could also give it a random chance to appear, as the first few items do, to make it more common. To do that just replace the "if (not instance_exists" part with "else if (rand (x,y) =z)". Where x= the lowest random number, y=the highest random number, and z=the number that must be returned to create the instance.

Finally, make sure your object has the parent of "oItem", and copy the creation script which is in a similar item to give it a description and price when you find it in the shop. Then run a number of tests to see if it shows up as frequently as you like, is the price you want, correct text displayed and so on. Good luck man!
Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
Kegluneq
Big Bossy
Mossy
*
Posts: 2260



View Profile Email
« Reply #136 on: January 26, 2010, 08:21:59 PM »

I added a nice little table of contents to the first post.
Logged

A wild SHINY MOSSY appeared!
Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #137 on: January 27, 2010, 06:44:40 AM »

That's handy-dandy! Thanks Keg!  Grin
Edit: to avoid dreaded double-post Smiley

Here to answer Banna8's question regarding adding an item to crates/pots:

If your object is already implemented and in-game, this is a really simple step. Open the oPlayer1 object, then in his step event (not end step) double click the code underneath the "!Action" comment.

Let's assume you want to add an object called oLipstickBox to the crates.
Scroll down to line 252 where you will see a comment // open crate with the following code:

Code:
if (kUp and kAttackPressed and collision_point(x, y, oCrate, 0, 0))
{
        if (isRealLevel()) global.totalCrates += 1;
        chest = instance_place(x, y, oCrate);
        if (isRoom("rTutorial")) obj = instance_create(chest.x, chest.y, oBombBag);
        else if (rand(1,500) == 1) obj = instance_create(chest.x, chest.y, oJetpack);
        else if (rand(1,200) == 1) obj = instance_create(chest.x, chest.y, oCapePickup);
        else if (rand(1,100) == 1) obj = instance_create(chest.x, chest.y, oShotgun);
        else if (rand(1,100) == 1) obj = instance_create(chest.x, chest.y, oMattock);
        else if (rand(1,100) == 1) obj = instance_create(chest.x, chest.y, oTeleporter);
        else if (rand(1,90) == 1) obj = instance_create(chest.x, chest.y, oGloves);
        else if (rand(1,90) == 1) obj = instance_create(chest.x, chest.y, oSpectacles);
        else if (rand(1,80) == 1) obj = instance_create(chest.x, chest.y, oWebCannon);
        else if (rand(1,80) == 1) obj = instance_create(chest.x, chest.y, oPistol);
        else if (rand(1,80) == 1) obj = instance_create(chest.x, chest.y, oMitt);
        else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oPaste);
        else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oSpringShoes);
        else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oSpikeShoes);
        else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oMachete);
        else if (rand(1,40) == 1) obj = instance_create(chest.x, chest.y, oBombBox);
        else if (rand(1,40) == 1) obj = instance_create(chest.x, chest.y, oBow);
        else if (rand(1,20) == 1) obj = instance_create(chest.x, chest.y, oCompass);
        else if (rand(1,10) == 1) obj = instance_create(chest.x, chest.y, oParaPickup);
        else if (rand(1,2) == 1) obj = instance_create(chest.x, chest.y, oRopePile);
        else obj = instance_create(chest.x, chest.y, oBombBag);
        obj.cost = 0;
        playSound(global.sndPickup);
        if (chest == holdItem)
        {
            holdItem = 0;
            pickupItemType = "";
        }
        with chest { instance_create(x, y, oPoof); instance_destroy(); }
       
        kAttackPressed = false;
}
Most of this you won't want to mess with, but rather look at the random numbers to get an idea how rare some items are.
Code:
else if (rand(1,500) == 1) obj = instance_create(chest.x, chest.y, oJetpack);
Means a "random" number between 1 and 500 is checked, then if it falls on 1 the crate will spawn a jetpack. Generally this is unlikely to happen but,
Code:
else if (rand(1,2) == 1) obj = instance_create(chest.x, chest.y, oRopePile);
Means if a number rolled from either 1 or 2 lands on 1, a rope pile will be created, much more likely.

So, what you want to do now is simply decide how rare you want your item to be. Let's say you want it more rare than ropes (1,2), but less rare than a parachute (1,10). We'll settle on a one in five chance. The easiest way is to copy paste the line above, parachute in this case, and change the variables:
Code:
else if (rand(1,10) == 1) obj = instance_create(chest.x, chest.y, oParaPickup);
else if (rand(1,5) == 1) obj = instance_create(chest.x, chest.y, oLipstickBox);
Two things to note here;
One, you do not have to put them in order of rarity, but it is good practice and will make them easier to find.
Two, you also do not have to set a check for a return of "one", this was simply Derek's method. You could easily make it extremely likely to show up by adding more lines and more numbers to make it spawn, like so:
Code:
else if (rand(1,10) == 1) obj = instance_create(chest.x, chest.y, oParaPickup);
else if (rand(1,5) == 1) obj = instance_create(chest.x, chest.y, oLipstickBox);
else if (rand(1,5) == 2) obj = instance_create(chest.x, chest.y, oLipstickBox);
else if (rand(1,5) == 3) obj = instance_create(chest.x, chest.y, oLipstickBox);
Now if the number returns any 1-3, it will produce a Lipstick Box! (There may be a way to put these in one code, but I don't know it  Undecided)

That's it! The oJar object acts in a similar way, only the code is in the object itself. If you want an item added there, do the same as here and add it to both the instance destroy event, and collision with whip event in the jar object. Now go make some box items!  Grin (Also sorry this was such a humongous post!)
« Last Edit: January 27, 2010, 07:13:55 AM by Arucard » Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
MagiMaster
Bulb
*
Posts: 97


View Profile
« Reply #138 on: January 27, 2010, 11:33:52 AM »

If you want a chance other than 1 in something, it should look like this:
Code:
if (rand(1,10) <= 3) { do something; }

(If you put rand(1,10) in multiple times, you get a different number every time.)
« Last Edit: January 27, 2010, 11:37:40 PM by MagiMaster » Logged
banna8
Mossbaby
*
Posts: 281


View Profile Email
« Reply #139 on: January 27, 2010, 02:10:49 PM »

I will be incorporating this in the next build.
Logged
marsgreekgod
Big Bossy
Mossy
*
Posts: 9806


The will of the Galaxy.


View Profile WWW Email
« Reply #140 on: January 27, 2010, 05:40:56 PM »

Can some one help me out? in spelunky de bomb, i would like ropes to still blow up, but not destroy them selves and see to not be able to, any help?
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: 2260



View Profile Email
« Reply #141 on: January 27, 2010, 06:09:28 PM »

You'd probably have to edit explosions to not destroy ropes.
Logged

A wild SHINY MOSSY appeared!
Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #142 on: January 28, 2010, 02:32:14 AM »

If you want a chance other than 1 in something, it should look like this:
Code:
if (rand(1,10) <= 3) { do something; }

(If you put rand(1,10) in multiple times, you get a different number every time.)
Thanks, I knew there was some easier way to do it.
Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
marsgreekgod
Big Bossy
Mossy
*
Posts: 9806


The will of the Galaxy.


View Profile WWW Email
« Reply #143 on: January 28, 2010, 02:54:58 AM »

You'd probably have to edit explosions to not destroy ropes.
I would think that, but it doesn't seem to be there!
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!
Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #144 on: January 28, 2010, 03:02:22 AM »

Mars, in the oExplosion object go into the collision with oItem event. You will see a block that starts else if (other.type == "Rope") , just delete that whole block.
Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
marsgreekgod
Big Bossy
Mossy
*
Posts: 9806


The will of the Galaxy.


View Profile WWW Email
« Reply #145 on: January 28, 2010, 03:19:08 AM »

Mars, in the oExplosion object go into the collision with oItem event. You will see a block that starts else if (other.type == "Rope") , just delete that whole block.
already try that, thats what throws the item rope aroudn when a bomb hits 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!
Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #146 on: January 28, 2010, 03:54:58 AM »

That's weird, it works fine in Vanilla Spelunky.  Sad
Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
marsgreekgod
Big Bossy
Mossy
*
Posts: 9806


The will of the Galaxy.


View Profile WWW Email
« Reply #147 on: January 28, 2010, 11:01:20 AM »

That's weird, it works fine in Vanilla Spelunky.  Sad
1)vannila spelunky?
2)... then what do I do?
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!
Kirby
Mossy
*
Posts: 1502


Too Long Away

nrmario@hotmail.com
View Profile WWW
« Reply #148 on: January 28, 2010, 12:14:10 PM »

I can answer something!
Vanilla Spelunky is regular Spelunky with no mods.
Logged

I'm learning Japanese!
Add me on Steam! http://steamcommunity.com/id/KirbyLord/
banna8
Mossbaby
*
Posts: 281


View Profile Email
« Reply #149 on: January 28, 2010, 03:17:21 PM »

I want to change the bomb shops. something like,

Code:
if (global.isDamsel)
{shop sign sprite = oSignKissing
  Shop intro text changes
  only lipstick items show up
 }
else
{
  do normal bomb stuff
}

obviously, thats not actual code.
Logged
Pages: 1 ... 8 9 [10] 11 12 ... 64
  Print  
 
Jump to: